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.92 by root, Mon Sep 22 07:29:29 2008 UTC vs.
Revision 1.103 by root, Wed Jan 6 08:01:39 2010 UTC

12#if defined(__BORLANDC__) || defined(_MSC_VER) 12#if defined(__BORLANDC__) || defined(_MSC_VER)
13# define snprintf _snprintf // C compilers have this in stdio.h 13# define snprintf _snprintf // C compilers have this in stdio.h
14#endif 14#endif
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// guarentees, 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
76 77
77enum { 78enum {
78 INCR_M_WS = 0, // initial whitespace skipping, must be 0 79 INCR_M_WS = 0, // initial whitespace skipping, must be 0
79 INCR_M_STR, // inside string 80 INCR_M_STR, // inside string
80 INCR_M_BS, // inside backslash 81 INCR_M_BS, // inside backslash
82 INCR_M_C0, // inside comment in initial whitespace sequence
83 INCR_M_C1, // inside comment in other places
81 INCR_M_JSON // outside anything, count nesting 84 INCR_M_JSON // outside anything, count nesting
82}; 85};
83 86
84#define INCR_DONE(json) ((json)->incr_nest <= 0 && (json)->incr_mode == INCR_M_JSON) 87#define INCR_DONE(json) ((json)->incr_nest <= 0 && (json)->incr_mode == INCR_M_JSON)
85 88
175 *s++ = 0x80 | ( ch & 0x3f); 178 *s++ = 0x80 | ( ch & 0x3f);
176 179
177 return s; 180 return s;
178} 181}
179 182
183// convert offset pointer to character index, sv must be string
184static STRLEN
185ptr_to_index (SV *sv, char *offset)
186{
187 return SvUTF8 (sv)
188 ? utf8_distance (offset, SvPVX (sv))
189 : offset - SvPVX (sv);
190}
191
180///////////////////////////////////////////////////////////////////////////// 192/////////////////////////////////////////////////////////////////////////////
181// encoder 193// encoder
182 194
183// structure used for encoding JSON 195// structure used for encoding JSON
184typedef struct 196typedef struct
194INLINE void 206INLINE void
195need (enc_t *enc, STRLEN len) 207need (enc_t *enc, STRLEN len)
196{ 208{
197 if (expect_false (enc->cur + len >= enc->end)) 209 if (expect_false (enc->cur + len >= enc->end))
198 { 210 {
199 STRLEN cur = enc->cur - SvPVX (enc->sv); 211 STRLEN cur = enc->cur - (char *)SvPVX (enc->sv);
200 SvGROW (enc->sv, cur + len + 1); 212 SvGROW (enc->sv, cur + (len < (cur >> 2) ? cur >> 2 : len) + 1);
201 enc->cur = SvPVX (enc->sv) + cur; 213 enc->cur = SvPVX (enc->sv) + cur;
202 enc->end = SvPVX (enc->sv) + SvLEN (enc->sv) - 1; 214 enc->end = SvPVX (enc->sv) + SvLEN (enc->sv) - 1;
203 } 215 }
204} 216}
205 217
462 474
463 // for canonical output we have to sort by keys first 475 // for canonical output we have to sort by keys first
464 // actually, this is mostly due to the stupid so-called 476 // actually, this is mostly due to the stupid so-called
465 // security workaround added somewhere in 5.8.x 477 // security workaround added somewhere in 5.8.x
466 // that randomises hash orderings 478 // that randomises hash orderings
467 if (enc->json.flags & F_CANONICAL) 479 if (enc->json.flags & F_CANONICAL && !SvRMAGICAL (hv))
468 { 480 {
469 int count = hv_iterinit (hv); 481 int count = hv_iterinit (hv);
470 482
471 if (SvMAGICAL (hv)) 483 if (SvMAGICAL (hv))
472 { 484 {
750 : enc.json.flags & F_LATIN1 ? 0x000100UL 762 : enc.json.flags & F_LATIN1 ? 0x000100UL
751 : 0x110000UL; 763 : 0x110000UL;
752 764
753 SvPOK_only (enc.sv); 765 SvPOK_only (enc.sv);
754 encode_sv (&enc, scalar); 766 encode_sv (&enc, scalar);
767 encode_nl (&enc);
755 768
756 SvCUR_set (enc.sv, enc.cur - SvPVX (enc.sv)); 769 SvCUR_set (enc.sv, enc.cur - SvPVX (enc.sv));
757 *SvEND (enc.sv) = 0; // many xs functions expect a trailing 0 for text strings 770 *SvEND (enc.sv) = 0; // many xs functions expect a trailing 0 for text strings
758 771
759 if (!(enc.json.flags & (F_ASCII | F_LATIN1 | F_UTF8))) 772 if (!(enc.json.flags & (F_ASCII | F_LATIN1 | F_UTF8)))
939 else if (expect_true (ch >= 0x20 && ch < 0x80)) 952 else if (expect_true (ch >= 0x20 && ch < 0x80))
940 *cur++ = ch; 953 *cur++ = ch;
941 else if (ch >= 0x80) 954 else if (ch >= 0x80)
942 { 955 {
943 STRLEN clen; 956 STRLEN clen;
944 UV uch;
945 957
946 --dec_cur; 958 --dec_cur;
947 959
948 uch = decode_utf8 (dec_cur, dec->end - dec_cur, &clen); 960 decode_utf8 (dec_cur, dec->end - dec_cur, &clen);
949 if (clen == (STRLEN)-1) 961 if (clen == (STRLEN)-1)
950 ERR ("malformed UTF-8 character in JSON string"); 962 ERR ("malformed UTF-8 character in JSON string");
951 963
952 do 964 do
953 *cur++ = *dec_cur++; 965 *cur++ = *dec_cur++;
970 { 982 {
971 STRLEN len = cur - buf; 983 STRLEN len = cur - buf;
972 984
973 if (sv) 985 if (sv)
974 { 986 {
975 SvGROW (sv, SvCUR (sv) + len + 1); 987 STRLEN cur = SvCUR (sv);
988
989 if (SvLEN (sv) <= cur + len)
990 SvGROW (sv, cur + (len < (cur >> 2) ? cur >> 2 : len) + 1);
991
976 memcpy (SvPVX (sv) + SvCUR (sv), buf, len); 992 memcpy (SvPVX (sv) + SvCUR (sv), buf, len);
977 SvCUR_set (sv, SvCUR (sv) + len); 993 SvCUR_set (sv, SvCUR (sv) + len);
978 } 994 }
979 else 995 else
980 sv = newSVpvn (buf, len); 996 sv = newSVpvn (buf, len);
1071 1087
1072 // special case the rather common 1..5-digit-int case 1088 // special case the rather common 1..5-digit-int case
1073 if (*start == '-') 1089 if (*start == '-')
1074 switch (len) 1090 switch (len)
1075 { 1091 {
1076 case 2: return newSViv (-( start [1] - '0' * 1)); 1092 case 2: return newSViv (-(IV)( start [1] - '0' * 1));
1077 case 3: return newSViv (-( start [1] * 10 + start [2] - '0' * 11)); 1093 case 3: return newSViv (-(IV)( start [1] * 10 + start [2] - '0' * 11));
1078 case 4: return newSViv (-( start [1] * 100 + start [2] * 10 + start [3] - '0' * 111)); 1094 case 4: return newSViv (-(IV)( start [1] * 100 + start [2] * 10 + start [3] - '0' * 111));
1079 case 5: return newSViv (-( start [1] * 1000 + start [2] * 100 + start [3] * 10 + start [4] - '0' * 1111)); 1095 case 5: return newSViv (-(IV)( start [1] * 1000 + start [2] * 100 + start [3] * 10 + start [4] - '0' * 1111));
1080 case 6: return newSViv (-(start [1] * 10000 + start [2] * 1000 + start [3] * 100 + start [4] * 10 + start [5] - '0' * 11111)); 1096 case 6: return newSViv (-(IV)(start [1] * 10000 + start [2] * 1000 + start [3] * 100 + start [4] * 10 + start [5] - '0' * 11111));
1081 } 1097 }
1082 else 1098 else
1083 switch (len) 1099 switch (len)
1084 { 1100 {
1085 case 1: return newSViv ( start [0] - '0' * 1); 1101 case 1: return newSViv ( start [0] - '0' * 1);
1086 case 2: return newSViv ( start [0] * 10 + start [1] - '0' * 11); 1102 case 2: return newSViv ( start [0] * 10 + start [1] - '0' * 11);
1087 case 3: return newSViv ( start [0] * 100 + start [1] * 10 + start [2] - '0' * 111); 1103 case 3: return newSViv ( start [0] * 100 + start [1] * 10 + start [2] - '0' * 111);
1088 case 4: return newSViv ( start [0] * 1000 + start [1] * 100 + start [2] * 10 + start [3] - '0' * 1111); 1104 case 4: return newSViv ( start [0] * 1000 + start [1] * 100 + start [2] * 10 + start [3] - '0' * 1111);
1089 case 5: return newSViv ( start [0] * 10000 + start [1] * 1000 + start [2] * 100 + start [3] * 10 + start [4] - '0' * 11111); 1105 case 5: return newSViv ( start [0] * 10000 + start [1] * 1000 + start [2] * 100 + start [3] * 10 + start [4] - '0' * 11111);
1090 } 1106 }
1091 1107
1092 { 1108 {
1093 UV uv; 1109 UV uv;
1094 int numtype = grok_number (start, len, &uv); 1110 int numtype = grok_number (start, len, &uv);
1404fail: 1420fail:
1405 return 0; 1421 return 0;
1406} 1422}
1407 1423
1408static SV * 1424static SV *
1409decode_json (SV *string, JSON *json, STRLEN *offset_return) 1425decode_json (SV *string, JSON *json, char **offset_return)
1410{ 1426{
1411 dec_t dec; 1427 dec_t dec;
1412 STRLEN offset;
1413 SV *sv; 1428 SV *sv;
1414 1429
1430 /* work around bugs in 5.10 where manipulating magic values
1431 * will perl ignore the magic in subsequent accesses
1432 */
1415 SvGETMAGIC (string); 1433 /*SvGETMAGIC (string);*/
1434 if (SvMAGICAL (string))
1435 string = sv_2mortal (newSVsv (string));
1436
1416 SvUPGRADE (string, SVt_PV); 1437 SvUPGRADE (string, SVt_PV);
1417 1438
1418 /* work around a bug in perl 5.10, which causes SvCUR to fail an 1439 /* work around a bug in perl 5.10, which causes SvCUR to fail an
1419 * assertion with -DDEBUGGING, although SvCUR is documented to 1440 * assertion with -DDEBUGGING, although SvCUR is documented to
1420 * return the xpv_cur field which certainly exists after upgrading. 1441 * return the xpv_cur field which certainly exists after upgrading.
1423 * and hope for the best. 1444 * and hope for the best.
1424 * Damnit, SvPV_nolen still trips over yet another assertion. This 1445 * Damnit, SvPV_nolen still trips over yet another assertion. This
1425 * assertion business is seriously broken, try yet another workaround 1446 * assertion business is seriously broken, try yet another workaround
1426 * for the broken -DDEBUGGING. 1447 * for the broken -DDEBUGGING.
1427 */ 1448 */
1449 {
1428#ifdef DEBUGGING 1450#ifdef DEBUGGING
1429 offset = SvOK (string) ? sv_len (string) : 0; 1451 STRLEN offset = SvOK (string) ? sv_len (string) : 0;
1430#else 1452#else
1431 offset = SvCUR (string); 1453 STRLEN offset = SvCUR (string);
1432#endif 1454#endif
1433 1455
1434 if (offset > json->max_size && json->max_size) 1456 if (offset > json->max_size && json->max_size)
1435 croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu", 1457 croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu",
1436 (unsigned long)SvCUR (string), (unsigned long)json->max_size); 1458 (unsigned long)SvCUR (string), (unsigned long)json->max_size);
1459 }
1437 1460
1438 if (json->flags & F_UTF8) 1461 if (json->flags & F_UTF8)
1439 sv_utf8_downgrade (string, 0); 1462 sv_utf8_downgrade (string, 0);
1440 else 1463 else
1441 sv_utf8_upgrade (string); 1464 sv_utf8_upgrade (string);
1453 1476
1454 *dec.end = 0; // this should basically be a nop, too, but make sure it's there 1477 *dec.end = 0; // this should basically be a nop, too, but make sure it's there
1455 1478
1456 decode_ws (&dec); 1479 decode_ws (&dec);
1457 sv = decode_sv (&dec); 1480 sv = decode_sv (&dec);
1481
1482 if (offset_return)
1483 *offset_return = dec.cur;
1458 1484
1459 if (!(offset_return || !sv)) 1485 if (!(offset_return || !sv))
1460 { 1486 {
1461 // check for trailing garbage 1487 // check for trailing garbage
1462 decode_ws (&dec); 1488 decode_ws (&dec);
1465 { 1491 {
1466 dec.err = "garbage after JSON object"; 1492 dec.err = "garbage after JSON object";
1467 SvREFCNT_dec (sv); 1493 SvREFCNT_dec (sv);
1468 sv = 0; 1494 sv = 0;
1469 } 1495 }
1470 }
1471
1472 if (offset_return || !sv)
1473 {
1474 offset = dec.json.flags & F_UTF8
1475 ? dec.cur - SvPVX (string)
1476 : utf8_distance (dec.cur, SvPVX (string));
1477
1478 if (offset_return)
1479 *offset_return = offset;
1480 } 1496 }
1481 1497
1482 if (!sv) 1498 if (!sv)
1483 { 1499 {
1484 SV *uni = sv_newmortal (); 1500 SV *uni = sv_newmortal ();
1490 SAVEVPTR (PL_curcop); 1506 SAVEVPTR (PL_curcop);
1491 PL_curcop = &cop; 1507 PL_curcop = &cop;
1492 pv_uni_display (uni, dec.cur, dec.end - dec.cur, 20, UNI_DISPLAY_QQ); 1508 pv_uni_display (uni, dec.cur, dec.end - dec.cur, 20, UNI_DISPLAY_QQ);
1493 LEAVE; 1509 LEAVE;
1494 1510
1495 croak ("%s, at character offset %d [\"%s\"]", 1511 croak ("%s, at character offset %d (before \"%s\")",
1496 dec.err, 1512 dec.err,
1497 (int)offset, 1513 ptr_to_index (string, dec.cur),
1498 dec.cur != dec.end ? SvPV_nolen (uni) : "(end of string)"); 1514 dec.cur != dec.end ? SvPV_nolen (uni) : "(end of string)");
1499 } 1515 }
1500 1516
1501 sv = sv_2mortal (sv); 1517 sv = sv_2mortal (sv);
1502 1518
1511 1527
1512static void 1528static void
1513incr_parse (JSON *self) 1529incr_parse (JSON *self)
1514{ 1530{
1515 const char *p = SvPVX (self->incr_text) + self->incr_pos; 1531 const char *p = SvPVX (self->incr_text) + self->incr_pos;
1532
1533 // the state machine here is a bit convoluted and could be simplified a lot
1534 // but this would make it slower, so...
1516 1535
1517 for (;;) 1536 for (;;)
1518 { 1537 {
1519 //printf ("loop pod %d *p<%c><%s>, mode %d nest %d\n", p - SvPVX (self->incr_text), *p, p, self->incr_mode, self->incr_nest);//D 1538 //printf ("loop pod %d *p<%c><%s>, mode %d nest %d\n", p - SvPVX (self->incr_text), *p, p, self->incr_mode, self->incr_nest);//D
1520 switch (self->incr_mode) 1539 switch (self->incr_mode)
1521 { 1540 {
1522 // only used for intiial whitespace skipping 1541 // only used for initial whitespace skipping
1523 case INCR_M_WS: 1542 case INCR_M_WS:
1524 for (;;) 1543 for (;;)
1525 { 1544 {
1526 if (*p > 0x20) 1545 if (*p > 0x20)
1527 { 1546 {
1547 if (*p == '#')
1548 {
1549 self->incr_mode = INCR_M_C0;
1550 goto incr_m_c;
1551 }
1552 else
1553 {
1528 self->incr_mode = INCR_M_JSON; 1554 self->incr_mode = INCR_M_JSON;
1529 goto incr_m_json; 1555 goto incr_m_json;
1556 }
1530 } 1557 }
1531 else if (!*p) 1558 else if (!*p)
1532 goto interrupt; 1559 goto interrupt;
1533 1560
1534 ++p; 1561 ++p;
1540 goto interrupt; 1567 goto interrupt;
1541 1568
1542 ++p; 1569 ++p;
1543 self->incr_mode = INCR_M_STR; 1570 self->incr_mode = INCR_M_STR;
1544 goto incr_m_str; 1571 goto incr_m_str;
1572
1573 // inside #-style comments
1574 case INCR_M_C0:
1575 case INCR_M_C1:
1576 incr_m_c:
1577 for (;;)
1578 {
1579 if (*p == '\n')
1580 {
1581 self->incr_mode = self->incr_mode == INCR_M_C0 ? INCR_M_WS : INCR_M_JSON;
1582 break;
1583 }
1584 else if (!*p)
1585 goto interrupt;
1586
1587 ++p;
1588 }
1589
1590 break;
1545 1591
1546 // inside a string 1592 // inside a string
1547 case INCR_M_STR: 1593 case INCR_M_STR:
1548 incr_m_str: 1594 incr_m_str:
1549 for (;;) 1595 for (;;)
1608 1654
1609 case ']': 1655 case ']':
1610 case '}': 1656 case '}':
1611 if (--self->incr_nest <= 0) 1657 if (--self->incr_nest <= 0)
1612 goto interrupt; 1658 goto interrupt;
1659 break;
1660
1661 case '#':
1662 self->incr_mode = INCR_M_C1;
1663 goto incr_m_c;
1613 } 1664 }
1614 } 1665 }
1615 } 1666 }
1616 1667
1617 modechange: 1668 modechange:
1618 ; 1669 ;
1619 } 1670 }
1620 1671
1621interrupt: 1672interrupt:
1622 self->incr_pos = p - SvPVX (self->incr_text); 1673 self->incr_pos = p - SvPVX (self->incr_text);
1674 //printf ("interrupt<%.*s>\n", self->incr_pos, SvPVX(self->incr_text));//D
1623 //printf ("return pos %d mode %d nest %d\n", self->incr_pos, self->incr_mode, self->incr_nest);//D 1675 //printf ("return pos %d mode %d nest %d\n", self->incr_pos, self->incr_mode, self->incr_nest);//D
1624} 1676}
1625 1677
1626///////////////////////////////////////////////////////////////////////////// 1678/////////////////////////////////////////////////////////////////////////////
1627// XS interface functions 1679// XS interface functions
1642 json_stash = gv_stashpv ("JSON::XS" , 1); 1694 json_stash = gv_stashpv ("JSON::XS" , 1);
1643 json_boolean_stash = gv_stashpv ("JSON::XS::Boolean", 1); 1695 json_boolean_stash = gv_stashpv ("JSON::XS::Boolean", 1);
1644 1696
1645 json_true = get_bool ("JSON::XS::true"); 1697 json_true = get_bool ("JSON::XS::true");
1646 json_false = get_bool ("JSON::XS::false"); 1698 json_false = get_bool ("JSON::XS::false");
1699
1700 CvNODEBUG_on (get_cv ("JSON::XS::incr_text", 0)); /* the debugger completely breaks lvalue subs */
1647} 1701}
1648 1702
1649PROTOTYPES: DISABLE 1703PROTOTYPES: DISABLE
1650 1704
1651void CLONE (...) 1705void CLONE (...)
1771 XPUSHs (decode_json (jsonstr, self, 0)); 1825 XPUSHs (decode_json (jsonstr, self, 0));
1772 1826
1773void decode_prefix (JSON *self, SV *jsonstr) 1827void decode_prefix (JSON *self, SV *jsonstr)
1774 PPCODE: 1828 PPCODE:
1775{ 1829{
1776 STRLEN offset; 1830 char *offset;
1777 EXTEND (SP, 2); 1831 EXTEND (SP, 2);
1778 PUSHs (decode_json (jsonstr, self, &offset)); 1832 PUSHs (decode_json (jsonstr, self, &offset));
1779 PUSHs (sv_2mortal (newSVuv (offset))); 1833 PUSHs (sv_2mortal (newSVuv (ptr_to_index (jsonstr, offset))));
1780} 1834}
1781 1835
1782void incr_parse (JSON *self, SV *jsonstr = 0) 1836void incr_parse (JSON *self, SV *jsonstr = 0)
1783 PPCODE: 1837 PPCODE:
1784{ 1838{
1786 self->incr_text = newSVpvn ("", 0); 1840 self->incr_text = newSVpvn ("", 0);
1787 1841
1788 // append data, if any 1842 // append data, if any
1789 if (jsonstr) 1843 if (jsonstr)
1790 { 1844 {
1791 if (SvUTF8 (jsonstr) && !SvUTF8 (self->incr_text)) 1845 if (SvUTF8 (jsonstr))
1792 { 1846 {
1847 if (!SvUTF8 (self->incr_text))
1848 {
1793 /* utf-8-ness differs, need to upgrade */ 1849 /* utf-8-ness differs, need to upgrade */
1794 sv_utf8_upgrade (self->incr_text); 1850 sv_utf8_upgrade (self->incr_text);
1795 1851
1796 if (self->incr_pos) 1852 if (self->incr_pos)
1797 self->incr_pos = utf8_hop ((U8 *)SvPVX (self->incr_text), self->incr_pos) 1853 self->incr_pos = utf8_hop ((U8 *)SvPVX (self->incr_text), self->incr_pos)
1798 - (U8 *)SvPVX (self->incr_text); 1854 - (U8 *)SvPVX (self->incr_text);
1855 }
1799 } 1856 }
1857 else if (SvUTF8 (self->incr_text))
1858 sv_utf8_upgrade (jsonstr);
1800 1859
1801 { 1860 {
1802 STRLEN len; 1861 STRLEN len;
1803 const char *str = SvPV (jsonstr, len); 1862 const char *str = SvPV (jsonstr, len);
1804 SvGROW (self->incr_text, SvCUR (self->incr_text) + len + 1); 1863 STRLEN cur = SvCUR (self->incr_text);
1864
1865 if (SvLEN (self->incr_text) <= cur + len)
1866 SvGROW (self->incr_text, cur + (len < (cur >> 2) ? cur >> 2 : len) + 1);
1867
1805 Move (str, SvEND (self->incr_text), len, char); 1868 Move (str, SvEND (self->incr_text), len, char);
1806 SvCUR_set (self->incr_text, SvCUR (self->incr_text) + len); 1869 SvCUR_set (self->incr_text, SvCUR (self->incr_text) + len);
1807 *SvEND (self->incr_text) = 0; // this should basically be a nop, too, but make sure it's there 1870 *SvEND (self->incr_text) = 0; // this should basically be a nop, too, but make sure it's there
1808 } 1871 }
1809 } 1872 }
1810 1873
1811 if (GIMME_V != G_VOID) 1874 if (GIMME_V != G_VOID)
1812 do 1875 do
1813 { 1876 {
1814 STRLEN offset; 1877 char *offset;
1815 1878
1816 if (!INCR_DONE (self)) 1879 if (!INCR_DONE (self))
1817 { 1880 {
1818 incr_parse (self); 1881 incr_parse (self);
1819 1882
1825 break; 1888 break;
1826 } 1889 }
1827 1890
1828 XPUSHs (decode_json (self->incr_text, self, &offset)); 1891 XPUSHs (decode_json (self->incr_text, self, &offset));
1829 1892
1830 sv_chop (self->incr_text, SvPV_nolen (self->incr_text) + offset);
1831 self->incr_pos -= offset; 1893 self->incr_pos -= offset - SvPVX (self->incr_text);
1832 self->incr_nest = 0; 1894 self->incr_nest = 0;
1833 self->incr_mode = 0; 1895 self->incr_mode = 0;
1896
1897 sv_chop (self->incr_text, offset);
1834 } 1898 }
1835 while (GIMME_V == G_ARRAY); 1899 while (GIMME_V == G_ARRAY);
1836} 1900}
1837 1901
1838SV *incr_text (JSON *self) 1902SV *incr_text (JSON *self)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines