diff --git a/.gitignore b/.gitignore index a2baa14..4c4115c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ missing *.la stamp-h1 *.pyc +*.pc diff --git a/CHANGES b/CHANGES index abe0062..02f28c4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,54 +1,117 @@ -Version 1.1.3, released 2009-12-18 +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, released 2009-11-08 +Version 1.1.2 +============= + +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, released 2009-10-20 +Version 1.1 +=========== + +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 +119,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 +============= -* Fixed broken json_is_boolean() +Released 2009-09-04 + +* Fixed broken `json_is_boolean()` -Version 1.0, released 2009-08-25 +Version 1.0 +=========== + +Released 2009-08-25 * Initial release diff --git a/LICENSE b/LICENSE index 6c6dbed..b5c2887 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ -Copyright (c) 2009 Petri Lehtinen +Copyright (c) 2009, 2010 Petri Lehtinen +Copyright (c) 2010 Sean Middleditch Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile.am b/Makefile.am index 185eaab..a141cd5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,3 +2,6 @@ EXTRA_DIST = CHANGES LICENSE README.rst SUBDIRS = doc src test check-local: html + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = jansson.pc diff --git a/configure.ac b/configure.ac index 43ce1d0..5290793 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.59]) -AC_INIT([jansson], [1.1.3+], [petri@digip.org]) +AC_INIT([jansson], [1.2], [petri@digip.org]) AM_INIT_AUTOMAKE([1.10 foreign]) @@ -20,6 +20,7 @@ AC_PROG_LIBTOOL # Checks for library functions. AC_CONFIG_FILES([ + jansson.pc Makefile doc/Makefile src/Makefile diff --git a/doc/Makefile.am b/doc/Makefile.am index cb3723f..d620775 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,5 @@ -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 gettingstarted.rst \ + github_commits.c index.rst tutorial.rst ext/refcounting.py SPHINXBUILD = sphinx-build SPHINXOPTS = -d _build/doctrees -W diff --git a/doc/changes.rst b/doc/changes.rst new file mode 100644 index 0000000..ea56843 --- /dev/null +++ b/doc/changes.rst @@ -0,0 +1,5 @@ +****************** +Changes in Jansson +****************** + +.. include:: ../CHANGES diff --git a/doc/conf.py b/doc/conf.py index 10f444d..06530e3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -50,9 +50,9 @@ copyright = u'2009, Petri Lehtinen' # built documents. # # The short X.Y version. -version = '1.1' +version = '1.2' # The full version, including alpha/beta/rc tags. -release = '1.1.3+' +release = '1.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -72,7 +72,7 @@ release = '1.1.3+' 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 diff --git a/doc/index.rst b/doc/index.rst index 1ae9bf3..d6018b9 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -35,6 +35,7 @@ Contents gettingstarted tutorial apiref + changes Indices and Tables diff --git a/jansson.pc.in b/jansson.pc.in new file mode 100644 index 0000000..d9bf4da --- /dev/null +++ b/jansson.pc.in @@ -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} diff --git a/src/Makefile.am b/src/Makefile.am index d5c20e8..460b26a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,6 @@ libjansson_la_SOURCES = \ value.c libjansson_la_LDFLAGS = \ -export-symbols-regex '^json_' \ - -version-info 1:2:1 + -version-info 2:0:2 AM_CFLAGS = -Wall -Wextra -Werror diff --git a/test/Makefile.am b/test/Makefile.am index e468d22..86d1614 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,5 +1,5 @@ SUBDIRS = bin suites -EXTRA_DIST = scripts +EXTRA_DIST = scripts run-suites TESTS = run-suites TESTS_ENVIRONMENT = \ diff --git a/test/run-suites b/test/run-suites index e736004..6e5baf6 100755 --- a/test/run-suites +++ b/test/run-suites @@ -14,7 +14,7 @@ done if [ -z "$SUITES" ]; then suitedirs=$top_srcdir/test/suites/* for suitedir in $suitedirs; do - if [ -x $suitedir/run ]; then + if [ -d $suitedir ]; then SUITES="$SUITES `basename $suitedir`" fi done diff --git a/test/scripts/run-tests.sh b/test/scripts/run-tests.sh index 2559766..5d140ff 100644 --- a/test/scripts/run-tests.sh +++ b/test/scripts/run-tests.sh @@ -29,7 +29,7 @@ for test_path in $suite_srcdir/*; do rm -rf $test_log mkdir -p $test_log if [ $VERBOSE -eq 1 ]; then - echo -n "$name... " + echo -n "$test_name... " fi if run_test; then diff --git a/test/suites/api/Makefile.am b/test/suites/api/Makefile.am index 35f1ee0..ddeb147 100644 --- a/test/suites/api/Makefile.am +++ b/test/suites/api/Makefile.am @@ -1,3 +1,5 @@ +EXTRA_DIST = run + check_PROGRAMS = \ test_array \ test_equal \ diff --git a/test/suites/api/run b/test/suites/api/run index 02e92b0..8688e0f 100755 --- a/test/suites/api/run +++ b/test/suites/api/run @@ -17,7 +17,8 @@ run_test() { else $test_runner $suite_builddir/${test_name%.c} \ >$test_log/stdout \ - 2>$test_log/stderr + 2>$test_log/stderr \ + || return 1 valgrind_check $test_log/stderr || return 1 fi } diff --git a/test/suites/api/test_object.c b/test/suites/api/test_object.c index 7e9ada8..849dac0 100644 --- a/test/suites/api/test_object.c +++ b/test/suites/api/test_object.c @@ -205,10 +205,68 @@ static void test_set_nocheck() json_decref(object); } +static void test_iterators() +{ + json_t *object, *foo, *bar, *baz; + void *iter; + + if(json_object_iter(NULL)) + fail("able to iterate over NULL"); + + if(json_object_iter_next(NULL, NULL)) + fail("able to increment an iterator on a NULL object"); + + object = json_object(); + foo = json_string("foo"); + bar = json_string("bar"); + baz = json_string("baz"); + if(!object || !foo || !bar || !bar) + fail("unable to create values"); + + if(json_object_iter_next(object, NULL)) + fail("able to increment a NULL iterator"); + + if(json_object_set(object, "a", foo) || + json_object_set(object, "b", bar) || + json_object_set(object, "c", baz)) + fail("unable to populate object"); + + iter = json_object_iter(object); + if(!iter) + fail("unable to get iterator"); + if(strcmp(json_object_iter_key(iter), "a")) + fail("iterating failed: wrong key"); + if(json_object_iter_value(iter) != foo) + fail("iterating failed: wrong value"); + + iter = json_object_iter_next(object, iter); + if(!iter) + fail("unable to increment iterator"); + if(strcmp(json_object_iter_key(iter), "b")) + fail("iterating failed: wrong key"); + if(json_object_iter_value(iter) != bar) + fail("iterating failed: wrong value"); + + iter = json_object_iter_next(object, iter); + if(!iter) + fail("unable to increment iterator"); + if(strcmp(json_object_iter_key(iter), "c")) + fail("iterating failed: wrong key"); + if(json_object_iter_value(iter) != baz) + fail("iterating failed: wrong value"); + + if(json_object_iter_next(object, iter) != NULL) + fail("able to iterate over the end"); + + json_decref(object); + json_decref(foo); + json_decref(bar); + json_decref(baz); +} + static void test_misc() { json_t *object, *string, *other_string, *value; - void *iter; object = json_object(); string = json_string("test"); @@ -231,17 +289,6 @@ static void test_misc() if(!json_object_set(object, "a", NULL)) fail("able to set NULL value"); - iter = json_object_iter(object); - if(!iter) - fail("unable to get iterator"); - - if(strcmp(json_object_iter_key(iter), "a")) - fail("iterating failed: wrong key"); - if(json_object_iter_value(iter) != string) - fail("iterating failed: wrong value"); - if(json_object_iter_next(object, iter) != NULL) - fail("able to iterate over the end"); - /* invalid UTF-8 in key */ if(!json_object_set(object, "a\xefz", string)) fail("able to set invalid unicode key"); @@ -332,6 +379,7 @@ int main() test_update(); test_circular(); test_set_nocheck(); + test_iterators(); return 0; }