r50458 - in /branches/upstream/libjson-xs-perl/current: Changes MANIFEST META.json META.yml README XS.pm XS.xs t/01_utf8.t t/06_pc_pretty.t t/22_comment_at_eof.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Jan 7 16:20:51 UTC 2010


Author: jawnsy-guest
Date: Thu Jan  7 16:20:44 2010
New Revision: 50458

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50458
Log:
[svn-upgrade] Integrating new upstream version, libjson-xs-perl (2.270)

Added:
    branches/upstream/libjson-xs-perl/current/META.json
    branches/upstream/libjson-xs-perl/current/t/22_comment_at_eof.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/README
    branches/upstream/libjson-xs-perl/current/XS.pm
    branches/upstream/libjson-xs-perl/current/XS.xs
    branches/upstream/libjson-xs-perl/current/t/01_utf8.t
    branches/upstream/libjson-xs-perl/current/t/06_pc_pretty.t

Modified: branches/upstream/libjson-xs-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/Changes?rev=50458&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/Changes (original)
+++ branches/upstream/libjson-xs-perl/current/Changes Thu Jan  7 16:20:44 2010
@@ -1,4 +1,14 @@
 Revision history for Perl extension JSON::XS
+
+2.27  Thu Jan  7 07:35:08 CET 2010
+	- support relaxed option inside the incremental parser
+          (testcase provided by IKEGAMI via Makamaka).
+
+2.26  Sat Oct 10 03:26:19 CEST 2009
+	- big integers could become truncated (based on patch
+          by Strobl Anton).
+	- output format change: indent now adds a final newline, which is
+          more expected and more true to the documentation.
 
 2.25  Sat Aug  8 12:04:41 CEST 2009
 	- the perl debugger completely breaks lvalue subs - try to work

Modified: branches/upstream/libjson-xs-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/MANIFEST?rev=50458&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/MANIFEST (original)
+++ branches/upstream/libjson-xs-perl/current/MANIFEST Thu Jan  7 16:20:44 2010
@@ -30,6 +30,8 @@
 t/19_incr.t
 t/20_faihu.t
 t/21_evans.t
+t/22_comment_at_eof.t
 t/99_binary.t
 typemap
 META.yml                                 Module meta-data (added by MakeMaker)
+META.json                                Module meta-data (added by MakeMaker)

Added: branches/upstream/libjson-xs-perl/current/META.json
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/META.json?rev=50458&op=file
==============================================================================
--- branches/upstream/libjson-xs-perl/current/META.json (added)
+++ branches/upstream/libjson-xs-perl/current/META.json Thu Jan  7 16:20:44 2010
@@ -1,0 +1,1 @@
+{"no_index":{"directory":["t","inc"]},"meta-spec":{"version":1.4,"url":"http://module-build.sourceforge.net/META-spec-v1.4.html"},"generated_by":"ExtUtils::MakeMaker version 6.54","distribution_type":"module","version":"2.27","name":"JSON-XS","author":[],"license":"unknown","build_requires":{"ExtUtils::MakeMaker":0},"requires":{"common::sense":0},"abstract":null,"configure_requires":{"ExtUtils::MakeMaker":0}}

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=50458&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/META.yml (original)
+++ branches/upstream/libjson-xs-perl/current/META.yml Thu Jan  7 16:20:44 2010
@@ -9,9 +9,9 @@
       "version" : 1.4,
       "url" : "http://module-build.sourceforge.net/META-spec-v1.4.html"
    },
-   "generated_by" : "ExtUtils::MakeMaker version 6.50",
+   "generated_by" : "ExtUtils::MakeMaker version 6.54",
    "distribution_type" : "module",
-   "version" : "2.25",
+   "version" : "2.27",
    "name" : "JSON-XS",
    "author" : [],
    "license" : "unknown",

Modified: branches/upstream/libjson-xs-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/README?rev=50458&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/README (original)
+++ branches/upstream/libjson-xs-perl/current/README Thu Jan  7 16:20:44 2010
@@ -1155,10 +1155,10 @@
     This will *usually* generate JSON texts that also parse as valid YAML.
     Please note that YAML has hardcoded limits on (simple) object key
     lengths that JSON doesn't have and also has different and incompatible
-    unicode handling, so you should make sure that your hash keys are
-    noticeably shorter than the 1024 "stream characters" YAML allows and
-    that you do not have characters with codepoint values outside the
-    Unicode BMP (basic multilingual page). YAML also does not allow "\/"
+    unicode character escape syntax, so you should make sure that your hash
+    keys are noticeably shorter than the 1024 "stream characters" YAML
+    allows and that you do not have characters with codepoint values outside
+    the Unicode BMP (basic multilingual page). YAML also does not allow "\/"
     sequences in strings (which JSON::XS does not *currently* generate, but
     other JSON generators might).
 
@@ -1184,6 +1184,12 @@
         compatible to it, and educating users about the changes, instead of
         spreading lies about the real compatibility for many *years* and
         trying to silence people who point out that it isn't true.
+
+        Addendum/2009: the YAML 1.2 spec is still incomaptible with JSON,
+        even though the incompatibilities have been documented (and are
+        known to Brian) for many years and the spec makes explicit claims
+        that YAML is a superset of JSON. It would be so easy to fix, but
+        apparently, bullying and corrupting userdata is so much easier.
 
   SPEED
     It seems that JSON::XS is surprisingly fast, as shown in the following

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=50458&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/XS.pm (original)
+++ branches/upstream/libjson-xs-perl/current/XS.pm Thu Jan  7 16:20:44 2010
@@ -103,7 +103,7 @@
 
 use common::sense;
 
-our $VERSION = '2.25';
+our $VERSION = '2.27';
 our @ISA = qw(Exporter);
 
 our @EXPORT = qw(encode_json decode_json to_json from_json);
@@ -1270,12 +1270,12 @@
 This will I<usually> generate JSON texts that also parse as valid
 YAML. Please note that YAML has hardcoded limits on (simple) object key
 lengths that JSON doesn't have and also has different and incompatible
-unicode handling, so you should make sure that your hash keys are
-noticeably shorter than the 1024 "stream characters" YAML allows and that
-you do not have characters with codepoint values outside the Unicode BMP
-(basic multilingual page). YAML also does not allow C<\/> sequences in
-strings (which JSON::XS does not I<currently> generate, but other JSON
-generators might).
+unicode character escape syntax, so you should make sure that your hash
+keys are noticeably shorter than the 1024 "stream characters" YAML allows
+and that you do not have characters with codepoint values outside the
+Unicode BMP (basic multilingual page). YAML also does not allow C<\/>
+sequences in strings (which JSON::XS does not I<currently> generate, but
+other JSON generators might).
 
 There might be other incompatibilities that I am not aware of (or the YAML
 specification has been changed yet again - it does so quite often). In
@@ -1303,6 +1303,12 @@
 educating users about the changes, instead of spreading lies about the
 real compatibility for many I<years> and trying to silence people who
 point out that it isn't true.
+
+Addendum/2009: the YAML 1.2 spec is still incomaptible with JSON, even
+though the incompatibilities have been documented (and are known to
+Brian) for many years and the spec makes explicit claims that YAML is a
+superset of JSON. It would be so easy to fix, but apparently, bullying and
+corrupting userdata is so much easier.
 
 =back
 

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=50458&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/XS.xs (original)
+++ branches/upstream/libjson-xs-perl/current/XS.xs Thu Jan  7 16:20:44 2010
@@ -19,7 +19,8 @@
 # define UTF8_MAXBYTES 13
 #endif
 
-#define IVUV_MAXCHARS (sizeof (UV) * CHAR_BIT * 28 / 93 + 2)
+// three extra for rounding, sign, and end of string
+#define IVUV_MAXCHARS (sizeof (UV) * CHAR_BIT * 28 / 93 + 3)
 
 #define F_ASCII          0x00000001UL
 #define F_LATIN1         0x00000002UL
@@ -78,6 +79,8 @@
   INCR_M_WS = 0, // initial whitespace skipping, must be 0
   INCR_M_STR,    // inside string
   INCR_M_BS,     // inside backslash
+  INCR_M_C0,     // inside comment in initial whitespace sequence
+  INCR_M_C1,     // inside comment in other places
   INCR_M_JSON    // outside anything, count nesting
 };
 
@@ -761,6 +764,7 @@
 
   SvPOK_only (enc.sv);
   encode_sv (&enc, scalar);
+  encode_nl (&enc);
 
   SvCUR_set (enc.sv, enc.cur - SvPVX (enc.sv));
   *SvEND (enc.sv) = 0; // many xs functions expect a trailing 0 for text strings
@@ -950,11 +954,10 @@
           else if (ch >= 0x80)
             {
               STRLEN clen;
-              UV uch;
 
               --dec_cur;
 
-              uch = decode_utf8 (dec_cur, dec->end - dec_cur, &clen);
+              decode_utf8 (dec_cur, dec->end - dec_cur, &clen);
               if (clen == (STRLEN)-1)
                 ERR ("malformed UTF-8 character in JSON string");
 
@@ -1527,19 +1530,30 @@
 {
   const char *p = SvPVX (self->incr_text) + self->incr_pos;
 
+  // the state machine here is a bit convoluted and could be simplified a lot
+  // but this would make it slower, so...
+
   for (;;)
     {
       //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
       switch (self->incr_mode)
         {
-          // only used for intiial whitespace skipping
+          // only used for initial whitespace skipping
           case INCR_M_WS:
             for (;;)
               {
                 if (*p > 0x20)
                   {
-                    self->incr_mode = INCR_M_JSON;
-                    goto incr_m_json;
+                    if (*p == '#')
+                      {
+                        self->incr_mode = INCR_M_C0;
+                        goto incr_m_c;
+                      }
+                    else
+                      {
+                        self->incr_mode = INCR_M_JSON;
+                        goto incr_m_json;
+                      }
                   }
                 else if (!*p)
                   goto interrupt;
@@ -1555,6 +1569,25 @@
             ++p;
             self->incr_mode = INCR_M_STR;
             goto incr_m_str;
+
+          // inside #-style comments
+          case INCR_M_C0:
+          case INCR_M_C1:
+          incr_m_c:
+            for (;;)
+              {
+                if (*p == '\n')
+                  {
+                    self->incr_mode = self->incr_mode == INCR_M_C0 ? INCR_M_WS : INCR_M_JSON;
+                    break;
+                  }
+                else if (!*p)
+                  goto interrupt;
+
+                ++p;
+              }
+
+            break;
 
           // inside a string
           case INCR_M_STR:
@@ -1623,6 +1656,11 @@
                     case '}':
                       if (--self->incr_nest <= 0)
                         goto interrupt;
+                      break;
+
+                    case '#':
+                      self->incr_mode = INCR_M_C1;
+                      goto incr_m_c;
                   }
               }
         }
@@ -1633,6 +1671,7 @@
 
 interrupt:
   self->incr_pos = p - SvPVX (self->incr_text);
+  //printf ("interrupt<%.*s>\n", self->incr_pos, SvPVX(self->incr_text));//D
   //printf ("return pos %d mode %d nest %d\n", self->incr_pos, self->incr_mode, self->incr_nest);//D
 }
 

Modified: branches/upstream/libjson-xs-perl/current/t/01_utf8.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/t/01_utf8.t?rev=50458&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/t/01_utf8.t (original)
+++ branches/upstream/libjson-xs-perl/current/t/01_utf8.t Thu Jan  7 16:20:44 2010
@@ -11,7 +11,7 @@
 ok (JSON::XS->new->allow_nonref (1)->utf8 (1)->encode ("ü") eq "\"\xc3\xbc\"");
 ok (JSON::XS->new->allow_nonref (1)->encode ("ü") eq "\"ü\"");
 ok (JSON::XS->new->allow_nonref (1)->ascii (1)->utf8 (1)->encode (chr 0x8000) eq '"\u8000"');
-ok (JSON::XS->new->allow_nonref (1)->ascii (1)->utf8 (1)->pretty (1)->encode (chr 0x10402) eq '"\ud801\udc02"');
+ok (JSON::XS->new->allow_nonref (1)->ascii (1)->utf8 (1)->pretty (1)->encode (chr 0x10402) eq "\"\\ud801\\udc02\"\n");
 
 eval { JSON::XS->new->allow_nonref (1)->utf8 (1)->decode ('"ü"') };
 ok $@ =~ /malformed UTF-8/;

Modified: branches/upstream/libjson-xs-perl/current/t/06_pc_pretty.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/t/06_pc_pretty.t?rev=50458&op=diff
==============================================================================
--- branches/upstream/libjson-xs-perl/current/t/06_pc_pretty.t (original)
+++ branches/upstream/libjson-xs-perl/current/t/06_pc_pretty.t Thu Jan  7 16:20:44 2010
@@ -24,7 +24,8 @@
    {
       "foo" : "bar"
    }
-]|);
+]
+|);
 
 $obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
 $pc->pretty(0);
@@ -44,7 +45,8 @@
       1,
       2
    ]
-}|);
+}
+|);
 
 $obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
 $pc->pretty(0);
@@ -54,11 +56,11 @@
 
 $obj = {foo => "bar"};
 $pc->indent(1);
-is($pc->encode($obj), qq|{\n   "foo":"bar"\n}|, "nospace");
+is($pc->encode($obj), qq|{\n   "foo":"bar"\n}\n|, "nospace");
 $pc->space_after(1);
-is($pc->encode($obj), qq|{\n   "foo": "bar"\n}|, "after");
+is($pc->encode($obj), qq|{\n   "foo": "bar"\n}\n|, "after");
 $pc->space_before(1);
-is($pc->encode($obj), qq|{\n   "foo" : "bar"\n}|, "both");
+is($pc->encode($obj), qq|{\n   "foo" : "bar"\n}\n|, "both");
 $pc->space_after(0);
-is($pc->encode($obj), qq|{\n   "foo" :"bar"\n}|, "before");
+is($pc->encode($obj), qq|{\n   "foo" :"bar"\n}\n|, "before");
 

Added: branches/upstream/libjson-xs-perl/current/t/22_comment_at_eof.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-xs-perl/current/t/22_comment_at_eof.t?rev=50458&op=file
==============================================================================
--- branches/upstream/libjson-xs-perl/current/t/22_comment_at_eof.t (added)
+++ branches/upstream/libjson-xs-perl/current/t/22_comment_at_eof.t Thu Jan  7 16:20:44 2010
@@ -1,0 +1,46 @@
+# provided by IKEGAMI at cpan.org
+
+use strict;
+use warnings;
+
+use Test::More tests => 13;
+
+use JSON::XS;
+
+use Data::Dumper qw( Dumper );
+
+sub decoder {
+   my ($str) = @_;
+
+   my $json = JSON::XS->new->relaxed;
+
+   $json->incr_parse($_[0]);
+
+   my $rv;
+   if (!eval { $rv = $json->incr_parse(); 1 }) {
+       $rv = "died with $@";
+   }
+
+   local $Data::Dumper::Useqq = 1;
+   local $Data::Dumper::Terse = 1;
+   local $Data::Dumper::Indent = 0;
+
+   return Dumper($rv);
+}
+
+is( decoder( "[]"        ), '[]', 'array baseline' );
+is( decoder( " []"       ), '[]', 'space ignored before array' );
+is( decoder( "\n[]"      ), '[]', 'newline ignored before array' );
+is( decoder( "# foo\n[]" ), '[]', 'comment ignored before array' );
+is( decoder( "# fo[o\n[]"), '[]', 'comment ignored before array' );
+is( decoder( "# fo]o\n[]"), '[]', 'comment ignored before array' );
+is( decoder( "[# fo]o\n]"), '[]', 'comment ignored inside array' );
+
+is( decoder( ""        ), 'undef', 'eof baseline' );
+is( decoder( " "       ), 'undef', 'space ignored before eof' );
+is( decoder( "\n"      ), 'undef', 'newline ignored before eof' );
+is( decoder( "#,foo\n" ), 'undef', 'comment ignored before eof' );
+is( decoder( "# []o\n" ), 'undef', 'comment ignored before eof' );
+
+is( decoder(qq/#\n[#foo\n"#\\n"#\n]/), '["#\n"]', 'array and string in multiple lines' );
+




More information about the Pkg-perl-cvs-commits mailing list