r36749 - in /branches/upstream/libjson-xs-perl/current: Changes MANIFEST META.yml XS.pm XS.xs t/21_evans.t
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Sat May 30 07:09:24 UTC 2009
Author: ryan52-guest
Date: Sat May 30 07:08:53 2009
New Revision: 36749
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36749
Log:
[svn-upgrade] Integrating new upstream version, libjson-xs-perl (2.24)
Added:
branches/upstream/libjson-xs-perl/current/t/21_evans.t
Modified:
branches/upstream/libjson-xs-perl/current/Changes
branches/upstream/libjson-xs-perl/current/MANIFEST
branches/upstream/libjson-xs-perl/current/META.yml
branches/upstream/libjson-xs-perl/current/XS.pm
branches/upstream/libjson-xs-perl/current/XS.xs
Modified: branches/upstream/libjson-xs-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/Changes?rev=36749&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/Changes (original)
+++ branches/upstream/libjson-xs-perl/current/Changes Sat May 30 07:08:53 2009
@@ -1,4 +1,12 @@
Revision history for Perl extension JSON::XS
+
+2.24 Sat May 30 08:25:45 CEST 2009
+ - the incremental parser did not update its parse offset
+ pointer correctly when parsing utf8-strings (nicely
+ debugged by Martin Evans).
+ - appending a non-utf8-string to the incremental parser
+ in utf8 mode failed to upgrade the string.
+ - wording of parse error messages has been improved.
2.232 Sun Feb 22 11:12:25 CET 2009
- use an exponential algorithm to extend strings, to
Modified: branches/upstream/libjson-xs-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/MANIFEST?rev=36749&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/MANIFEST (original)
+++ branches/upstream/libjson-xs-perl/current/MANIFEST Sat May 30 07:08:53 2009
@@ -29,6 +29,7 @@
t/18_json_checker.t
t/19_incr.t
t/20_faihu.t
+t/21_evans.t
t/99_binary.t
typemap
META.yml Module meta-data (added by MakeMaker)
Modified: branches/upstream/libjson-xs-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/META.yml?rev=36749&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/META.yml (original)
+++ branches/upstream/libjson-xs-perl/current/META.yml Sat May 30 07:08:53 2009
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: JSON-XS
-version: 2.232
+version: 2.24
abstract: ~
author: []
license: unknown
Modified: branches/upstream/libjson-xs-perl/current/XS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/XS.pm?rev=36749&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/XS.pm (original)
+++ branches/upstream/libjson-xs-perl/current/XS.pm Sat May 30 07:08:53 2009
@@ -104,7 +104,7 @@
no warnings;
use strict;
-our $VERSION = '2.232';
+our $VERSION = '2.24';
our @ISA = qw(Exporter);
our @EXPORT = qw(encode_json decode_json to_json from_json);
Modified: branches/upstream/libjson-xs-perl/current/XS.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/XS.xs?rev=36749&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/XS.xs (original)
+++ branches/upstream/libjson-xs-perl/current/XS.xs Sat May 30 07:08:53 2009
@@ -175,6 +175,15 @@
*s++ = 0x80 | ( ch & 0x3f);
return s;
+}
+
+// convert offset pointer to character index, sv must be string
+static STRLEN
+ptr_to_index (SV *sv, char *offset)
+{
+ return SvUTF8 (sv)
+ ? utf8_distance (offset, SvPVX (sv))
+ : offset - SvPVX (sv);
}
/////////////////////////////////////////////////////////////////////////////
@@ -1410,10 +1419,9 @@
}
static SV *
-decode_json (SV *string, JSON *json, STRLEN *offset_return)
+decode_json (SV *string, JSON *json, char **offset_return)
{
dec_t dec;
- STRLEN offset;
SV *sv;
/* work around bugs in 5.10 where manipulating magic values
@@ -1435,15 +1443,17 @@
* assertion business is seriously broken, try yet another workaround
* for the broken -DDEBUGGING.
*/
+ {
#ifdef DEBUGGING
- offset = SvOK (string) ? sv_len (string) : 0;
+ STRLEN offset = SvOK (string) ? sv_len (string) : 0;
#else
- offset = SvCUR (string);
+ STRLEN offset = SvCUR (string);
#endif
- if (offset > json->max_size && json->max_size)
- croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu",
- (unsigned long)SvCUR (string), (unsigned long)json->max_size);
+ if (offset > json->max_size && json->max_size)
+ croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu",
+ (unsigned long)SvCUR (string), (unsigned long)json->max_size);
+ }
if (json->flags & F_UTF8)
sv_utf8_downgrade (string, 0);
@@ -1465,6 +1475,9 @@
decode_ws (&dec);
sv = decode_sv (&dec);
+
+ if (offset_return)
+ *offset_return = dec.cur;
if (!(offset_return || !sv))
{
@@ -1477,16 +1490,6 @@
SvREFCNT_dec (sv);
sv = 0;
}
- }
-
- if (offset_return || !sv)
- {
- offset = dec.json.flags & F_UTF8
- ? dec.cur - SvPVX (string)
- : utf8_distance (dec.cur, SvPVX (string));
-
- if (offset_return)
- *offset_return = offset;
}
if (!sv)
@@ -1502,9 +1505,9 @@
pv_uni_display (uni, dec.cur, dec.end - dec.cur, 20, UNI_DISPLAY_QQ);
LEAVE;
- croak ("%s, at character offset %d [\"%s\"]",
+ croak ("%s, at character offset %d (before \"%s\")",
dec.err,
- (int)offset,
+ ptr_to_index (string, dec.cur),
dec.cur != dec.end ? SvPV_nolen (uni) : "(end of string)");
}
@@ -1783,10 +1786,10 @@
void decode_prefix (JSON *self, SV *jsonstr)
PPCODE:
{
- STRLEN offset;
+ char *offset;
EXTEND (SP, 2);
PUSHs (decode_json (jsonstr, self, &offset));
- PUSHs (sv_2mortal (newSVuv (offset)));
+ PUSHs (sv_2mortal (newSVuv (ptr_to_index (jsonstr, offset))));
}
void incr_parse (JSON *self, SV *jsonstr = 0)
@@ -1798,15 +1801,20 @@
// append data, if any
if (jsonstr)
{
- if (SvUTF8 (jsonstr) && !SvUTF8 (self->incr_text))
+ if (SvUTF8 (jsonstr))
{
- /* utf-8-ness differs, need to upgrade */
- sv_utf8_upgrade (self->incr_text);
-
- if (self->incr_pos)
- self->incr_pos = utf8_hop ((U8 *)SvPVX (self->incr_text), self->incr_pos)
- - (U8 *)SvPVX (self->incr_text);
+ if (!SvUTF8 (self->incr_text))
+ {
+ /* utf-8-ness differs, need to upgrade */
+ sv_utf8_upgrade (self->incr_text);
+
+ if (self->incr_pos)
+ self->incr_pos = utf8_hop ((U8 *)SvPVX (self->incr_text), self->incr_pos)
+ - (U8 *)SvPVX (self->incr_text);
+ }
}
+ else if (SvUTF8 (self->incr_text))
+ sv_utf8_upgrade (jsonstr);
{
STRLEN len;
@@ -1825,7 +1833,7 @@
if (GIMME_V != G_VOID)
do
{
- STRLEN offset;
+ char *offset;
if (!INCR_DONE (self))
{
@@ -1841,10 +1849,11 @@
XPUSHs (decode_json (self->incr_text, self, &offset));
- sv_chop (self->incr_text, SvPV_nolen (self->incr_text) + offset);
- self->incr_pos -= offset;
+ self->incr_pos -= offset - SvPVX (self->incr_text);
self->incr_nest = 0;
self->incr_mode = 0;
+
+ sv_chop (self->incr_text, offset);
}
while (GIMME_V == G_ARRAY);
}
Added: branches/upstream/libjson-xs-perl/current/t/21_evans.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/t/21_evans.t?rev=36749&op=file
==============================================================================
--- branches/upstream/libjson-xs-perl/current/t/21_evans.t (added)
+++ branches/upstream/libjson-xs-perl/current/t/21_evans.t Sat May 30 07:08:53 2009
@@ -1,0 +1,23 @@
+#! perl
+
+# adapted from a test by Martin Evans
+
+use strict;
+use warnings;
+
+use JSON::XS;
+
+print "1..1\n";
+
+my $data = ["\x{53f0}\x{6240}\x{306e}\x{6d41}\x{3057}",
+ "\x{6c60}\x{306e}\x{30ab}\x{30a8}\x{30eb}"];
+my $js = JSON::XS->new->encode ($data);
+my $j = new JSON::XS;
+my $object = $j->incr_parse ($js);
+
+die "no object" if !$object;
+
+eval { $j->incr_text };
+
+print $@ ? "not " : "", "ok 1 # $@\n";
+
More information about the Pkg-perl-cvs-commits
mailing list