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.120 by root, Mon Oct 28 23:23:10 2013 UTC vs.
Revision 1.123 by root, Sun Dec 8 20:44:23 2013 UTC

15 15
16// some old perls do not have this, try to make it work, no 16// some old perls do not have this, try to make it work, no
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
21
22// compatibility with perl <5.18
23#ifndef HvNAMELEN_get
24# define HvNAMELEN_get(hv) strlen (HvNAME (hv))
25#endif
26#ifndef HvNAMELEN
27# define HvNAMELEN(hv) HvNAMELEN_get (hv)
28#endif
29#ifndef HvNAMEUTF8
30# define HvNAMEUTF8(hv) 0
20#endif 31#endif
21 32
22// three extra for rounding, sign, and end of string 33// three extra for rounding, sign, and end of string
23#define IVUV_MAXCHARS (sizeof (UV) * CHAR_BIT * 28 / 93 + 3) 34#define IVUV_MAXCHARS (sizeof (UV) * CHAR_BIT * 28 / 93 + 3)
24 35
719 count = call_sv ((SV *)GvCV (method), G_ARRAY); 730 count = call_sv ((SV *)GvCV (method), G_ARRAY);
720 SPAGAIN; 731 SPAGAIN;
721 732
722 // catch this surprisingly common error 733 // catch this surprisingly common error
723 if (SvROK (TOPs) && SvRV (TOPs) == sv) 734 if (SvROK (TOPs) && SvRV (TOPs) == sv)
724 croak ("%s::TO_JSON method returned same object as was passed instead of a new one", HvNAME (SvSTASH (sv))); 735 croak ("%s::FREEZE method returned same object as was passed instead of a new one", HvNAME (SvSTASH (sv)));
725 736
726 encode_ch (enc, '('); 737 encode_ch (enc, '(');
727 encode_ch (enc, '"'); 738 encode_ch (enc, '"');
728 encode_str (enc, HvNAME (stash), HvNAMELEN (stash), HvNAMEUTF8 (stash)); 739 encode_str (enc, HvNAME (stash), HvNAMELEN (stash), HvNAMEUTF8 (stash));
729 encode_ch (enc, '"'); 740 encode_ch (enc, '"');
1492 if (!(dec->json.flags & F_ALLOW_TAGS)) 1503 if (!(dec->json.flags & F_ALLOW_TAGS))
1493 ERR ("malformed JSON string, neither array, object, number, string or atom"); 1504 ERR ("malformed JSON string, neither array, object, number, string or atom");
1494 1505
1495 ++dec->cur; 1506 ++dec->cur;
1496 1507
1508 decode_ws (dec);
1509
1497 tag = decode_sv (dec); 1510 tag = decode_sv (dec);
1498 if (!tag) 1511 if (!tag)
1499 goto fail; 1512 goto fail;
1500 1513
1501 if (!SvPOK (tag)) 1514 if (!SvPOK (tag))
1502 ERR ("malformed JSON string, (tag) must be a string"); 1515 ERR ("malformed JSON string, (tag) must be a string");
1503 1516
1517 decode_ws (dec);
1518
1504 if (*dec->cur != ')') 1519 if (*dec->cur != ')')
1505 ERR (") expected after tag"); 1520 ERR (") expected after tag");
1506 1521
1507 ++dec->cur; 1522 ++dec->cur;
1523
1524 decode_ws (dec);
1508 1525
1509 val = decode_sv (dec); 1526 val = decode_sv (dec);
1510 if (!val) 1527 if (!val)
1511 goto fail; 1528 goto fail;
1512 1529

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines