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.99 by root, Sat Aug 8 10:06:02 2009 UTC vs.
Revision 1.102 by root, Sat Oct 10 01:48:50 2009 UTC

17// guarantees, though. if it breaks, you get to keep the pieces. 17// guarantees, though. if it breaks, you get to keep the pieces.
18#ifndef UTF8_MAXBYTES 18#ifndef UTF8_MAXBYTES
19# define UTF8_MAXBYTES 13 19# define UTF8_MAXBYTES 13
20#endif 20#endif
21 21
22// three extra for rounding, sign, and end of string
22#define IVUV_MAXCHARS (sizeof (UV) * CHAR_BIT * 28 / 93 + 2) 23#define IVUV_MAXCHARS (sizeof (UV) * CHAR_BIT * 28 / 93 + 3)
23 24
24#define F_ASCII 0x00000001UL 25#define F_ASCII 0x00000001UL
25#define F_LATIN1 0x00000002UL 26#define F_LATIN1 0x00000002UL
26#define F_UTF8 0x00000004UL 27#define F_UTF8 0x00000004UL
27#define F_INDENT 0x00000008UL 28#define F_INDENT 0x00000008UL
759 : enc.json.flags & F_LATIN1 ? 0x000100UL 760 : enc.json.flags & F_LATIN1 ? 0x000100UL
760 : 0x110000UL; 761 : 0x110000UL;
761 762
762 SvPOK_only (enc.sv); 763 SvPOK_only (enc.sv);
763 encode_sv (&enc, scalar); 764 encode_sv (&enc, scalar);
765 encode_nl (&enc);
764 766
765 SvCUR_set (enc.sv, enc.cur - SvPVX (enc.sv)); 767 SvCUR_set (enc.sv, enc.cur - SvPVX (enc.sv));
766 *SvEND (enc.sv) = 0; // many xs functions expect a trailing 0 for text strings 768 *SvEND (enc.sv) = 0; // many xs functions expect a trailing 0 for text strings
767 769
768 if (!(enc.json.flags & (F_ASCII | F_LATIN1 | F_UTF8))) 770 if (!(enc.json.flags & (F_ASCII | F_LATIN1 | F_UTF8)))
948 else if (expect_true (ch >= 0x20 && ch < 0x80)) 950 else if (expect_true (ch >= 0x20 && ch < 0x80))
949 *cur++ = ch; 951 *cur++ = ch;
950 else if (ch >= 0x80) 952 else if (ch >= 0x80)
951 { 953 {
952 STRLEN clen; 954 STRLEN clen;
953 UV uch;
954 955
955 --dec_cur; 956 --dec_cur;
956 957
957 uch = decode_utf8 (dec_cur, dec->end - dec_cur, &clen); 958 decode_utf8 (dec_cur, dec->end - dec_cur, &clen);
958 if (clen == (STRLEN)-1) 959 if (clen == (STRLEN)-1)
959 ERR ("malformed UTF-8 character in JSON string"); 960 ERR ("malformed UTF-8 character in JSON string");
960 961
961 do 962 do
962 *cur++ = *dec_cur++; 963 *cur++ = *dec_cur++;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines