[Python-modules-commits] [ujson] 01/10: Import ujson_1.34.orig.tar.gz

Sandro Tosi morph at moszumanska.debian.org
Sun Jan 17 23:05:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository ujson.

commit 052e70ebfb6cb71249602030bfd4cf5b75d52439
Author: Sandro Tosi <morph at debian.org>
Date:   Sun Jan 17 22:42:12 2016 +0000

    Import ujson_1.34.orig.tar.gz
---
 MANIFEST.in                         |   0
 PKG-INFO                            | 401 ++++++++-------
 README.rst                          |  25 +-
 lib/ultrajson.h                     |  73 +--
 lib/ultrajsondec.c                  |  52 +-
 lib/ultrajsonenc.c                  | 115 ++++-
 python/JSONtoObj.c                  |  27 +-
 python/objToJSON.c                  | 947 +++++++++++++++++++++---------------
 python/py_defines.h                 |  21 +-
 python/ujson.c                      |   9 +-
 python/version.h                    |  23 +-
 setup.cfg                           |  10 +-
 setup.py                            |   0
 tests/sample.json                   |   0
 tests/tests.py                      | 438 +++++++++++------
 ujson.egg-info/PKG-INFO             | 401 ++++++++-------
 ujson.egg-info/SOURCES.txt          |   0
 ujson.egg-info/dependency_links.txt |   0
 ujson.egg-info/top_level.txt        |   0
 19 files changed, 1507 insertions(+), 1035 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
old mode 100644
new mode 100755
diff --git a/PKG-INFO b/PKG-INFO
index 56b5c5d..4c6e55b 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,189 +1,212 @@
-Metadata-Version: 1.0
-Name: ujson
-Version: 1.33
-Summary: Ultra fast JSON encoder and decoder for Python
-Home-page: http://www.esn.me
-Author: Jonas Tarnstrom
-Author-email: jonas.tarnstrom at esn.me
-License: BSD License
-Download-URL: http://github.com/esnme/ultrajson
-Description: UltraJSON
-        =============
-        UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.
-        
-        For a more painless day to day C/C++ JSON decoder experience please checkout ujson4c_, based on UltraJSON.
-        
-        .. _ujson4c: http://github.com/esnme/ujson4c/
-        
-        | Please checkout the rest of the projects in the Ultra series:
-        | http://github.com/esnme/ultramemcache
-        | http://github.com/esnme/ultramysql
-        
-        To install it just run Pip as usual::
-        
-            $ pip install ujson
-        
-        ============
-        Usage
-        ============
-        May be used as a drop in replacement for most other JSON parsers for Python::
-        
-            >>> import ujson
-            >>> ujson.dumps([{"key": "value"}, 81, True])
-            '[{"key":"value"},81,true]'
-            >>> ujson.loads("""[{"key": "value"}, 81, true]""")
-            [{u'key': u'value'}, 81, True]
-            
-        ~~~~~~~~~~~~~~~
-        Encoder options
-        ~~~~~~~~~~~~~~~    
-        encode_html_chars
-        -----------------
-        Used to enable special encoding of "unsafe" HTML characters into safer Unicode sequences. Default is false::
-        
-            >>> ujson.dumps("<script>John&Doe", encode_html_chars=True)
-            '"\\u003cscript\\u003eJohn\\u0026Doe"'
-        
-        ensure_ascii
-        -------------
-        Limits output to ASCII and escapes all extended characters above 127. Default is true. If your end format supports UTF-8 setting this option to false is highly recommended to save space::
-        
-            >>> ujson.dumps(u"\xe5\xe4\xf6")
-            '"\\u00e5\\u00e4\\u00f6"'
-            >>> ujson.dumps(u"\xe5\xe4\xf6", ensure_ascii=False)
-            '"\xc3\xa5\xc3\xa4\xc3\xb6"'
-        
-        double_precision
-        ----------------
-        Controls how many decimals to encode for double or decimal values. Default is 9::
-        
-            >>> ujson.dumps(math.pi)
-            '3.1415926536'
-            >>> ujson.dumps(math.pi, double_precision=1)
-            '3.1'
-            >>> ujson.dumps(math.pi, double_precision=0)
-            '3'
-            >>> ujson.dumps(math.pi, double_precision=4)
-            '3.1416'
-            
-        ~~~~~~~~~~~~~~~~
-        Decoders options
-        ~~~~~~~~~~~~~~~~    
-        precise_float
-        -------------
-        Set to enable usage of higher precision (strtod) function when decoding string to double values. Default is to use fast but less precise builtin functionality::
-        
-            >>> ujson.loads("4.56")
-            4.5600000000000005
-            >>> ujson.loads("4.56", precise_float=True)
-            4.5599999999999996
-        
-            
-        ============
-        Benchmarks
-        ============
-        *UltraJSON* calls/sec compared to three other popular JSON parsers with performance gain specified below each.
-        
-        ~~~~~~~~~~~~~
-        Test machine:
-        ~~~~~~~~~~~~~
-        Linux version 2.6.32-131.0.15.el6.x86_64
-        
-        ~~~~~~~~~
-        Versions:
-        ~~~~~~~~~
-        
-        - ujson: 1.21
-        - simplejson: 2.6.2
-        - cjson: 1.05
-        - yajl: 0.3.5
-        - Python: Python 2.6.6 (r266:84292, Jul 20 2011, 10:22:43)
-        
-        
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         | ujson  | simplejson | cjson  | yajl    |
-        +=========================================+========+============+========+=========+
-        | Array with 256 utf-8 strings            |        |            |        |         |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Encode                                  | 4090,74|    899,39  |83,86   | 3189,86 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |       4,55 |48,78   | 1,28    |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Decode                                  | 863,29 |     586,15 |201,61  | 352,48  |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |      1,47  | 4,28   | 2,45    |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Medium complex object                   |        |            |        |         |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Encode                                  | 9750,37|   1377,15  |1512,06 | 3341,91 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |     7,08   | 6,45   | 2,92    |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Decode                                  | 5576,75|   4247,16  | 3587,83| 2850,13 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        1,31|   1,55 |   1,96  |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Array with 256 strings                  |        |            |        |         |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Encode                                  |17998,01|  12954,46  |8715,02 | 15924,35|
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        1,39|    2,07|    1,13 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Decode                                  |14540,71|  19696,13  |14908,46| 9547,14 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |       0,74 |   0,98 |   1,52  |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Array with 256 doubles                  |        |            |        |         |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Encode                                  | 2185,20|   1466,87  | 1956,99| 3421,10 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        1,49|   1,12 |  0,64   |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Decode                                  |16062,01|  8990,50   | 9743,40|8331,74  |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        1,79|    1,65|   1,93  |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Array with 256 True values              |        |            |        |         |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Encode                                  |69767,60|  25202,56  |41145,99|64330,76 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |       2,77 |  1,70  |  1,08   |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |Decode                                   |91416,02|  56439,97  |54918,09| 42786,02|
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        1,62|   1,66 |  2,14   |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Array with 256 dict{string, int} pairs  |        |            |        |         |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |            |        |         |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Encode                                  |11307,54|   1830,45  | 2720,90| 7725,56 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        6,18|   4,16 |  1,46   |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Decode                                  |8695,94 |  7572,89   | 6076,71|5231,32  |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        1,15|    1,43|   1,66  |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Dict with 256 arrays with 256 dict      |        |            |        |         |
-        +-----------------------------------------+--------+------------+--------+---------+
-        | Encode                                  | 37,76  |    4,88    | 10,49  | 27,62   |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        7,74|    3,60| 1,37    |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |Decode                                   |  17,70 |    15,56   | 11,25  | 12,00   |
-        +-----------------------------------------+--------+------------+--------+---------+
-        |                                         |        |        1,14|    1,57|    1,47 |
-        +-----------------------------------------+--------+------------+--------+---------+
-        
-Platform: any
-Classifier: Development Status :: 5 - Production/Stable
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: BSD License
-Classifier: Programming Language :: C
-Classifier: Programming Language :: Python :: 2.4
-Classifier: Programming Language :: Python :: 2.5
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
+Metadata-Version: 1.1
+Name: ujson
+Version: 1.34
+Summary: Ultra fast JSON encoder and decoder for Python
+Home-page: http://www.esn.me
+Author: Jonas Tarnstrom
+Author-email: jonas.tarnstrom at esn.me
+License: BSD License
+Download-URL: http://github.com/esnme/ultrajson
+Description: UltraJSON
+        =============
+        .. image:: https://travis-ci.org/esnme/ultrajson.svg?branch=master
+            :target: https://travis-ci.org/esnme/ultrajson
+            
+        UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.
+        
+        For a more painless day to day C/C++ JSON decoder experience please checkout ujson4c_, based on UltraJSON.
+        
+        .. _ujson4c: http://github.com/esnme/ujson4c/
+        
+        | Please checkout the rest of the projects in the Ultra series:
+        | http://github.com/esnme/ultramemcache
+        | http://github.com/esnme/ultramysql
+        
+        To install it just run Pip as usual::
+        
+            $ pip install ujson
+        
+        ============
+        Usage
+        ============
+        May be used as a drop in replacement for most other JSON parsers for Python::
+        
+            >>> import ujson
+            >>> ujson.dumps([{"key": "value"}, 81, True])
+            '[{"key":"value"},81,true]'
+            >>> ujson.loads("""[{"key": "value"}, 81, true]""")
+            [{u'key': u'value'}, 81, True]
+            
+        ~~~~~~~~~~~~~~~
+        Encoder options
+        ~~~~~~~~~~~~~~~    
+        encode_html_chars
+        -----------------
+        Used to enable special encoding of "unsafe" HTML characters into safer Unicode sequences. Default is false::
+        
+            >>> ujson.dumps("<script>John&Doe", encode_html_chars=True)
+            '"\\u003cscript\\u003eJohn\\u0026Doe"'
+        
+        ensure_ascii
+        -------------
+        Limits output to ASCII and escapes all extended characters above 127. Default is true. If your end format supports UTF-8 setting this option to false is highly recommended to save space::
+        
+            >>> ujson.dumps(u"\xe5\xe4\xf6")
+            '"\\u00e5\\u00e4\\u00f6"'
+            >>> ujson.dumps(u"\xe5\xe4\xf6", ensure_ascii=False)
+            '"\xc3\xa5\xc3\xa4\xc3\xb6"'
+        
+        double_precision
+        ----------------
+        Controls how many decimals to encode for double or decimal values. Default is 9::
+        
+            >>> ujson.dumps(math.pi)
+            '3.1415926536'
+            >>> ujson.dumps(math.pi, double_precision=1)
+            '3.1'
+            >>> ujson.dumps(math.pi, double_precision=0)
+            '3'
+            >>> ujson.dumps(math.pi, double_precision=4)
+            '3.1416'
+        
+        escape_forward_slashes
+        ----------------------
+        Controls whether forward slashes (``/``) are escaped. Default is True::
+        
+            >>> ujson.dumps("http://esn.me")
+            '"http:\/\/esn.me"'
+            >>> ujson.dumps("http://esn.me", escape_forward_slashes=False)
+            '"http://esn.me"'
+        
+        indent
+        ----------------------
+        Controls whether indention ("pretty output") is enabled. Default is 0 (disabled)::
+        
+            >>> ujson.dumps({"foo": "bar"})
+            '{"foo":"bar"}'
+            >>> ujson.dumps({"foo": "bar"}, indent=4)
+            {
+                "foo":"bar"
+            }
+        
+        ~~~~~~~~~~~~~~~~
+        Decoders options
+        ~~~~~~~~~~~~~~~~    
+        precise_float
+        -------------
+        Set to enable usage of higher precision (strtod) function when decoding string to double values. Default is to use fast but less precise builtin functionality::
+        
+            >>> ujson.loads("4.56")
+            4.5600000000000005
+            >>> ujson.loads("4.56", precise_float=True)
+            4.5599999999999996
+        
+            
+        ============
+        Benchmarks
+        ============
+        *UltraJSON* calls/sec compared to three other popular JSON parsers with performance gain specified below each.
+        
+        ~~~~~~~~~~~~~
+        Test machine:
+        ~~~~~~~~~~~~~
+        Linux version 2.6.32-131.0.15.el6.x86_64
+        
+        ~~~~~~~~~
+        Versions:
+        ~~~~~~~~~
+        
+        - ujson: 1.21
+        - simplejson: 2.6.2
+        - cjson: 1.05
+        - yajl: 0.3.5
+        - Python: Python 2.6.6 (r266:84292, Jul 20 2011, 10:22:43)
+        
+        
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         | ujson  | simplejson | cjson  | yajl    |
+        +=========================================+========+============+========+=========+
+        | Array with 256 utf-8 strings            |        |            |        |         |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Encode                                  | 4090,74|    899,39  |83,86   | 3189,86 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |       4,55 |48,78   | 1,28    |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Decode                                  | 863,29 |     586,15 |201,61  | 352,48  |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |      1,47  | 4,28   | 2,45    |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Medium complex object                   |        |            |        |         |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Encode                                  | 9750,37|   1377,15  |1512,06 | 3341,91 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |     7,08   | 6,45   | 2,92    |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Decode                                  | 5576,75|   4247,16  | 3587,83| 2850,13 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        1,31|   1,55 |   1,96  |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Array with 256 strings                  |        |            |        |         |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Encode                                  |17998,01|  12954,46  |8715,02 | 15924,35|
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        1,39|    2,07|    1,13 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Decode                                  |14540,71|  19696,13  |14908,46| 9547,14 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |       0,74 |   0,98 |   1,52  |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Array with 256 doubles                  |        |            |        |         |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Encode                                  | 2185,20|   1466,87  | 1956,99| 3421,10 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        1,49|   1,12 |  0,64   |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Decode                                  |16062,01|  8990,50   | 9743,40|8331,74  |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        1,79|    1,65|   1,93  |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Array with 256 True values              |        |            |        |         |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Encode                                  |69767,60|  25202,56  |41145,99|64330,76 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |       2,77 |  1,70  |  1,08   |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |Decode                                   |91416,02|  56439,97  |54918,09| 42786,02|
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        1,62|   1,66 |  2,14   |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Array with 256 dict{string, int} pairs  |        |            |        |         |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |            |        |         |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Encode                                  |11307,54|   1830,45  | 2720,90| 7725,56 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        6,18|   4,16 |  1,46   |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Decode                                  |8695,94 |  7572,89   | 6076,71|5231,32  |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        1,15|    1,43|   1,66  |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Dict with 256 arrays with 256 dict      |        |            |        |         |
+        +-----------------------------------------+--------+------------+--------+---------+
+        | Encode                                  | 37,76  |    4,88    | 10,49  | 27,62   |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        7,74|    3,60| 1,37    |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |Decode                                   |  17,70 |    15,56   | 11,25  | 12,00   |
+        +-----------------------------------------+--------+------------+--------+---------+
+        |                                         |        |        1,14|    1,57|    1,47 |
+        +-----------------------------------------+--------+------------+--------+---------+
+        
+Platform: any
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Programming Language :: C
+Classifier: Programming Language :: Python :: 2.4
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
diff --git a/README.rst b/README.rst
old mode 100644
new mode 100755
index 67a3a63..3b25b3e
--- a/README.rst
+++ b/README.rst
@@ -1,5 +1,8 @@
 UltraJSON
 =============
+.. image:: https://travis-ci.org/esnme/ultrajson.svg?branch=master
+    :target: https://travis-ci.org/esnme/ultrajson
+    
 UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.
 
 For a more painless day to day C/C++ JSON decoder experience please checkout ujson4c_, based on UltraJSON.
@@ -56,7 +59,27 @@ Controls how many decimals to encode for double or decimal values. Default is 9:
     '3'
     >>> ujson.dumps(math.pi, double_precision=4)
     '3.1416'
-    
+
+escape_forward_slashes
+----------------------
+Controls whether forward slashes (``/``) are escaped. Default is True::
+
+    >>> ujson.dumps("http://esn.me")
+    '"http:\/\/esn.me"'
+    >>> ujson.dumps("http://esn.me", escape_forward_slashes=False)
+    '"http://esn.me"'
+
+indent
+----------------------
+Controls whether indention ("pretty output") is enabled. Default is 0 (disabled)::
+
+    >>> ujson.dumps({"foo": "bar"})
+    '{"foo":"bar"}'
+    >>> ujson.dumps({"foo": "bar"}, indent=4)
+    {
+        "foo":"bar"
+    }
+
 ~~~~~~~~~~~~~~~~
 Decoders options
 ~~~~~~~~~~~~~~~~    
diff --git a/lib/ultrajson.h b/lib/ultrajson.h
old mode 100644
new mode 100755
index 787cd4c..d0fc267
--- a/lib/ultrajson.h
+++ b/lib/ultrajson.h
@@ -1,22 +1,23 @@
 /*
-Copyright (c) 2011-2013, ESN Social Software AB and Jonas Tarnstrom
+Developed by ESN, an Electronic Arts Inc. studio. 
+Copyright (c) 2014, Electronic Arts Inc.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-    * Neither the name of the ESN Social Software AB nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+* Neither the name of ESN, Electronic Arts Inc. nor the
+names of its contributors may be used to endorse or promote products
+derived from this software without specific prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL ESN SOCIAL SOFTWARE AB OR JONAS TARNSTROM BE LIABLE
+DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS INC. BE LIABLE 
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -145,16 +146,17 @@ typedef int64_t JSLONG;
 
 enum JSTYPES
 {
-  JT_NULL,        // NULL
-  JT_TRUE,        //boolean true
-  JT_FALSE,       //boolean false
-  JT_INT,         //(JSINT32 (signed 32-bit))
-  JT_LONG,        //(JSINT64 (signed 64-bit))
-  JT_DOUBLE,    //(double)
-  JT_UTF8,        //(char 8-bit)
-  JT_ARRAY,       // Array structure
+  JT_NULL,      // NULL
+  JT_TRUE,      // boolean true
+  JT_FALSE,     // boolean false
+  JT_INT,       // (JSINT32 (signed 32-bit))
+  JT_LONG,      // (JSINT64 (signed 64-bit))
+  JT_ULONG,     // (JSUINT64 (unsigned 64-bit))
+  JT_DOUBLE,    // (double)
+  JT_UTF8,      // (char 8-bit)
+  JT_ARRAY,     // Array structure
   JT_OBJECT,    // Key/Value structure
-  JT_INVALID,    // Internal, do not return nor expect
+  JT_INVALID,   // Internal, do not return nor expect
 };
 
 typedef void * JSOBJ;
@@ -164,11 +166,11 @@ typedef struct __JSONTypeContext
 {
   int type;
   void *prv;
+  void *encoder_prv;
 } JSONTypeContext;
 
 /*
 Function pointer declarations, suitable for implementing UltraJSON */
-typedef void (*JSPFN_ITERBEGIN)(JSOBJ obj, JSONTypeContext *tc);
 typedef int (*JSPFN_ITERNEXT)(JSOBJ obj, JSONTypeContext *tc);
 typedef void (*JSPFN_ITEREND)(JSOBJ obj, JSONTypeContext *tc);
 typedef JSOBJ (*JSPFN_ITERGETVALUE)(JSOBJ obj, JSONTypeContext *tc);
@@ -177,22 +179,20 @@ typedef void *(*JSPFN_MALLOC)(size_t size);
 typedef void (*JSPFN_FREE)(void *pptr);
 typedef void *(*JSPFN_REALLOC)(void *base, size_t size);
 
+
+struct __JSONObjectEncoder;
+
 typedef struct __JSONObjectEncoder
 {
-  void (*beginTypeContext)(JSOBJ obj, JSONTypeContext *tc);
+  void (*beginTypeContext)(JSOBJ obj, JSONTypeContext *tc, struct __JSONObjectEncoder *enc);
   void (*endTypeContext)(JSOBJ obj, JSONTypeContext *tc);
   const char *(*getStringValue)(JSOBJ obj, JSONTypeContext *tc, size_t *_outLen);
   JSINT64 (*getLongValue)(JSOBJ obj, JSONTypeContext *tc);
+  JSUINT64 (*getUnsignedLongValue)(JSOBJ obj, JSONTypeContext *tc);
   JSINT32 (*getIntValue)(JSOBJ obj, JSONTypeContext *tc);
   double (*getDoubleValue)(JSOBJ obj, JSONTypeContext *tc);
 
   /*
-  Begin iteration of an iteratable object (JS_ARRAY or JS_OBJECT)
-  Implementor should setup iteration state in ti->prv
-  */
-  JSPFN_ITERBEGIN iterBegin;
-
-  /*
   Retrieve next object in an iteration. Should return 0 to indicate iteration has reached end or 1 if there are more items.
   Implementor is responsible for keeping state of the iteration. Use ti->prv fields for this
   */
@@ -233,7 +233,7 @@ typedef struct __JSONObjectEncoder
   int recursionMax;
 
   /*
-  Configuration for max decimals of double floating poiunt numbers to encode (0-9) */
+  Configuration for max decimals of double floating point numbers to encode (0-9) */
   int doublePrecision;
 
   /*
@@ -245,6 +245,22 @@ typedef struct __JSONObjectEncoder
   int encodeHTMLChars;
 
   /*
+  If true, '/' will be encoded as \/. If false, no escaping. */
+  int escapeForwardSlashes;
+
+  /*
+  If true, dictionaries are iterated through in sorted key order. */
+  int sortKeys;
+
+  /*
+  Configuration for spaces of indent */
+  int indent;
+
+  /*
+  Private pointer to be used by the caller. Passed as encoder_prv in JSONTypeContext */
+  void *prv;
+
+  /*
   Set to an error message if error occured */
   const char *errorMsg;
   JSOBJ errorObj;
@@ -294,6 +310,7 @@ typedef struct __JSONObjectDecoder
   JSOBJ (*newArray)(void *prv);
   JSOBJ (*newInt)(void *prv, JSINT32 value);
   JSOBJ (*newLong)(void *prv, JSINT64 value);
+  JSOBJ (*newUnsignedLong)(void *prv, JSUINT64 value);
   JSOBJ (*newDouble)(void *prv, double value);
   void (*releaseObject)(void *prv, JSOBJ obj);
   JSPFN_MALLOC malloc;
diff --git a/lib/ultrajsondec.c b/lib/ultrajsondec.c
old mode 100644
new mode 100755
index c344341..21a732e
--- a/lib/ultrajsondec.c
+++ b/lib/ultrajsondec.c
@@ -1,5 +1,6 @@
 /*
-Copyright (c) 2011-2013, ESN Social Software AB and Jonas Tarnstrom
+Developed by ESN, an Electronic Arts Inc. studio. 
+Copyright (c) 2014, Electronic Arts Inc.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -9,14 +10,14 @@ notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 notice, this list of conditions and the following disclaimer in the
 documentation and/or other materials provided with the distribution.
-* Neither the name of the ESN Social Software AB nor the
+* Neither the name of ESN, Electronic Arts Inc. nor the
 names of its contributors may be used to endorse or promote products
 derived from this software without specific prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL ESN SOCIAL SOFTWARE AB OR JONAS TARNSTROM BE LIABLE
+DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS INC. BE LIABLE 
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -75,12 +76,6 @@ static JSOBJ SetError( struct DecoderState *ds, int offset, const char *message)
   return NULL;
 }
 
-static void ClearError( struct DecoderState *ds)
-{
-  ds->dec->errorOffset = 0;
-  ds->dec->errorStr = NULL;
-}
-
 double createDouble(double intNeg, double intValue, double frcValue, int frcDecimalCount)
 {
   static const double g_pow10[] = {1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001,0.0000001, 0.00000001, 0.000000001, 0.0000000001, 0.00000000001, 0.000000000001, 0.0000000000001, 0.00000000000001, 0.000000000000001};
@@ -109,6 +104,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_numeric (struct DecoderState *ds)
   int intNeg = 1;
   int mantSize = 0;
   JSUINT64 intValue;
+  JSUINT64 prevIntValue;
   int chr;
   int decimalCount = 0;
   double frcValue = 0.0;
@@ -145,13 +141,17 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_numeric (struct DecoderState *ds)
       case '8':
       case '9':
       {
-        //FIXME: Check for arithemtic overflow here
         //PERF: Don't do 64-bit arithmetic here unless we know we have to
+        prevIntValue = intValue;
         intValue = intValue * 10ULL + (JSLONG) (chr - 48);
 
-        if (intValue > overflowLimit)
+        if (intNeg == 1 && prevIntValue > intValue)
+        {
+          return SetError(ds, -1, "Value is too big!");
+        }
+        else if (intNeg == -1 && intValue > overflowLimit)
         {
-          return SetError(ds, -1, overflowLimit == LLONG_MAX ? "Value is too big" : "Value is too small");
+          return SetError(ds, -1, overflowLimit == LLONG_MAX ? "Value is too big!" : "Value is too small");
         }
 
         offset ++;
@@ -185,7 +185,11 @@ BREAK_INT_LOOP:
   ds->lastType = JT_INT;
   ds->start = offset;
 
-  if ((intValue >> 31))
+  if (intNeg == 1 && (intValue & 0x8000000000000000ULL) != 0)
+  {
+    return ds->dec->newUnsignedLong(ds->prv, intValue);
+  }
+  else if ((intValue >> 31))
   {
     return ds->dec->newLong(ds->prv, (JSINT64) (intValue * (JSINT64) intNeg));
   }
@@ -438,7 +442,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds)
 
     if (ds->escHeap)
     {
-      if (newSize > (UINT_MAX / sizeof(wchar_t)))
+      if (newSize > (SIZE_MAX / sizeof(wchar_t)))
       {
         return SetError(ds, -1, "Could not reserve memory block");
       }
@@ -453,8 +457,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds)
     else
     {
       wchar_t *oldStart = ds->escStart;
-      ds->escHeap = 1;
-      if (newSize > (UINT_MAX / sizeof(wchar_t)))
+      if (newSize > (SIZE_MAX / sizeof(wchar_t)))
       {
         return SetError(ds, -1, "Could not reserve memory block");
       }
@@ -463,6 +466,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds)
       {
         return SetError(ds, -1, "Could not reserve memory block");
       }
+      ds->escHeap = 1;
       memcpy(ds->escStart, oldStart, escLen * sizeof(wchar_t));
     }
 
@@ -885,12 +889,18 @@ JSOBJ JSON_DecodeObject(JSONObjectDecoder *dec, const char *buffer, size_t cbBuf
     dec->free(ds.escStart);
   }
 
-  SkipWhitespace(&ds);
-
-  if (ds.start != ds.end && ret)
+  if (!(dec->errorStr))
   {
-    dec->releaseObject(ds.prv, ret);
-    return SetError(&ds, -1, "Trailing data");
+    if ((ds.end - ds.start) > 0)
+    {
+      SkipWhitespace(&ds);
+    }
+
+    if (ds.start != ds.end && ret)
+    {
+      dec->releaseObject(ds.prv, ret);
+      return SetError(&ds, -1, "Trailing data");
+    }
   }
 
   return ret;
diff --git a/lib/ultrajsonenc.c b/lib/ultrajsonenc.c
old mode 100644
new mode 100755
index 0bef1a4..47016f6
--- a/lib/ultrajsonenc.c
+++ b/lib/ultrajsonenc.c
@@ -1,22 +1,23 @@
 /*
-Copyright (c) 2011-2013, ESN Social Software AB and Jonas Tarnstrom
+Developed by ESN, an Electronic Arts Inc. studio. 
+Copyright (c) 2014, Electronic Arts Inc.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-    * Neither the name of the ESN Social Software AB nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+* Neither the name of ESN, Electronic Arts Inc. nor the
+names of its contributors may be used to endorse or promote products
+derived from this software without specific prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL ESN SOCIAL SOFTWARE AB OR JONAS TARNSTROM BE LIABLE
+DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS INC. BE LIABLE 
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -51,6 +52,10 @@ http://www.opensource.apple.com/source/tcl/tcl-14/tcl/license.terms
 #define FALSE 0
 #endif
 
+#if ( (defined(_WIN32) || defined(WIN32) ) && ( defined(_MSC_VER) ) )
+#define snprintf sprintf_s
+#endif
+
 /*
 Worst cases being:
 
@@ -179,7 +184,6 @@ int Buffer_EscapeStringUnvalidated (JSONObjectEncoder *enc, const char *io, cons
       }
       case '\"': (*of++) = '\\'; (*of++) = '\"'; break;
       case '\\': (*of++) = '\\'; (*of++) = '\\'; break;
-      case '/':  (*of++) = '\\'; (*of++) = '/'; break;
       case '\b': (*of++) = '\\'; (*of++) = 'b'; break;
       case '\f': (*of++) = '\\'; (*of++) = 'f'; break;
       case '\n': (*of++) = '\\'; (*of++) = 'n'; break;
@@ -201,6 +205,19 @@ int Buffer_EscapeStringUnvalidated (JSONObjectEncoder *enc, const char *io, cons
           break;
         }
       }
+      case '/':
+      {
+        if (enc->escapeForwardSlashes)
+        {
+          (*of++) = '\\'; (*of++) = '/';
+        }
+        else
+        {
+          // Same as default case below.
+          (*of++) = (*io);
+        }
+        break;
+      }
       case 0x01:
       case 0x02:
       case 0x03:
@@ -418,9 +435,17 @@ int Buffer_EscapeStringValidated (JSOBJ obj, JSONObjectEncoder *enc, const char
       case 22:
       case 24:
       {
-        *(of++) = *( (char *) (g_escapeChars + utflen + 0));
-        *(of++) = *( (char *) (g_escapeChars + utflen + 1));
-        io ++;
+        if (enc->escapeForwardSlashes)
+        {
+          *(of++) = *( (char *) (g_escapeChars + utflen + 0));
+          *(of++) = *( (char *) (g_escapeChars + utflen + 1));
+          io ++;
+        }
+        else
+        {
+          // Same as case 1 above.
+          *(of++) = (*io++);
+        }
         continue;
       }
       // This can never happen, it's here to make L4 VC++ happy
@@ -473,6 +498,20 @@ FASTCALL_ATTR INLINE_PREFIX void FASTCALL_MSVC strreverse(char* begin, char* end
   aux = *end, *end-- = *begin, *begin++ = aux;
 }
 
+void Buffer_AppendIndentNewlineUnchecked(JSONObjectEncoder *enc)
+{
+  if (enc->indent > 0) Buffer_AppendCharUnchecked(enc, '\n');
+}
+
+void Buffer_AppendIndentUnchecked(JSONObjectEncoder *enc, JSINT32 value)
+{
+  int i;
+  if (enc->indent > 0)
+    while (value-- > 0)
+      for (i = 0; i < enc->indent; i++)
+        Buffer_AppendCharUnchecked(enc, ' ');
+}
+
 void Buffer_AppendIntUnchecked(JSONObjectEncoder *enc, JSINT32 value)
 {
   char* wstr;
@@ -505,6 +544,21 @@ void Buffer_AppendLongUnchecked(JSONObjectEncoder *enc, JSINT64 value)
   enc->offset += (wstr - (enc->offset));
 }
 
+void Buffer_AppendUnsignedLongUnchecked(JSONObjectEncoder *enc, JSUINT64 value)
+{
+  char* wstr;
+  JSUINT64 uvalue = value;
+
+  wstr = enc->offset;
+  // Conversion. Number is reversed.
+
+  do *wstr++ = (char)(48 + (uvalue % 10ULL)); while(uvalue /= 10ULL);
+
+  // Reverse string
+  strreverse(enc->offset,wstr - 1);
+  enc->offset += (wstr - (enc->offset));
+}
+
 int Buffer_AppendDoubleUnchecked(JSOBJ obj, JSONObjectEncoder *enc, double value)
 {
   /* if input is larger than thres_max, revert to exponential */
@@ -573,11 +627,7 @@ int Buffer_AppendDoubleUnchecked(JSOBJ obj, JSONObjectEncoder *enc, double value
   */
   if (value > thres_max)
   {
-#ifdef _WIN32
-  enc->offset += sprintf_s(str, enc->end - enc->offset, "%.15e", neg ? -value : value);
-#else
-  enc->offset += snprintf(str, enc->end - enc->offset, "%.15e", neg ? -value : value);
-#endif
+     enc->offset += snprintf(str, enc->end - enc->offset, "%.15e", neg ? -value : value);
      return TRUE;
    }
 
@@ -712,7 +762,8 @@ void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName)
 #endif
     }
 
-    enc->beginTypeContext(obj, &tc);
+    tc.encoder_prv = enc->prv;
+    enc->beginTypeContext(obj, &tc, enc);
 
     switch (tc.type)
     {
@@ -724,9 +775,9 @@ void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName)
       case JT_ARRAY:
       {
         count = 0;
-        enc->iterBegin(obj, &tc);
 
         Buffer_AppendCharUnchecked (enc, '[');
+        Buffer_AppendIndentNewlineUnchecked (enc);
 
         while (enc->iterNext(obj, &tc))
         {
@@ -736,16 +787,20 @@ void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName)
 #ifndef JSON_NO_EXTRA_WHITESPACE
             Buffer_AppendCharUnchecked (buffer, ' ');
 #endif
+            Buffer_AppendIndentNewlineUnchecked (enc);
           }
 
           iterObj = enc->iterGetValue(obj, &tc);
 
           enc->level ++;
+          Buffer_AppendIndentUnchecked (enc, enc->level);
           encode (iterObj, enc, NULL, 0);
           count ++;
       }
 
       enc->iterEnd(obj, &tc);
+      Buffer_AppendIndentNewlineUnchecked (enc);
+      Buffer_AppendIndentUnchecked (enc, enc->level);
       Buffer_AppendCharUnchecked (enc, ']');
       break;
   }
@@ -753,9 +808,9 @@ void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName)
   case JT_OBJECT:
   {
     count = 0;
-    enc->iterBegin(obj, &tc);
 
     Buffer_AppendCharUnchecked (enc, '{');
+    Buffer_AppendIndentNewlineUnchecked (enc);
 
     while (enc->iterNext(obj, &tc))
     {
@@ -765,17 +820,21 @@ void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName)
 #ifndef JSON_NO_EXTRA_WHITESPACE
         Buffer_AppendCharUnchecked (enc, ' ');
 #endif
+        Buffer_AppendIndentNewlineUnchecked (enc);
       }
 
       iterObj = enc->iterGetValue(obj, &tc);
       objName = enc->iterGetName(obj, &tc, &szlen);
 
       enc->level ++;
+      Buffer_AppendIndentUnchecked (enc, enc->level);
       encode (iterObj, enc, objName, szlen);
       count ++;
     }
 
     enc->iterEnd(obj, &tc);
+    Buffer_AppendIndentNewlineUnchecked (enc);
+    Buffer_AppendIndentUnchecked (enc, enc->level);
     Buffer_AppendCharUnchecked (enc, '}');
     break;
   }
@@ -786,6 +845,12 @@ void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName)
     break;
   }
 
... 2644 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/ujson.git



More information about the Python-modules-commits mailing list