avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bru...@apache.org
Subject svn commit: r1057728 [1/2] - in /avro/trunk: ./ lang/c/jansson/ lang/c/jansson/doc/ lang/c/jansson/doc/ext/ lang/c/jansson/src/ lang/c/jansson/test/ lang/c/jansson/test/bin/ lang/c/jansson/test/scripts/ lang/c/jansson/test/testdata/ lang/c/jansson/test...
Date Tue, 11 Jan 2011 16:53:57 GMT
Author: brucem
Date: Tue Jan 11 16:53:53 2011
New Revision: 1057728

URL: http://svn.apache.org/viewvc?rev=1057728&view=rev
Log:
AVRO-729. Upgrading to Jansson 1.3

This patch updates our internal copy of the Jansson library to version
1.3.  This is needed for the new code that will decode and encode JSON
versions of an Avro datum.

Added:
    avro/trunk/lang/c/jansson/doc/changes.rst
    avro/trunk/lang/c/jansson/doc/conformance.rst
    avro/trunk/lang/c/jansson/jansson.pc.in
    avro/trunk/lang/c/jansson/src/jansson.h.in
    avro/trunk/lang/c/jansson/test/bin/
    avro/trunk/lang/c/jansson/test/bin/Makefile.am
    avro/trunk/lang/c/jansson/test/bin/json_process.c
    avro/trunk/lang/c/jansson/test/run-suites
    avro/trunk/lang/c/jansson/test/scripts/
    avro/trunk/lang/c/jansson/test/scripts/run-tests.sh
    avro/trunk/lang/c/jansson/test/scripts/valgrind.sh
Removed:
    avro/trunk/lang/c/jansson/test/json-compare.py
    avro/trunk/lang/c/jansson/test/load_file_dump_file.c
    avro/trunk/lang/c/jansson/test/loadf_dumpf.c
    avro/trunk/lang/c/jansson/test/loads_dumps.c
    avro/trunk/lang/c/jansson/test/run-test
    avro/trunk/lang/c/jansson/test/split-testfile.py
    avro/trunk/lang/c/jansson/test/test-api
    avro/trunk/lang/c/jansson/test/test-invalid
    avro/trunk/lang/c/jansson/test/test-valid
    avro/trunk/lang/c/jansson/test/testdata/Makefile.am
    avro/trunk/lang/c/jansson/test/testdata/invalid
    avro/trunk/lang/c/jansson/test/testdata/invalid-strip
    avro/trunk/lang/c/jansson/test/testdata/invalid-unicode
    avro/trunk/lang/c/jansson/test/testdata/valid
    avro/trunk/lang/c/jansson/test/testdata/valid-strip
    avro/trunk/lang/c/jansson/test/testprogs/Makefile.am
    avro/trunk/lang/c/jansson/test/testprogs/test_array.c
    avro/trunk/lang/c/jansson/test/testprogs/test_load.c
    avro/trunk/lang/c/jansson/test/testprogs/test_number.c
    avro/trunk/lang/c/jansson/test/testprogs/test_object.c
    avro/trunk/lang/c/jansson/test/testprogs/test_simple.c
    avro/trunk/lang/c/jansson/test/testprogs/util.h
Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c/jansson/.gitignore
    avro/trunk/lang/c/jansson/CHANGES
    avro/trunk/lang/c/jansson/LICENSE
    avro/trunk/lang/c/jansson/Makefile.am
    avro/trunk/lang/c/jansson/README.rst
    avro/trunk/lang/c/jansson/configure.ac
    avro/trunk/lang/c/jansson/doc/Makefile.am
    avro/trunk/lang/c/jansson/doc/README
    avro/trunk/lang/c/jansson/doc/apiref.rst
    avro/trunk/lang/c/jansson/doc/conf.py
    avro/trunk/lang/c/jansson/doc/ext/refcounting.py
    avro/trunk/lang/c/jansson/doc/gettingstarted.rst
    avro/trunk/lang/c/jansson/doc/github_commits.c
    avro/trunk/lang/c/jansson/doc/index.rst
    avro/trunk/lang/c/jansson/src/Makefile.am
    avro/trunk/lang/c/jansson/src/dump.c
    avro/trunk/lang/c/jansson/src/hashtable.c
    avro/trunk/lang/c/jansson/src/hashtable.h
    avro/trunk/lang/c/jansson/src/jansson.h
    avro/trunk/lang/c/jansson/src/jansson_private.h
    avro/trunk/lang/c/jansson/src/load.c
    avro/trunk/lang/c/jansson/src/strbuffer.c
    avro/trunk/lang/c/jansson/src/strbuffer.h
    avro/trunk/lang/c/jansson/src/utf.c
    avro/trunk/lang/c/jansson/src/utf.h
    avro/trunk/lang/c/jansson/src/util.h
    avro/trunk/lang/c/jansson/src/value.c
    avro/trunk/lang/c/jansson/test/Makefile.am

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Jan 11 16:53:53 2011
@@ -103,6 +103,8 @@ Avro 1.5.0 (unreleased)
     AVRO-729. C: avro_schema_to_json can take const schema. (Douglas Creager
     via brucem)
 
+    AVRO-729. C: Update to Jansson 1.3. (Douglas Creager via brucem)
+
   BUG FIXES
 
     AVRO-675. C: Bytes and fixed setters don't update datum size.

Modified: avro/trunk/lang/c/jansson/.gitignore
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/.gitignore?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/.gitignore (original)
+++ avro/trunk/lang/c/jansson/.gitignore Tue Jan 11 16:53:53 2011
@@ -4,3 +4,4 @@ depcomp
 install-sh
 ltmain.sh
 missing
+jansson.pc

Modified: avro/trunk/lang/c/jansson/CHANGES
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/CHANGES?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/CHANGES (original)
+++ avro/trunk/lang/c/jansson/CHANGES Tue Jan 11 16:53:53 2011
@@ -1,54 +1,172 @@
-Version 1.1.3, released 2009-12-18
+Version 1.3
+===========
+
+Released 2010-06-13
+
+* New encoding flags:
+
+  - ``JSON_PRESERVE_ORDER``: Preserve the insertion order of object
+    keys.
+
+* Bug fixes:
+
+  - Fix an error that occured when an array or object was first
+    encoded as empty, then populated with some data, and then
+    re-encoded
+
+  - Fix the situation like above, but when the first encoding resulted
+    in an error
+
+* Documentation:
+
+  - Clarify the documentation on reference stealing, providing an
+    example usage pattern
+
+
+Version 1.2.1
+=============
+
+Released 2010-04-03
+
+* Bug fixes:
+
+  - Fix reference counting on ``true``, ``false`` and ``null``
+  - Estimate real number underflows in decoder with 0.0 instead of
+    issuing an error
+
+* Portability:
+
+  - Make ``int32_t`` available on all systems
+  - Support compilers that don't have the ``inline`` keyword
+  - Require Autoconf 2.60 (for ``int32_t``)
+
+* Tests:
+
+  - Print test names correctly when ``VERBOSE=1``
+  - ``test/suites/api``: Fail when a test fails
+  - Enhance tests for iterators
+  - Enhance tests for decoding texts that contain null bytes
+
+* Documentation:
+
+  - Don't remove ``changes.rst`` in ``make clean``
+  - Add a chapter on RFC conformance
+
+
+Version 1.2
+===========
+
+Released 2010-01-21
+
+* New functions:
+
+  - `json_equal()`: Test whether two JSON values are equal
+  - `json_copy()` and `json_deep_copy()`: Make shallow and deep copies
+    of JSON values
+  - Add a version of all functions taking a string argument that
+    doesn't check for valid UTF-8: `json_string_nocheck()`,
+    `json_string_set_nocheck()`, `json_object_set_nocheck()`,
+    `json_object_set_new_nocheck()`
+
+* New encoding flags:
+
+  - ``JSON_SORT_KEYS``: Sort objects by key
+  - ``JSON_ENSURE_ASCII``: Escape all non-ASCII Unicode characters
+  - ``JSON_COMPACT``: Use a compact representation with all unneeded
+    whitespace stripped
+
+* Bug fixes:
+
+  - Revise and unify whitespace usage in encoder: Add spaces between
+    array and object items, never append newline to output.
+  - Remove const qualifier from the ``json_t`` parameter in
+    `json_string_set()`, `json_integer_set()` and `json_real_set`.
+  - Use ``int32_t`` internally for representing Unicode code points
+    (int is not enough on all platforms)
+
+* Other changes:
+
+  - Convert ``CHANGES`` (this file) to reStructured text and add it to
+    HTML documentation
+  - The test system has been refactored. Python is no longer required
+    to run the tests.
+  - Documentation can now be built by invoking ``make html``
+  - Support for pkg-config
+
+
+Version 1.1.3
+=============
+
+Released 2009-12-18
 
 * Encode reals correctly, so that first encoding and then decoding a
   real always produces the same value
-* Don't export private symbols in libjansson.so
+* Don't export private symbols in ``libjansson.so``
+
 
+Version 1.1.2
+=============
 
-Version 1.1.2, released 2009-11-08
+Released 2009-11-08
 
 * Fix a bug where an error message was not produced if the input file
-  could not be opened in json_load_file()
+  could not be opened in `json_load_file()`
 * Fix an assertion failure in decoder caused by a minus sign without a
   digit after it
-* Remove an unneeded include for stdint.h in jansson.h
+* Remove an unneeded include of ``stdint.h`` in ``jansson.h``
 
 
-Version 1.1.1, released 2009-10-26
+Version 1.1.1
+=============
+
+Released 2009-10-26
 
 * All documentation files were not distributed with v1.1; build
   documentation in make distcheck to prevent this in the future
-* Fix v1.1 release date in CHANGES
+* Fix v1.1 release date in ``CHANGES``
+
 
+Version 1.1
+===========
 
-Version 1.1, released 2009-10-20
+Released 2009-10-20
 
 * API additions and improvements:
+
   - Extend array and object APIs
   - Add functions to modify integer, real and string values
   - Improve argument validation
-  - Use unsigned int instead of uint32_t for encoding flags
+  - Use unsigned int instead of ``uint32_t`` for encoding flags
+
 * Enhance documentation
+
   - Add getting started guide and tutorial
   - Fix some typos
   - General clarifications and cleanup
+
 * Check for integer and real overflows and underflows in decoder
-* Make singleton values thread-safe (true, false and null)
+* Make singleton values thread-safe (``true``, ``false`` and ``null``)
 * Enhance circular reference handling
-* Don't define -std=c99 in AM_CFLAGS
-* Add C++ guards to jansson.h
+* Don't define ``-std=c99`` in ``AM_CFLAGS``
+* Add C++ guards to ``jansson.h``
 * Minor performance and portability improvements
 * Expand test coverage
 
 
-Version 1.0.4, released 2009-10-11
+Version 1.0.4
+=============
+
+Released 2009-10-11
 
 * Relax Autoconf version requirement to 2.59
-* Make Jansson compile on platforms where plain char is unsigned
+* Make Jansson compile on platforms where plain ``char`` is unsigned
 * Fix API tests for object
 
 
-Version 1.0.3, released 2009-09-14
+Version 1.0.3
+=============
+
+Released 2009-09-14
 
 * Check for integer and real overflows and underflows in decoder
 * Use the Python json module for tests, or simplejson if the json
@@ -56,16 +174,25 @@ Version 1.0.3, released 2009-09-14
 * Distribute changelog (this file)
 
 
-Version 1.0.2, released 2009-09-08
+Version 1.0.2
+=============
+
+Released 2009-09-08
 
 * Handle EOF correctly in decoder
 
 
-Version 1.0.1, released 2009-09-04
+Version 1.0.1
+=============
+
+Released 2009-09-04
+
+* Fixed broken `json_is_boolean()`
 
-* Fixed broken json_is_boolean()
 
+Version 1.0
+===========
 
-Version 1.0, released 2009-08-25
+Released 2009-08-25
 
 * Initial release

Modified: avro/trunk/lang/c/jansson/LICENSE
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/LICENSE?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/LICENSE (original)
+++ avro/trunk/lang/c/jansson/LICENSE Tue Jan 11 16:53:53 2011
@@ -1,4 +1,4 @@
-Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal

Modified: avro/trunk/lang/c/jansson/Makefile.am
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/Makefile.am?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/Makefile.am (original)
+++ avro/trunk/lang/c/jansson/Makefile.am Tue Jan 11 16:53:53 2011
@@ -1,7 +1,7 @@
 EXTRA_DIST = CHANGES LICENSE README.rst
 SUBDIRS = doc src test
 
-distcheck-hook:
-	sphinx-build -b html -W \
-		$(distdir)/doc \
-		$(distdir)/_build/doc/.build/html
+#check-local: html
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = jansson.pc

Modified: avro/trunk/lang/c/jansson/README.rst
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/README.rst?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/README.rst (original)
+++ avro/trunk/lang/c/jansson/README.rst Tue Jan 11 16:53:53 2011
@@ -36,8 +36,6 @@ To run the test suite, invoke::
 
    $ make check
 
-Python_ is required to run the tests.
-
 
 Documentation
 -------------
@@ -49,15 +47,13 @@ available at http://www.digip.org/jansso
 
 To generate HTML documentation yourself, invoke::
 
-   cd doc/
-   sphinx-build . .build/html
+   make html
 
-... and point your browser to ``.build/html/index.html``. Sphinx_ is
+and point your browser to ``doc/_build/html/index.html``. Sphinx_ is
 required to generate the documentation.
 
 
 .. _Jansson: http://www.digip.org/jansson/
 .. _`MIT license`: http://www.opensource.org/licenses/mit-license.php
-.. _Python: http://www.python.org/
 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
 .. _Sphinx: http://sphinx.pocoo.org/

Modified: avro/trunk/lang/c/jansson/configure.ac
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/configure.ac?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/configure.ac (original)
+++ avro/trunk/lang/c/jansson/configure.ac Tue Jan 11 16:53:53 2011
@@ -1,13 +1,14 @@
-AC_PREREQ([2.59])
-AC_INIT([jansson], [1.1.3], [petri@digip.org])
+AC_PREREQ([2.60])
+AC_INIT([jansson], [1.3], [petri@digip.org])
 
-AM_INIT_AUTOMAKE([foreign])
+AM_INIT_AUTOMAKE([1.10 foreign])
 
 AC_CONFIG_SRCDIR([src/value.c])
 AC_CONFIG_HEADERS([config.h])
 
 # Checks for programs.
 AC_PROG_CC
+AC_PROG_CXX
 AC_PROG_LIBTOOL
 
 # Checks for libraries.
@@ -15,15 +16,27 @@ AC_PROG_LIBTOOL
 # Checks for header files.
 
 # Checks for typedefs, structures, and compiler characteristics.
+AC_TYPE_INT32_T
+
+AC_C_INLINE
+case $ac_cv_c_inline in
+    yes) json_inline=inline;;
+    no) json_inline=;;
+    *) json_inline=$ac_cv_c_inline;;
+esac
+AC_SUBST([json_inline])
 
 # Checks for library functions.
 
 AC_CONFIG_FILES([
+        jansson.pc
         Makefile
         doc/Makefile
         src/Makefile
+        src/jansson.h
         test/Makefile
-        test/testdata/Makefile
-        test/testprogs/Makefile
+        test/bin/Makefile
+        test/suites/Makefile
+        test/suites/api/Makefile
 ])
 AC_OUTPUT

Modified: avro/trunk/lang/c/jansson/doc/Makefile.am
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/Makefile.am?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/doc/Makefile.am (original)
+++ avro/trunk/lang/c/jansson/doc/Makefile.am Tue Jan 11 16:53:53 2011
@@ -1,7 +1,20 @@
-EXTRA_DIST = \
-	conf.py apiref.rst gettingstarted.rst github_commits.c index.rst \
-	tutorial.rst ext/refcounting.py
+EXTRA_DIST = conf.py apiref.rst changes.rst conformance.rst		\
+	gettingstarted.rst github_commits.c index.rst tutorial.rst	\
+	ext/refcounting.py
+
+SPHINXBUILD = sphinx-build
+SPHINXOPTS = -d _build/doctrees -W
+
+html-local:
+	$(SPHINXBUILD) -b html $(SPHINXOPTS) $(srcdir) _build/html
+
+install-html-local: html
+	mkdir -p $(DESTDIR)$(htmldir)
+	cp -r _build/html $(DESTDIR)$(htmldir)
+
+uninstall-local:
+	rm -rf $(DESTDIR)$(htmldir)
 
 clean-local:
-	rm -rf .build
+	rm -rf _build
 	rm -f ext/refcounting.pyc

Modified: avro/trunk/lang/c/jansson/doc/README
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/README?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/doc/README (original)
+++ avro/trunk/lang/c/jansson/doc/README Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 To build the documentation, invoke
 
-    sphinx-build . .build/html
+    make html
 
-in this directory. Then point your browser to .build/html/index.html.
+Then point your browser to _build/html/index.html.

Modified: avro/trunk/lang/c/jansson/doc/apiref.rst
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/apiref.rst?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/doc/apiref.rst (original)
+++ avro/trunk/lang/c/jansson/doc/apiref.rst Tue Jan 11 16:53:53 2011
@@ -154,9 +154,31 @@ Normally, all functions accepting a JSON
 manage the reference, i.e. increase and decrease the reference count
 as needed. However, some functions **steal** the reference, i.e. they
 have the same result as if the user called :cfunc:`json_decref()` on
-the argument right after calling the function. These are usually
-convenience functions for adding new references to containers and not
-to worry about the reference count.
+the argument right after calling the function. These functions are
+suffixed with ``_new`` or have ``_new_`` somewhere in their name.
+
+For example, the following code creates a new JSON array and appends
+an integer to it::
+
+  json_t *array, *integer;
+
+  array = json_array();
+  integer = json_integer(42);
+
+  json_array_append(array, integer);
+  json_decref(integer);
+
+Note how the caller has to release the reference to the integer value
+by calling :cfunc:`json_decref()`. By using a reference stealing
+function :cfunc:`json_array_append_new()` instead of
+:cfunc:`json_array_append()`, the code becomes much simpler::
+
+  json_t *array = json_array();
+  json_array_append_new(array, json_integer(42));
+
+In this case, the user doesn't have to explicitly release the
+reference to the integer value, as :cfunc:`json_array_append_new()`
+steals the reference when appending the value to the array.
 
 In the following sections it is clearly documented whether a function
 will return a new or borrowed reference or steal a reference to its
@@ -229,6 +251,16 @@ String
    Returns a new JSON string, or *NULL* on error. *value* must be a
    valid UTF-8 encoded Unicode string.
 
+.. cfunction:: json_t *json_string_nocheck(const char *value)
+
+   .. refcounting:: new
+
+   Like :cfunc:`json_string`, but doesn't check that *value* is valid
+   UTF-8. Use this function only if you are certain that this really
+   is the case (e.g. you have already checked it by other means).
+
+   .. versionadded:: 1.2
+
 .. cfunction:: const char *json_string_value(const json_t *string)
 
    Returns the associated value of *string* as a null terminated UTF-8
@@ -242,6 +274,15 @@ String
 
    .. versionadded:: 1.1
 
+.. cfunction:: int json_string_set_nocheck(const json_t *string, const char *value)
+
+   Like :cfunc:`json_string_set`, but doesn't check that *value* is
+   valid UTF-8. Use this function only if you are certain that this
+   really is the case (e.g. you have already checked it by other
+   means).
+
+   .. versionadded:: 1.2
+
 
 Number
 ======
@@ -420,6 +461,15 @@ Unicode string and the value is any JSON
    already is a value for *key*, it is replaced by the new value.
    Returns 0 on success and -1 on error.
 
+.. cfunction:: int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
+
+   Like :cfunc:`json_object_set`, but doesn't check that *key* is
+   valid UTF-8. Use this function only if you are certain that this
+   really is the case (e.g. you have already checked it by other
+   means).
+
+   .. versionadded:: 1.2
+
 .. cfunction:: int json_object_set_new(json_t *object, const char *key, json_t *value)
 
    Like :cfunc:`json_object_set()` but steals the reference to
@@ -428,6 +478,15 @@ Unicode string and the value is any JSON
 
    .. versionadded:: 1.1
 
+.. cfunction:: int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value)
+
+   Like :cfunc:`json_object_set_new`, but doesn't check that *key* is
+   valid UTF-8. Use this function only if you are certain that this
+   really is the case (e.g. you have already checked it by other
+   means).
+
+   .. versionadded:: 1.2
+
 .. cfunction:: int json_object_del(json_t *object, const char *key)
 
    Delete *key* from *object* if it exists. Returns 0 on success, or
@@ -456,6 +515,16 @@ The following functions implement an ite
    Returns an opaque iterator which can be used to iterate over all
    key-value pairs in *object*, or *NULL* if *object* is empty.
 
+.. cfunction:: void *json_object_iter_at(json_t *object, const char *key)
+
+   Like :cfunc:`json_object_iter()`, but returns an iterator to the
+   key-value pair in *object* whose key is equal to *key*, or NULL if
+   *key* is not found in *object*. Iterating forward to the end of
+   *object* only yields all key-value pairs of the object if *key*
+   happens to be the first key in the underlying hash table.
+
+   .. versionadded:: 1.3
+
 .. cfunction:: void *json_object_iter_next(json_t *object, void *iter)
 
    Returns an iterator pointing to the next key-value pair in *object*
@@ -472,6 +541,21 @@ The following functions implement an ite
 
    Extract the associated value from *iter*.
 
+.. cfunction:: int json_object_iter_set(json_t *object, void *iter, json_t *value)
+
+   Set the value of the key-value pair in *object*, that is pointed to
+   by *iter*, to *value*.
+
+   .. versionadded:: 1.3
+
+.. cfunction:: int json_object_iter_set_new(json_t *object, void *iter, json_t *value)
+
+   Like :cfunc:`json_object_iter_set()`, but steals the reference to
+   *value*. This is useful when *value* is newly created and not used
+   after the call.
+
+   .. versionadded:: 1.3
+
 The iteration protocol can be used for example as follows::
 
    /* obj is a JSON object */
@@ -494,16 +578,52 @@ This sections describes the functions th
 values to JSON. Only objects and arrays can be encoded, since they are
 the only valid "root" values of a JSON text.
 
+By default, the output has no newlines, and spaces are used between
+array and object elements for a readable output. This behavior can be
+altered by using the ``JSON_INDENT`` and ``JSON_COMPACT`` flags
+described below. A newline is never appended to the end of the encoded
+JSON data.
+
 Each function takes a *flags* parameter that controls some aspects of
 how the data is encoded. Its default value is 0. The following macros
 can be ORed together to obtain *flags*.
 
 ``JSON_INDENT(n)``
-   Pretty-print the result, indenting arrays and objects by *n*
-   spaces. The valid range for *n* is between 0 and 255, other values
-   result in an undefined output. If ``JSON_INDENT`` is not used or
-   *n* is 0, no pretty-printing is done and the result is a compact
-   representation.
+   Pretty-print the result, using newlines between array and object
+   items, and indenting with *n* spaces. The valid range for *n* is
+   between 0 and 255, other values result in an undefined output. If
+   ``JSON_INDENT`` is not used or *n* is 0, no newlines are inserted
+   between array and object items.
+
+``JSON_COMPACT``
+   This flag enables a compact representation, i.e. sets the separator
+   between array and object items to ``","`` and between object keys
+   and values to ``":"``. Without this flag, the corresponding
+   separators are ``", "`` and ``": "`` for more readable output.
+
+   .. versionadded:: 1.2
+
+``JSON_ENSURE_ASCII``
+   If this flag is used, the output is guaranteed to consist only of
+   ASCII characters. This is achived by escaping all Unicode
+   characters outside the ASCII range.
+
+   .. versionadded:: 1.2
+
+``JSON_SORT_KEYS``
+   If this flag is used, all the objects in output are sorted by key.
+   This is useful e.g. if two JSON texts are diffed or visually
+   compared.
+
+   .. versionadded:: 1.2
+
+``JSON_PRESERVE_ORDER``
+   If this flag is used, object keys in the output are sorted into the
+   same order in which they were first inserted to the object. For
+   example, decoding a JSON text and then encoding with this flag
+   preserves the order of object keys.
+
+   .. versionadded:: 1.3
 
 The following functions perform the actual JSON encoding. The result
 is in UTF-8.
@@ -608,3 +728,75 @@ The following functions perform the actu
    object it contains, or *NULL* on error, in which case *error* is
    filled with information about the error. See above for discussion
    on the *error* parameter.
+
+
+Equality
+========
+
+Testing for equality of two JSON values cannot, in general, be
+achieved using the ``==`` operator. Equality in the terms of the
+``==`` operator states that the two :ctype:`json_t` pointers point to
+exactly the same JSON value. However, two JSON values can be equal not
+only if they are exactly the same value, but also if they have equal
+"contents":
+
+* Two integer or real values are equal if their contained numeric
+  values are equal. An integer value is never equal to a real value,
+  though.
+
+* Two strings are equal if their contained UTF-8 strings are equal.
+
+* Two arrays are equal if they have the same number of elements and
+  each element in the first array is equal to the corresponding
+  element in the second array.
+
+* Two objects are equal if they have exactly the same keys and the
+  value for each key in the first object is equal to the value of the
+  corresponding key in the second object.
+
+* Two true, false or null values have no "contents", so they are equal
+  if their types are equal. (Because these values are singletons,
+  their equality can actually be tested with ``==``.)
+
+The following function can be used to test whether two JSON values are
+equal.
+
+.. cfunction:: int json_equal(json_t *value1, json_t *value2)
+
+   Returns 1 if *value1* and *value2* are equal, as defined above.
+   Returns 0 if they are inequal or one or both of the pointers are
+   *NULL*.
+
+   .. versionadded:: 1.2
+
+
+Copying
+=======
+
+Because of reference counting, passing JSON values around doesn't
+require copying them. But sometimes a fresh copy of a JSON value is
+needed. For example, if you need to modify an array, but still want to
+use the original afterwards, you should take a copy of it first.
+
+Jansson supports two kinds of copying: shallow and deep. There is a
+difference between these methods only for arrays and objects. Shallow
+copying only copies the first level value (array or object) and uses
+the same child values in the copied value. Deep copying makes a fresh
+copy of the child values, too. Moreover, all the child values are deep
+copied in a recursive fashion.
+
+.. cfunction:: json_t *json_copy(json_t *value)
+
+   .. refcounting:: new
+
+   Returns a shallow copy of *value*, or *NULL* on error.
+
+   .. versionadded:: 1.2
+
+.. cfunction:: json_t *json_deep_copy(json_t *value)
+
+   .. refcounting:: new
+
+   Returns a deep copy of *value*, or *NULL* on error.
+
+   .. versionadded:: 1.2

Added: avro/trunk/lang/c/jansson/doc/changes.rst
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/changes.rst?rev=1057728&view=auto
==============================================================================
--- avro/trunk/lang/c/jansson/doc/changes.rst (added)
+++ avro/trunk/lang/c/jansson/doc/changes.rst Tue Jan 11 16:53:53 2011
@@ -0,0 +1,5 @@
+******************
+Changes in Jansson
+******************
+
+.. include:: ../CHANGES

Modified: avro/trunk/lang/c/jansson/doc/conf.py
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/conf.py?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/doc/conf.py (original)
+++ avro/trunk/lang/c/jansson/doc/conf.py Tue Jan 11 16:53:53 2011
@@ -43,16 +43,16 @@ master_doc = 'index'
 
 # General information about the project.
 project = u'Jansson'
-copyright = u'2009, Petri Lehtinen'
+copyright = u'2009, 2010 Petri Lehtinen'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '1.1'
+version = '1.3'
 # The full version, including alpha/beta/rc tags.
-release = '1.1.3'
+release = '1.3'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
@@ -69,10 +69,10 @@ release = '1.1.3'
 
 # List of directories, relative to source directory, that shouldn't be searched
 # for source files.
-exclude_trees = ['.build']
+exclude_trees = ['_build']
 
 # The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
+default_role = 'cfunc'
 
 # If true, '()' will be appended to :func: etc. cross-reference text.
 #add_function_parentheses = True

Added: avro/trunk/lang/c/jansson/doc/conformance.rst
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/conformance.rst?rev=1057728&view=auto
==============================================================================
--- avro/trunk/lang/c/jansson/doc/conformance.rst (added)
+++ avro/trunk/lang/c/jansson/doc/conformance.rst Tue Jan 11 16:53:53 2011
@@ -0,0 +1,102 @@
+***************
+RFC Conformance
+***************
+
+JSON is specified in :rfc:`4627`, *"The application/json Media Type
+for JavaScript Object Notation (JSON)"*. This chapter discusses
+Jansson's conformance to this specification.
+
+Character Encoding
+==================
+
+Jansson only supports UTF-8 encoded JSON texts. It does not support or
+auto-detect any of the other encodings mentioned in the RFC, namely
+UTF-16LE, UTF-16BE, UTF-32LE or UTF-32BE. Pure ASCII is supported, as
+it's a subset of UTF-8.
+
+Strings
+=======
+
+JSON strings are mapped to C-style null-terminated character arrays,
+and UTF-8 encoding is used internally. Strings may not contain
+embedded null characters, not even escaped ones.
+
+For example, trying to decode the following JSON text leads to a parse
+error::
+
+    ["this string contains the null character: \u0000"]
+
+All other Unicode codepoints U+0001 through U+10FFFF are allowed.
+
+Numbers
+=======
+
+Real vs. Integer
+----------------
+
+JSON makes no distinction between real and integer numbers; Jansson
+does. Real numbers are mapped to the ``double`` type and integers to
+the ``int`` type.
+
+A JSON number is considered to be a real number if its lexical
+representation includes one of ``e``, ``E``, or ``.``; regardless if
+its actual numeric value is a true integer (e.g., all of ``1E6``,
+``3.0``, ``400E-2``, and ``3.14E3`` are mathematical integers, but
+will be treated as real values).
+
+All other JSON numbers are considered integers.
+
+When encoding to JSON, real values are always represented
+with a fractional part; e.g., the ``double`` value 3.0 will be
+represented in JSON as ``3.0``, not ``3``.
+
+Overflow, Underflow & Precision
+-------------------------------
+
+Real numbers whose absolute values are too small to be represented in
+a C double will be silently estimated with 0.0. Thus, depending on
+platform, JSON numbers very close to zero such as 1E-999 may result in
+0.0.
+
+Real numbers whose absolute values are too large to be represented in
+a C ``double`` type will result in an overflow error (a JSON decoding
+error). Thus, depending on platform, JSON numbers like 1E+999 or
+-1E+999 may result in a parsing error.
+
+Likewise, integer numbers whose absolute values are too large to be
+represented in the ``int`` type will result in an overflow error (a
+JSON decoding error). Thus, depending on platform, JSON numbers like
+1000000000000000 may result in parsing error.
+
+Parsing JSON real numbers may result in a loss of precision. As long
+as overflow does not occur (i.e. a total loss of precision), the
+rounded approximate value is silently used. Thus the JSON number
+1.000000000000000005 may, depending on platform, result in the
+``double`` value 1.0.
+
+Signed zeros
+------------
+
+JSON makes no statement about what a number means; however Javascript
+(ECMAscript) does state that +0.0 and -0.0 must be treated as being
+distinct values, i.e. -0.0 |not-equal| 0.0. Jansson relies on the
+underlying floating point library in the C environment in which it is
+compiled. Therefore it is platform-dependent whether 0.0 and -0.0 will
+be distinct values. Most platforms that use the IEEE 754
+floating-point standard will support signed zeros.
+
+Note that this only applies to floating-point; neither JSON, C, or
+IEEE support the concept of signed integer zeros.
+
+.. |not-equal| unicode:: U+2260
+
+Types
+-----
+
+No support is provided in Jansson for any C numeric types other than
+``int`` and ``double``. This excludes things such as unsigned types,
+``long``, ``long long``, ``long double``, etc. Obviously, shorter
+types like ``short`` and ``float`` are implicitly handled via the
+ordinary C type coercion rules (subject to overflow semantics). Also,
+no support or hooks are provided for any supplemental "bignum" type
+add-on packages.

Modified: avro/trunk/lang/c/jansson/doc/ext/refcounting.py
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/ext/refcounting.py?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/doc/ext/refcounting.py (original)
+++ avro/trunk/lang/c/jansson/doc/ext/refcounting.py Tue Jan 11 16:53:53 2011
@@ -19,7 +19,7 @@
 
        <description of the json_object function>
 
-    :copyright: Copyright 2009 Petri Lehtinen <petri@digip.org>
+    :copyright: Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
     :license: MIT, see LICENSE for details.
 """
 

Modified: avro/trunk/lang/c/jansson/doc/gettingstarted.rst
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/gettingstarted.rst?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/doc/gettingstarted.rst (original)
+++ avro/trunk/lang/c/jansson/doc/gettingstarted.rst Tue Jan 11 16:53:53 2011
@@ -31,9 +31,9 @@ the ``--prefix=DIR`` argument to ``./con
 no options to customize the resulting Jansson binary.)
 
 The command ``make check`` runs the test suite distributed with
-Jansson. Python_ is required to run the tests. This step is not
-strictly necessary, but it may find possible problems that Jansson has
-on your platform. If any problems are found, please report them.
+Jansson. This step is not strictly necessary, but it may find possible
+problems that Jansson has on your platform. If any problems are found,
+please report them.
 
 If you obtained the source from a Git repository (or any other source
 control system), there's no ``./configure`` script as it's not kept in
@@ -44,12 +44,11 @@ to use ``autoreconf``::
     autoreconf -vi
 
 This command creates the ``./configure`` script, which can then be
-used as described in the previous section.
+used as described above.
 
 .. _autoconf: http://www.gnu.org/software/autoconf/
 .. _automake: http://www.gnu.org/software/automake/
 .. _libtool: http://www.gnu.org/software/libtool/
-.. _Python: http://www.python.org/
 
 
 Installing Prebuilt Binary Packages
@@ -76,18 +75,17 @@ Documentation is in the ``doc/`` subdire
 reStructuredText_ with Sphinx_ annotations. To generate the HTML
 documentation, invoke::
 
-   cd doc/
-   sphinx-build . .build/html
+   make html
 
-... and point your browser to ``.build/html/index.html``. Sphinx_ is
+and point your browser to ``doc/_build/html/index.html``. Sphinx_ is
 required to generate the documentation.
 
 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
 .. _Sphinx: http://sphinx.pocoo.org/
 
 
-Compiling Programs Using Jansson
-================================
+Compiling Programs That Use Jansson
+===================================
 
 Jansson involves one C header file, :file:`jansson.h`, so it's enough
 to put the line
@@ -102,3 +100,9 @@ There's also just one library to link wi
 link the program as follows::
 
     cc -o prog prog.c -ljansson
+
+Starting from version 1.2, there's also support for pkg-config_::
+
+    cc -o prog prog.c `pkg-config --cflags --libs jansson`
+
+.. _pkg-config: http://pkg-config.freedesktop.org/

Modified: avro/trunk/lang/c/jansson/doc/github_commits.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/github_commits.c?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/doc/github_commits.c (original)
+++ avro/trunk/lang/c/jansson/doc/github_commits.c Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.

Modified: avro/trunk/lang/c/jansson/doc/index.rst
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/doc/index.rst?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/doc/index.rst (original)
+++ avro/trunk/lang/c/jansson/doc/index.rst Tue Jan 11 16:53:53 2011
@@ -34,7 +34,9 @@ Contents
 
    gettingstarted
    tutorial
+   conformance
    apiref
+   changes
 
 
 Indices and Tables

Added: avro/trunk/lang/c/jansson/jansson.pc.in
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/jansson.pc.in?rev=1057728&view=auto
==============================================================================
--- avro/trunk/lang/c/jansson/jansson.pc.in (added)
+++ avro/trunk/lang/c/jansson/jansson.pc.in Tue Jan 11 16:53:53 2011
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=${prefix}/include
+
+Name: Jansson
+Description: Library for encoding, decoding and manipulating JSON data
+Version: @VERSION@
+Libs: -L${libdir} -ljansson
+Cflags: -I${includedir}

Modified: avro/trunk/lang/c/jansson/src/Makefile.am
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/Makefile.am?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/Makefile.am (original)
+++ avro/trunk/lang/c/jansson/src/Makefile.am Tue Jan 11 16:53:53 2011
@@ -1,6 +1,6 @@
-noinst_HEADERS = jansson.h
+include_HEADERS = jansson.h
 
-noinst_LTLIBRARIES = libjansson.la
+lib_LTLIBRARIES = libjansson.la
 libjansson_la_SOURCES = \
 	dump.c \
 	hashtable.c \
@@ -15,6 +15,6 @@ libjansson_la_SOURCES = \
 	value.c
 libjansson_la_LDFLAGS = \
 	-export-symbols-regex '^json_' \
-	-version-info 1:2:1
+	-version-info 3:0:3
 
 AM_CFLAGS = -Wall -Wextra -Werror

Modified: avro/trunk/lang/c/jansson/src/dump.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/dump.c?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/dump.c (original)
+++ avro/trunk/lang/c/jansson/src/dump.c Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
@@ -9,10 +9,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #include <jansson.h>
 #include "jansson_private.h"
 #include "strbuffer.h"
+#include "utf.h"
 
 #define MAX_INTEGER_STR_LENGTH  100
 #define MAX_REAL_STR_LENGTH     100
@@ -42,7 +44,7 @@ static int dump_to_file(const char *buff
 /* 256 spaces (the maximum indentation size) */
 static char whitespace[] = "                                                                                                                                                                                                                                                                ";
 
-static int dump_indent(unsigned long flags, int depth, dump_func dump, void *data)
+static int dump_indent(unsigned long flags, int depth, int space, dump_func dump, void *data)
 {
     if(JSON_INDENT(flags) > 0)
     {
@@ -57,37 +59,56 @@ static int dump_indent(unsigned long fla
                 return -1;
         }
     }
+    else if(space && !(flags & JSON_COMPACT))
+    {
+        return dump(" ", 1, data);
+    }
     return 0;
 }
 
-static int dump_string(const char *str, dump_func dump, void *data)
+static int dump_string(const char *str, int ascii, dump_func dump, void *data)
 {
-    const char *end;
+    const char *pos, *end;
+    int32_t codepoint;
 
     if(dump("\"", 1, data))
         return -1;
 
-    end = str;
+    end = pos = str;
     while(1)
     {
         const char *text;
-        char seq[7];
+        char seq[13];
         int length;
 
-        while(*end && *end != '\\' && *end != '"' && (unsigned char)*end > 0x1F)
-            end++;
+        while(*end)
+        {
+            end = utf8_iterate(pos, &codepoint);
+            if(!end)
+                return -1;
+
+            /* mandatory escape or control char */
+            if(codepoint == '\\' || codepoint == '"' || codepoint < 0x20)
+                break;
+
+            /* non-ASCII */
+            if(ascii && codepoint > 0x7F)
+                break;
+
+            pos = end;
+        }
 
-        if(end != str) {
-            if(dump(str, end - str, data))
+        if(pos != str) {
+            if(dump(str, pos - str, data))
                 return -1;
         }
 
-        if(!*end)
+        if(end == pos)
             break;
 
         /* handle \, ", and control codes */
         length = 2;
-        switch(*end)
+        switch(codepoint)
         {
             case '\\': text = "\\\\"; break;
             case '\"': text = "\\\""; break;
@@ -98,9 +119,27 @@ static int dump_string(const char *str, 
             case '\t': text = "\\t"; break;
             default:
             {
-                sprintf(seq, "\\u00%02x", *end);
+                /* codepoint is in BMP */
+                if(codepoint < 0x10000)
+                {
+                    sprintf(seq, "\\u%04x", codepoint);
+                    length = 6;
+                }
+
+                /* not in BMP -> construct a UTF-16 surrogate pair */
+                else
+                {
+                    int32_t first, last;
+
+                    codepoint -= 0x10000;
+                    first = 0xD800 | ((codepoint & 0xffc00) >> 10);
+                    last = 0xDC00 | (codepoint & 0x003ff);
+
+                    sprintf(seq, "\\u%04x\\u%04x", first, last);
+                    length = 12;
+                }
+
                 text = seq;
-                length = 6;
                 break;
             }
         }
@@ -108,16 +147,29 @@ static int dump_string(const char *str, 
         if(dump(text, length, data))
             return -1;
 
-        end++;
-        str = end;
+        str = pos = end;
     }
 
     return dump("\"", 1, data);
 }
 
+static int object_key_compare_keys(const void *key1, const void *key2)
+{
+    return strcmp((*(const object_key_t **)key1)->key,
+                  (*(const object_key_t **)key2)->key);
+}
+
+static int object_key_compare_serials(const void *key1, const void *key2)
+{
+    return (*(const object_key_t **)key1)->serial -
+           (*(const object_key_t **)key2)->serial;
+}
+
 static int do_dump(const json_t *json, unsigned long flags, int depth,
                    dump_func dump, void *data)
 {
+    int ascii = flags & JSON_ENSURE_ASCII ? 1 : 0;
+
     switch(json_typeof(json)) {
         case JSON_NULL:
             return dump("null", 4, data);
@@ -168,7 +220,7 @@ static int do_dump(const json_t *json, u
         }
 
         case JSON_STRING:
-            return dump_string(json_string_value(json), dump, data);
+            return dump_string(json_string_value(json), ascii, dump, data);
 
         case JSON_ARRAY:
         {
@@ -179,87 +231,181 @@ static int do_dump(const json_t *json, u
             /* detect circular references */
             array = json_to_array(json);
             if(array->visited)
-                return -1;
+                goto array_error;
             array->visited = 1;
 
             n = json_array_size(json);
 
             if(dump("[", 1, data))
-                return -1;
-            if(n == 0)
+                goto array_error;
+            if(n == 0) {
+                array->visited = 0;
                 return dump("]", 1, data);
-            if(dump_indent(flags, depth + 1, dump, data))
-                return -1;
+            }
+            if(dump_indent(flags, depth + 1, 0, dump, data))
+                goto array_error;
 
             for(i = 0; i < n; ++i) {
                 if(do_dump(json_array_get(json, i), flags, depth + 1,
                            dump, data))
-                    return -1;
+                    goto array_error;
 
                 if(i < n - 1)
                 {
                     if(dump(",", 1, data) ||
-                       dump_indent(flags, depth + 1, dump, data))
-                        return -1;
+                       dump_indent(flags, depth + 1, 1, dump, data))
+                        goto array_error;
                 }
                 else
                 {
-                    if(dump_indent(flags, depth, dump, data))
-                        return -1;
+                    if(dump_indent(flags, depth, 0, dump, data))
+                        goto array_error;
                 }
             }
 
             array->visited = 0;
             return dump("]", 1, data);
+
+        array_error:
+            array->visited = 0;
+            return -1;
         }
 
         case JSON_OBJECT:
         {
             json_object_t *object;
             void *iter;
+            const char *separator;
+            int separator_length;
+
+            if(flags & JSON_COMPACT) {
+                separator = ":";
+                separator_length = 1;
+            }
+            else {
+                separator = ": ";
+                separator_length = 2;
+            }
 
             /* detect circular references */
             object = json_to_object(json);
             if(object->visited)
-                return -1;
+                goto object_error;
             object->visited = 1;
 
             iter = json_object_iter((json_t *)json);
 
             if(dump("{", 1, data))
-                return -1;
-            if(!iter)
+                goto object_error;
+            if(!iter) {
+                object->visited = 0;
                 return dump("}", 1, data);
-            if(dump_indent(flags, depth + 1, dump, data))
-                return -1;
+            }
+            if(dump_indent(flags, depth + 1, 0, dump, data))
+                goto object_error;
 
-            while(iter)
+            if(flags & JSON_SORT_KEYS || flags & JSON_PRESERVE_ORDER)
             {
-                void *next = json_object_iter_next((json_t *)json, iter);
-
-                dump_string(json_object_iter_key(iter), dump, data);
-                if(dump(": ", 2, data) ||
-                   do_dump(json_object_iter_value(iter), flags, depth + 1,
-                           dump, data))
-                    return -1;
+                const object_key_t **keys;
+                unsigned int size;
+                unsigned int i;
+                int (*cmp_func)(const void *, const void *);
+
+                size = json_object_size(json);
+                keys = malloc(size * sizeof(object_key_t *));
+                if(!keys)
+                    goto object_error;
 
-                if(next)
+                i = 0;
+                while(iter)
                 {
-                    if(dump(",", 1, data) ||
-                       dump_indent(flags, depth + 1, dump, data))
-                        return -1;
+                    keys[i] = jsonp_object_iter_fullkey(iter);
+                    iter = json_object_iter_next((json_t *)json, iter);
+                    i++;
                 }
+                assert(i == size);
+
+                if(flags & JSON_SORT_KEYS)
+                    cmp_func = object_key_compare_keys;
                 else
+                    cmp_func = object_key_compare_serials;
+
+                qsort(keys, size, sizeof(object_key_t *), cmp_func);
+
+                for(i = 0; i < size; i++)
                 {
-                    if(dump_indent(flags, depth, dump, data))
-                        return -1;
+                    const char *key;
+                    json_t *value;
+
+                    key = keys[i]->key;
+                    value = json_object_get(json, key);
+                    assert(value);
+
+                    dump_string(key, ascii, dump, data);
+                    if(dump(separator, separator_length, data) ||
+                       do_dump(value, flags, depth + 1, dump, data))
+                    {
+                        free(keys);
+                        goto object_error;
+                    }
+
+                    if(i < size - 1)
+                    {
+                        if(dump(",", 1, data) ||
+                           dump_indent(flags, depth + 1, 1, dump, data))
+                        {
+                            free(keys);
+                            goto object_error;
+                        }
+                    }
+                    else
+                    {
+                        if(dump_indent(flags, depth, 0, dump, data))
+                        {
+                            free(keys);
+                            goto object_error;
+                        }
+                    }
                 }
 
-                iter = next;
+                free(keys);
+            }
+            else
+            {
+                /* Don't sort keys */
+
+                while(iter)
+                {
+                    void *next = json_object_iter_next((json_t *)json, iter);
+
+                    dump_string(json_object_iter_key(iter), ascii, dump, data);
+                    if(dump(separator, separator_length, data) ||
+                       do_dump(json_object_iter_value(iter), flags, depth + 1,
+                               dump, data))
+                        goto object_error;
+
+                    if(next)
+                    {
+                        if(dump(",", 1, data) ||
+                           dump_indent(flags, depth + 1, 1, dump, data))
+                            goto object_error;
+                    }
+                    else
+                    {
+                        if(dump_indent(flags, depth, 0, dump, data))
+                            goto object_error;
+                    }
+
+                    iter = next;
+                }
             }
 
             object->visited = 0;
             return dump("}", 1, data);
+
+        object_error:
+            object->visited = 0;
+            return -1;
         }
 
         default:
@@ -285,11 +431,6 @@ char *json_dumps(const json_t *json, uns
         return NULL;
     }
 
-    if(dump_to_strbuffer("\n", 1, (void *)&strbuff)) {
-        strbuffer_close(&strbuff);
-        return NULL;
-    }
-
     result = strdup(strbuffer_value(&strbuff));
     strbuffer_close(&strbuff);
 
@@ -301,9 +442,7 @@ int json_dumpf(const json_t *json, FILE 
     if(!json_is_array(json) && !json_is_object(json))
         return -1;
 
-    if(do_dump(json, flags, 0, dump_to_file, (void *)output))
-        return -1;
-    return dump_to_file("\n", 1, (void *)output);
+    return do_dump(json, flags, 0, dump_to_file, (void *)output);
 }
 
 int json_dump_file(const json_t *json, const char *path, unsigned long flags)

Modified: avro/trunk/lang/c/jansson/src/hashtable.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/hashtable.c?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/hashtable.c (original)
+++ avro/trunk/lang/c/jansson/src/hashtable.c Tue Jan 11 16:53:53 2011
@@ -1,10 +1,12 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
  */
 
+#include <config.h>
+
 #include <stdlib.h>
 #include "hashtable.h"
 
@@ -247,31 +249,39 @@ int hashtable_set(hashtable_t *hashtable
     bucket_t *bucket;
     unsigned int hash, index;
 
-    hash = hashtable->hash_key(key);
-
-    /* if the key already exists, delete it */
-    hashtable_do_del(hashtable, key, hash);
-
     /* rehash if the load ratio exceeds 1 */
     if(hashtable->size >= num_buckets(hashtable))
         if(hashtable_do_rehash(hashtable))
             return -1;
 
-    pair = malloc(sizeof(pair_t));
-    if(!pair)
-        return -1;
-
-    pair->key = key;
-    pair->value = value;
-    pair->hash = hash;
-    list_init(&pair->list);
-
+    hash = hashtable->hash_key(key);
     index = hash % num_buckets(hashtable);
     bucket = &hashtable->buckets[index];
+    pair = hashtable_find_pair(hashtable, bucket, key, hash);
 
-    insert_to_bucket(hashtable, bucket, &pair->list);
+    if(pair)
+    {
+        if(hashtable->free_key)
+            hashtable->free_key(key);
+        if(hashtable->free_value)
+            hashtable->free_value(pair->value);
+        pair->value = value;
+    }
+    else
+    {
+        pair = malloc(sizeof(pair_t));
+        if(!pair)
+            return -1;
+
+        pair->key = key;
+        pair->value = value;
+        pair->hash = hash;
+        list_init(&pair->list);
+
+        insert_to_bucket(hashtable, bucket, &pair->list);
 
-    hashtable->size++;
+        hashtable->size++;
+    }
     return 0;
 }
 
@@ -318,6 +328,22 @@ void *hashtable_iter(hashtable_t *hashta
     return hashtable_iter_next(hashtable, &hashtable->list);
 }
 
+void *hashtable_iter_at(hashtable_t *hashtable, const void *key)
+{
+    pair_t *pair;
+    unsigned int hash;
+    bucket_t *bucket;
+
+    hash = hashtable->hash_key(key);
+    bucket = &hashtable->buckets[hash % num_buckets(hashtable)];
+
+    pair = hashtable_find_pair(hashtable, bucket, key, hash);
+    if(!pair)
+        return NULL;
+
+    return &pair->list;
+}
+
 void *hashtable_iter_next(hashtable_t *hashtable, void *iter)
 {
     list_t *list = (list_t *)iter;
@@ -337,3 +363,13 @@ void *hashtable_iter_value(void *iter)
     pair_t *pair = list_to_pair((list_t *)iter);
     return pair->value;
 }
+
+void hashtable_iter_set(hashtable_t *hashtable, void *iter, void *value)
+{
+    pair_t *pair = list_to_pair((list_t *)iter);
+
+    if(hashtable->free_value)
+        hashtable->free_value(pair->value);
+
+    pair->value = value;
+}

Modified: avro/trunk/lang/c/jansson/src/hashtable.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/hashtable.h?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/hashtable.h (original)
+++ avro/trunk/lang/c/jansson/src/hashtable.h Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
@@ -161,6 +161,17 @@ void hashtable_clear(hashtable_t *hashta
 void *hashtable_iter(hashtable_t *hashtable);
 
 /**
+ * hashtable_iter_at - Return an iterator at a specific key
+ *
+ * @hashtable: The hashtable object
+ * @key: The key that the iterator should point to
+ *
+ * Like hashtable_iter() but returns an iterator pointing to a
+ * specific key.
+ */
+void *hashtable_iter_at(hashtable_t *hashtable, const void *key);
+
+/**
  * hashtable_iter_next - Advance an iterator
  *
  * @hashtable: The hashtable object
@@ -185,4 +196,12 @@ void *hashtable_iter_key(void *iter);
  */
 void *hashtable_iter_value(void *iter);
 
+/**
+ * hashtable_iter_set - Set the value pointed by an iterator
+ *
+ * @iter: The iterator
+ * @value: The value to set
+ */
+void hashtable_iter_set(hashtable_t *hashtable, void *iter, void *value);
+
 #endif

Modified: avro/trunk/lang/c/jansson/src/jansson.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/jansson.h?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/jansson.h (original)
+++ avro/trunk/lang/c/jansson/src/jansson.h Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
@@ -10,7 +10,10 @@
 
 #include <stdio.h>
 
-#ifdef __cplusplus
+#ifndef __cplusplus
+#define JSON_INLINE inline
+#else
+#define JSON_INLINE inline
 extern "C" {
 #endif
 
@@ -49,13 +52,15 @@ typedef struct {
 json_t *json_object(void);
 json_t *json_array(void);
 json_t *json_string(const char *value);
+json_t *json_string_nocheck(const char *value);
 json_t *json_integer(int value);
 json_t *json_real(double value);
 json_t *json_true(void);
 json_t *json_false(void);
 json_t *json_null(void);
 
-static inline json_t *json_incref(json_t *json)
+static JSON_INLINE
+json_t *json_incref(json_t *json)
 {
     if(json && json->refcount != (unsigned int)-1)
         ++json->refcount;
@@ -65,7 +70,8 @@ static inline json_t *json_incref(json_t
 /* do not call json_delete directly */
 void json_delete(json_t *json);
 
-static inline void json_decref(json_t *json)
+static JSON_INLINE
+void json_decref(json_t *json)
 {
     if(json && json->refcount != (unsigned int)-1 && --json->refcount == 0)
         json_delete(json);
@@ -77,20 +83,35 @@ static inline void json_decref(json_t *j
 unsigned int json_object_size(const json_t *object);
 json_t *json_object_get(const json_t *object, const char *key);
 int json_object_set_new(json_t *object, const char *key, json_t *value);
+int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value);
 int json_object_del(json_t *object, const char *key);
 int json_object_clear(json_t *object);
 int json_object_update(json_t *object, json_t *other);
 void *json_object_iter(json_t *object);
+void *json_object_iter_at(json_t *object, const char *key);
 void *json_object_iter_next(json_t *object, void *iter);
 const char *json_object_iter_key(void *iter);
 json_t *json_object_iter_value(void *iter);
+int json_object_iter_set_new(json_t *object, void *iter, json_t *value);
 
-static inline
+static JSON_INLINE
 int json_object_set(json_t *object, const char *key, json_t *value)
 {
     return json_object_set_new(object, key, json_incref(value));
 }
 
+static JSON_INLINE
+int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
+{
+    return json_object_set_new_nocheck(object, key, json_incref(value));
+}
+
+static inline
+int json_object_iter_set(json_t *object, void *iter, json_t *value)
+{
+    return json_object_iter_set_new(object, iter, json_incref(value));
+}
+
 unsigned int json_array_size(const json_t *array);
 json_t *json_array_get(const json_t *array, unsigned int index);
 int json_array_set_new(json_t *array, unsigned int index, json_t *value);
@@ -100,19 +121,19 @@ int json_array_remove(json_t *array, uns
 int json_array_clear(json_t *array);
 int json_array_extend(json_t *array, json_t *other);
 
-static inline
+static JSON_INLINE
 int json_array_set(json_t *array, unsigned int index, json_t *value)
 {
     return json_array_set_new(array, index, json_incref(value));
 }
 
-static inline
+static JSON_INLINE
 int json_array_append(json_t *array, json_t *value)
 {
     return json_array_append_new(array, json_incref(value));
 }
 
-static inline
+static JSON_INLINE
 int json_array_insert(json_t *array, unsigned int index, json_t *value)
 {
     return json_array_insert_new(array, index, json_incref(value));
@@ -123,9 +144,21 @@ int json_integer_value(const json_t *int
 double json_real_value(const json_t *real);
 double json_number_value(const json_t *json);
 
-int json_string_set(const json_t *string, const char *value);
-int json_integer_set(const json_t *integer, int value);
-int json_real_set(const json_t *real, double value);
+int json_string_set(json_t *string, const char *value);
+int json_string_set_nocheck(json_t *string, const char *value);
+int json_integer_set(json_t *integer, int value);
+int json_real_set(json_t *real, double value);
+
+
+/* equality */
+
+int json_equal(json_t *value1, json_t *value2);
+
+
+/* copying */
+
+json_t *json_copy(json_t *value);
+json_t *json_deep_copy(json_t *value);
 
 
 /* loading, printing */
@@ -141,7 +174,11 @@ json_t *json_loads(const char *input, js
 json_t *json_loadf(FILE *input, json_error_t *error);
 json_t *json_load_file(const char *path, json_error_t *error);
 
-#define JSON_INDENT(n)   (n & 0xFF)
+#define JSON_INDENT(n)      (n & 0xFF)
+#define JSON_COMPACT        0x100
+#define JSON_ENSURE_ASCII   0x200
+#define JSON_SORT_KEYS      0x400
+#define JSON_PRESERVE_ORDER 0x800
 
 char *json_dumps(const json_t *json, unsigned long flags);
 int json_dumpf(const json_t *json, FILE *output, unsigned long flags);

Added: avro/trunk/lang/c/jansson/src/jansson.h.in
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/jansson.h.in?rev=1057728&view=auto
==============================================================================
--- avro/trunk/lang/c/jansson/src/jansson.h.in (added)
+++ avro/trunk/lang/c/jansson/src/jansson.h.in Tue Jan 11 16:53:53 2011
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
+ *
+ * Jansson is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See LICENSE for details.
+ */
+
+#ifndef JANSSON_H
+#define JANSSON_H
+
+#include <stdio.h>
+
+#ifndef __cplusplus
+#define JSON_INLINE @json_inline@
+#else
+#define JSON_INLINE inline
+extern "C" {
+#endif
+
+/* types */
+
+typedef enum {
+    JSON_OBJECT,
+    JSON_ARRAY,
+    JSON_STRING,
+    JSON_INTEGER,
+    JSON_REAL,
+    JSON_TRUE,
+    JSON_FALSE,
+    JSON_NULL
+} json_type;
+
+typedef struct {
+    json_type type;
+    unsigned long refcount;
+} json_t;
+
+#define json_typeof(json)      ((json)->type)
+#define json_is_object(json)   (json && json_typeof(json) == JSON_OBJECT)
+#define json_is_array(json)    (json && json_typeof(json) == JSON_ARRAY)
+#define json_is_string(json)   (json && json_typeof(json) == JSON_STRING)
+#define json_is_integer(json)  (json && json_typeof(json) == JSON_INTEGER)
+#define json_is_real(json)     (json && json_typeof(json) == JSON_REAL)
+#define json_is_number(json)   (json_is_integer(json) || json_is_real(json))
+#define json_is_true(json)     (json && json_typeof(json) == JSON_TRUE)
+#define json_is_false(json)    (json && json_typeof(json) == JSON_FALSE)
+#define json_is_boolean(json)  (json_is_true(json) || json_is_false(json))
+#define json_is_null(json)     (json && json_typeof(json) == JSON_NULL)
+
+/* construction, destruction, reference counting */
+
+json_t *json_object(void);
+json_t *json_array(void);
+json_t *json_string(const char *value);
+json_t *json_string_nocheck(const char *value);
+json_t *json_integer(int value);
+json_t *json_real(double value);
+json_t *json_true(void);
+json_t *json_false(void);
+json_t *json_null(void);
+
+static JSON_INLINE
+json_t *json_incref(json_t *json)
+{
+    if(json && json->refcount != (unsigned int)-1)
+        ++json->refcount;
+    return json;
+}
+
+/* do not call json_delete directly */
+void json_delete(json_t *json);
+
+static JSON_INLINE
+void json_decref(json_t *json)
+{
+    if(json && json->refcount != (unsigned int)-1 && --json->refcount == 0)
+        json_delete(json);
+}
+
+
+/* getters, setters, manipulation */
+
+unsigned int json_object_size(const json_t *object);
+json_t *json_object_get(const json_t *object, const char *key);
+int json_object_set_new(json_t *object, const char *key, json_t *value);
+int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value);
+int json_object_del(json_t *object, const char *key);
+int json_object_clear(json_t *object);
+int json_object_update(json_t *object, json_t *other);
+void *json_object_iter(json_t *object);
+void *json_object_iter_at(json_t *object, const char *key);
+void *json_object_iter_next(json_t *object, void *iter);
+const char *json_object_iter_key(void *iter);
+json_t *json_object_iter_value(void *iter);
+int json_object_iter_set_new(json_t *object, void *iter, json_t *value);
+
+static JSON_INLINE
+int json_object_set(json_t *object, const char *key, json_t *value)
+{
+    return json_object_set_new(object, key, json_incref(value));
+}
+
+static JSON_INLINE
+int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
+{
+    return json_object_set_new_nocheck(object, key, json_incref(value));
+}
+
+static inline
+int json_object_iter_set(json_t *object, void *iter, json_t *value)
+{
+    return json_object_iter_set_new(object, iter, json_incref(value));
+}
+
+unsigned int json_array_size(const json_t *array);
+json_t *json_array_get(const json_t *array, unsigned int index);
+int json_array_set_new(json_t *array, unsigned int index, json_t *value);
+int json_array_append_new(json_t *array, json_t *value);
+int json_array_insert_new(json_t *array, unsigned int index, json_t *value);
+int json_array_remove(json_t *array, unsigned int index);
+int json_array_clear(json_t *array);
+int json_array_extend(json_t *array, json_t *other);
+
+static JSON_INLINE
+int json_array_set(json_t *array, unsigned int index, json_t *value)
+{
+    return json_array_set_new(array, index, json_incref(value));
+}
+
+static JSON_INLINE
+int json_array_append(json_t *array, json_t *value)
+{
+    return json_array_append_new(array, json_incref(value));
+}
+
+static JSON_INLINE
+int json_array_insert(json_t *array, unsigned int index, json_t *value)
+{
+    return json_array_insert_new(array, index, json_incref(value));
+}
+
+const char *json_string_value(const json_t *string);
+int json_integer_value(const json_t *integer);
+double json_real_value(const json_t *real);
+double json_number_value(const json_t *json);
+
+int json_string_set(json_t *string, const char *value);
+int json_string_set_nocheck(json_t *string, const char *value);
+int json_integer_set(json_t *integer, int value);
+int json_real_set(json_t *real, double value);
+
+
+/* equality */
+
+int json_equal(json_t *value1, json_t *value2);
+
+
+/* copying */
+
+json_t *json_copy(json_t *value);
+json_t *json_deep_copy(json_t *value);
+
+
+/* loading, printing */
+
+#define JSON_ERROR_TEXT_LENGTH  160
+
+typedef struct {
+    char text[JSON_ERROR_TEXT_LENGTH];
+    int line;
+} json_error_t;
+
+json_t *json_loads(const char *input, json_error_t *error);
+json_t *json_loadf(FILE *input, json_error_t *error);
+json_t *json_load_file(const char *path, json_error_t *error);
+
+#define JSON_INDENT(n)      (n & 0xFF)
+#define JSON_COMPACT        0x100
+#define JSON_ENSURE_ASCII   0x200
+#define JSON_SORT_KEYS      0x400
+#define JSON_PRESERVE_ORDER 0x800
+
+char *json_dumps(const json_t *json, unsigned long flags);
+int json_dumpf(const json_t *json, FILE *output, unsigned long flags);
+int json_dump_file(const json_t *json, const char *path, unsigned long flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: avro/trunk/lang/c/jansson/src/jansson_private.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/jansson_private.h?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/jansson_private.h (original)
+++ avro/trunk/lang/c/jansson/src/jansson_private.h Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
@@ -17,6 +17,7 @@
 typedef struct {
     json_t json;
     hashtable_t hashtable;
+    unsigned long serial;
     int visited;
 } json_object_t;
 
@@ -49,7 +50,11 @@ typedef struct {
 #define json_to_real(json_)   container_of(json_, json_real_t, json)
 #define json_to_integer(json_) container_of(json_, json_integer_t, json)
 
-int json_object_set_nocheck(json_t *json, const char *key, json_t *value);
-json_t *json_string_nocheck(const char *value);
+typedef struct {
+    unsigned long serial;
+    char key[];
+} object_key_t;
+
+const object_key_t *jsonp_object_iter_fullkey(void *iter);
 
 #endif

Modified: avro/trunk/lang/c/jansson/src/load.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/load.c?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/load.c (original)
+++ avro/trunk/lang/c/jansson/src/load.c Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
@@ -113,7 +113,8 @@ static void error_set(json_error_t *erro
 
 /*** lexical analyzer ***/
 
-void stream_init(stream_t *stream, get_func get, eof_func eof, void *data)
+static void
+stream_init(stream_t *stream, get_func get, eof_func eof, void *data)
 {
     stream->get = get;
     stream->eof = eof;
@@ -148,7 +149,7 @@ static char stream_get(stream_t *stream,
             for(i = 1; i < count; i++)
                 stream->buffer[i] = stream->get(stream->data);
 
-            if(!utf8_check_full(stream->buffer, count))
+            if(!utf8_check_full(stream->buffer, count, NULL))
                 goto out;
 
             stream->stream_pos += count;
@@ -221,10 +222,10 @@ static void lex_save_cached(lex_t *lex)
 }
 
 /* assumes that str points to 'u' plus at least 4 valid hex digits */
-static int decode_unicode_escape(const char *str)
+static int32_t decode_unicode_escape(const char *str)
 {
     int i;
-    int value = 0;
+    int32_t value = 0;
 
     assert(str[0] == 'u');
 
@@ -325,7 +326,7 @@ static void lex_scan_string(lex_t *lex, 
             if(*p == 'u') {
                 char buffer[4];
                 int length;
-                int value;
+                int32_t value;
 
                 value = decode_unicode_escape(p);
                 p += 5;
@@ -333,7 +334,7 @@ static void lex_scan_string(lex_t *lex, 
                 if(0xD800 <= value && value <= 0xDBFF) {
                     /* surrogate pair */
                     if(*p == '\\' && *(p + 1) == 'u') {
-                        int value2 = decode_unicode_escape(++p);
+                        int32_t value2 = decode_unicode_escape(++p);
                         p += 5;
 
                         if(0xDC00 <= value2 && value2 <= 0xDFFF) {
@@ -483,14 +484,7 @@ static int lex_scan_number(lex_t *lex, c
     value = strtod(saved_text, &end);
     assert(end == saved_text + lex->saved_text.length);
 
-    if(value == 0 && errno == ERANGE) {
-        error_set(error, lex, "real number underflow");
-        goto out;
-    }
-
-    /* Cannot test for +/-HUGE_VAL because the HUGE_VAL constant is
-       only defined in C99 mode. So let's trust in sole errno. */
-    else if(errno == ERANGE) {
+    if(errno == ERANGE && value != 0) {
         error_set(error, lex, "real number overflow");
         goto out;
     }

Modified: avro/trunk/lang/c/jansson/src/strbuffer.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/strbuffer.c?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/strbuffer.c (original)
+++ avro/trunk/lang/c/jansson/src/strbuffer.c Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.

Modified: avro/trunk/lang/c/jansson/src/strbuffer.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/strbuffer.h?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/strbuffer.h (original)
+++ avro/trunk/lang/c/jansson/src/strbuffer.h Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.

Modified: avro/trunk/lang/c/jansson/src/utf.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/utf.c?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/utf.c (original)
+++ avro/trunk/lang/c/jansson/src/utf.c Tue Jan 11 16:53:53 2011
@@ -1,13 +1,14 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
  */
 
 #include <string.h>
+#include "utf.h"
 
-int utf8_encode(int codepoint, char *buffer, int *size)
+int utf8_encode(int32_t codepoint, char *buffer, int *size)
 {
     if(codepoint < 0)
         return -1;
@@ -79,9 +80,10 @@ int utf8_check_first(char byte)
     }
 }
 
-int utf8_check_full(const char *buffer, int size)
+int utf8_check_full(const char *buffer, int size, int32_t *codepoint)
 {
-    int i, value = 0;
+    int i;
+    int32_t value = 0;
     unsigned char u = (unsigned char)buffer[0];
 
     if(size == 2)
@@ -128,9 +130,38 @@ int utf8_check_full(const char *buffer, 
         return 0;
     }
 
+    if(codepoint)
+        *codepoint = value;
+
     return 1;
 }
 
+const char *utf8_iterate(const char *buffer, int32_t *codepoint)
+{
+    int count;
+    int32_t value;
+
+    if(!*buffer)
+        return buffer;
+
+    count = utf8_check_first(buffer[0]);
+    if(count <= 0)
+        return NULL;
+
+    if(count == 1)
+        value = (unsigned char)buffer[0];
+    else
+    {
+        if(!utf8_check_full(buffer, count, &value))
+            return NULL;
+    }
+
+    if(codepoint)
+        *codepoint = value;
+
+    return buffer + count;
+}
+
 int utf8_check_string(const char *string, int length)
 {
     int i;
@@ -148,7 +179,7 @@ int utf8_check_string(const char *string
             if(i + count > length)
                 return 0;
 
-            if(!utf8_check_full(&string[i], count))
+            if(!utf8_check_full(&string[i], count, NULL))
                 return 0;
 
             i += count - 1;

Modified: avro/trunk/lang/c/jansson/src/utf.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/utf.h?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/utf.h (original)
+++ avro/trunk/lang/c/jansson/src/utf.h Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.
@@ -8,10 +8,20 @@
 #ifndef UTF_H
 #define UTF_H
 
+#include <config.h>
+
+#ifdef HAVE_INTTYPES_H
+/* inttypes.h includes stdint.h in a standard environment, so there's
+no need to include stdint.h separately. If inttypes.h doesn't define
+int32_t, it's defined in config.h. */
+#include <inttypes.h>
+#endif
+
 int utf8_encode(int codepoint, char *buffer, int *size);
 
 int utf8_check_first(char byte);
-int utf8_check_full(const char *buffer, int size);
+int utf8_check_full(const char *buffer, int size, int32_t *codepoint);
+const char *utf8_iterate(const char *buffer, int32_t *codepoint);
 
 int utf8_check_string(const char *string, int length);
 

Modified: avro/trunk/lang/c/jansson/src/util.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/util.h?rev=1057728&r1=1057727&r2=1057728&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/util.h (original)
+++ avro/trunk/lang/c/jansson/src/util.h Tue Jan 11 16:53:53 2011
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
  *
  * Jansson is free software; you can redistribute it and/or modify
  * it under the terms of the MIT license. See LICENSE for details.



Mime
View raw message