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.89 by root, Sat Jul 19 04:21:32 2008 UTC vs.
Revision 1.92 by root, Mon Sep 22 07:29:29 2008 UTC

280 (int)((uch - 0x10000) % 0x400 + 0xDC00)); 280 (int)((uch - 0x10000) % 0x400 + 0xDC00));
281 enc->cur += 12; 281 enc->cur += 12;
282 } 282 }
283 else 283 else
284 { 284 {
285 static char hexdigit [16] = "0123456789abcdef";
286 need (enc, len += 5); 285 need (enc, len += 5);
287 *enc->cur++ = '\\'; 286 *enc->cur++ = '\\';
288 *enc->cur++ = 'u'; 287 *enc->cur++ = 'u';
289 *enc->cur++ = hexdigit [ uch >> 12 ]; 288 *enc->cur++ = PL_hexdigit [ uch >> 12 ];
290 *enc->cur++ = hexdigit [(uch >> 8) & 15]; 289 *enc->cur++ = PL_hexdigit [(uch >> 8) & 15];
291 *enc->cur++ = hexdigit [(uch >> 4) & 15]; 290 *enc->cur++ = PL_hexdigit [(uch >> 4) & 15];
292 *enc->cur++ = hexdigit [(uch >> 0) & 15]; 291 *enc->cur++ = PL_hexdigit [(uch >> 0) & 15];
293 } 292 }
294 293
295 str += clen; 294 str += clen;
296 } 295 }
297 else if (enc->json.flags & F_LATIN1) 296 else if (enc->json.flags & F_LATIN1)
461 460
462 encode_ch (enc, '{'); 461 encode_ch (enc, '{');
463 462
464 // for canonical output we have to sort by keys first 463 // for canonical output we have to sort by keys first
465 // actually, this is mostly due to the stupid so-called 464 // actually, this is mostly due to the stupid so-called
466 // security workaround added somewhere in 5.8.x. 465 // security workaround added somewhere in 5.8.x
467 // that randomises hash orderings 466 // that randomises hash orderings
468 if (enc->json.flags & F_CANONICAL) 467 if (enc->json.flags & F_CANONICAL)
469 { 468 {
470 int count = hv_iterinit (hv); 469 int count = hv_iterinit (hv);
471 470
1420 * assertion with -DDEBUGGING, although SvCUR is documented to 1419 * assertion with -DDEBUGGING, although SvCUR is documented to
1421 * return the xpv_cur field which certainly exists after upgrading. 1420 * return the xpv_cur field which certainly exists after upgrading.
1422 * according to nicholas clark, calling SvPOK fixes this. 1421 * according to nicholas clark, calling SvPOK fixes this.
1423 * But it doesn't fix it, so try another workaround, call SvPV_nolen 1422 * But it doesn't fix it, so try another workaround, call SvPV_nolen
1424 * and hope for the best. 1423 * and hope for the best.
1424 * Damnit, SvPV_nolen still trips over yet another assertion. This
1425 * assertion business is seriously broken, try yet another workaround
1426 * for the broken -DDEBUGGING.
1425 */ 1427 */
1426#ifdef DEBUGGING 1428#ifdef DEBUGGING
1427 SvPV_nolen (string); 1429 offset = SvOK (string) ? sv_len (string) : 0;
1430#else
1431 offset = SvCUR (string);
1428#endif 1432#endif
1429 1433
1430 if (SvCUR (string) > json->max_size && json->max_size) 1434 if (offset > json->max_size && json->max_size)
1431 croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu", 1435 croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu",
1432 (unsigned long)SvCUR (string), (unsigned long)json->max_size); 1436 (unsigned long)SvCUR (string), (unsigned long)json->max_size);
1433 1437
1434 if (json->flags & F_UTF8) 1438 if (json->flags & F_UTF8)
1435 sv_utf8_downgrade (string, 0); 1439 sv_utf8_downgrade (string, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines