--- JSON-XS/XS.xs 2007/03/31 14:20:06 1.22 +++ JSON-XS/XS.xs 2007/04/03 23:34:17 1.23 @@ -78,7 +78,10 @@ return ((s[0] & 0x1f) << 6) | (s[1] & 0x3f); } else - return (UV)-1; + { + *clen = (STRLEN)-1; + return (UV)-1; + } } ///////////////////////////////////////////////////////////////////////////// @@ -677,18 +680,20 @@ ERR ("malformed UTF-8 character in JSON string"); do - { - *cur++ = *dec->cur++; - } + *cur++ = *dec->cur++; while (--clen); utf8 = 1; } - else if (!ch) - ERR ("unexpected end of string while parsing json string"); else - ERR ("invalid character encountered"); + { + --dec->cur; + if (!ch) + ERR ("unexpected end of string while parsing json string"); + else + ERR ("invalid character encountered while parsing json string"); + } } while (cur < buf + SHORT_STRING_LEN); @@ -1004,7 +1009,7 @@ pv_uni_display (uni, dec.cur, dec.end - dec.cur, 20, UNI_DISPLAY_QQ); LEAVE; - croak ("%s, at character offset %d (%s)", + croak ("%s, at character offset %d [\"%s\"]", dec.err, (int)offset, dec.cur != dec.end ? SvPV_nolen (uni) : "(end of string)");