r36752 - in /trunk/libjson-xs-perl: Changes MANIFEST META.yml XS.pm XS.xs debian/changelog debian/control t/21_evans.t

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Sat May 30 07:27:52 UTC 2009


Author: ryan52-guest
Date: Sat May 30 07:27:47 2009
New Revision: 36752

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36752
Log:
* New upstream release
* Add myself to Uploaders
* Debian Policy 3.8.1

Added:
    trunk/libjson-xs-perl/t/21_evans.t
Modified:
    trunk/libjson-xs-perl/Changes
    trunk/libjson-xs-perl/MANIFEST
    trunk/libjson-xs-perl/META.yml
    trunk/libjson-xs-perl/XS.pm
    trunk/libjson-xs-perl/XS.xs
    trunk/libjson-xs-perl/debian/changelog
    trunk/libjson-xs-perl/debian/control

Modified: trunk/libjson-xs-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjson-xs-perl/Changes?rev=36752&op=diff
==============================================================================
--- trunk/libjson-xs-perl/Changes (original)
+++ trunk/libjson-xs-perl/Changes Sat May 30 07:27:47 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: trunk/libjson-xs-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjson-xs-perl/MANIFEST?rev=36752&op=diff
==============================================================================
--- trunk/libjson-xs-perl/MANIFEST (original)
+++ trunk/libjson-xs-perl/MANIFEST Sat May 30 07:27:47 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: trunk/libjson-xs-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjson-xs-perl/META.yml?rev=36752&op=diff
==============================================================================
--- trunk/libjson-xs-perl/META.yml (original)
+++ trunk/libjson-xs-perl/META.yml Sat May 30 07:27:47 2009
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               JSON-XS
-version:            2.232
+version:            2.24
 abstract:           ~
 author:  []
 license:            unknown

Modified: trunk/libjson-xs-perl/XS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjson-xs-perl/XS.pm?rev=36752&op=diff
==============================================================================
--- trunk/libjson-xs-perl/XS.pm (original)
+++ trunk/libjson-xs-perl/XS.pm Sat May 30 07:27:47 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: trunk/libjson-xs-perl/XS.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjson-xs-perl/XS.xs?rev=36752&op=diff
==============================================================================
--- trunk/libjson-xs-perl/XS.xs (original)
+++ trunk/libjson-xs-perl/XS.xs Sat May 30 07:27:47 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);
 }

Modified: trunk/libjson-xs-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjson-xs-perl/debian/changelog?rev=36752&op=diff
==============================================================================
--- trunk/libjson-xs-perl/debian/changelog (original)
+++ trunk/libjson-xs-perl/debian/changelog Sat May 30 07:27:47 2009
@@ -1,3 +1,11 @@
+libjson-xs-perl (2.240-1) UNRELEASED; urgency=low
+
+  * New upstream release
+  * Add myself to Uploaders
+  * Debian Policy 3.8.1
+
+ -- Ryan Niebur <ryanryan52 at gmail.com>  Sat, 30 May 2009 00:18:27 -0700
+
 libjson-xs-perl (2.232-1) unstable; urgency=low
 
   [ Ansgar Burchardt ]

Modified: trunk/libjson-xs-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjson-xs-perl/debian/control?rev=36752&op=diff
==============================================================================
--- trunk/libjson-xs-perl/debian/control (original)
+++ trunk/libjson-xs-perl/debian/control Sat May 30 07:27:47 2009
@@ -6,8 +6,8 @@
 Uploaders: Angel Abad (Ikusnet SLL) <angel at grupoikusnet.com>,
  Ivan Kohler <ivan-debian at 420.am>,
  Niko Tyni <ntyni at debian.org>, gregor herrmann <gregoa at debian.org>,
- Ansgar Burchardt <ansgar at 43-1.org>
-Standards-Version: 3.8.0
+ Ansgar Burchardt <ansgar at 43-1.org>, Ryan Niebur <ryanryan52 at gmail.com>
+Standards-Version: 3.8.1
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libjson-xs-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libjson-xs-perl/
 Homepage: http://search.cpan.org/dist/JSON-XS/

Added: trunk/libjson-xs-perl/t/21_evans.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjson-xs-perl/t/21_evans.t?rev=36752&op=file
==============================================================================
--- trunk/libjson-xs-perl/t/21_evans.t (added)
+++ trunk/libjson-xs-perl/t/21_evans.t Sat May 30 07:27:47 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