ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/XS.xs
(Generate patch)

Comparing JSON-XS/XS.xs (file contents):
Revision 1.22 by root, Sat Mar 31 14:20:06 2007 UTC vs.
Revision 1.23 by root, Tue Apr 3 23:34:17 2007 UTC

76 { 76 {
77 *clen = 2; 77 *clen = 2;
78 return ((s[0] & 0x1f) << 6) | (s[1] & 0x3f); 78 return ((s[0] & 0x1f) << 6) | (s[1] & 0x3f);
79 } 79 }
80 else 80 else
81 {
82 *clen = (STRLEN)-1;
81 return (UV)-1; 83 return (UV)-1;
84 }
82} 85}
83 86
84///////////////////////////////////////////////////////////////////////////// 87/////////////////////////////////////////////////////////////////////////////
85// encoder 88// encoder
86 89
675 UV uch = decode_utf8 (dec->cur, dec->end - dec->cur, &clen); 678 UV uch = decode_utf8 (dec->cur, dec->end - dec->cur, &clen);
676 if (clen == (STRLEN)-1) 679 if (clen == (STRLEN)-1)
677 ERR ("malformed UTF-8 character in JSON string"); 680 ERR ("malformed UTF-8 character in JSON string");
678 681
679 do 682 do
680 {
681 *cur++ = *dec->cur++; 683 *cur++ = *dec->cur++;
682 }
683 while (--clen); 684 while (--clen);
684 685
685 utf8 = 1; 686 utf8 = 1;
686 } 687 }
687 else if (!ch)
688 ERR ("unexpected end of string while parsing json string");
689 else 688 else
689 {
690 --dec->cur;
691
692 if (!ch)
693 ERR ("unexpected end of string while parsing json string");
694 else
690 ERR ("invalid character encountered"); 695 ERR ("invalid character encountered while parsing json string");
691 696 }
692 } 697 }
693 while (cur < buf + SHORT_STRING_LEN); 698 while (cur < buf + SHORT_STRING_LEN);
694 699
695 STRLEN len = cur - buf; 700 STRLEN len = cur - buf;
696 701
1002 SAVEVPTR (PL_curcop); 1007 SAVEVPTR (PL_curcop);
1003 PL_curcop = &cop; 1008 PL_curcop = &cop;
1004 pv_uni_display (uni, dec.cur, dec.end - dec.cur, 20, UNI_DISPLAY_QQ); 1009 pv_uni_display (uni, dec.cur, dec.end - dec.cur, 20, UNI_DISPLAY_QQ);
1005 LEAVE; 1010 LEAVE;
1006 1011
1007 croak ("%s, at character offset %d (%s)", 1012 croak ("%s, at character offset %d [\"%s\"]",
1008 dec.err, 1013 dec.err,
1009 (int)offset, 1014 (int)offset,
1010 dec.cur != dec.end ? SvPV_nolen (uni) : "(end of string)"); 1015 dec.cur != dec.end ? SvPV_nolen (uni) : "(end of string)");
1011 } 1016 }
1012 1017

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines