Factor exception wrapped read() into nextChar().
This commit is contained in:
@@ -339,18 +339,9 @@ public class Mustache
|
|||||||
public Accumulator parse (Reader source) {
|
public Accumulator parse (Reader source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
|
||||||
while (true) {
|
int v;
|
||||||
char c;
|
while ((v = nextChar()) != -1) {
|
||||||
try {
|
char c = (char)v;
|
||||||
int v = source.read();
|
|
||||||
if (v == -1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
c = (char)v;
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new MustacheException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
column = 0;
|
column = 0;
|
||||||
line++;
|
line++;
|
||||||
@@ -366,7 +357,6 @@ public class Mustache
|
|||||||
column++;
|
column++;
|
||||||
skipNewline = false;
|
skipNewline = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseChar(c);
|
parseChar(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,11 +443,7 @@ public class Mustache
|
|||||||
if (delims.isStaches() && text.charAt(0) == delims.start1) {
|
if (delims.isStaches() && text.charAt(0) == delims.start1) {
|
||||||
// we've only parsed }} at this point, so we have to slurp in another
|
// we've only parsed }} at this point, so we have to slurp in another
|
||||||
// character from the input stream and check it
|
// character from the input stream and check it
|
||||||
int end3;
|
int end3 = nextChar();
|
||||||
try { end3 = source.read(); }
|
|
||||||
catch (IOException e) {
|
|
||||||
throw new MustacheException(e);
|
|
||||||
}
|
|
||||||
if (end3 != '}') {
|
if (end3 != '}') {
|
||||||
String got = (end3 == -1) ? "" : String.valueOf((char)end3);
|
String got = (end3 == -1) ? "" : String.valueOf((char)end3);
|
||||||
throw new MustacheParseException(
|
throw new MustacheParseException(
|
||||||
@@ -480,6 +466,14 @@ public class Mustache
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int nextChar () {
|
||||||
|
try {
|
||||||
|
return source.read();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new MustacheException(ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class Delims {
|
protected static class Delims {
|
||||||
|
|||||||
Reference in New Issue
Block a user