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.87 by root, Tue Jun 3 06:43:45 2008 UTC vs.
Revision 1.90 by root, Sun Jul 20 17:55:19 2008 UTC

79 INCR_M_STR, // inside string 79 INCR_M_STR, // inside string
80 INCR_M_BS, // inside backslash 80 INCR_M_BS, // inside backslash
81 INCR_M_JSON // outside anything, count nesting 81 INCR_M_JSON // outside anything, count nesting
82}; 82};
83 83
84#define INCR_DONE(json) (!(json)->incr_nest && (json)->incr_mode == INCR_M_JSON) 84#define INCR_DONE(json) ((json)->incr_nest <= 0 && (json)->incr_mode == INCR_M_JSON)
85 85
86typedef struct { 86typedef struct {
87 U32 flags; 87 U32 flags;
88 U32 max_depth; 88 U32 max_depth;
89 STRLEN max_size; 89 STRLEN max_size;
92 HV *cb_sk_object; 92 HV *cb_sk_object;
93 93
94 // for the incremental parser 94 // for the incremental parser
95 SV *incr_text; // the source text so far 95 SV *incr_text; // the source text so far
96 STRLEN incr_pos; // the current offset into the text 96 STRLEN incr_pos; // the current offset into the text
97 unsigned char incr_nest; // {[]}-nesting level 97 int incr_nest; // {[]}-nesting level
98 unsigned char incr_mode; 98 unsigned char incr_mode;
99} JSON; 99} JSON;
100 100
101INLINE void 101INLINE void
102json_init (JSON *json) 102json_init (JSON *json)
1418 1418
1419 /* work around a bug in perl 5.10, which causes SvCUR to fail an 1419 /* work around a bug in perl 5.10, which causes SvCUR to fail an
1420 * assertion with -DDEBUGGING, although SvCUR is documented to 1420 * assertion with -DDEBUGGING, although SvCUR is documented to
1421 * return the xpv_cur field which certainly exists after upgrading. 1421 * return the xpv_cur field which certainly exists after upgrading.
1422 * according to nicholas clark, calling SvPOK fixes this. 1422 * according to nicholas clark, calling SvPOK fixes this.
1423 * But it doesn't fix it, so try another workaround, call SvPV_nolen
1424 * and hope for the best.
1425 * Damnit, SvPV_nolen still trips over yet another assertion. This
1426 * assertion business is seriously broken, try yet another workaround
1427 * for the broken -DDEBUGGING.
1423 */ 1428 */
1424 SvPOK (string); 1429#ifdef DEBUGGING
1430 offset = SvOK (string) ? sv_len (string) : 0;
1431#else
1432 offset = SvCUR (string);
1433#endif
1425 1434
1426 if (SvCUR (string) > json->max_size && json->max_size) 1435 if (offset > json->max_size && json->max_size)
1427 croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu", 1436 croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu",
1428 (unsigned long)SvCUR (string), (unsigned long)json->max_size); 1437 (unsigned long)SvCUR (string), (unsigned long)json->max_size);
1429 1438
1430 if (json->flags & F_UTF8) 1439 if (json->flags & F_UTF8)
1431 sv_utf8_downgrade (string, 0); 1440 sv_utf8_downgrade (string, 0);
1598 croak (ERR_NESTING_EXCEEDED); 1607 croak (ERR_NESTING_EXCEEDED);
1599 break; 1608 break;
1600 1609
1601 case ']': 1610 case ']':
1602 case '}': 1611 case '}':
1603 if (!--self->incr_nest) 1612 if (--self->incr_nest <= 0)
1604 goto interrupt; 1613 goto interrupt;
1605 } 1614 }
1606 } 1615 }
1607 } 1616 }
1608 1617

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines