r62112 - in /trunk/libyaml-syck-perl: Changes META.yml debian/changelog debian/copyright lib/JSON/Syck.pm lib/YAML/Syck.pm perl_syck.h syck_.c t/2-scalars.t t/json-numbers.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Sat Aug 28 14:03:35 UTC 2010


Author: ansgar-guest
Date: Sat Aug 28 14:03:26 2010
New Revision: 62112

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=62112
Log:
* New upstream release.
* debian/copyright: Refer to "Debian systems" instead of
  "Debian GNU/Linux systems".

Modified:
    trunk/libyaml-syck-perl/Changes
    trunk/libyaml-syck-perl/META.yml
    trunk/libyaml-syck-perl/debian/changelog
    trunk/libyaml-syck-perl/debian/copyright
    trunk/libyaml-syck-perl/lib/JSON/Syck.pm
    trunk/libyaml-syck-perl/lib/YAML/Syck.pm
    trunk/libyaml-syck-perl/perl_syck.h
    trunk/libyaml-syck-perl/syck_.c
    trunk/libyaml-syck-perl/t/2-scalars.t
    trunk/libyaml-syck-perl/t/json-numbers.t

Modified: trunk/libyaml-syck-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/Changes?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/Changes (original)
+++ trunk/libyaml-syck-perl/Changes Sat Aug 28 14:03:26 2010
@@ -1,6 +1,15 @@
+[Changes for 1.14 (YAML::Syck 0.37 ) - 2010-08-03]
+* RT RT60771 - Further refactor for JSON. if a number is a valid
+  perl string, quote it. "1" + "1" = "11" in javascript.
+* add YAML tests to make sure HEX and octal preserve their information
+
+[Changes for 1.13 (YAML::Syck 0.36 ) - 2010-08-03]
+* RT RT60771 - quoted negative integer and quoted zeroes.
+  This was breaking JSON since "0" is true in javascript.
+
 [Changes for 1.12 (YAML::Syck 0.35 ) - 2010-08-03]
 * The tie test proved to be very unstable for 5.8 and it's not
-  relevant for tie actually. I'm converting it to a TODO for now.
+  relevant for tie actually. I'm converting it to a TODO for 
 
 [Changes for 1.11 (YAML::Syck 0.35 ) - 2010-08-03]
 * Tests are now stable. releasing 1.11

Modified: trunk/libyaml-syck-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/META.yml?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/META.yml (original)
+++ trunk/libyaml-syck-perl/META.yml Sat Aug 28 14:03:26 2010
@@ -25,4 +25,4 @@
   homepage: http://search.cpan.org/dist/YAML-Syck
   license: http://opensource.org/licenses/mit-license.php
   repository: http://github.com/avar/YAML-Syck
-version: 1.12
+version: 1.14

Modified: trunk/libyaml-syck-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/debian/changelog?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/debian/changelog (original)
+++ trunk/libyaml-syck-perl/debian/changelog Sat Aug 28 14:03:26 2010
@@ -1,3 +1,11 @@
+libyaml-syck-perl (1.14-1) unstable; urgency=low
+
+  * New upstream release.
+  * debian/copyright: Refer to "Debian systems" instead of
+    "Debian GNU/Linux systems".
+
+ -- Ansgar Burchardt <ansgar at 43-1.org>  Sat, 28 Aug 2010 22:42:49 +0900
+
 libyaml-syck-perl (1.12-1) unstable; urgency=low
 
   * New upstream release.

Modified: trunk/libyaml-syck-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/debian/copyright?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/debian/copyright (original)
+++ trunk/libyaml-syck-perl/debian/copyright Sat Aug 28 14:03:26 2010
@@ -21,7 +21,7 @@
  2010, gregor herrmann <gregoa at debian.org>
 License: MIT
 
-Files: *.c, *h
+Files: *.c, *.h
 Copyright: 2003, "why the lucky stiff"
 License: MIT or other
  This software may not be used directly by any living being.  ANY use of this
@@ -94,7 +94,7 @@
  This program is free software; you can redistribute it and/or modify
  it under the terms of the Artistic License, which comes with Perl.
  .
- On Debian GNU/Linux systems, the complete text of the Artistic License
+ On Debian systems, the complete text of the Artistic License
  can be found in `/usr/share/common-licenses/Artistic'.
 
 License: GPL-1+
@@ -102,5 +102,6 @@
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 1, or (at your option)
  any later version.
- On Debian GNU/Linux systems, the complete text of version 1 of the GNU
- General Public License can be found in `/usr/share/common-licenses/GPL-1'.
+ .
+ On Debian systems, the complete text of version 1 of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL-1'.

Modified: trunk/libyaml-syck-perl/lib/JSON/Syck.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/lib/JSON/Syck.pm?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/lib/JSON/Syck.pm (original)
+++ trunk/libyaml-syck-perl/lib/JSON/Syck.pm Sat Aug 28 14:03:26 2010
@@ -5,7 +5,7 @@
 use YAML::Syck ();
 
 BEGIN {
-    $VERSION    = '0.35';
+    $VERSION    = '0.37';
     @EXPORT_OK  = qw( Load Dump LoadFile DumpFile );
     @ISA        = 'Exporter';
     *Load       = \&YAML::Syck::LoadJSON;

Modified: trunk/libyaml-syck-perl/lib/YAML/Syck.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/lib/YAML/Syck.pm?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/lib/YAML/Syck.pm (original)
+++ trunk/libyaml-syck-perl/lib/YAML/Syck.pm Sat Aug 28 14:03:26 2010
@@ -13,7 +13,7 @@
 use Exporter;
 
 BEGIN {
-    $VERSION = '1.12';
+    $VERSION = '1.14';
     @EXPORT  = qw( Dump Load DumpFile LoadFile );
     @ISA     = qw( Exporter );
 

Modified: trunk/libyaml-syck-perl/perl_syck.h
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/perl_syck.h?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/perl_syck.h (original)
+++ trunk/libyaml-syck-perl/perl_syck.h Sat Aug 28 14:03:26 2010
@@ -982,6 +982,8 @@
         /* emit a string */
         STRLEN len = sv_len(sv);
 
+/* JSON should preserve quotes even on simple integers ("0" is true in javascript) */
+#ifndef YAML_IS_JSON
         if (looks_like_number(sv)) {
         	if(syck_str_is_unquotable_integer(SvPV_nolen(sv), sv_len(sv))) {
         		/* emit an unquoted number only if it's a very basic integer. /^-?[1-9][0-9]*$/ */
@@ -992,7 +994,9 @@
         		syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, SvPV_nolen(sv), len);
         	}
         }
-        else if (len == 0) {
+        else
+#endif
+        	if (len == 0) {
             syck_emit_scalar(e, OBJOF("str"), SCALAR_QUOTED, 0, 0, 0, "", 0);
         }
         else if (IS_UTF8(sv)) {

Modified: trunk/libyaml-syck-perl/syck_.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/syck_.c?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/syck_.c (original)
+++ trunk/libyaml-syck-perl/syck_.c Sat Aug 28 14:03:26 2010
@@ -503,19 +503,20 @@
 }
 
 int syck_str_is_unquotable_integer(char* str, long len) {
-	int idx;
-
-	if(!str) return 0; /* Don't parse null strings */
-	if(len < 1) return 0; /* empty strings can't be numbers */
-	if(len > 9) return 0; /* Ints larger than 9 digits (32bit) might not portable. Force a string. */
-
-	if(str[0] == '-' && (len < 2 || str[1] > '9' || str[1] < '1')) return 0;
-	if(str[0] > '9' || str[0] < '1') return 0;
-
-	/* Look for illegal characters */
-	for ( idx = 1; idx < len; idx++ ) {
-		if(!isdigit(str[idx])) return 0;
-	}
-
-	return 1;
-}
+    int idx;
+
+    if(!str) return 0; /* Don't parse null strings */
+    if(len < 1) return 0; /* empty strings can't be numbers */
+    if(len > 9) return 0; /* Ints larger than 9 digits (32bit) might not portable. Force a string. */
+
+    if(str[0] == '0' && len == 1) return 1; /* 0 is unquoted. */
+    if(str[0] == '-') {str++; len --;} /* supress the leading '-' sign if detected for testing purposes only. */
+    if(str[0]  == '0') return 0; /* Octals need to be quoted or you lose data converting them to an integer. This also accidentally blocks -0 which probably needs to be quoted. */
+
+    /* Look for illegal characters */
+    for ( idx = 1; idx < len; idx++ ) {
+        if(!isdigit(str[idx])) return 0;
+    }
+
+    return 1;
+}

Modified: trunk/libyaml-syck-perl/t/2-scalars.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/t/2-scalars.t?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/t/2-scalars.t (original)
+++ trunk/libyaml-syck-perl/t/2-scalars.t Sat Aug 28 14:03:26 2010
@@ -1,4 +1,4 @@
-use t::TestYAML tests => 121;
+use t::TestYAML tests => 134;
 
 ok(YAML::Syck->VERSION);
 
@@ -228,6 +228,19 @@
     roundtrip($_);
 }
 
+# Simple integers dump without quotes
+foreach (1, 2, 3, 0, -1, -2, -3) {
+    is(Dump($_), "--- $_\n", "Dumped version of file is unquoted");
+}
+
+is(Dump('0x10'), "--- 0x10\n",   "hex Dump preserves as string");
+is(Load("--- '0x10'\n"), "0x10", "hex Load preserves as string");
+
+is(Dump('080'), "--- '080'\n",   "oct Dump preserves by quoting");
+is(Load("--- '080'\n"), "080", "oct Load preserves by quoting");
+
+is(Dump('00'), "--- '00'\n",   "00 Dump preserves by quoting");
+is(Load("--- '00'\n"), "00", "00 Load preserves by quoting");
 
 # RT 54780 - double quoted loading style
 

Modified: trunk/libyaml-syck-perl/t/json-numbers.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libyaml-syck-perl/t/json-numbers.t?rev=62112&op=diff
==============================================================================
--- trunk/libyaml-syck-perl/t/json-numbers.t (original)
+++ trunk/libyaml-syck-perl/t/json-numbers.t Sat Aug 28 14:03:26 2010
@@ -1,14 +1,14 @@
-use Test::More tests => 10;
+use Test::More tests => 53;
 
 use JSON::Syck qw(Dump);
 
 my @arr1 = sort {$a cmp $b} qw/1 2 54 howdy/;
-is(Dump(\@arr1), '[1,2,54,"howdy"]', "cmp sort doesn't coerce numbers into strings");
+is(Dump(\@arr1), '["1","2","54","howdy"]', "cmp sort causes numbers to coerce into strings and thus be quoted.");
 
 {
     no warnings "numeric";
     my @arr2 = sort {$a <=> $b} qw/1 2 54 howdy/;
-    is(Dump(\@arr2), '["howdy",1,2,54]', "Numeric sort doesn't coerce non-numeric strings into numbers");
+    is(Dump(\@arr2), '["howdy","1","2","54"]', "Numeric sort doesn't coerce non-numeric strings into numbers because they still contain their valid string");
 }
 
 my @arr54 = ("howdy",1,2,54);
@@ -21,5 +21,12 @@
 is(Dump('1,000,000'),    '"1,000,000"', "numbers with commas get quoted.");
 is(Dump('1e+6'),    '"1e+6"', "Scientific notation gets quoted.");
 is(Dump('10e+6'),    '"10e+6"', "Scientific notation gets quoted.");
+is(Dump('0123'),    '"0123"', "Scientific notation gets quoted.");
 
-
+# for simple integers, we need to preserve their string state as perl knows it if possible.
+# JSON overloaded + for string concatenation. This means you get all sorts of wierdness if we try to strip quotes on strings not IVs
+# "0" is true 0 is false. 1 + 1 = 2 but "1" + "1" = "11"
+for(-10..10) { 
+  is(Dump($_),  $_,         '"0" != 0 in JSON. 0 is false "0" is true.');
+  is(Dump("$_"),  "\"$_\"", 'Strigified integer is stringified in JSON');
+}




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