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

Comparing CBOR-XS/XS.xs (file contents):
Revision 1.40 by root, Tue Dec 10 13:54:40 2013 UTC vs.
Revision 1.43 by root, Sun Jan 5 14:24:54 2014 UTC

736{ 736{
737 // for speed reasons, we specialcase single-string 737 // for speed reasons, we specialcase single-string
738 // byte or utf-8 strings as keys, but only when !stringref 738 // byte or utf-8 strings as keys, but only when !stringref
739 739
740 if (ecb_expect_true (!dec->stringref)) 740 if (ecb_expect_true (!dec->stringref))
741 if (ecb_expect_true ((*dec->cur - MAJOR_BYTES) <= LENGTH_EXT8)) 741 if (ecb_expect_true ((U8)(*dec->cur - MAJOR_BYTES) <= LENGTH_EXT8))
742 { 742 {
743 I32 len = decode_uint (dec); 743 I32 len = decode_uint (dec);
744 char *key = (char *)dec->cur; 744 char *key = (char *)dec->cur;
745 745
746 dec->cur += len; 746 dec->cur += len;
747 747
748 hv_store (hv, key, len, decode_sv (dec), 0); 748 hv_store (hv, key, len, decode_sv (dec), 0);
749 749
750 return; 750 return;
751 } 751 }
752 else if (ecb_expect_true ((*dec->cur - MAJOR_TEXT) <= LENGTH_EXT8)) 752 else if (ecb_expect_true ((U8)(*dec->cur - MAJOR_TEXT) <= LENGTH_EXT8))
753 { 753 {
754 I32 len = decode_uint (dec); 754 I32 len = decode_uint (dec);
755 char *key = (char *)dec->cur; 755 char *key = (char *)dec->cur;
756 756
757 dec->cur += len; 757 dec->cur += len;
1447 EXTEND (SP, 2); 1447 EXTEND (SP, 2);
1448 PUSHs (sv); 1448 PUSHs (sv);
1449 PUSHs (sv_2mortal (newSVuv (offset - SvPVX (cborstr)))); 1449 PUSHs (sv_2mortal (newSVuv (offset - SvPVX (cborstr))));
1450} 1450}
1451 1451
1452void incr_parse (CBOR *self, SV *cborstr, int chop = 0) 1452void incr_parse (CBOR *self, SV *cborstr)
1453 ALIAS:
1454 incr_parse_multiple = 1
1453 PPCODE: 1455 PPCODE:
1454{ 1456{
1455 if (SvUTF8 (cborstr)) 1457 if (SvUTF8 (cborstr))
1456 sv_utf8_downgrade (cborstr, 0); 1458 sv_utf8_downgrade (cborstr, 0);
1457 1459
1462 self->incr_need = 1; 1464 self->incr_need = 1;
1463 1465
1464 av_push (self->incr_count, newSViv (1)); 1466 av_push (self->incr_count, newSViv (1));
1465 } 1467 }
1466 1468
1467 for (;;) 1469 do
1468 { 1470 {
1469 if (!incr_parse (self, cborstr)) 1471 if (!incr_parse (self, cborstr))
1470 { 1472 {
1471 if (self->incr_need > self->max_size && self->max_size) 1473 if (self->incr_need > self->max_size && self->max_size)
1472 croak ("attempted decode of CBOR text of %lu bytes size, but max_size is set to %lu", 1474 croak ("attempted decode of CBOR text of %lu bytes size, but max_size is set to %lu",
1473 (unsigned long)self->incr_need, (unsigned long)self->max_size); 1475 (unsigned long)self->incr_need, (unsigned long)self->max_size);
1474 1476
1475 break; 1477 break;
1476 } 1478 }
1477 1479
1478 SV *sv; 1480 SV *sv;
1479 char *offset; 1481 char *offset;
1480 1482
1481 PUTBACK; sv = decode_cbor (cborstr, self, &offset); SPAGAIN; 1483 PUTBACK; sv = decode_cbor (cborstr, self, &offset); SPAGAIN;
1482 XPUSHs (sv); 1484 XPUSHs (sv);
1483 1485
1486 sv_chop (cborstr, offset);
1487
1484 av_clear (self->incr_count); 1488 av_clear (self->incr_count);
1485 av_push (self->incr_count, newSViv (1)); 1489 av_push (self->incr_count, newSViv (1));
1486 1490
1487 if (chop)
1488 {
1489 self->incr_pos = 0; 1491 self->incr_pos = 0;
1490 sv_chop (cborstr, offset);
1491 }
1492 else
1493 self->incr_pos = offset - SvPVX (cborstr);
1494
1495 self->incr_need = self->incr_pos + 1; 1492 self->incr_need = self->incr_pos + 1;
1496 } 1493 }
1494 while (ix);
1497} 1495}
1498 1496
1499void incr_reset (CBOR *self) 1497void incr_reset (CBOR *self)
1500 CODE: 1498 CODE:
1501{ 1499{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines