Skip to content

Commit

Permalink
more corrections for proper position reports in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjaylward committed Jun 21, 2017
1 parent 5b0f7ae commit 9b1b551
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions CDL.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ private static String getValue(JSONTokener x) throws JSONException {
c = x.next();
if (c == q) {
//Handle escaped double-quote
if(x.next() != '\"')
{
x.back();
char nextC = x.next();
if(nextC != '\"') {
// if our quote was the end of the file, don't step
if(nextC > 0) {
x.back();
}
break;
}
}
Expand Down
9 changes: 6 additions & 3 deletions JSONTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public char next() throws JSONException {

if (c <= 0) { // End of stream
this.eof = true;
c = 0;
return 0;
}
}
this.index += 1;
Expand Down Expand Up @@ -214,8 +214,11 @@ public char next() throws JSONException {
public char next(char c) throws JSONException {
char n = this.next();
if (n != c) {
throw this.syntaxError("Expected '" + c + "' and instead saw '" +
n + "'");
if(n > 0) {
throw this.syntaxError("Expected '" + c + "' and instead saw '" +
n + "'");
}
throw this.syntaxError("Expected '" + c + "' and instead saw ''");
}
return n;
}
Expand Down
5 changes: 4 additions & 1 deletion XMLTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public Object nextContent() throws JSONException {
}
sb = new StringBuilder();
for (;;) {
if (c == '<' || c == 0) {
if (c == 0) {
return sb.toString().trim();
}
if (c == '<' ) {
back();
return sb.toString().trim();
}
Expand Down

0 comments on commit 9b1b551

Please sign in to comment.