소스 검색

Updated to jansson 2.13.1

Brucey 5 년 전
부모
커밋
7c380fa683
36개의 변경된 파일1343개의 추가작업 그리고 1398개의 파일을 삭제
  1. 3 1
      jansson.mod/jansson.bmx
  2. 2 0
      jansson.mod/jansson/.gitignore
  3. 8 0
      jansson.mod/jansson/.travis.yml
  4. 58 0
      jansson.mod/jansson/CHANGES
  5. 6 6
      jansson.mod/jansson/CMakeLists.txt
  6. 1 1
      jansson.mod/jansson/LICENSE
  7. 3 1
      jansson.mod/jansson/Makefile.am
  8. 12 0
      jansson.mod/jansson/README.rst
  9. 3 3
      jansson.mod/jansson/cmake/CoverallsGenerateGcov.cmake
  10. 19 5
      jansson.mod/jansson/cmake/FindSphinx.cmake
  11. 1 1
      jansson.mod/jansson/configure.ac
  12. 33 10
      jansson.mod/jansson/doc/apiref.rst
  13. 2 2
      jansson.mod/jansson/doc/conf.py
  14. 21 0
      jansson.mod/jansson/doc/gettingstarted.rst
  15. 29 50
      jansson.mod/jansson/doc/github_commits.c
  16. 1 1
      jansson.mod/jansson/doc/tutorial.rst
  17. 2 2
      jansson.mod/jansson/src/Makefile.am
  18. 136 171
      jansson.mod/jansson/src/dump.c
  19. 13 20
      jansson.mod/jansson/src/error.c
  20. 55 93
      jansson.mod/jansson/src/hashtable.c
  21. 4 6
      jansson.mod/jansson/src/hashtable.h
  22. 15 15
      jansson.mod/jansson/src/hashtable_seed.c
  23. 1 0
      jansson.mod/jansson/src/jansson.def
  24. 125 111
      jansson.mod/jansson/src/jansson.h
  25. 32 27
      jansson.mod/jansson/src/jansson_private.h
  26. 224 257
      jansson.mod/jansson/src/load.c
  27. 2 1
      jansson.mod/jansson/src/lookup3.h
  28. 9 17
      jansson.mod/jansson/src/memory.c
  29. 202 219
      jansson.mod/jansson/src/pack_unpack.c
  30. 23 36
      jansson.mod/jansson/src/strbuffer.c
  31. 4 3
      jansson.mod/jansson/src/strbuffer.h
  32. 19 31
      jansson.mod/jansson/src/strconv.c
  33. 41 69
      jansson.mod/jansson/src/utf.c
  34. 1 0
      jansson.mod/jansson/src/utf.h
  35. 231 233
      jansson.mod/jansson/src/value.c
  36. 2 6
      jansson.mod/jansson/src/version.c

+ 3 - 1
jansson.mod/jansson.bmx

@@ -22,11 +22,13 @@ SuperStrict
 
 Module Text.Jansson
 
-ModuleInfo "Version: 1.05"
+ModuleInfo "Version: 1.06"
 ModuleInfo "Author: Bruce A Henderson"
 ModuleInfo "License: MIT"
 ModuleInfo "Copyright: 2014-2020 Bruce A Henderson"
 
+ModuleInfo "History: 1.06"
+ModuleInfo "History: Updated to Jansson 2.13.1."
 ModuleInfo "History: 1.05"
 ModuleInfo "History: Updated to Jansson with fractional precision support."
 ModuleInfo "History: 1.04"

+ 2 - 0
jansson.mod/jansson/.gitignore

@@ -33,3 +33,5 @@ stamp-h1
 *.exe
 .idea
 cmake-build-debug/
+*.log
+*.trs

+ 8 - 0
jansson.mod/jansson/.travis.yml

@@ -1,9 +1,13 @@
 env:
+  global:
+    - CLANG_FORMAT_VERSION=9
   matrix:
     - JANSSON_BUILD_METHOD=cmake JANSSON_CMAKE_OPTIONS="-DJANSSON_TEST_WITH_VALGRIND=ON" JANSSON_EXTRA_INSTALL="valgrind"
     - JANSSON_BUILD_METHOD=autotools
     - JANSSON_BUILD_METHOD=coverage JANSSON_CMAKE_OPTIONS="-DJANSSON_COVERAGE=ON -DJANSSON_COVERALLS=ON -DCMAKE_BUILD_TYPE=Debug" JANSSON_EXTRA_INSTALL="lcov curl"
     - JANSSON_BUILD_METHOD=fuzzer
+    - JANSSON_BUILD_METHOD=lint CLANG_FORMAT=clang-format-9
+dist: bionic
 language: c
 compiler:
   - gcc
@@ -14,13 +18,17 @@ matrix:
       env: JANSSON_BUILD_METHOD=coverage JANSSON_CMAKE_OPTIONS="-DJANSSON_COVERAGE=ON -DJANSSON_COVERALLS=ON -DCMAKE_BUILD_TYPE=Debug" JANSSON_EXTRA_INSTALL="lcov curl"
     - compiler: clang
       env: JANSSON_BUILD_METHOD=fuzzer
+    - compiler: gcc
+      env: JANSSON_BUILD_METHOD=lint CLANG_FORMAT=clang-format-9
   allow_failures:
     - env: JANSSON_BUILD_METHOD=coverage JANSSON_CMAKE_OPTIONS="-DJANSSON_COVERAGE=ON -DJANSSON_COVERALLS=ON -DCMAKE_BUILD_TYPE=Debug" JANSSON_EXTRA_INSTALL="lcov curl"
 install:
   - sudo apt-get update -qq
   - sudo apt-get install -y -qq cmake $JANSSON_EXTRA_INSTALL
+  - if [ "$TRAVIS_COMPILER" = "clang" ]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main" -y && sudo apt-get install -y -qq clang-9 clang-format-9; fi
 script:
   - if [ "$JANSSON_BUILD_METHOD" = "autotools" ]; then autoreconf -f -i && CFLAGS=-Werror ./configure && make check; fi
   - if [ "$JANSSON_BUILD_METHOD" = "cmake" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && ctest --output-on-failure; fi
   - if [ "$JANSSON_BUILD_METHOD" = "coverage" ]; then mkdir build && cd build && cmake $JANSSON_CMAKE_OPTIONS .. && cmake --build . && cmake --build . --target coveralls; fi
   - if [ "$JANSSON_BUILD_METHOD" = "fuzzer" ]; then ./test/ossfuzz/travisoss.sh; fi
+  - if [ "$JANSSON_BUILD_METHOD" = "lint" ]; then ./scripts/clang-format-check; fi

+ 58 - 0
jansson.mod/jansson/CHANGES

@@ -1,4 +1,62 @@
+Version 2.13.1
+==============
+
+Released 2020-05-07
+
+* Build:
+
+  - Include `jansson_version_str()` and `jansson_version_cmp()` in
+    shared library. (#534)
+
+  - Include `scripts/` in tarball. (#535)
+
+
+Version 2.13
+============
+
+Released 2020-05-05
+
+* New Features:
+
+  - Add `jansson_version_str()` and `jansson_version_cmp()` for runtime
+    version checking (#465).
+
+  - Add `json_object_update_new()`, `json_object_update_existing_new()`
+    and `json_object_update_missing_new()` functions (#499).
+
+  - Add `json_object_update_recursive()` (#505).
+
+* Build:
+
+  - Add ``-Wno-format-truncation`` to suppress format truncation warnings (#489).
+
+* Bug fixes:
+
+  - Remove ``strtod`` macro definition for MinGW (#498).
+
+  - Add infinite loop check in `json_deep_copy()` (#490).
+
+  - Add ``pipe`` macro definition for MinGW (#500).
+
+  - Enhance ``JANSSON_ATTRS`` macro to support earlier C standard(C89) (#501).
+
+  - Update version detection for sphinx-build (#502).
+
+* Documentation:
+
+  - Fix typos (#483, #494).
+
+  - Document that call the custom free function to free the return value 
+    of `json_dumps()` if you have a custom malloc/free (#490).
+
+  - Add vcpkg installation instructions (#496).
+
+  - Document that non-blocking file descriptor is not supported on
+    `json_loadfd()` (#503).
+
+
 Version 2.12
+============
 
 Released 2018-11-26
 

+ 6 - 6
jansson.mod/jansson/CMakeLists.txt

@@ -1,7 +1,7 @@
 # Notes:
 #
 # Author: Paul Harris, June 2012
-# Additions: Joakim Soderberg, Febuary 2013
+# Additions: Joakim Soderberg, February 2013
 #
 # Supports: building static/shared, release/debug/etc, can also build html docs
 # and some of the tests.
@@ -35,7 +35,7 @@
 # >> make test (to run the tests, if you enabled them)
 #
 # Brief description on how it works:
-# There is a small heirachy of CMakeLists.txt files which define how the
+# There is a small hierarchy of CMakeLists.txt files which define how the
 # project is built.
 # Header file detection etc is done, and the results are written into config.h
 # and jansson_config.h, which are generated from the corresponding
@@ -85,10 +85,10 @@ endif()
 # set (JANSSON_VERSION "2.3.1")
 # set (JANSSON_SOVERSION 2)
 
-set(JANSSON_DISPLAY_VERSION "2.12")
+set(JANSSON_DISPLAY_VERSION "2.13.1")
 
 # This is what is required to match the same numbers as automake's
-set(JANSSON_VERSION "4.11.1")
+set(JANSSON_VERSION "4.13.0")
 set(JANSSON_SOVERSION 4)
 
 # for CheckFunctionKeywords
@@ -100,7 +100,7 @@ include (CheckFunctionKeywords)
 include (CheckIncludeFiles)
 include (CheckTypeSize)
 
-# supress format-truncation warning
+# suppress format-truncation warning
 include (CheckCCompilerFlag)
 check_c_compiler_flag(-Wno-format-truncation HAS_NO_FORMAT_TRUNCATION)
 if (HAS_NO_FORMAT_TRUNCATION)
@@ -215,7 +215,7 @@ else ()
    set (JSON_UINT8 "unsigned char")
 endif ()
 
-# Check for ssize_t and SSIZE_T existance.
+# Check for ssize_t and SSIZE_T existence.
 check_type_size(ssize_t SSIZE_T)
 check_type_size(SSIZE_T UPPERCASE_SSIZE_T)
 if(NOT HAVE_SSIZE_T)

+ 1 - 1
jansson.mod/jansson/LICENSE

@@ -1,4 +1,4 @@
-Copyright (c) 2009-2018 Petri Lehtinen <[email protected]>
+Copyright (c) 2009-2020 Petri Lehtinen <[email protected]>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal

+ 3 - 1
jansson.mod/jansson/Makefile.am

@@ -1,4 +1,4 @@
-EXTRA_DIST = CHANGES LICENSE README.rst CMakeLists.txt cmake android examples
+EXTRA_DIST = CHANGES LICENSE README.rst CMakeLists.txt cmake android examples scripts
 SUBDIRS = doc src test
 
 # "make distcheck" builds the dvi target, so use it to check that the
@@ -8,3 +8,5 @@ dvi:
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = jansson.pc
+
+TESTS = scripts/clang-format-check

+ 12 - 0
jansson.mod/jansson/README.rst

@@ -30,6 +30,18 @@ source distribution for details.
 Compilation and Installation
 ----------------------------
 
+You can download and install Jansson using the `vcpkg <https://github.com/Microsoft/vcpkg/>`_ dependency manager:
+
+.. code-block:: bash
+
+    git clone https://github.com/Microsoft/vcpkg.git
+    cd vcpkg
+    ./bootstrap-vcpkg.sh
+    ./vcpkg integrate install
+    vcpkg install jansson
+
+The Jansson port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please `create an issue or pull request <https://github.com/Microsoft/vcpkg/>`_ on the vcpkg repository.
+
 If you obtained a `source tarball`_ from the "Releases" section of the main
 site just use the standard autotools commands::
 

+ 3 - 3
jansson.mod/jansson/cmake/CoverallsGenerateGcov.cmake

@@ -102,8 +102,8 @@ if (GIT_FOUND)
 	message("Git branch: ${GIT_BRANCH}")
 	message("Git author: ${GIT_AUTHOR_NAME}")
 	message("Git e-mail: ${GIT_AUTHOR_EMAIL}")
-	message("Git commiter name: ${GIT_COMMITTER_NAME}")
-	message("Git commiter e-mail: ${GIT_COMMITTER_EMAIL}")
+	message("Git committer name: ${GIT_COMMITTER_NAME}")
+	message("Git committer e-mail: ${GIT_COMMITTER_EMAIL}")
 	message("Git commit message: ${GIT_COMMIT_MESSAGE}")
 
 endif()
@@ -265,7 +265,7 @@ foreach (GCOV_FILE ${GCOV_FILES})
 	# Instead of trying to parse the source from the
 	# gcov file, simply read the file contents from the source file.
 	# (Parsing it from the gcov is hard because C-code uses ; in many places
-	#  which also happens to be the same as the CMake list delimeter).
+	#  which also happens to be the same as the CMake list delimiter).
 	file(READ ${GCOV_SRC_PATH} GCOV_FILE_SOURCE)
 
 	string(REPLACE "\\" "\\\\" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")

+ 19 - 5
jansson.mod/jansson/cmake/FindSphinx.cmake

@@ -241,27 +241,42 @@ endif ()
 
 # ----------------------------------------------------------------------------
 # determine Sphinx version
+# some quick experiments by @ploxiln
+# - sphinx 1.7 and later have the version output format like "sphinx-build 1.7.2"
+# - sphinx 1.2 through 1.6 have the version output format like "Sphinx (sphinx-build) 1.2.2"
+# - sphinx 1.1 and before do not have a "--version" flag, but it causes the help output like "-h" does which includes version like "Sphinx v1.0.2"
 if (Sphinx-build_EXECUTABLE)
   # intentionally use invalid -h option here as the help that is shown then
   # will include the Sphinx version information
   if (Sphinx_PYTHON_EXECUTABLE)
     execute_process (
-      COMMAND "${Sphinx_PYTHON_EXECUTABLE}" ${Sphinx_PYTHON_OPTIONS} "${Sphinx-build_EXECUTABLE}" -h
+      COMMAND "${Sphinx_PYTHON_EXECUTABLE}" ${Sphinx_PYTHON_OPTIONS} "${Sphinx-build_EXECUTABLE}" --version
       OUTPUT_VARIABLE _Sphinx_VERSION
       ERROR_VARIABLE  _Sphinx_VERSION
     )
   elseif (UNIX)
     execute_process (
-      COMMAND "${Sphinx-build_EXECUTABLE}" -h
+      COMMAND "${Sphinx-build_EXECUTABLE}" --version
       OUTPUT_VARIABLE _Sphinx_VERSION
       ERROR_VARIABLE  _Sphinx_VERSION
     )
   endif ()
 
   # The sphinx version can also contain a "b" instead of the last dot.
-  # For example "Sphinx v1.2b1" so we cannot just split on "."
-  if (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+(\\.|b)[0-9]+)")
+  # For example "Sphinx v1.2b1" or "Sphinx 1.7.0b2" so we cannot just split on "."
+  if (_Sphinx_VERSION MATCHES "sphinx-build ([0-9]+\\.[0-9]+(\\.|a?|b?)([0-9]*)(b?)([0-9]*))")
     set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}")
+    set (_SPHINX_VERSION_FOUND)
+  elseif (_Sphinx_VERSION MATCHES "Sphinx v([0-9]+\\.[0-9]+(\\.|b?)([0-9]*)(b?)([0-9]*))")
+    set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}")
+    set (_SPHINX_VERSION_FOUND)
+  elseif (_Sphinx_VERSION MATCHES "Sphinx \\(sphinx-build\\) ([0-9]+\\.[0-9]+(\\.|a?|b?)([0-9]*)(b?)([0-9]*))")
+    set (Sphinx_VERSION_STRING "${CMAKE_MATCH_1}")
+    set (_SPHINX_VERSION_FOUND)
+  endif ()
+endif ()
+
+if(_SPHINX_VERSION_FOUND)
     string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.|b)[0-9]+" "\\1" Sphinx_VERSION_MAJOR ${Sphinx_VERSION_STRING})
     string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.|b)[0-9]+" "\\1" Sphinx_VERSION_MINOR ${Sphinx_VERSION_STRING})
     string(REGEX REPLACE "[0-9]+\\.[0-9]+(\\.|b)([0-9]+)" "\\1" Sphinx_VERSION_PATCH ${Sphinx_VERSION_STRING})
@@ -270,7 +285,6 @@ if (Sphinx-build_EXECUTABLE)
     if (Sphinx_VERSION_PATCH EQUAL 0)
       string (REGEX REPLACE "\\.0$" "" Sphinx_VERSION_STRING "${Sphinx_VERSION_STRING}")
     endif ()
-  endif()
 endif ()
 
 # ----------------------------------------------------------------------------

+ 1 - 1
jansson.mod/jansson/configure.ac

@@ -1,5 +1,5 @@
 AC_PREREQ([2.60])
-AC_INIT([jansson], [2.12], [[email protected]])
+AC_INIT([jansson], [2.13.1], [https://github.com/akheron/jansson/issues])
 
 AC_CONFIG_AUX_DIR([.])
 AM_INIT_AUTOMAKE([1.10 foreign])

+ 33 - 10
jansson.mod/jansson/doc/apiref.rst

@@ -708,6 +708,30 @@ allowed in object keys.
 
    .. versionadded:: 2.3
 
+.. function:: int json_object_update_new(json_t *object, json_t *other)
+
+   Like :func:`json_object_update()`, but steals the reference to
+   *other*. This is useful when *other* is newly created and not used
+   after the call.
+
+.. function:: int json_object_update_existing_new(json_t *object, json_t *other)
+
+   Like :func:`json_object_update_new()`, but only the values of existing
+   keys are updated. No new keys are created. Returns 0 on success or
+   -1 on error.
+
+.. function:: int json_object_update_missing_new(json_t *object, json_t *other)
+
+   Like :func:`json_object_update_new()`, but only new keys are created.
+   The value of any existing key is not changed. Returns 0 on success
+   or -1 on error.
+
+.. function:: int json_object_update_recursive(json_t *object, json_t *other)
+
+   Like :func:`json_object_update()`, but object values in *other* are
+   recursively merged with the corresponding values in *object* if they are also
+   objects, instead of overwriting them. Returns 0 on success or -1 on error.
+
 .. function:: json_object_foreach(object, key, value)
 
    Iterate over every key-value pair of ``object``, running the block
@@ -1085,20 +1109,15 @@ can be ORed together to obtain *flags*.
 
    .. versionadded:: 2.10
 
-``JSON_FRACTIONAL_DIGITS``
-   When combined with `JSON_REAL_PRECISION(n), output all real numbers
-   with at most *n* digits after the decimal (rather than *n* total
-   digits).
-
-   .. versionadded:: 2.13
-
 These functions output UTF-8:
 
 .. function:: char *json_dumps(const json_t *json, size_t flags)
 
    Returns the JSON representation of *json* as a string, or *NULL* on
    error. *flags* is described above. The return value must be freed
-   by the caller using :func:`free()`.
+   by the caller using :func:`free()`. Note that if you have called
+   :func:`json_set_alloc_funcs()` to override :func:`free()`, you should
+   call your custom free function instead to free the return value.
 
 .. function:: size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags)
 
@@ -1338,7 +1357,11 @@ If no error or position information is needed, you can pass *NULL*.
    It is important to note that this function can only succeed on stream
    file descriptors (such as SOCK_STREAM). Using this function on a
    non-stream file descriptor will result in undefined behavior. For
-   non-stream file descriptors, see instead :func:`json_loadb()`.
+   non-stream file descriptors, see instead :func:`json_loadb()`. In
+   addition, please note that this function cannot be used on non-blocking 
+   file descriptors (such as a non-blocking socket). Using this function 
+   on non-blocking file descriptors has a high risk of data loss because 
+   it does not support resuming.
 
    This function requires POSIX and fails on all non-POSIX systems.
 
@@ -1635,7 +1658,7 @@ type whose address should be passed.
     Convert each item in the JSON object according to the inner format
     string ``fmt``. The first, third, etc. format specifier represent
     a key, and must be ``s``. The corresponding argument to unpack
-    functions is read as the object key. The second fourth, etc.
+    functions is read as the object key. The second, fourth, etc.
     format specifier represent a value and is written to the address
     given as the corresponding argument. **Note** that every other
     argument is read from and every other is written to.

+ 2 - 2
jansson.mod/jansson/doc/conf.py

@@ -41,14 +41,14 @@ master_doc = 'index'
 
 # General information about the project.
 project = u'Jansson'
-copyright = u'2009-2016, Petri Lehtinen'
+copyright = u'2009-2020, 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 = '2.12'
+version = '2.13.1'
 # The full version, including alpha/beta/rc tags.
 release = version
 

+ 21 - 0
jansson.mod/jansson/doc/gettingstarted.rst

@@ -84,6 +84,11 @@ Generating make files on unix:
     cd build
     cmake .. # or ccmake .. for a GUI.
 
+.. note::
+
+   If you don't want to build docs or ``Sphinx`` is not installed, you should add ``"-DJANSSON_BUILD_DOCS=OFF"`` in the ``cmake`` command.
+
+
 Then to build::
 
     make
@@ -115,6 +120,7 @@ Creating Visual Studio project files from the command line:
    - ``Visual Studio 12 2013``
    - ``Visual Studio 14 2015``
    - ``Visual Studio 15 2017``
+   - ``Visual Studio 16 2019``
 
    Any later version should also work.
 
@@ -136,6 +142,21 @@ for the project, run::
 
     cmake -LH ..
 
+Windows (MinGW)
+^^^^^^^^^^^^^^^
+If you prefer using MinGW on Windows, make sure MinGW installed and ``{MinGW}/bin`` has been added to  ``PATH``, then do the following commands:
+
+.. parsed-literal::
+
+    <unpack>
+    cd jansson-|release|
+
+    md build
+    cd build
+    cmake -G "MinGW Makefiles" ..
+    mingw32-make
+
+
 Mac OSX (Xcode)
 ^^^^^^^^^^^^^^^
 If you prefer using Xcode instead of make files on OSX,

+ 29 - 50
jansson.mod/jansson/doc/github_commits.c

@@ -8,37 +8,33 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <jansson.h>
 #include <curl/curl.h>
+#include <jansson.h>
 
-#define BUFFER_SIZE  (256 * 1024)  /* 256 KB */
+#define BUFFER_SIZE (256 * 1024) /* 256 KB */
 
-#define URL_FORMAT   "https://api.github.com/repos/%s/%s/commits"
-#define URL_SIZE     256
+#define URL_FORMAT "https://api.github.com/repos/%s/%s/commits"
+#define URL_SIZE   256
 
 /* Return the offset of the first newline in text or the length of
    text if there's no newline */
-static int newline_offset(const char *text)
-{
+static int newline_offset(const char *text) {
     const char *newline = strchr(text, '\n');
-    if(!newline)
+    if (!newline)
         return strlen(text);
     else
         return (int)(newline - text);
 }
 
-struct write_result
-{
+struct write_result {
     char *data;
     int pos;
 };
 
-static size_t write_response(void *ptr, size_t size, size_t nmemb, void *stream)
-{
+static size_t write_response(void *ptr, size_t size, size_t nmemb, void *stream) {
     struct write_result *result = (struct write_result *)stream;
 
-    if(result->pos + size * nmemb >= BUFFER_SIZE - 1)
-    {
+    if (result->pos + size * nmemb >= BUFFER_SIZE - 1) {
         fprintf(stderr, "error: too small buffer\n");
         return 0;
     }
@@ -49,8 +45,7 @@ static size_t write_response(void *ptr, size_t size, size_t nmemb, void *stream)
     return size * nmemb;
 }
 
-static char *request(const char *url)
-{
+static char *request(const char *url) {
     CURL *curl = NULL;
     CURLcode status;
     struct curl_slist *headers = NULL;
@@ -59,17 +54,14 @@ static char *request(const char *url)
 
     curl_global_init(CURL_GLOBAL_ALL);
     curl = curl_easy_init();
-    if(!curl)
+    if (!curl)
         goto error;
 
     data = malloc(BUFFER_SIZE);
-    if(!data)
+    if (!data)
         goto error;
 
-    struct write_result write_result = {
-        .data = data,
-        .pos = 0
-    };
+    struct write_result write_result = {.data = data, .pos = 0};
 
     curl_easy_setopt(curl, CURLOPT_URL, url);
 
@@ -81,16 +73,14 @@ static char *request(const char *url)
     curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result);
 
     status = curl_easy_perform(curl);
-    if(status != 0)
-    {
+    if (status != 0) {
         fprintf(stderr, "error: unable to request data from %s:\n", url);
         fprintf(stderr, "%s\n", curl_easy_strerror(status));
         goto error;
     }
 
     curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
-    if(code != 200)
-    {
+    if (code != 200) {
         fprintf(stderr, "error: server responded with code %ld\n", code);
         goto error;
     }
@@ -105,18 +95,17 @@ static char *request(const char *url)
     return data;
 
 error:
-    if(data)
+    if (data)
         free(data);
-    if(curl)
+    if (curl)
         curl_easy_cleanup(curl);
-    if(headers)
+    if (headers)
         curl_slist_free_all(headers);
     curl_global_cleanup();
     return NULL;
 }
 
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
     size_t i;
     char *text;
     char url[URL_SIZE];
@@ -124,8 +113,7 @@ int main(int argc, char *argv[])
     json_t *root;
     json_error_t error;
 
-    if(argc != 3)
-    {
+    if (argc != 3) {
         fprintf(stderr, "usage: %s USER REPOSITORY\n\n", argv[0]);
         fprintf(stderr, "List commits at USER's REPOSITORY.\n\n");
         return 2;
@@ -134,65 +122,56 @@ int main(int argc, char *argv[])
     snprintf(url, URL_SIZE, URL_FORMAT, argv[1], argv[2]);
 
     text = request(url);
-    if(!text)
+    if (!text)
         return 1;
 
     root = json_loads(text, 0, &error);
     free(text);
 
-    if(!root)
-    {
+    if (!root) {
         fprintf(stderr, "error: on line %d: %s\n", error.line, error.text);
         return 1;
     }
 
-    if(!json_is_array(root))
-    {
+    if (!json_is_array(root)) {
         fprintf(stderr, "error: root is not an array\n");
         json_decref(root);
         return 1;
     }
 
-    for(i = 0; i < json_array_size(root); i++)
-    {
+    for (i = 0; i < json_array_size(root); i++) {
         json_t *data, *sha, *commit, *message;
         const char *message_text;
 
         data = json_array_get(root, i);
-        if(!json_is_object(data))
-        {
+        if (!json_is_object(data)) {
             fprintf(stderr, "error: commit data %d is not an object\n", (int)(i + 1));
             json_decref(root);
             return 1;
         }
 
         sha = json_object_get(data, "sha");
-        if(!json_is_string(sha))
-        {
+        if (!json_is_string(sha)) {
             fprintf(stderr, "error: commit %d: sha is not a string\n", (int)(i + 1));
             return 1;
         }
 
         commit = json_object_get(data, "commit");
-        if(!json_is_object(commit))
-        {
+        if (!json_is_object(commit)) {
             fprintf(stderr, "error: commit %d: commit is not an object\n", (int)(i + 1));
             json_decref(root);
             return 1;
         }
 
         message = json_object_get(commit, "message");
-        if(!json_is_string(message))
-        {
+        if (!json_is_string(message)) {
             fprintf(stderr, "error: commit %d: message is not a string\n", (int)(i + 1));
             json_decref(root);
             return 1;
         }
 
         message_text = json_string_value(message);
-        printf("%.8s %.*s\n",
-               json_string_value(sha),
-               newline_offset(message_text),
+        printf("%.8s %.*s\n", json_string_value(sha), newline_offset(message_text),
                message_text);
     }
 

+ 1 - 1
jansson.mod/jansson/doc/tutorial.rst

@@ -74,7 +74,7 @@ function::
 
     static char *request(const char *url);
 
-It takes the URL as a parameter, preforms a HTTP GET request, and
+It takes the URL as a parameter, performs a HTTP GET request, and
 returns a newly allocated string that contains the response body. If
 the request fails, an error message is printed to stderr and the
 return value is *NULL*. For full details, refer to :download:`the code

+ 2 - 2
jansson.mod/jansson/src/Makefile.am

@@ -24,6 +24,6 @@ libjansson_la_SOURCES = \
 	version.c
 libjansson_la_LDFLAGS = \
 	-no-undefined \
-	-export-symbols-regex '^json_' \
-	-version-info 15:1:11 \
+	-export-symbols-regex '^json_|^jansson_' \
+	-version-info 17:0:13 \
 	@JSON_BSYMBOLIC_LDFLAGS@

+ 136 - 171
jansson.mod/jansson/src/dump.c

@@ -11,10 +11,10 @@
 
 #include "jansson_private.h"
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <assert.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -23,11 +23,11 @@
 #include "strbuffer.h"
 #include "utf.h"
 
-#define MAX_INTEGER_STR_LENGTH  100
-#define MAX_REAL_STR_LENGTH     100
+#define MAX_INTEGER_STR_LENGTH 100
+#define MAX_REAL_STR_LENGTH    100
 
-#define FLAGS_TO_INDENT(f)      ((f) & 0x1F)
-#define FLAGS_TO_PRECISION(f)   (((f) >> 11) & 0x1F)
+#define FLAGS_TO_INDENT(f)    ((f)&0x1F)
+#define FLAGS_TO_PRECISION(f) (((f) >> 11) & 0x1F)
 
 struct buffer {
     const size_t size;
@@ -35,35 +35,31 @@ struct buffer {
     char *data;
 };
 
-static int dump_to_strbuffer(const char *buffer, size_t size, void *data)
-{
+static int dump_to_strbuffer(const char *buffer, size_t size, void *data) {
     return strbuffer_append_bytes((strbuffer_t *)data, buffer, size);
 }
 
-static int dump_to_buffer(const char *buffer, size_t size, void *data)
-{
+static int dump_to_buffer(const char *buffer, size_t size, void *data) {
     struct buffer *buf = (struct buffer *)data;
 
-    if(buf->used + size <= buf->size)
+    if (buf->used + size <= buf->size)
         memcpy(&buf->data[buf->used], buffer, size);
 
     buf->used += size;
     return 0;
 }
 
-static int dump_to_file(const char *buffer, size_t size, void *data)
-{
+static int dump_to_file(const char *buffer, size_t size, void *data) {
     FILE *dest = (FILE *)data;
-    if(fwrite(buffer, size, 1, dest) != 1)
+    if (fwrite(buffer, size, 1, dest) != 1)
         return -1;
     return 0;
 }
 
-static int dump_to_fd(const char *buffer, size_t size, void *data)
-{
+static int dump_to_fd(const char *buffer, size_t size, void *data) {
 #ifdef HAVE_UNISTD_H
     int *dest = (int *)data;
-    if(write(*dest, buffer, size) == (ssize_t)size)
+    if (write(*dest, buffer, size) == (ssize_t)size)
         return 0;
 #endif
     return -1;
@@ -72,108 +68,116 @@ static int dump_to_fd(const char *buffer, size_t size, void *data)
 /* 32 spaces (the maximum indentation size) */
 static const char whitespace[] = "                                ";
 
-static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t dump, void *data)
-{
-    if(FLAGS_TO_INDENT(flags) > 0)
-    {
+static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t dump,
+                       void *data) {
+    if (FLAGS_TO_INDENT(flags) > 0) {
         unsigned int ws_count = FLAGS_TO_INDENT(flags), n_spaces = depth * ws_count;
 
-        if(dump("\n", 1, data))
+        if (dump("\n", 1, data))
             return -1;
 
-        while(n_spaces > 0)
-        {
-            int cur_n = n_spaces < sizeof whitespace - 1 ? n_spaces : sizeof whitespace - 1;
+        while (n_spaces > 0) {
+            int cur_n =
+                n_spaces < sizeof whitespace - 1 ? n_spaces : sizeof whitespace - 1;
 
-            if(dump(whitespace, cur_n, data))
+            if (dump(whitespace, cur_n, data))
                 return -1;
 
             n_spaces -= cur_n;
         }
-    }
-    else if(space && !(flags & JSON_COMPACT))
-    {
+    } else if (space && !(flags & JSON_COMPACT)) {
         return dump(" ", 1, data);
     }
     return 0;
 }
 
-static int dump_string(const char *str, size_t len, json_dump_callback_t dump, void *data, size_t flags)
-{
+static int dump_string(const char *str, size_t len, json_dump_callback_t dump, void *data,
+                       size_t flags) {
     const char *pos, *end, *lim;
     int32_t codepoint = 0;
 
-    if(dump("\"", 1, data))
+    if (dump("\"", 1, data))
         return -1;
 
     end = pos = str;
     lim = str + len;
-    while(1)
-    {
+    while (1) {
         const char *text;
         char seq[13];
         int length;
 
-        while(end < lim)
-        {
+        while (end < lim) {
             end = utf8_iterate(pos, lim - pos, &codepoint);
-            if(!end)
+            if (!end)
                 return -1;
 
             /* mandatory escape or control char */
-            if(codepoint == '\\' || codepoint == '"' || codepoint < 0x20)
+            if (codepoint == '\\' || codepoint == '"' || codepoint < 0x20)
                 break;
 
             /* slash */
-            if((flags & JSON_ESCAPE_SLASH) && codepoint == '/')
+            if ((flags & JSON_ESCAPE_SLASH) && codepoint == '/')
                 break;
 
             /* non-ASCII */
-            if((flags & JSON_ENSURE_ASCII) && codepoint > 0x7F)
+            if ((flags & JSON_ENSURE_ASCII) && codepoint > 0x7F)
                 break;
 
             pos = end;
         }
 
-        if(pos != str) {
-            if(dump(str, pos - str, data))
+        if (pos != str) {
+            if (dump(str, pos - str, data))
                 return -1;
         }
 
-        if(end == pos)
+        if (end == pos)
             break;
 
         /* handle \, /, ", and control codes */
         length = 2;
-        switch(codepoint)
-        {
-            case '\\': text = "\\\\"; break;
-            case '\"': text = "\\\""; break;
-            case '\b': text = "\\b"; break;
-            case '\f': text = "\\f"; break;
-            case '\n': text = "\\n"; break;
-            case '\r': text = "\\r"; break;
-            case '\t': text = "\\t"; break;
-            case '/':  text = "\\/"; break;
-            default:
-            {
+        switch (codepoint) {
+            case '\\':
+                text = "\\\\";
+                break;
+            case '\"':
+                text = "\\\"";
+                break;
+            case '\b':
+                text = "\\b";
+                break;
+            case '\f':
+                text = "\\f";
+                break;
+            case '\n':
+                text = "\\n";
+                break;
+            case '\r':
+                text = "\\r";
+                break;
+            case '\t':
+                text = "\\t";
+                break;
+            case '/':
+                text = "\\/";
+                break;
+            default: {
                 /* codepoint is in BMP */
-                if(codepoint < 0x10000)
-                {
+                if (codepoint < 0x10000) {
                     snprintf(seq, sizeof(seq), "\\u%04X", (unsigned int)codepoint);
                     length = 6;
                 }
 
                 /* not in BMP -> construct a UTF-16 surrogate pair */
-                else
-                {
+                else {
                     int32_t first, last;
 
                     codepoint -= 0x10000;
                     first = 0xD800 | ((codepoint & 0xffc00) >> 10);
                     last = 0xDC00 | (codepoint & 0x003ff);
 
-                    snprintf(seq, sizeof(seq), "\\u%04X\\u%04X", (unsigned int)first, (unsigned int)last);
+                    snprintf(seq, sizeof(seq), "\\u%04X\\u%04X", (unsigned int)first,
+                             (unsigned int)last);
                     length = 12;
                 }
 
@@ -182,7 +186,7 @@ static int dump_string(const char *str, size_t len, json_dump_callback_t dump, v
             }
         }
 
-        if(dump(text, length, data))
+        if (dump(text, length, data))
             return -1;
 
         str = pos = end;
@@ -191,31 +195,20 @@ static int dump_string(const char *str, size_t len, json_dump_callback_t dump, v
     return dump("\"", 1, data);
 }
 
-static int compare_keys(const void *key1, const void *key2)
-{
+static int compare_keys(const void *key1, const void *key2) {
     return strcmp(*(const char **)key1, *(const char **)key2);
 }
 
-static int loop_check(hashtable_t *parents, const json_t *json, char *key, size_t key_size)
-{
-    snprintf(key, key_size, "%p", json);
-    if (hashtable_get(parents, key))
-        return -1;
-
-    return hashtable_set(parents, key, json_null());
-}
-
-static int do_dump(const json_t *json, size_t flags, int depth,
-                   hashtable_t *parents, json_dump_callback_t dump, void *data)
-{
+static int do_dump(const json_t *json, size_t flags, int depth, hashtable_t *parents,
+                   json_dump_callback_t dump, void *data) {
     int embed = flags & JSON_EMBED;
 
     flags &= ~JSON_EMBED;
 
-    if(!json)
+    if (!json)
         return -1;
 
-    switch(json_typeof(json)) {
+    switch (json_typeof(json)) {
         case JSON_NULL:
             return dump("null", 4, data);
 
@@ -225,73 +218,68 @@ static int do_dump(const json_t *json, size_t flags, int depth,
         case JSON_FALSE:
             return dump("false", 5, data);
 
-        case JSON_INTEGER:
-        {
+        case JSON_INTEGER: {
             char buffer[MAX_INTEGER_STR_LENGTH];
             int size;
 
-            size = snprintf(buffer, MAX_INTEGER_STR_LENGTH,
-                            "%" JSON_INTEGER_FORMAT,
+            size = snprintf(buffer, MAX_INTEGER_STR_LENGTH, "%" JSON_INTEGER_FORMAT,
                             json_integer_value(json));
-            if(size < 0 || size >= MAX_INTEGER_STR_LENGTH)
+            if (size < 0 || size >= MAX_INTEGER_STR_LENGTH)
                 return -1;
 
             return dump(buffer, size, data);
         }
 
-        case JSON_REAL:
-        {
+        case JSON_REAL: {
             char buffer[MAX_REAL_STR_LENGTH];
             int size;
             double value = json_real_value(json);
 
             size = jsonp_dtostr(buffer, MAX_REAL_STR_LENGTH, value,
                                 FLAGS_TO_PRECISION(flags), flags & JSON_FRACTIONAL_DIGITS);
-            if(size < 0)
+            if (size < 0)
                 return -1;
 
             return dump(buffer, size, data);
         }
 
         case JSON_STRING:
-            return dump_string(json_string_value(json), json_string_length(json), dump, data, flags);
+            return dump_string(json_string_value(json), json_string_length(json), dump,
+                               data, flags);
 
-        case JSON_ARRAY:
-        {
+        case JSON_ARRAY: {
             size_t n;
             size_t i;
-            /* Space for "0x", double the sizeof a pointer for the hex and a terminator. */
+            /* Space for "0x", double the sizeof a pointer for the hex and a
+             * terminator. */
             char key[2 + (sizeof(json) * 2) + 1];
 
             /* detect circular references */
-            if (loop_check(parents, json, key, sizeof(key)))
+            if (jsonp_loop_check(parents, json, key, sizeof(key)))
                 return -1;
 
             n = json_array_size(json);
 
-            if(!embed && dump("[", 1, data))
+            if (!embed && dump("[", 1, data))
                 return -1;
-            if(n == 0) {
+            if (n == 0) {
                 hashtable_del(parents, key);
                 return embed ? 0 : dump("]", 1, data);
             }
-            if(dump_indent(flags, depth + 1, 0, dump, data))
+            if (dump_indent(flags, depth + 1, 0, dump, data))
                 return -1;
 
-            for(i = 0; i < n; ++i) {
-                if(do_dump(json_array_get(json, i), flags, depth + 1,
-                           parents, dump, data))
+            for (i = 0; i < n; ++i) {
+                if (do_dump(json_array_get(json, i), flags, depth + 1, parents, dump,
+                            data))
                     return -1;
 
-                if(i < n - 1)
-                {
-                    if(dump(",", 1, data) ||
-                       dump_indent(flags, depth + 1, 1, dump, data))
+                if (i < n - 1) {
+                    if (dump(",", 1, data) ||
+                        dump_indent(flags, depth + 1, 1, dump, data))
                         return -1;
-                }
-                else
-                {
-                    if(dump_indent(flags, depth, 0, dump, data))
+                } else {
+                    if (dump_indent(flags, depth, 0, dump, data))
                         return -1;
                 }
             }
@@ -300,51 +288,46 @@ static int do_dump(const json_t *json, size_t flags, int depth,
             return embed ? 0 : dump("]", 1, data);
         }
 
-        case JSON_OBJECT:
-        {
+        case JSON_OBJECT: {
             void *iter;
             const char *separator;
             int separator_length;
-            /* Space for "0x", double the sizeof a pointer for the hex and a terminator. */
-            char loop_key[2 + (sizeof(json) * 2) + 1];
+            char loop_key[LOOP_KEY_LEN];
 
-            if(flags & JSON_COMPACT) {
+            if (flags & JSON_COMPACT) {
                 separator = ":";
                 separator_length = 1;
-            }
-            else {
+            } else {
                 separator = ": ";
                 separator_length = 2;
             }
 
             /* detect circular references */
-            if (loop_check(parents, json, loop_key, sizeof(loop_key)))
+            if (jsonp_loop_check(parents, json, loop_key, sizeof(loop_key)))
                 return -1;
 
             iter = json_object_iter((json_t *)json);
 
-            if(!embed && dump("{", 1, data))
+            if (!embed && dump("{", 1, data))
                 return -1;
-            if(!iter) {
+            if (!iter) {
                 hashtable_del(parents, loop_key);
                 return embed ? 0 : dump("}", 1, data);
             }
-            if(dump_indent(flags, depth + 1, 0, dump, data))
+            if (dump_indent(flags, depth + 1, 0, dump, data))
                 return -1;
 
-            if(flags & JSON_SORT_KEYS)
-            {
+            if (flags & JSON_SORT_KEYS) {
                 const char **keys;
                 size_t size, i;
 
                 size = json_object_size(json);
                 keys = jsonp_malloc(size * sizeof(const char *));
-                if(!keys)
+                if (!keys)
                     return -1;
 
                 i = 0;
-                while(iter)
-                {
+                while (iter) {
                     keys[i] = json_object_iter_key(iter);
                     iter = json_object_iter_next((json_t *)json, iter);
                     i++;
@@ -353,8 +336,7 @@ static int do_dump(const json_t *json, size_t flags, int depth,
 
                 qsort(keys, size, sizeof(const char *), compare_keys);
 
-                for(i = 0; i < size; i++)
-                {
+                for (i = 0; i < size; i++) {
                     const char *key;
                     json_t *value;
 
@@ -363,26 +345,20 @@ static int do_dump(const json_t *json, size_t flags, int depth,
                     assert(value);
 
                     dump_string(key, strlen(key), dump, data, flags);
-                    if(dump(separator, separator_length, data) ||
-                       do_dump(value, flags, depth + 1, parents, dump, data))
-                    {
+                    if (dump(separator, separator_length, data) ||
+                        do_dump(value, flags, depth + 1, parents, dump, data)) {
                         jsonp_free(keys);
                         return -1;
                     }
 
-                    if(i < size - 1)
-                    {
-                        if(dump(",", 1, data) ||
-                           dump_indent(flags, depth + 1, 1, dump, data))
-                        {
+                    if (i < size - 1) {
+                        if (dump(",", 1, data) ||
+                            dump_indent(flags, depth + 1, 1, dump, data)) {
                             jsonp_free(keys);
                             return -1;
                         }
-                    }
-                    else
-                    {
-                        if(dump_indent(flags, depth, 0, dump, data))
-                        {
+                    } else {
+                        if (dump_indent(flags, depth, 0, dump, data)) {
                             jsonp_free(keys);
                             return -1;
                         }
@@ -390,31 +366,25 @@ static int do_dump(const json_t *json, size_t flags, int depth,
                 }
 
                 jsonp_free(keys);
-            }
-            else
-            {
+            } else {
                 /* Don't sort keys */
 
-                while(iter)
-                {
+                while (iter) {
                     void *next = json_object_iter_next((json_t *)json, iter);
                     const char *key = json_object_iter_key(iter);
 
                     dump_string(key, strlen(key), dump, data, flags);
-                    if(dump(separator, separator_length, data) ||
-                       do_dump(json_object_iter_value(iter), flags, depth + 1,
-                               parents, dump, data))
+                    if (dump(separator, separator_length, data) ||
+                        do_dump(json_object_iter_value(iter), flags, depth + 1, parents,
+                                dump, data))
                         return -1;
 
-                    if(next)
-                    {
-                        if(dump(",", 1, data) ||
-                           dump_indent(flags, depth + 1, 1, dump, data))
+                    if (next) {
+                        if (dump(",", 1, data) ||
+                            dump_indent(flags, depth + 1, 1, dump, data))
                             return -1;
-                    }
-                    else
-                    {
-                        if(dump_indent(flags, depth, 0, dump, data))
+                    } else {
+                        if (dump_indent(flags, depth, 0, dump, data))
                             return -1;
                     }
 
@@ -432,15 +402,14 @@ static int do_dump(const json_t *json, size_t flags, int depth,
     }
 }
 
-char *json_dumps(const json_t *json, size_t flags)
-{
+char *json_dumps(const json_t *json, size_t flags) {
     strbuffer_t strbuff;
     char *result;
 
-    if(strbuffer_init(&strbuff))
+    if (strbuffer_init(&strbuff))
         return NULL;
 
-    if(json_dump_callback(json, dump_to_strbuffer, (void *)&strbuff, flags))
+    if (json_dump_callback(json, dump_to_strbuffer, (void *)&strbuff, flags))
         result = NULL;
     else
         result = jsonp_strdup(strbuffer_value(&strbuff));
@@ -449,50 +418,46 @@ char *json_dumps(const json_t *json, size_t flags)
     return result;
 }
 
-size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags)
-{
-    struct buffer buf = { size, 0, buffer };
+size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags) {
+    struct buffer buf = {size, 0, buffer};
 
-    if(json_dump_callback(json, dump_to_buffer, (void *)&buf, flags))
+    if (json_dump_callback(json, dump_to_buffer, (void *)&buf, flags))
         return 0;
 
     return buf.used;
 }
 
-int json_dumpf(const json_t *json, FILE *output, size_t flags)
-{
+int json_dumpf(const json_t *json, FILE *output, size_t flags) {
     return json_dump_callback(json, dump_to_file, (void *)output, flags);
 }
 
-int json_dumpfd(const json_t *json, int output, size_t flags)
-{
+int json_dumpfd(const json_t *json, int output, size_t flags) {
     return json_dump_callback(json, dump_to_fd, (void *)&output, flags);
 }
 
-int json_dump_file(const json_t *json, const char *path, size_t flags)
-{
+int json_dump_file(const json_t *json, const char *path, size_t flags) {
     int result;
 
     FILE *output = fopen(path, "w");
-    if(!output)
+    if (!output)
         return -1;
 
     result = json_dumpf(json, output, flags);
 
-    if(fclose(output) != 0)
+    if (fclose(output) != 0)
         return -1;
 
     return result;
 }
 
-int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags)
-{
+int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data,
+                       size_t flags) {
     int res;
     hashtable_t parents_set;
 
-    if(!(flags & JSON_ENCODE_ANY)) {
-        if(!json_is_array(json) && !json_is_object(json))
-           return -1;
+    if (!(flags & JSON_ENCODE_ANY)) {
+        if (!json_is_array(json) && !json_is_object(json))
+            return -1;
     }
 
     if (hashtable_init(&parents_set))

+ 13 - 20
jansson.mod/jansson/src/error.c

@@ -1,30 +1,27 @@
-#include <string.h>
 #include "jansson_private.h"
+#include <string.h>
 
-void jsonp_error_init(json_error_t *error, const char *source)
-{
-    if(error)
-    {
+void jsonp_error_init(json_error_t *error, const char *source) {
+    if (error) {
         error->text[0] = '\0';
         error->line = -1;
         error->column = -1;
         error->position = 0;
-        if(source)
+        if (source)
             jsonp_error_set_source(error, source);
         else
             error->source[0] = '\0';
     }
 }
 
-void jsonp_error_set_source(json_error_t *error, const char *source)
-{
+void jsonp_error_set_source(json_error_t *error, const char *source) {
     size_t length;
 
-    if(!error || !source)
+    if (!error || !source)
         return;
 
     length = strlen(source);
-    if(length < JSON_ERROR_SOURCE_LENGTH)
+    if (length < JSON_ERROR_SOURCE_LENGTH)
         strncpy(error->source, source, length + 1);
     else {
         size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4;
@@ -33,10 +30,8 @@ void jsonp_error_set_source(json_error_t *error, const char *source)
     }
 }
 
-void jsonp_error_set(json_error_t *error, int line, int column,
-                     size_t position, enum json_error_code code,
-                     const char *msg, ...)
-{
+void jsonp_error_set(json_error_t *error, int line, int column, size_t position,
+                     enum json_error_code code, const char *msg, ...) {
     va_list ap;
 
     va_start(ap, msg);
@@ -44,14 +39,12 @@ void jsonp_error_set(json_error_t *error, int line, int column,
     va_end(ap);
 }
 
-void jsonp_error_vset(json_error_t *error, int line, int column,
-                      size_t position, enum json_error_code code,
-                      const char *msg, va_list ap)
-{
-    if(!error)
+void jsonp_error_vset(json_error_t *error, int line, int column, size_t position,
+                      enum json_error_code code, const char *msg, va_list ap) {
+    if (!error)
         return;
 
-    if(error->text[0] != '\0') {
+    if (error->text[0] != '\0') {
         /* error already set */
         return;
     }

+ 55 - 93
jansson.mod/jansson/src/hashtable.c

@@ -16,9 +16,9 @@
 #include <stdint.h>
 #endif
 
-#include <jansson_config.h>   /* for JSON_INLINE */
-#include "jansson_private.h"  /* for container_of() */
 #include "hashtable.h"
+#include "jansson_private.h" /* for container_of() */
+#include <jansson_config.h>  /* for JSON_INLINE */
 
 #ifndef INITIAL_HASHTABLE_ORDER
 #define INITIAL_HASHTABLE_ORDER 3
@@ -33,67 +33,56 @@ extern volatile uint32_t hashtable_seed;
 /* Implementation of the hash function */
 #include "lookup3.h"
 
-#define list_to_pair(list_)  container_of(list_, pair_t, list)
-#define ordered_list_to_pair(list_)  container_of(list_, pair_t, ordered_list)
-#define hash_str(key)        ((size_t)hashlittle((key), strlen(key), hashtable_seed))
+#define list_to_pair(list_)         container_of(list_, pair_t, list)
+#define ordered_list_to_pair(list_) container_of(list_, pair_t, ordered_list)
+#define hash_str(key)               ((size_t)hashlittle((key), strlen(key), hashtable_seed))
 
-static JSON_INLINE void list_init(list_t *list)
-{
+static JSON_INLINE void list_init(list_t *list) {
     list->next = list;
     list->prev = list;
 }
 
-static JSON_INLINE void list_insert(list_t *list, list_t *node)
-{
+static JSON_INLINE void list_insert(list_t *list, list_t *node) {
     node->next = list;
     node->prev = list->prev;
     list->prev->next = node;
     list->prev = node;
 }
 
-static JSON_INLINE void list_remove(list_t *list)
-{
+static JSON_INLINE void list_remove(list_t *list) {
     list->prev->next = list->next;
     list->next->prev = list->prev;
 }
 
-static JSON_INLINE int bucket_is_empty(hashtable_t *hashtable, bucket_t *bucket)
-{
+static JSON_INLINE int bucket_is_empty(hashtable_t *hashtable, bucket_t *bucket) {
     return bucket->first == &hashtable->list && bucket->first == bucket->last;
 }
 
-static void insert_to_bucket(hashtable_t *hashtable, bucket_t *bucket,
-                             list_t *list)
-{
-    if(bucket_is_empty(hashtable, bucket))
-    {
+static void insert_to_bucket(hashtable_t *hashtable, bucket_t *bucket, list_t *list) {
+    if (bucket_is_empty(hashtable, bucket)) {
         list_insert(&hashtable->list, list);
         bucket->first = bucket->last = list;
-    }
-    else
-    {
+    } else {
         list_insert(bucket->first, list);
         bucket->first = list;
     }
 }
 
 static pair_t *hashtable_find_pair(hashtable_t *hashtable, bucket_t *bucket,
-                                   const char *key, size_t hash)
-{
+                                   const char *key, size_t hash) {
     list_t *list;
     pair_t *pair;
 
-    if(bucket_is_empty(hashtable, bucket))
+    if (bucket_is_empty(hashtable, bucket))
         return NULL;
 
     list = bucket->first;
-    while(1)
-    {
+    while (1) {
         pair = list_to_pair(list);
-        if(pair->hash == hash && strcmp(pair->key, key) == 0)
+        if (pair->hash == hash && strcmp(pair->key, key) == 0)
             return pair;
 
-        if(list == bucket->last)
+        if (list == bucket->last)
             break;
 
         list = list->next;
@@ -103,9 +92,7 @@ static pair_t *hashtable_find_pair(hashtable_t *hashtable, bucket_t *bucket,
 }
 
 /* returns 0 on success, -1 if key was not found */
-static int hashtable_do_del(hashtable_t *hashtable,
-                            const char *key, size_t hash)
-{
+static int hashtable_do_del(hashtable_t *hashtable, const char *key, size_t hash) {
     pair_t *pair;
     bucket_t *bucket;
     size_t index;
@@ -114,16 +101,16 @@ static int hashtable_do_del(hashtable_t *hashtable,
     bucket = &hashtable->buckets[index];
 
     pair = hashtable_find_pair(hashtable, bucket, key, hash);
-    if(!pair)
+    if (!pair)
         return -1;
 
-    if(&pair->list == bucket->first && &pair->list == bucket->last)
+    if (&pair->list == bucket->first && &pair->list == bucket->last)
         bucket->first = bucket->last = &hashtable->list;
 
-    else if(&pair->list == bucket->first)
+    else if (&pair->list == bucket->first)
         bucket->first = pair->list.next;
 
-    else if(&pair->list == bucket->last)
+    else if (&pair->list == bucket->last)
         bucket->last = pair->list.prev;
 
     list_remove(&pair->list);
@@ -136,13 +123,11 @@ static int hashtable_do_del(hashtable_t *hashtable,
     return 0;
 }
 
-static void hashtable_do_clear(hashtable_t *hashtable)
-{
+static void hashtable_do_clear(hashtable_t *hashtable) {
     list_t *list, *next;
     pair_t *pair;
 
-    for(list = hashtable->list.next; list != &hashtable->list; list = next)
-    {
+    for (list = hashtable->list.next; list != &hashtable->list; list = next) {
         next = list->next;
         pair = list_to_pair(list);
         json_decref(pair->value);
@@ -150,8 +135,7 @@ static void hashtable_do_clear(hashtable_t *hashtable)
     }
 }
 
-static int hashtable_do_rehash(hashtable_t *hashtable)
-{
+static int hashtable_do_rehash(hashtable_t *hashtable) {
     list_t *list, *next;
     pair_t *pair;
     size_t i, index, new_size, new_order;
@@ -161,23 +145,21 @@ static int hashtable_do_rehash(hashtable_t *hashtable)
     new_size = hashsize(new_order);
 
     new_buckets = jsonp_malloc(new_size * sizeof(bucket_t));
-    if(!new_buckets)
+    if (!new_buckets)
         return -1;
 
     jsonp_free(hashtable->buckets);
     hashtable->buckets = new_buckets;
     hashtable->order = new_order;
 
-    for(i = 0; i < hashsize(hashtable->order); i++)
-    {
-        hashtable->buckets[i].first = hashtable->buckets[i].last =
-            &hashtable->list;
+    for (i = 0; i < hashsize(hashtable->order); i++) {
+        hashtable->buckets[i].first = hashtable->buckets[i].last = &hashtable->list;
     }
 
     list = hashtable->list.next;
     list_init(&hashtable->list);
 
-    for(; list != &hashtable->list; list = next) {
+    for (; list != &hashtable->list; list = next) {
         next = list->next;
         pair = list_to_pair(list);
         index = pair->hash % new_size;
@@ -187,44 +169,38 @@ static int hashtable_do_rehash(hashtable_t *hashtable)
     return 0;
 }
 
-
-int hashtable_init(hashtable_t *hashtable)
-{
+int hashtable_init(hashtable_t *hashtable) {
     size_t i;
 
     hashtable->size = 0;
     hashtable->order = INITIAL_HASHTABLE_ORDER;
     hashtable->buckets = jsonp_malloc(hashsize(hashtable->order) * sizeof(bucket_t));
-    if(!hashtable->buckets)
+    if (!hashtable->buckets)
         return -1;
 
     list_init(&hashtable->list);
     list_init(&hashtable->ordered_list);
 
-    for(i = 0; i < hashsize(hashtable->order); i++)
-    {
-        hashtable->buckets[i].first = hashtable->buckets[i].last =
-            &hashtable->list;
+    for (i = 0; i < hashsize(hashtable->order); i++) {
+        hashtable->buckets[i].first = hashtable->buckets[i].last = &hashtable->list;
     }
 
     return 0;
 }
 
-void hashtable_close(hashtable_t *hashtable)
-{
+void hashtable_close(hashtable_t *hashtable) {
     hashtable_do_clear(hashtable);
     jsonp_free(hashtable->buckets);
 }
 
-int hashtable_set(hashtable_t *hashtable, const char *key, json_t *value)
-{
+int hashtable_set(hashtable_t *hashtable, const char *key, json_t *value) {
     pair_t *pair;
     bucket_t *bucket;
     size_t hash, index;
 
     /* rehash if the load ratio exceeds 1 */
-    if(hashtable->size >= hashsize(hashtable->order))
-        if(hashtable_do_rehash(hashtable))
+    if (hashtable->size >= hashsize(hashtable->order))
+        if (hashtable_do_rehash(hashtable))
             return -1;
 
     hash = hash_str(key);
@@ -232,25 +208,22 @@ int hashtable_set(hashtable_t *hashtable, const char *key, json_t *value)
     bucket = &hashtable->buckets[index];
     pair = hashtable_find_pair(hashtable, bucket, key, hash);
 
-    if(pair)
-    {
+    if (pair) {
         json_decref(pair->value);
         pair->value = value;
-    }
-    else
-    {
+    } else {
         /* offsetof(...) returns the size of pair_t without the last,
            flexible member. This way, the correct amount is
            allocated. */
 
         size_t len = strlen(key);
-        if(len >= (size_t)-1 - offsetof(pair_t, key)) {
+        if (len >= (size_t)-1 - offsetof(pair_t, key)) {
             /* Avoid an overflow if the key is very long */
             return -1;
         }
 
         pair = jsonp_malloc(offsetof(pair_t, key) + len + 1);
-        if(!pair)
+        if (!pair)
             return -1;
 
         pair->hash = hash;
@@ -267,8 +240,7 @@ int hashtable_set(hashtable_t *hashtable, const char *key, json_t *value)
     return 0;
 }
 
-void *hashtable_get(hashtable_t *hashtable, const char *key)
-{
+void *hashtable_get(hashtable_t *hashtable, const char *key) {
     pair_t *pair;
     size_t hash;
     bucket_t *bucket;
@@ -277,28 +249,24 @@ void *hashtable_get(hashtable_t *hashtable, const char *key)
     bucket = &hashtable->buckets[hash & hashmask(hashtable->order)];
 
     pair = hashtable_find_pair(hashtable, bucket, key, hash);
-    if(!pair)
+    if (!pair)
         return NULL;
 
     return pair->value;
 }
 
-int hashtable_del(hashtable_t *hashtable, const char *key)
-{
+int hashtable_del(hashtable_t *hashtable, const char *key) {
     size_t hash = hash_str(key);
     return hashtable_do_del(hashtable, key, hash);
 }
 
-void hashtable_clear(hashtable_t *hashtable)
-{
+void hashtable_clear(hashtable_t *hashtable) {
     size_t i;
 
     hashtable_do_clear(hashtable);
 
-    for(i = 0; i < hashsize(hashtable->order); i++)
-    {
-        hashtable->buckets[i].first = hashtable->buckets[i].last =
-            &hashtable->list;
+    for (i = 0; i < hashsize(hashtable->order); i++) {
+        hashtable->buckets[i].first = hashtable->buckets[i].last = &hashtable->list;
     }
 
     list_init(&hashtable->list);
@@ -306,13 +274,11 @@ void hashtable_clear(hashtable_t *hashtable)
     hashtable->size = 0;
 }
 
-void *hashtable_iter(hashtable_t *hashtable)
-{
+void *hashtable_iter(hashtable_t *hashtable) {
     return hashtable_iter_next(hashtable, &hashtable->ordered_list);
 }
 
-void *hashtable_iter_at(hashtable_t *hashtable, const char *key)
-{
+void *hashtable_iter_at(hashtable_t *hashtable, const char *key) {
     pair_t *pair;
     size_t hash;
     bucket_t *bucket;
@@ -321,34 +287,30 @@ void *hashtable_iter_at(hashtable_t *hashtable, const char *key)
     bucket = &hashtable->buckets[hash & hashmask(hashtable->order)];
 
     pair = hashtable_find_pair(hashtable, bucket, key, hash);
-    if(!pair)
+    if (!pair)
         return NULL;
 
     return &pair->ordered_list;
 }
 
-void *hashtable_iter_next(hashtable_t *hashtable, void *iter)
-{
+void *hashtable_iter_next(hashtable_t *hashtable, void *iter) {
     list_t *list = (list_t *)iter;
-    if(list->next == &hashtable->ordered_list)
+    if (list->next == &hashtable->ordered_list)
         return NULL;
     return list->next;
 }
 
-void *hashtable_iter_key(void *iter)
-{
+void *hashtable_iter_key(void *iter) {
     pair_t *pair = ordered_list_to_pair((list_t *)iter);
     return pair->key;
 }
 
-void *hashtable_iter_value(void *iter)
-{
+void *hashtable_iter_value(void *iter) {
     pair_t *pair = ordered_list_to_pair((list_t *)iter);
     return pair->value;
 }
 
-void hashtable_iter_set(void *iter, json_t *value)
-{
+void hashtable_iter_set(void *iter, json_t *value) {
     pair_t *pair = ordered_list_to_pair((list_t *)iter);
 
     json_decref(pair->value);

+ 4 - 6
jansson.mod/jansson/src/hashtable.h

@@ -8,8 +8,8 @@
 #ifndef HASHTABLE_H
 #define HASHTABLE_H
 
-#include <stdlib.h>
 #include "jansson.h"
+#include <stdlib.h>
 
 struct hashtable_list {
     struct hashtable_list *prev;
@@ -35,16 +35,14 @@ struct hashtable_bucket {
 typedef struct hashtable {
     size_t size;
     struct hashtable_bucket *buckets;
-    size_t order;  /* hashtable has pow(2, order) buckets */
+    size_t order; /* hashtable has pow(2, order) buckets */
     struct hashtable_list list;
     struct hashtable_list ordered_list;
 } hashtable_t;
 
-
-#define hashtable_key_to_iter(key_) \
+#define hashtable_key_to_iter(key_)                                                      \
     (&(container_of(key_, struct hashtable_pair, key)->ordered_list))
 
-
 /**
  * hashtable_init - Initialize a hashtable object
  *
@@ -55,7 +53,7 @@ typedef struct hashtable {
  *
  * Returns 0 on success, -1 on error (out of memory).
  */
-int hashtable_init(hashtable_t *hashtable) JANSSON_ATTRS(warn_unused_result);
+int hashtable_init(hashtable_t *hashtable) JANSSON_ATTRS((warn_unused_result));
 
 /**
  * hashtable_close - Release all resources used by a hashtable object

+ 15 - 15
jansson.mod/jansson/src/hashtable_seed.c

@@ -44,7 +44,6 @@
 
 #include "jansson.h"
 
-
 static uint32_t buf_to_uint32(char *data) {
     size_t i;
     uint32_t result = 0;
@@ -55,8 +54,6 @@ static uint32_t buf_to_uint32(char *data) {
     return result;
 }
 
-
-
 /* /dev/urandom */
 #if !defined(_WIN32) && defined(USE_URANDOM)
 static int seed_from_urandom(uint32_t *seed) {
@@ -97,12 +94,13 @@ static int seed_from_urandom(uint32_t *seed) {
 #if defined(_WIN32) && defined(USE_WINDOWS_CRYPTOAPI)
 #include <wincrypt.h>
 
-typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv, LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags);
-typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer);
-typedef BOOL (WINAPI *CRYPTRELEASECONTEXT)(HCRYPTPROV hProv, DWORD dwFlags);
+typedef BOOL(WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv, LPCSTR pszContainer,
+                                           LPCSTR pszProvider, DWORD dwProvType,
+                                           DWORD dwFlags);
+typedef BOOL(WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer);
+typedef BOOL(WINAPI *CRYPTRELEASECONTEXT)(HCRYPTPROV hProv, DWORD dwFlags);
 
-static int seed_from_windows_cryptoapi(uint32_t *seed)
-{
+static int seed_from_windows_cryptoapi(uint32_t *seed) {
     HINSTANCE hAdvAPI32 = NULL;
     CRYPTACQUIRECONTEXTA pCryptAcquireContext = NULL;
     CRYPTGENRANDOM pCryptGenRandom = NULL;
@@ -112,10 +110,11 @@ static int seed_from_windows_cryptoapi(uint32_t *seed)
     int ok;
 
     hAdvAPI32 = GetModuleHandle(TEXT("advapi32.dll"));
-    if(hAdvAPI32 == NULL)
+    if (hAdvAPI32 == NULL)
         return 1;
 
-    pCryptAcquireContext = (CRYPTACQUIRECONTEXTA)GetProcAddress(hAdvAPI32, "CryptAcquireContextA");
+    pCryptAcquireContext =
+        (CRYPTACQUIRECONTEXTA)GetProcAddress(hAdvAPI32, "CryptAcquireContextA");
     if (!pCryptAcquireContext)
         return 1;
 
@@ -123,11 +122,13 @@ static int seed_from_windows_cryptoapi(uint32_t *seed)
     if (!pCryptGenRandom)
         return 1;
 
-    pCryptReleaseContext = (CRYPTRELEASECONTEXT)GetProcAddress(hAdvAPI32, "CryptReleaseContext");
+    pCryptReleaseContext =
+        (CRYPTRELEASECONTEXT)GetProcAddress(hAdvAPI32, "CryptReleaseContext");
     if (!pCryptReleaseContext)
         return 1;
 
-    if (!pCryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
+    if (!pCryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
+                              CRYPT_VERIFYCONTEXT))
         return 1;
 
     ok = pCryptGenRandom(hCryptProv, sizeof(uint32_t), data);
@@ -190,7 +191,6 @@ static uint32_t generate_seed() {
     return seed;
 }
 
-
 volatile uint32_t hashtable_seed = 0;
 
 #if defined(HAVE_ATOMIC_BUILTINS) && (defined(HAVE_SCHED_YIELD) || !defined(_WIN32))
@@ -212,7 +212,7 @@ void json_object_seed(size_t seed) {
 #ifdef HAVE_SCHED_YIELD
                 sched_yield();
 #endif
-            } while(__atomic_load_n(&hashtable_seed, __ATOMIC_ACQUIRE) == 0);
+            } while (__atomic_load_n(&hashtable_seed, __ATOMIC_ACQUIRE) == 0);
         }
     }
 }
@@ -239,7 +239,7 @@ void json_object_seed(size_t seed) {
                 sched_yield();
 #endif
             }
-        } while(hashtable_seed == 0);
+        } while (hashtable_seed == 0);
     }
 }
 #elif defined(_WIN32)

+ 1 - 0
jansson.mod/jansson/src/jansson.def

@@ -41,6 +41,7 @@ EXPORTS
     json_object_update
     json_object_update_existing
     json_object_update_missing
+    json_object_update_recursive
     json_object_iter
     json_object_iter_at
     json_object_iter_next

+ 125 - 111
jansson.mod/jansson/src/jansson.h

@@ -8,9 +8,9 @@
 #ifndef JANSSON_H
 #define JANSSON_H
 
-#include <stdio.h>
-#include <stdlib.h>  /* for size_t */
 #include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h> /* for size_t */
 
 #include "jansson_config.h"
 
@@ -20,18 +20,18 @@ extern "C" {
 
 /* version */
 
-#define JANSSON_MAJOR_VERSION  2
-#define JANSSON_MINOR_VERSION  12
-#define JANSSON_MICRO_VERSION  0
+#define JANSSON_MAJOR_VERSION 2
+#define JANSSON_MINOR_VERSION 13
+#define JANSSON_MICRO_VERSION 1
 
 /* Micro version is omitted if it's 0 */
-#define JANSSON_VERSION  "2.12"
+#define JANSSON_VERSION "2.13.1"
 
 /* Version as a 3-byte hex number, e.g. 0x010201 == 1.2.1. Use this
    for numeric comparisons, e.g. #if JANSSON_VERSION_HEX >= ... */
-#define JANSSON_VERSION_HEX  ((JANSSON_MAJOR_VERSION << 16) |   \
-                              (JANSSON_MINOR_VERSION << 8)  |   \
-                              (JANSSON_MICRO_VERSION << 0))
+#define JANSSON_VERSION_HEX                                                              \
+    ((JANSSON_MAJOR_VERSION << 16) | (JANSSON_MINOR_VERSION << 8) |                      \
+     (JANSSON_MICRO_VERSION << 0))
 
 /* If __atomic or __sync builtins are available the library is thread
  * safe for all read-only functions plus reference counting. */
@@ -40,9 +40,9 @@ extern "C" {
 #endif
 
 #if defined(__GNUC__) || defined(__clang__)
-#define JANSSON_ATTRS(...) __attribute__((__VA_ARGS__))
+#define JANSSON_ATTRS(x) __attribute__(x)
 #else
-#define JANSSON_ATTRS(...)
+#define JANSSON_ATTRS(x)
 #endif
 
 /* types */
@@ -77,18 +77,18 @@ typedef long json_int_t;
 #endif /* JSON_INTEGER_IS_LONG_LONG */
 #endif
 
-#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_boolean_value     json_is_true
-#define json_is_boolean(json)  (json_is_true(json) || json_is_false(json))
-#define json_is_null(json)     ((json) && json_typeof(json) == JSON_NULL)
+#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_boolean_value    json_is_true
+#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 */
 
@@ -102,13 +102,15 @@ json_t *json_integer(json_int_t value);
 json_t *json_real(double value);
 json_t *json_true(void);
 json_t *json_false(void);
-#define json_boolean(val)      ((val) ? json_true() : json_false())
+#define json_boolean(val) ((val) ? json_true() : json_false())
 json_t *json_null(void);
 
 /* do not call JSON_INTERNAL_INCREF or JSON_INTERNAL_DECREF directly */
 #if JSON_HAVE_ATOMIC_BUILTINS
-#define JSON_INTERNAL_INCREF(json) __atomic_add_fetch(&json->refcount, 1, __ATOMIC_ACQUIRE)
-#define JSON_INTERNAL_DECREF(json) __atomic_sub_fetch(&json->refcount, 1, __ATOMIC_RELEASE)
+#define JSON_INTERNAL_INCREF(json)                                                       \
+    __atomic_add_fetch(&json->refcount, 1, __ATOMIC_ACQUIRE)
+#define JSON_INTERNAL_DECREF(json)                                                       \
+    __atomic_sub_fetch(&json->refcount, 1, __ATOMIC_RELEASE)
 #elif JSON_HAVE_SYNC_BUILTINS
 #define JSON_INTERNAL_INCREF(json) __sync_add_and_fetch(&json->refcount, 1)
 #define JSON_INTERNAL_DECREF(json) __sync_sub_and_fetch(&json->refcount, 1)
@@ -117,10 +119,8 @@ json_t *json_null(void);
 #define JSON_INTERNAL_DECREF(json) (--json->refcount)
 #endif
 
-static JSON_INLINE
-json_t *json_incref(json_t *json)
-{
-    if(json && json->refcount != (size_t)-1)
+static JSON_INLINE json_t *json_incref(json_t *json) {
+    if (json && json->refcount != (size_t)-1)
         JSON_INTERNAL_INCREF(json);
     return json;
 }
@@ -128,31 +128,26 @@ json_t *json_incref(json_t *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 != (size_t)-1 && JSON_INTERNAL_DECREF(json) == 0)
+static JSON_INLINE void json_decref(json_t *json) {
+    if (json && json->refcount != (size_t)-1 && JSON_INTERNAL_DECREF(json) == 0)
         json_delete(json);
 }
 
 #if defined(__GNUC__) || defined(__clang__)
-static JSON_INLINE
-void json_decrefp(json_t **json)
-{
-    if(json) {
+static JSON_INLINE void json_decrefp(json_t **json) {
+    if (json) {
         json_decref(*json);
-	*json = NULL;
+        *json = NULL;
     }
 }
 
 #define json_auto_t json_t __attribute__((cleanup(json_decrefp)))
 #endif
 
-
 /* error reporting */
 
-#define JSON_ERROR_TEXT_LENGTH    160
-#define JSON_ERROR_SOURCE_LENGTH   80
+#define JSON_ERROR_TEXT_LENGTH   160
+#define JSON_ERROR_SOURCE_LENGTH 80
 
 typedef struct json_error_t {
     int line;
@@ -191,7 +186,8 @@ static JSON_INLINE enum json_error_code json_error_code(const json_error_t *e) {
 
 void json_object_seed(size_t seed);
 size_t json_object_size(const json_t *object);
-json_t *json_object_get(const json_t *object, const char *key) JANSSON_ATTRS(warn_unused_result);
+json_t *json_object_get(const json_t *object, const char *key)
+    JANSSON_ATTRS((warn_unused_result));
 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);
@@ -199,6 +195,7 @@ int json_object_clear(json_t *object);
 int json_object_update(json_t *object, json_t *other);
 int json_object_update_existing(json_t *object, json_t *other);
 int json_object_update_missing(json_t *object, json_t *other);
+int json_object_update_recursive(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_key_to_iter(const char *key);
@@ -207,43 +204,58 @@ 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);
 
-#define json_object_foreach(object, key, value) \
-    for(key = json_object_iter_key(json_object_iter(object)); \
-        key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
-        key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key))))
-
-#define json_object_foreach_safe(object, n, key, value)     \
-    for(key = json_object_iter_key(json_object_iter(object)), \
-            n = json_object_iter_next(object, json_object_key_to_iter(key)); \
-        key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
-        key = json_object_iter_key(n), \
-            n = json_object_iter_next(object, json_object_key_to_iter(key)))
-
-#define json_array_foreach(array, index, value) \
-	for(index = 0; \
-		index < json_array_size(array) && (value = json_array_get(array, index)); \
-		index++)
-
-static JSON_INLINE
-int json_object_set(json_t *object, const char *key, json_t *value)
-{
+#define json_object_foreach(object, key, value)                                          \
+    for (key = json_object_iter_key(json_object_iter(object));                           \
+         key && (value = json_object_iter_value(json_object_key_to_iter(key)));          \
+         key = json_object_iter_key(                                                     \
+             json_object_iter_next(object, json_object_key_to_iter(key))))
+
+#define json_object_foreach_safe(object, n, key, value)                                  \
+    for (key = json_object_iter_key(json_object_iter(object)),                           \
+        n = json_object_iter_next(object, json_object_key_to_iter(key));                 \
+         key && (value = json_object_iter_value(json_object_key_to_iter(key)));          \
+         key = json_object_iter_key(n),                                                  \
+        n = json_object_iter_next(object, json_object_key_to_iter(key)))
+
+#define json_array_foreach(array, index, value)                                          \
+    for (index = 0;                                                                      \
+         index < json_array_size(array) && (value = json_array_get(array, index));       \
+         index++)
+
+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)
-{
+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 JSON_INLINE
-int json_object_iter_set(json_t *object, void *iter, json_t *value)
-{
+static JSON_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));
 }
 
+static JSON_INLINE int json_object_update_new(json_t *object, json_t *other) {
+    int ret = json_object_update(object, other);
+    json_decref(other);
+    return ret;
+}
+
+static JSON_INLINE int json_object_update_existing_new(json_t *object, json_t *other) {
+    int ret = json_object_update_existing(object, other);
+    json_decref(other);
+    return ret;
+}
+
+static JSON_INLINE int json_object_update_missing_new(json_t *object, json_t *other) {
+    int ret = json_object_update_missing(object, other);
+    json_decref(other);
+    return ret;
+}
+
 size_t json_array_size(const json_t *array);
-json_t *json_array_get(const json_t *array, size_t index) JANSSON_ATTRS(warn_unused_result);
+json_t *json_array_get(const json_t *array, size_t index)
+    JANSSON_ATTRS((warn_unused_result));
 int json_array_set_new(json_t *array, size_t index, json_t *value);
 int json_array_append_new(json_t *array, json_t *value);
 int json_array_insert_new(json_t *array, size_t index, json_t *value);
@@ -251,21 +263,15 @@ int json_array_remove(json_t *array, size_t 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, size_t ind, json_t *value)
-{
+static JSON_INLINE int json_array_set(json_t *array, size_t ind, json_t *value) {
     return json_array_set_new(array, ind, json_incref(value));
 }
 
-static JSON_INLINE
-int json_array_append(json_t *array, json_t *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, size_t ind, json_t *value)
-{
+static JSON_INLINE int json_array_insert(json_t *array, size_t ind, json_t *value) {
     return json_array_insert_new(array, ind, json_incref(value));
 }
 
@@ -284,33 +290,35 @@ int json_real_set(json_t *real, double value);
 
 /* pack, unpack */
 
-json_t *json_pack(const char *fmt, ...) JANSSON_ATTRS(warn_unused_result);
-json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...) JANSSON_ATTRS(warn_unused_result);
-json_t *json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap) JANSSON_ATTRS(warn_unused_result);
+json_t *json_pack(const char *fmt, ...) JANSSON_ATTRS((warn_unused_result));
+json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...)
+    JANSSON_ATTRS((warn_unused_result));
+json_t *json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap)
+    JANSSON_ATTRS((warn_unused_result));
 
-#define JSON_VALIDATE_ONLY  0x1
-#define JSON_STRICT         0x2
+#define JSON_VALIDATE_ONLY 0x1
+#define JSON_STRICT        0x2
 
 int json_unpack(json_t *root, const char *fmt, ...);
 int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...);
-int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, va_list ap);
+int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt,
+                    va_list ap);
 
 /* sprintf */
 
-json_t *json_sprintf(const char *fmt, ...) JANSSON_ATTRS(warn_unused_result, format(printf, 1, 2));
-json_t *json_vsprintf(const char *fmt, va_list ap) JANSSON_ATTRS(warn_unused_result, format(printf, 1, 0));
-
+json_t *json_sprintf(const char *fmt, ...)
+    JANSSON_ATTRS((warn_unused_result, format(printf, 1, 2)));
+json_t *json_vsprintf(const char *fmt, va_list ap)
+    JANSSON_ATTRS((warn_unused_result, format(printf, 1, 0)));
 
 /* equality */
 
 int json_equal(const json_t *value1, const json_t *value2);
 
-
 /* copying */
 
-json_t *json_copy(json_t *value) JANSSON_ATTRS(warn_unused_result);
-json_t *json_deep_copy(const json_t *value) JANSSON_ATTRS(warn_unused_result);
-
+json_t *json_copy(json_t *value) JANSSON_ATTRS((warn_unused_result));
+json_t *json_deep_copy(const json_t *value) JANSSON_ATTRS((warn_unused_result));
 
 /* decoding */
 
@@ -322,36 +330,42 @@ json_t *json_deep_copy(const json_t *value) JANSSON_ATTRS(warn_unused_result);
 
 typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data);
 
-json_t *json_loads(const char *input, size_t flags, json_error_t *error) JANSSON_ATTRS(warn_unused_result);
-json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error) JANSSON_ATTRS(warn_unused_result);
-json_t *json_loadf(FILE *input, size_t flags, json_error_t *error) JANSSON_ATTRS(warn_unused_result);
-json_t *json_loadfd(int input, size_t flags, json_error_t *error) JANSSON_ATTRS(warn_unused_result);
-json_t *json_load_file(const char *path, size_t flags, json_error_t *error) JANSSON_ATTRS(warn_unused_result);
-json_t *json_load_callback(json_load_callback_t callback, void *data, size_t flags, json_error_t *error) JANSSON_ATTRS(warn_unused_result);
-
+json_t *json_loads(const char *input, size_t flags, json_error_t *error)
+    JANSSON_ATTRS((warn_unused_result));
+json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error)
+    JANSSON_ATTRS((warn_unused_result));
+json_t *json_loadf(FILE *input, size_t flags, json_error_t *error)
+    JANSSON_ATTRS((warn_unused_result));
+json_t *json_loadfd(int input, size_t flags, json_error_t *error)
+    JANSSON_ATTRS((warn_unused_result));
+json_t *json_load_file(const char *path, size_t flags, json_error_t *error)
+    JANSSON_ATTRS((warn_unused_result));
+json_t *json_load_callback(json_load_callback_t callback, void *data, size_t flags,
+                           json_error_t *error) JANSSON_ATTRS((warn_unused_result));
 
 /* encoding */
 
-#define JSON_MAX_INDENT         0x1F
-#define JSON_INDENT(n)          ((n) & JSON_MAX_INDENT)
-#define JSON_COMPACT            0x20
-#define JSON_ENSURE_ASCII       0x40
-#define JSON_SORT_KEYS          0x80
-#define JSON_PRESERVE_ORDER     0x100
-#define JSON_ENCODE_ANY         0x200
-#define JSON_ESCAPE_SLASH       0x400
-#define JSON_REAL_PRECISION(n)  (((n) & 0x1F) << 11)
-#define JSON_EMBED              0x10000
+#define JSON_MAX_INDENT        0x1F
+#define JSON_INDENT(n)         ((n)&JSON_MAX_INDENT)
+#define JSON_COMPACT           0x20
+#define JSON_ENSURE_ASCII      0x40
+#define JSON_SORT_KEYS         0x80
+#define JSON_PRESERVE_ORDER    0x100
+#define JSON_ENCODE_ANY        0x200
+#define JSON_ESCAPE_SLASH      0x400
+#define JSON_REAL_PRECISION(n) (((n)&0x1F) << 11)
+#define JSON_EMBED             0x10000
 #define JSON_FRACTIONAL_DIGITS  0x20000
 
 typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);
 
-char *json_dumps(const json_t *json, size_t flags) JANSSON_ATTRS(warn_unused_result);
+char *json_dumps(const json_t *json, size_t flags) JANSSON_ATTRS((warn_unused_result));
 size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags);
 int json_dumpf(const json_t *json, FILE *output, size_t flags);
 int json_dumpfd(const json_t *json, int output, size_t flags);
 int json_dump_file(const json_t *json, const char *path, size_t flags);
-int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags);
+int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data,
+                       size_t flags);
 
 /* custom memory allocation */
 

+ 32 - 27
jansson.mod/jansson/src/jansson_private.h

@@ -8,18 +8,18 @@
 #ifndef JANSSON_PRIVATE_H
 #define JANSSON_PRIVATE_H
 
-#include "jansson_private_config.h"
-#include <stddef.h>
-#include "jansson.h"
 #include "hashtable.h"
+#include "jansson.h"
+#include "jansson_private_config.h"
 #include "strbuffer.h"
+#include <stddef.h>
 
-#define container_of(ptr_, type_, member_)  \
+#define container_of(ptr_, type_, member_)                                               \
     ((type_ *)((char *)ptr_ - offsetof(type_, member_)))
 
 /* On some platforms, max() may already be defined */
 #ifndef max
-#define max(a, b)  ((a) > (b) ? (a) : (b))
+#define max(a, b) ((a) > (b) ? (a) : (b))
 #endif
 
 /* va_copy is a C99 feature. In C89 implementations, it's sometimes
@@ -28,7 +28,7 @@
 #ifdef __va_copy
 #define va_copy __va_copy
 #else
-#define va_copy(a, b)  memcpy(&(a), &(b), sizeof(va_list))
+#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list))
 #endif
 #endif
 
@@ -72,38 +72,43 @@ json_t *jsonp_stringn_nocheck_own(const char *value, size_t len);
 /* Error message formatting */
 void jsonp_error_init(json_error_t *error, const char *source);
 void jsonp_error_set_source(json_error_t *error, const char *source);
-void jsonp_error_set(json_error_t *error, int line, int column,
-                     size_t position, enum json_error_code code,
-                     const char *msg, ...);
-void jsonp_error_vset(json_error_t *error, int line, int column,
-                      size_t position, enum json_error_code code,
-                      const char *msg, va_list ap);
+void jsonp_error_set(json_error_t *error, int line, int column, size_t position,
+                     enum json_error_code code, const char *msg, ...);
+void jsonp_error_vset(json_error_t *error, int line, int column, size_t position,
+                      enum json_error_code code, const char *msg, va_list ap);
 
 /* Locale independent string<->double conversions */
 int jsonp_strtod(strbuffer_t *strbuffer, double *out);
 int jsonp_dtostr(char *buffer, size_t size, double value, int prec, int frac_digits);
 
 /* Wrappers for custom memory functions */
-void* jsonp_malloc(size_t size) JANSSON_ATTRS(warn_unused_result);
+void *jsonp_malloc(size_t size) JANSSON_ATTRS((warn_unused_result));
 void jsonp_free(void *ptr);
-char *jsonp_strndup(const char *str, size_t length) JANSSON_ATTRS(warn_unused_result);
-char *jsonp_strdup(const char *str) JANSSON_ATTRS(warn_unused_result);
-char *jsonp_strndup(const char *str, size_t len) JANSSON_ATTRS(warn_unused_result);
+char *jsonp_strndup(const char *str, size_t length) JANSSON_ATTRS((warn_unused_result));
+char *jsonp_strdup(const char *str) JANSSON_ATTRS((warn_unused_result));
+char *jsonp_strndup(const char *str, size_t len) JANSSON_ATTRS((warn_unused_result));
 
+/* Circular reference check*/
+/* Space for "0x", double the sizeof a pointer for the hex and a terminator. */
+#define LOOP_KEY_LEN (2 + (sizeof(json_t *) * 2) + 1)
+int jsonp_loop_check(hashtable_t *parents, const json_t *json, char *key,
+                     size_t key_size);
 
 /* Windows compatibility */
 #if defined(_WIN32) || defined(WIN32)
-#  if defined(_MSC_VER)  /* MS compiller */
-#    if (_MSC_VER < 1900) && !defined(snprintf)  /* snprintf not defined yet & not introduced */
-#      define snprintf _snprintf
-#    endif
-#    if (_MSC_VER < 1500) && !defined(vsnprintf)  /* vsnprintf not defined yet & not introduced */
-#      define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
-#    endif
-#  else  /* Other Windows compiller, old definition */
-#    define snprintf _snprintf
-#    define vsnprintf _vsnprintf
-#  endif
+#if defined(_MSC_VER) /* MS compiller */
+#if (_MSC_VER < 1900) &&                                                                 \
+    !defined(snprintf) /* snprintf not defined yet & not introduced */
+#define snprintf _snprintf
+#endif
+#if (_MSC_VER < 1500) &&                                                                 \
+    !defined(vsnprintf) /* vsnprintf not defined yet & not introduced */
+#define vsnprintf(b, c, f, a) _vsnprintf(b, c, f, a)
+#endif
+#else /* Other Windows compiller, old definition */
+#define snprintf  _snprintf
+#define vsnprintf _vsnprintf
+#endif
 #endif
 
 #endif

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 224 - 257
jansson.mod/jansson/src/load.c


+ 2 - 1
jansson.mod/jansson/src/lookup3.h

@@ -1,3 +1,4 @@
+// clang-format off
 /*
 -------------------------------------------------------------------------------
 lookup3.c, by Bob Jenkins, May 2006, Public Domain.
@@ -243,7 +244,7 @@ static uint32_t hashlittle(const void *key, size_t length, uint32_t initval)
      * rest of the string.  Every machine with memory protection I've seen
      * does it on word boundaries, so is OK with this.  But VALGRIND will
      * still catch it and complain.  The masking trick does make the hash
-     * noticably faster for short strings (like English words).
+     * noticeably faster for short strings (like English words).
      */
 #ifndef NO_MASKING_TRICK
 

+ 9 - 17
jansson.mod/jansson/src/memory.c

@@ -20,33 +20,27 @@
 static json_malloc_t do_malloc = malloc;
 static json_free_t do_free = free;
 
-void *jsonp_malloc(size_t size)
-{
-    if(!size)
+void *jsonp_malloc(size_t size) {
+    if (!size)
         return NULL;
 
     return (*do_malloc)(size);
 }
 
-void jsonp_free(void *ptr)
-{
-    if(!ptr)
+void jsonp_free(void *ptr) {
+    if (!ptr)
         return;
 
     (*do_free)(ptr);
 }
 
-char *jsonp_strdup(const char *str)
-{
-    return jsonp_strndup(str, strlen(str));
-}
+char *jsonp_strdup(const char *str) { return jsonp_strndup(str, strlen(str)); }
 
-char *jsonp_strndup(const char *str, size_t len)
-{
+char *jsonp_strndup(const char *str, size_t len) {
     char *new_str;
 
     new_str = jsonp_malloc(len + 1);
-    if(!new_str)
+    if (!new_str)
         return NULL;
 
     memcpy(new_str, str, len);
@@ -54,14 +48,12 @@ char *jsonp_strndup(const char *str, size_t len)
     return new_str;
 }
 
-void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn)
-{
+void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) {
     do_malloc = malloc_fn;
     do_free = free_fn;
 }
 
-void json_get_alloc_funcs(json_malloc_t *malloc_fn, json_free_t *free_fn)
-{
+void json_get_alloc_funcs(json_malloc_t *malloc_fn, json_free_t *free_fn) {
     if (malloc_fn)
         *malloc_fn = do_malloc;
     if (free_fn)

+ 202 - 219
jansson.mod/jansson/src/pack_unpack.c

@@ -6,10 +6,10 @@
  * it under the terms of the MIT license. See LICENSE for details.
  */
 
-#include <string.h>
 #include "jansson.h"
 #include "jansson_private.h"
 #include "utf.h"
+#include <string.h>
 
 typedef struct {
     int line;
@@ -34,24 +34,15 @@ typedef struct {
 
 #define token(scanner) ((scanner)->token.token)
 
-static const char * const type_names[] = {
-    "object",
-    "array",
-    "string",
-    "integer",
-    "real",
-    "true",
-    "false",
-    "null"
-};
+static const char *const type_names[] = {"object", "array", "string", "integer",
+                                         "real",   "true",  "false",  "null"};
 
 #define type_name(x) type_names[json_typeof(x)]
 
 static const char unpack_value_starters[] = "{[siIbfFOon";
 
-static void scanner_init(scanner_t *s, json_error_t *error,
-                         size_t flags, const char *fmt)
-{
+static void scanner_init(scanner_t *s, json_error_t *error, size_t flags,
+                         const char *fmt) {
     s->error = error;
     s->flags = flags;
     s->fmt = s->start = fmt;
@@ -64,12 +55,11 @@ static void scanner_init(scanner_t *s, json_error_t *error,
     s->has_error = 0;
 }
 
-static void next_token(scanner_t *s)
-{
+static void next_token(scanner_t *s) {
     const char *t;
     s->prev_token = s->token;
 
-    if(s->next_token.line) {
+    if (s->next_token.line) {
         s->token = s->next_token;
         s->next_token.line = 0;
         return;
@@ -83,12 +73,11 @@ static void next_token(scanner_t *s)
     s->pos++;
 
     /* skip space and ignored chars */
-    while(*t == ' ' || *t == '\t' || *t == '\n' || *t == ',' || *t == ':') {
-        if(*t == '\n') {
+    while (*t == ' ' || *t == '\t' || *t == '\n' || *t == ',' || *t == ':') {
+        if (*t == '\n') {
             s->line++;
             s->column = 1;
-        }
-        else
+        } else
             s->column++;
 
         s->pos++;
@@ -100,24 +89,23 @@ static void next_token(scanner_t *s)
     s->token.column = s->column;
     s->token.pos = s->pos;
 
-    if (*t) t++;
+    if (*t)
+        t++;
     s->fmt = t;
 }
 
-static void prev_token(scanner_t *s)
-{
+static void prev_token(scanner_t *s) {
     s->next_token = s->token;
     s->token = s->prev_token;
 }
 
 static void set_error(scanner_t *s, const char *source, enum json_error_code code,
-                      const char *fmt, ...)
-{
+                      const char *fmt, ...) {
     va_list ap;
     va_start(ap, fmt);
 
-    jsonp_error_vset(s->error, s->token.line, s->token.column, s->token.pos,
-                     code, fmt, ap);
+    jsonp_error_vset(s->error, s->token.line, s->token.column, s->token.pos, code, fmt,
+                     ap);
 
     jsonp_error_set_source(s->error, source);
 
@@ -126,12 +114,10 @@ static void set_error(scanner_t *s, const char *source, enum json_error_code cod
 
 static json_t *pack(scanner_t *s, va_list *ap);
 
-
 /* ours will be set to 1 if jsonp_free() must be called for the result
    afterwards */
-static char *read_string(scanner_t *s, va_list *ap,
-                         const char *purpose, size_t *out_len, int *ours, int optional)
-{
+static char *read_string(scanner_t *s, va_list *ap, const char *purpose, size_t *out_len,
+                         int *ours, int optional) {
     char t;
     strbuffer_t strbuff;
     const char *str;
@@ -142,11 +128,11 @@ static char *read_string(scanner_t *s, va_list *ap,
     prev_token(s);
 
     *ours = 0;
-    if(t != '#' && t != '%' && t != '+') {
+    if (t != '#' && t != '%' && t != '+') {
         /* Optimize the simple case */
         str = va_arg(*ap, const char *);
 
-        if(!str) {
+        if (!str) {
             if (!optional) {
                 set_error(s, "<args>", json_error_null_value, "NULL %s", purpose);
                 s->has_error = 1;
@@ -156,7 +142,7 @@ static char *read_string(scanner_t *s, va_list *ap,
 
         length = strlen(str);
 
-        if(!utf8_check_string(str, length)) {
+        if (!utf8_check_string(str, length)) {
             set_error(s, "<args>", json_error_invalid_utf8, "Invalid UTF-8 %s", purpose);
             s->has_error = 1;
             return NULL;
@@ -165,55 +151,54 @@ static char *read_string(scanner_t *s, va_list *ap,
         *out_len = length;
         return (char *)str;
     } else if (optional) {
-        set_error(s, "<format>", json_error_invalid_format, "Cannot use '%c' on optional strings", t);
+        set_error(s, "<format>", json_error_invalid_format,
+                  "Cannot use '%c' on optional strings", t);
         s->has_error = 1;
 
         return NULL;
     }
 
-    if(strbuffer_init(&strbuff)) {
+    if (strbuffer_init(&strbuff)) {
         set_error(s, "<internal>", json_error_out_of_memory, "Out of memory");
         s->has_error = 1;
     }
 
-    while(1) {
+    while (1) {
         str = va_arg(*ap, const char *);
-        if(!str) {
+        if (!str) {
             set_error(s, "<args>", json_error_null_value, "NULL %s", purpose);
             s->has_error = 1;
         }
 
         next_token(s);
 
-        if(token(s) == '#') {
+        if (token(s) == '#') {
             length = va_arg(*ap, int);
-        }
-        else if(token(s) == '%') {
+        } else if (token(s) == '%') {
             length = va_arg(*ap, size_t);
-        }
-        else {
+        } else {
             prev_token(s);
             length = s->has_error ? 0 : strlen(str);
         }
 
-        if(!s->has_error && strbuffer_append_bytes(&strbuff, str, length) == -1) {
+        if (!s->has_error && strbuffer_append_bytes(&strbuff, str, length) == -1) {
             set_error(s, "<internal>", json_error_out_of_memory, "Out of memory");
             s->has_error = 1;
         }
 
         next_token(s);
-        if(token(s) != '+') {
+        if (token(s) != '+') {
             prev_token(s);
             break;
         }
     }
 
-    if(s->has_error) {
+    if (s->has_error) {
         strbuffer_close(&strbuff);
         return NULL;
     }
 
-    if(!utf8_check_string(strbuff.value, strbuff.length)) {
+    if (!utf8_check_string(strbuff.value, strbuff.length)) {
         set_error(s, "<args>", json_error_invalid_utf8, "Invalid UTF-8 %s", purpose);
         strbuffer_close(&strbuff);
         s->has_error = 1;
@@ -225,25 +210,26 @@ static char *read_string(scanner_t *s, va_list *ap,
     return strbuffer_steal_value(&strbuff);
 }
 
-static json_t *pack_object(scanner_t *s, va_list *ap)
-{
+static json_t *pack_object(scanner_t *s, va_list *ap) {
     json_t *object = json_object();
     next_token(s);
 
-    while(token(s) != '}') {
+    while (token(s) != '}') {
         char *key;
         size_t len;
         int ours;
         json_t *value;
         char valueOptional;
 
-        if(!token(s)) {
-            set_error(s, "<format>", json_error_invalid_format, "Unexpected end of format string");
+        if (!token(s)) {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Unexpected end of format string");
             goto error;
         }
 
-        if(token(s) != 's') {
-            set_error(s, "<format>", json_error_invalid_format, "Expected format 's', got '%c'", token(s));
+        if (token(s) != 's') {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Expected format 's', got '%c'", token(s));
             goto error;
         }
 
@@ -256,11 +242,11 @@ static json_t *pack_object(scanner_t *s, va_list *ap)
         prev_token(s);
 
         value = pack(s, ap);
-        if(!value) {
-            if(ours)
+        if (!value) {
+            if (ours)
                 jsonp_free(key);
 
-            if(valueOptional != '*') {
+            if (valueOptional != '*') {
                 set_error(s, "<args>", json_error_null_value, "NULL object value");
                 s->has_error = 1;
             }
@@ -269,21 +255,22 @@ static json_t *pack_object(scanner_t *s, va_list *ap)
             continue;
         }
 
-        if(s->has_error)
+        if (s->has_error)
             json_decref(value);
 
-        if(!s->has_error && json_object_set_new_nocheck(object, key, value)) {
-            set_error(s, "<internal>", json_error_out_of_memory, "Unable to add key \"%s\"", key);
+        if (!s->has_error && json_object_set_new_nocheck(object, key, value)) {
+            set_error(s, "<internal>", json_error_out_of_memory,
+                      "Unable to add key \"%s\"", key);
             s->has_error = 1;
         }
 
-        if(ours)
+        if (ours)
             jsonp_free(key);
 
         next_token(s);
     }
 
-    if(!s->has_error)
+    if (!s->has_error)
         return object;
 
 error:
@@ -291,17 +278,17 @@ error:
     return NULL;
 }
 
-static json_t *pack_array(scanner_t *s, va_list *ap)
-{
+static json_t *pack_array(scanner_t *s, va_list *ap) {
     json_t *array = json_array();
     next_token(s);
 
-    while(token(s) != ']') {
+    while (token(s) != ']') {
         json_t *value;
         char valueOptional;
 
-        if(!token(s)) {
-            set_error(s, "<format>", json_error_invalid_format, "Unexpected end of format string");
+        if (!token(s)) {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Unexpected end of format string");
             /* Format string errors are unrecoverable. */
             goto error;
         }
@@ -311,8 +298,8 @@ static json_t *pack_array(scanner_t *s, va_list *ap)
         prev_token(s);
 
         value = pack(s, ap);
-        if(!value) {
-            if(valueOptional != '*') {
+        if (!value) {
+            if (valueOptional != '*') {
                 s->has_error = 1;
             }
 
@@ -320,18 +307,19 @@ static json_t *pack_array(scanner_t *s, va_list *ap)
             continue;
         }
 
-        if(s->has_error)
+        if (s->has_error)
             json_decref(value);
 
-        if(!s->has_error && json_array_append_new(array, value)) {
-            set_error(s, "<internal>", json_error_out_of_memory, "Unable to append to array");
+        if (!s->has_error && json_array_append_new(array, value)) {
+            set_error(s, "<internal>", json_error_out_of_memory,
+                      "Unable to append to array");
             s->has_error = 1;
         }
 
         next_token(s);
     }
 
-    if(!s->has_error)
+    if (!s->has_error)
         return array;
 
 error:
@@ -339,8 +327,7 @@ error:
     return NULL;
 }
 
-static json_t *pack_string(scanner_t *s, va_list *ap)
-{
+static json_t *pack_string(scanner_t *s, va_list *ap) {
     char *str;
     char t;
     size_t len;
@@ -369,8 +356,7 @@ static json_t *pack_string(scanner_t *s, va_list *ap)
     return json_stringn_nocheck(str, len);
 }
 
-static json_t *pack_object_inter(scanner_t *s, va_list *ap, int need_incref)
-{
+static json_t *pack_object_inter(scanner_t *s, va_list *ap, int need_incref) {
     json_t *json;
     char ntoken;
 
@@ -399,8 +385,7 @@ static json_t *pack_object_inter(scanner_t *s, va_list *ap, int need_incref)
     return NULL;
 }
 
-static json_t *pack_integer(scanner_t *s, json_int_t value)
-{
+static json_t *pack_integer(scanner_t *s, json_int_t value) {
     json_t *json = json_integer(value);
 
     if (!json) {
@@ -411,8 +396,7 @@ static json_t *pack_integer(scanner_t *s, json_int_t value)
     return json;
 }
 
-static json_t *pack_real(scanner_t *s, double value)
-{
+static json_t *pack_real(scanner_t *s, double value) {
     /* Allocate without setting value so we can identify OOM error. */
     json_t *json = json_real(0.0);
 
@@ -426,7 +410,8 @@ static json_t *pack_real(scanner_t *s, double value)
     if (json_real_set(json, value)) {
         json_decref(json);
 
-        set_error(s, "<args>", json_error_numeric_overflow, "Invalid floating point value");
+        set_error(s, "<args>", json_error_numeric_overflow,
+                  "Invalid floating point value");
         s->has_error = 1;
 
         return NULL;
@@ -435,9 +420,8 @@ static json_t *pack_real(scanner_t *s, double value)
     return json;
 }
 
-static json_t *pack(scanner_t *s, va_list *ap)
-{
-    switch(token(s)) {
+static json_t *pack(scanner_t *s, va_list *ap) {
+    switch (token(s)) {
         case '{':
             return pack_object(s, ap);
 
@@ -469,8 +453,8 @@ static json_t *pack(scanner_t *s, va_list *ap)
             return pack_object_inter(s, ap, 0);
 
         default:
-            set_error(s, "<format>", json_error_invalid_format, "Unexpected format character '%c'",
-                      token(s));
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Unexpected format character '%c'", token(s));
             s->has_error = 1;
             return NULL;
     }
@@ -478,8 +462,7 @@ static json_t *pack(scanner_t *s, va_list *ap)
 
 static int unpack(scanner_t *s, json_t *root, va_list *ap);
 
-static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
-{
+static int unpack_object(scanner_t *s, json_t *root, va_list *ap) {
     int ret = -1;
     int strict = 0;
     int gotopt = 0;
@@ -491,81 +474,84 @@ static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
     */
     hashtable_t key_set;
 
-    if(hashtable_init(&key_set)) {
+    if (hashtable_init(&key_set)) {
         set_error(s, "<internal>", json_error_out_of_memory, "Out of memory");
         return -1;
     }
 
-    if(root && !json_is_object(root)) {
+    if (root && !json_is_object(root)) {
         set_error(s, "<validation>", json_error_wrong_type, "Expected object, got %s",
                   type_name(root));
         goto out;
     }
     next_token(s);
 
-    while(token(s) != '}') {
+    while (token(s) != '}') {
         const char *key;
         json_t *value;
         int opt = 0;
 
-        if(strict != 0) {
-            set_error(s, "<format>", json_error_invalid_format, "Expected '}' after '%c', got '%c'",
-                      (strict == 1 ? '!' : '*'), token(s));
+        if (strict != 0) {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Expected '}' after '%c', got '%c'", (strict == 1 ? '!' : '*'),
+                      token(s));
             goto out;
         }
 
-        if(!token(s)) {
-            set_error(s, "<format>", json_error_invalid_format, "Unexpected end of format string");
+        if (!token(s)) {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Unexpected end of format string");
             goto out;
         }
 
-        if(token(s) == '!' || token(s) == '*') {
+        if (token(s) == '!' || token(s) == '*') {
             strict = (token(s) == '!' ? 1 : -1);
             next_token(s);
             continue;
         }
 
-        if(token(s) != 's') {
-            set_error(s, "<format>", json_error_invalid_format, "Expected format 's', got '%c'", token(s));
+        if (token(s) != 's') {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Expected format 's', got '%c'", token(s));
             goto out;
         }
 
         key = va_arg(*ap, const char *);
-        if(!key) {
+        if (!key) {
             set_error(s, "<args>", json_error_null_value, "NULL object key");
             goto out;
         }
 
         next_token(s);
 
-        if(token(s) == '?') {
+        if (token(s) == '?') {
             opt = gotopt = 1;
             next_token(s);
         }
 
-        if(!root) {
+        if (!root) {
             /* skipping */
             value = NULL;
-        }
-        else {
+        } else {
             value = json_object_get(root, key);
-            if(!value && !opt) {
-                set_error(s, "<validation>", json_error_item_not_found, "Object item not found: %s", key);
+            if (!value && !opt) {
+                set_error(s, "<validation>", json_error_item_not_found,
+                          "Object item not found: %s", key);
                 goto out;
             }
         }
 
-        if(unpack(s, value, ap))
+        if (unpack(s, value, ap))
             goto out;
 
         hashtable_set(&key_set, key, json_null());
         next_token(s);
     }
 
-    if(strict == 0 && (s->flags & JSON_STRICT))
+    if (strict == 0 && (s->flags & JSON_STRICT))
         strict = 1;
 
-    if(root && strict == 1) {
+    if (root && strict == 1) {
         /* We need to check that all non optional items have been parsed */
         const char *key;
         /* keys_res is 1 for uninitialized, 0 for success, -1 for error. */
@@ -576,7 +562,7 @@ static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
 
         if (gotopt || json_object_size(root) != key_set.size) {
             json_object_foreach(root, key, value) {
-                if(!hashtable_get(&key_set, key)) {
+                if (!hashtable_get(&key_set, key)) {
                     unpacked++;
 
                     /* Save unrecognized keys for the error message */
@@ -587,14 +573,14 @@ static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
                     }
 
                     if (!keys_res)
-                        keys_res = strbuffer_append_bytes(&unrecognized_keys, key, strlen(key));
+                        keys_res =
+                            strbuffer_append_bytes(&unrecognized_keys, key, strlen(key));
                 }
             }
         }
         if (unpacked) {
             set_error(s, "<validation>", json_error_end_of_input_expected,
-                      "%li object item(s) left unpacked: %s",
-                      unpacked,
+                      "%li object item(s) left unpacked: %s", unpacked,
                       keys_res ? "<unknown>" : strbuffer_value(&unrecognized_keys));
             strbuffer_close(&unrecognized_keys);
             goto out;
@@ -608,80 +594,79 @@ out:
     return ret;
 }
 
-static int unpack_array(scanner_t *s, json_t *root, va_list *ap)
-{
+static int unpack_array(scanner_t *s, json_t *root, va_list *ap) {
     size_t i = 0;
     int strict = 0;
 
-    if(root && !json_is_array(root)) {
-        set_error(s, "<validation>", json_error_wrong_type, "Expected array, got %s", type_name(root));
+    if (root && !json_is_array(root)) {
+        set_error(s, "<validation>", json_error_wrong_type, "Expected array, got %s",
+                  type_name(root));
         return -1;
     }
     next_token(s);
 
-    while(token(s) != ']') {
+    while (token(s) != ']') {
         json_t *value;
 
-        if(strict != 0) {
-            set_error(s, "<format>", json_error_invalid_format, "Expected ']' after '%c', got '%c'",
-                      (strict == 1 ? '!' : '*'),
+        if (strict != 0) {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Expected ']' after '%c', got '%c'", (strict == 1 ? '!' : '*'),
                       token(s));
             return -1;
         }
 
-        if(!token(s)) {
-            set_error(s, "<format>", json_error_invalid_format, "Unexpected end of format string");
+        if (!token(s)) {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Unexpected end of format string");
             return -1;
         }
 
-        if(token(s) == '!' || token(s) == '*') {
+        if (token(s) == '!' || token(s) == '*') {
             strict = (token(s) == '!' ? 1 : -1);
             next_token(s);
             continue;
         }
 
-        if(!strchr(unpack_value_starters, token(s))) {
-            set_error(s, "<format>", json_error_invalid_format, "Unexpected format character '%c'",
-                      token(s));
+        if (!strchr(unpack_value_starters, token(s))) {
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Unexpected format character '%c'", token(s));
             return -1;
         }
 
-        if(!root) {
+        if (!root) {
             /* skipping */
             value = NULL;
-        }
-        else {
+        } else {
             value = json_array_get(root, i);
-            if(!value) {
-                set_error(s, "<validation>", json_error_index_out_of_range, "Array index %lu out of range",
-                          (unsigned long)i);
+            if (!value) {
+                set_error(s, "<validation>", json_error_index_out_of_range,
+                          "Array index %lu out of range", (unsigned long)i);
                 return -1;
             }
         }
 
-        if(unpack(s, value, ap))
+        if (unpack(s, value, ap))
             return -1;
 
         next_token(s);
         i++;
     }
 
-    if(strict == 0 && (s->flags & JSON_STRICT))
+    if (strict == 0 && (s->flags & JSON_STRICT))
         strict = 1;
 
-    if(root && strict == 1 && i != json_array_size(root)) {
+    if (root && strict == 1 && i != json_array_size(root)) {
         long diff = (long)json_array_size(root) - (long)i;
-        set_error(s, "<validation>", json_error_end_of_input_expected, "%li array item(s) left unpacked", diff);
+        set_error(s, "<validation>", json_error_end_of_input_expected,
+                  "%li array item(s) left unpacked", diff);
         return -1;
     }
 
     return 0;
 }
 
-static int unpack(scanner_t *s, json_t *root, va_list *ap)
-{
-    switch(token(s))
-    {
+static int unpack(scanner_t *s, json_t *root, va_list *ap) {
+    switch (token(s)) {
         case '{':
             return unpack_object(s, root, ap);
 
@@ -689,126 +674,126 @@ static int unpack(scanner_t *s, json_t *root, va_list *ap)
             return unpack_array(s, root, ap);
 
         case 's':
-            if(root && !json_is_string(root)) {
-                set_error(s, "<validation>", json_error_wrong_type, "Expected string, got %s",
-                          type_name(root));
+            if (root && !json_is_string(root)) {
+                set_error(s, "<validation>", json_error_wrong_type,
+                          "Expected string, got %s", type_name(root));
                 return -1;
             }
 
-            if(!(s->flags & JSON_VALIDATE_ONLY)) {
+            if (!(s->flags & JSON_VALIDATE_ONLY)) {
                 const char **str_target;
                 size_t *len_target = NULL;
 
                 str_target = va_arg(*ap, const char **);
-                if(!str_target) {
+                if (!str_target) {
                     set_error(s, "<args>", json_error_null_value, "NULL string argument");
                     return -1;
                 }
 
                 next_token(s);
 
-                if(token(s) == '%') {
+                if (token(s) == '%') {
                     len_target = va_arg(*ap, size_t *);
-                    if(!len_target) {
-                        set_error(s, "<args>", json_error_null_value, "NULL string length argument");
+                    if (!len_target) {
+                        set_error(s, "<args>", json_error_null_value,
+                                  "NULL string length argument");
                         return -1;
                     }
-                }
-                else
+                } else
                     prev_token(s);
 
-                if(root) {
+                if (root) {
                     *str_target = json_string_value(root);
-                    if(len_target)
+                    if (len_target)
                         *len_target = json_string_length(root);
                 }
             }
             return 0;
 
         case 'i':
-            if(root && !json_is_integer(root)) {
-                set_error(s, "<validation>", json_error_wrong_type, "Expected integer, got %s",
-                          type_name(root));
+            if (root && !json_is_integer(root)) {
+                set_error(s, "<validation>", json_error_wrong_type,
+                          "Expected integer, got %s", type_name(root));
                 return -1;
             }
 
-            if(!(s->flags & JSON_VALIDATE_ONLY)) {
-                int *target = va_arg(*ap, int*);
-                if(root)
+            if (!(s->flags & JSON_VALIDATE_ONLY)) {
+                int *target = va_arg(*ap, int *);
+                if (root)
                     *target = (int)json_integer_value(root);
             }
 
             return 0;
 
         case 'I':
-            if(root && !json_is_integer(root)) {
-                set_error(s, "<validation>", json_error_wrong_type, "Expected integer, got %s",
-                          type_name(root));
+            if (root && !json_is_integer(root)) {
+                set_error(s, "<validation>", json_error_wrong_type,
+                          "Expected integer, got %s", type_name(root));
                 return -1;
             }
 
-            if(!(s->flags & JSON_VALIDATE_ONLY)) {
-                json_int_t *target = va_arg(*ap, json_int_t*);
-                if(root)
+            if (!(s->flags & JSON_VALIDATE_ONLY)) {
+                json_int_t *target = va_arg(*ap, json_int_t *);
+                if (root)
                     *target = json_integer_value(root);
             }
 
             return 0;
 
         case 'b':
-            if(root && !json_is_boolean(root)) {
-                set_error(s, "<validation>", json_error_wrong_type, "Expected true or false, got %s",
-                          type_name(root));
+            if (root && !json_is_boolean(root)) {
+                set_error(s, "<validation>", json_error_wrong_type,
+                          "Expected true or false, got %s", type_name(root));
                 return -1;
             }
 
-            if(!(s->flags & JSON_VALIDATE_ONLY)) {
-                int *target = va_arg(*ap, int*);
-                if(root)
+            if (!(s->flags & JSON_VALIDATE_ONLY)) {
+                int *target = va_arg(*ap, int *);
+                if (root)
                     *target = json_is_true(root);
             }
 
             return 0;
 
         case 'f':
-            if(root && !json_is_real(root)) {
-                set_error(s, "<validation>", json_error_wrong_type, "Expected real, got %s",
-                          type_name(root));
+            if (root && !json_is_real(root)) {
+                set_error(s, "<validation>", json_error_wrong_type,
+                          "Expected real, got %s", type_name(root));
                 return -1;
             }
 
-            if(!(s->flags & JSON_VALIDATE_ONLY)) {
-                double *target = va_arg(*ap, double*);
-                if(root)
+            if (!(s->flags & JSON_VALIDATE_ONLY)) {
+                double *target = va_arg(*ap, double *);
+                if (root)
                     *target = json_real_value(root);
             }
 
             return 0;
 
         case 'F':
-            if(root && !json_is_number(root)) {
-                set_error(s, "<validation>", json_error_wrong_type, "Expected real or integer, got %s",
-                          type_name(root));
+            if (root && !json_is_number(root)) {
+                set_error(s, "<validation>", json_error_wrong_type,
+                          "Expected real or integer, got %s", type_name(root));
                 return -1;
             }
 
-            if(!(s->flags & JSON_VALIDATE_ONLY)) {
-                double *target = va_arg(*ap, double*);
-                if(root)
+            if (!(s->flags & JSON_VALIDATE_ONLY)) {
+                double *target = va_arg(*ap, double *);
+                if (root)
                     *target = json_number_value(root);
             }
 
             return 0;
 
         case 'O':
-            if(root && !(s->flags & JSON_VALIDATE_ONLY))
+            if (root && !(s->flags & JSON_VALIDATE_ONLY))
                 json_incref(root);
             /* Fall through */
 
         case 'o':
-            if(!(s->flags & JSON_VALIDATE_ONLY)) {
-                json_t **target = va_arg(*ap, json_t**);
-                if(root)
+            if (!(s->flags & JSON_VALIDATE_ONLY)) {
+                json_t **target = va_arg(*ap, json_t **);
+                if (root)
                     *target = root;
             }
 
@@ -816,30 +801,29 @@ static int unpack(scanner_t *s, json_t *root, va_list *ap)
 
         case 'n':
             /* Never assign, just validate */
-            if(root && !json_is_null(root)) {
-                set_error(s, "<validation>", json_error_wrong_type, "Expected null, got %s",
-                          type_name(root));
+            if (root && !json_is_null(root)) {
+                set_error(s, "<validation>", json_error_wrong_type,
+                          "Expected null, got %s", type_name(root));
                 return -1;
             }
             return 0;
 
         default:
-            set_error(s, "<format>", json_error_invalid_format, "Unexpected format character '%c'",
-                      token(s));
+            set_error(s, "<format>", json_error_invalid_format,
+                      "Unexpected format character '%c'", token(s));
             return -1;
     }
 }
 
-json_t *json_vpack_ex(json_error_t *error, size_t flags,
-                      const char *fmt, va_list ap)
-{
+json_t *json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap) {
     scanner_t s;
     va_list ap_copy;
     json_t *value;
 
-    if(!fmt || !*fmt) {
+    if (!fmt || !*fmt) {
         jsonp_error_init(error, "<format>");
-        jsonp_error_set(error, -1, -1, 0, json_error_invalid_argument, "NULL or empty format string");
+        jsonp_error_set(error, -1, -1, 0, json_error_invalid_argument,
+                        "NULL or empty format string");
         return NULL;
     }
     jsonp_error_init(error, NULL);
@@ -852,21 +836,21 @@ json_t *json_vpack_ex(json_error_t *error, size_t flags,
     va_end(ap_copy);
 
     /* This will cover all situations where s.has_error is true */
-    if(!value)
+    if (!value)
         return NULL;
 
     next_token(&s);
-    if(token(&s)) {
+    if (token(&s)) {
         json_decref(value);
-        set_error(&s, "<format>", json_error_invalid_format, "Garbage after format string");
+        set_error(&s, "<format>", json_error_invalid_format,
+                  "Garbage after format string");
         return NULL;
     }
 
     return value;
 }
 
-json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...)
-{
+json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...) {
     json_t *value;
     va_list ap;
 
@@ -877,8 +861,7 @@ json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...)
     return value;
 }
 
-json_t *json_pack(const char *fmt, ...)
-{
+json_t *json_pack(const char *fmt, ...) {
     json_t *value;
     va_list ap;
 
@@ -889,21 +872,21 @@ json_t *json_pack(const char *fmt, ...)
     return value;
 }
 
-int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags,
-                    const char *fmt, va_list ap)
-{
+int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt,
+                    va_list ap) {
     scanner_t s;
     va_list ap_copy;
 
-    if(!root) {
+    if (!root) {
         jsonp_error_init(error, "<root>");
         jsonp_error_set(error, -1, -1, 0, json_error_null_value, "NULL root value");
         return -1;
     }
 
-    if(!fmt || !*fmt) {
+    if (!fmt || !*fmt) {
         jsonp_error_init(error, "<format>");
-        jsonp_error_set(error, -1, -1, 0, json_error_invalid_argument, "NULL or empty format string");
+        jsonp_error_set(error, -1, -1, 0, json_error_invalid_argument,
+                        "NULL or empty format string");
         return -1;
     }
     jsonp_error_init(error, NULL);
@@ -912,23 +895,24 @@ int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags,
     next_token(&s);
 
     va_copy(ap_copy, ap);
-    if(unpack(&s, root, &ap_copy)) {
+    if (unpack(&s, root, &ap_copy)) {
         va_end(ap_copy);
         return -1;
     }
     va_end(ap_copy);
 
     next_token(&s);
-    if(token(&s)) {
-        set_error(&s, "<format>", json_error_invalid_format, "Garbage after format string");
+    if (token(&s)) {
+        set_error(&s, "<format>", json_error_invalid_format,
+                  "Garbage after format string");
         return -1;
     }
 
     return 0;
 }
 
-int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...)
-{
+int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt,
+                   ...) {
     int ret;
     va_list ap;
 
@@ -939,8 +923,7 @@ int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *
     return ret;
 }
 
-int json_unpack(json_t *root, const char *fmt, ...)
-{
+int json_unpack(json_t *root, const char *fmt, ...) {
     int ret;
     va_list ap;
 

+ 23 - 36
jansson.mod/jansson/src/strbuffer.c

@@ -9,22 +9,21 @@
 #define _GNU_SOURCE
 #endif
 
+#include "strbuffer.h"
+#include "jansson_private.h"
 #include <stdlib.h>
 #include <string.h>
-#include "jansson_private.h"
-#include "strbuffer.h"
 
-#define STRBUFFER_MIN_SIZE  16
-#define STRBUFFER_FACTOR    2
-#define STRBUFFER_SIZE_MAX  ((size_t)-1)
+#define STRBUFFER_MIN_SIZE 16
+#define STRBUFFER_FACTOR   2
+#define STRBUFFER_SIZE_MAX ((size_t)-1)
 
-int strbuffer_init(strbuffer_t *strbuff)
-{
+int strbuffer_init(strbuffer_t *strbuff) {
     strbuff->size = STRBUFFER_MIN_SIZE;
     strbuff->length = 0;
 
     strbuff->value = jsonp_malloc(strbuff->size);
-    if(!strbuff->value)
+    if (!strbuff->value)
         return -1;
 
     /* initialize to empty */
@@ -32,9 +31,8 @@ int strbuffer_init(strbuffer_t *strbuff)
     return 0;
 }
 
-void strbuffer_close(strbuffer_t *strbuff)
-{
-    if(strbuff->value)
+void strbuffer_close(strbuffer_t *strbuff) {
+    if (strbuff->value)
         jsonp_free(strbuff->value);
 
     strbuff->size = 0;
@@ -42,47 +40,38 @@ void strbuffer_close(strbuffer_t *strbuff)
     strbuff->value = NULL;
 }
 
-void strbuffer_clear(strbuffer_t *strbuff)
-{
+void strbuffer_clear(strbuffer_t *strbuff) {
     strbuff->length = 0;
     strbuff->value[0] = '\0';
 }
 
-const char *strbuffer_value(const strbuffer_t *strbuff)
-{
-    return strbuff->value;
-}
+const char *strbuffer_value(const strbuffer_t *strbuff) { return strbuff->value; }
 
-char *strbuffer_steal_value(strbuffer_t *strbuff)
-{
+char *strbuffer_steal_value(strbuffer_t *strbuff) {
     char *result = strbuff->value;
     strbuff->value = NULL;
     return result;
 }
 
-int strbuffer_append_byte(strbuffer_t *strbuff, char byte)
-{
+int strbuffer_append_byte(strbuffer_t *strbuff, char byte) {
     return strbuffer_append_bytes(strbuff, &byte, 1);
 }
 
-int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size)
-{
-    if(size >= strbuff->size - strbuff->length)
-    {
+int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) {
+    if (size >= strbuff->size - strbuff->length) {
         size_t new_size;
         char *new_value;
 
         /* avoid integer overflow */
-        if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR
-            || size > STRBUFFER_SIZE_MAX - 1
-            || strbuff->length > STRBUFFER_SIZE_MAX - 1 - size)
+        if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR ||
+            size > STRBUFFER_SIZE_MAX - 1 ||
+            strbuff->length > STRBUFFER_SIZE_MAX - 1 - size)
             return -1;
 
-        new_size = max(strbuff->size * STRBUFFER_FACTOR,
-                       strbuff->length + size + 1);
+        new_size = max(strbuff->size * STRBUFFER_FACTOR, strbuff->length + size + 1);
 
         new_value = jsonp_malloc(new_size);
-        if(!new_value)
+        if (!new_value)
             return -1;
 
         memcpy(new_value, strbuff->value, strbuff->length);
@@ -99,13 +88,11 @@ int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size)
     return 0;
 }
 
-char strbuffer_pop(strbuffer_t *strbuff)
-{
-    if(strbuff->length > 0) {
+char strbuffer_pop(strbuffer_t *strbuff) {
+    if (strbuff->length > 0) {
         char c = strbuff->value[--strbuff->length];
         strbuff->value[strbuff->length] = '\0';
         return c;
-    }
-    else
+    } else
         return '\0';
 }

+ 4 - 3
jansson.mod/jansson/src/strbuffer.h

@@ -8,15 +8,16 @@
 #ifndef STRBUFFER_H
 #define STRBUFFER_H
 
+#include "jansson.h"
 #include <stdlib.h>
 
 typedef struct {
     char *value;
-    size_t length;   /* bytes used */
-    size_t size;     /* bytes allocated */
+    size_t length; /* bytes used */
+    size_t size;   /* bytes allocated */
 } strbuffer_t;
 
-int strbuffer_init(strbuffer_t *strbuff) JANSSON_ATTRS(warn_unused_result);
+int strbuffer_init(strbuffer_t *strbuff) JANSSON_ATTRS((warn_unused_result));
 void strbuffer_close(strbuffer_t *strbuff);
 
 void strbuffer_clear(strbuffer_t *strbuff);

+ 19 - 31
jansson.mod/jansson/src/strconv.c

@@ -1,23 +1,16 @@
+#include "jansson_private.h"
+#include "strbuffer.h"
 #include <assert.h>
 #include <errno.h>
+#include <math.h>
 #include <stdio.h>
 #include <string.h>
-#include <math.h>
-#ifdef __MINGW32__
-#undef __NO_ISOCEXT /* ensure stdlib.h will declare prototypes for mingw own 'strtod' replacement, called '__strtod' */
-#endif
-#include "jansson_private.h"
-#include "strbuffer.h"
 
 /* need jansson_private_config.h to get the correct snprintf */
 #ifdef HAVE_CONFIG_H
 #include <jansson_private_config.h>
 #endif
 
-#ifdef __MINGW32__
-#define strtod __strtod
-#endif
-
 #if JSON_HAVE_LOCALECONV
 #include <locale.h>
 
@@ -31,41 +24,38 @@
     this way. Multi-threaded programs should use uselocale() instead.
 */
 
-static void to_locale(strbuffer_t *strbuffer)
-{
+static void to_locale(strbuffer_t *strbuffer) {
     const char *point;
     char *pos;
 
     point = localeconv()->decimal_point;
-    if(*point == '.') {
+    if (*point == '.') {
         /* No conversion needed */
         return;
     }
 
     pos = strchr(strbuffer->value, '.');
-    if(pos)
+    if (pos)
         *pos = *point;
 }
 
-static void from_locale(char *buffer)
-{
+static void from_locale(char *buffer) {
     const char *point;
     char *pos;
 
     point = localeconv()->decimal_point;
-    if(*point == '.') {
+    if (*point == '.') {
         /* No conversion needed */
         return;
     }
 
     pos = strchr(buffer, *point);
-    if(pos)
+    if (pos)
         *pos = '.';
 }
 #endif
 
-int jsonp_strtod(strbuffer_t *strbuffer, double *out)
-{
+int jsonp_strtod(strbuffer_t *strbuffer, double *out) {
     double value;
     char *end;
 
@@ -77,7 +67,7 @@ int jsonp_strtod(strbuffer_t *strbuffer, double *out)
     value = strtod(strbuffer->value, &end);
     assert(end == strbuffer->value + strbuffer->length);
 
-    if((value == HUGE_VAL || value == -HUGE_VAL) && errno == ERANGE) {
+    if ((value == HUGE_VAL || value == -HUGE_VAL) && errno == ERANGE) {
         /* Overflow */
         return -1;
     }
@@ -96,11 +86,11 @@ int jsonp_dtostr(char *buffer, size_t size, double value, int precision, int fra
         precision = 17;
 
     ret = snprintf(buffer, size, fractional_digits ? "%.*f" : "%.*g", precision, value);
-    if(ret < 0)
+    if (ret < 0)
         return -1;
 
     length = (size_t)ret;
-    if(length >= size)
+    if (length >= size)
         return -1;
 
 #if JSON_HAVE_LOCALECONV
@@ -109,10 +99,8 @@ int jsonp_dtostr(char *buffer, size_t size, double value, int precision, int fra
 
     /* Make sure there's a dot or 'e' in the output. Otherwise
        a real is converted to an integer when decoding */
-    if(strchr(buffer, '.') == NULL &&
-       strchr(buffer, 'e') == NULL)
-    {
-        if(length + 3 >= size) {
+    if (strchr(buffer, '.') == NULL && strchr(buffer, 'e') == NULL) {
+        if (length + 3 >= size) {
             /* No space to append ".0" */
             return -1;
         }
@@ -125,17 +113,17 @@ int jsonp_dtostr(char *buffer, size_t size, double value, int precision, int fra
     /* Remove leading '+' from positive exponent. Also remove leading
        zeros from exponents (added by some printf() implementations) */
     start = strchr(buffer, 'e');
-    if(start) {
+    if (start) {
         start++;
         end = start + 1;
 
-        if(*start == '-')
+        if (*start == '-')
             start++;
 
-        while(*end == '0')
+        while (*end == '0')
             end++;
 
-        if(end != start) {
+        if (end != start) {
             memmove(start, end, length - (size_t)(end - buffer));
             length -= (size_t)(end - start);
         }

+ 41 - 69
jansson.mod/jansson/src/utf.c

@@ -5,107 +5,85 @@
  * it under the terms of the MIT license. See LICENSE for details.
  */
 
-#include <string.h>
 #include "utf.h"
+#include <string.h>
 
-int utf8_encode(int32_t codepoint, char *buffer, size_t *size)
-{
-    if(codepoint < 0)
+int utf8_encode(int32_t codepoint, char *buffer, size_t *size) {
+    if (codepoint < 0)
         return -1;
-    else if(codepoint < 0x80)
-    {
+    else if (codepoint < 0x80) {
         buffer[0] = (char)codepoint;
         *size = 1;
-    }
-    else if(codepoint < 0x800)
-    {
+    } else if (codepoint < 0x800) {
         buffer[0] = 0xC0 + ((codepoint & 0x7C0) >> 6);
         buffer[1] = 0x80 + ((codepoint & 0x03F));
         *size = 2;
-    }
-    else if(codepoint < 0x10000)
-    {
+    } else if (codepoint < 0x10000) {
         buffer[0] = 0xE0 + ((codepoint & 0xF000) >> 12);
         buffer[1] = 0x80 + ((codepoint & 0x0FC0) >> 6);
         buffer[2] = 0x80 + ((codepoint & 0x003F));
         *size = 3;
-    }
-    else if(codepoint <= 0x10FFFF)
-    {
+    } else if (codepoint <= 0x10FFFF) {
         buffer[0] = 0xF0 + ((codepoint & 0x1C0000) >> 18);
         buffer[1] = 0x80 + ((codepoint & 0x03F000) >> 12);
         buffer[2] = 0x80 + ((codepoint & 0x000FC0) >> 6);
         buffer[3] = 0x80 + ((codepoint & 0x00003F));
         *size = 4;
-    }
-    else
+    } else
         return -1;
 
     return 0;
 }
 
-size_t utf8_check_first(char byte)
-{
+size_t utf8_check_first(char byte) {
     unsigned char u = (unsigned char)byte;
 
-    if(u < 0x80)
+    if (u < 0x80)
         return 1;
 
-    if(0x80 <= u && u <= 0xBF) {
+    if (0x80 <= u && u <= 0xBF) {
         /* second, third or fourth byte of a multi-byte
            sequence, i.e. a "continuation byte" */
         return 0;
-    }
-    else if(u == 0xC0 || u == 0xC1) {
+    } else if (u == 0xC0 || u == 0xC1) {
         /* overlong encoding of an ASCII byte */
         return 0;
-    }
-    else if(0xC2 <= u && u <= 0xDF) {
+    } else if (0xC2 <= u && u <= 0xDF) {
         /* 2-byte sequence */
         return 2;
     }
 
-    else if(0xE0 <= u && u <= 0xEF) {
+    else if (0xE0 <= u && u <= 0xEF) {
         /* 3-byte sequence */
         return 3;
-    }
-    else if(0xF0 <= u && u <= 0xF4) {
+    } else if (0xF0 <= u && u <= 0xF4) {
         /* 4-byte sequence */
         return 4;
-    }
-    else { /* u >= 0xF5 */
+    } else { /* u >= 0xF5 */
         /* Restricted (start of 4-, 5- or 6-byte sequence) or invalid
            UTF-8 */
         return 0;
     }
 }
 
-size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint)
-{
+size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint) {
     size_t i;
     int32_t value = 0;
     unsigned char u = (unsigned char)buffer[0];
 
-    if(size == 2)
-    {
+    if (size == 2) {
         value = u & 0x1F;
-    }
-    else if(size == 3)
-    {
+    } else if (size == 3) {
         value = u & 0xF;
-    }
-    else if(size == 4)
-    {
+    } else if (size == 4) {
         value = u & 0x7;
-    }
-    else
+    } else
         return 0;
 
-    for(i = 1; i < size; i++)
-    {
+    for (i = 1; i < size; i++) {
         u = (unsigned char)buffer[i];
 
-        if(u < 0x80 || u > 0xBF) {
+        if (u < 0x80 || u > 0xBF) {
             /* not a continuation byte */
             return 0;
         }
@@ -113,70 +91,64 @@ size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint)
         value = (value << 6) + (u & 0x3F);
     }
 
-    if(value > 0x10FFFF) {
+    if (value > 0x10FFFF) {
         /* not in Unicode range */
         return 0;
     }
 
-    else if(0xD800 <= value && value <= 0xDFFF) {
+    else if (0xD800 <= value && value <= 0xDFFF) {
         /* invalid code point (UTF-16 surrogate halves) */
         return 0;
     }
 
-    else if((size == 2 && value < 0x80) ||
-            (size == 3 && value < 0x800) ||
-            (size == 4 && value < 0x10000)) {
+    else if ((size == 2 && value < 0x80) || (size == 3 && value < 0x800) ||
+             (size == 4 && value < 0x10000)) {
         /* overlong encoding */
         return 0;
     }
 
-    if(codepoint)
+    if (codepoint)
         *codepoint = value;
 
     return 1;
 }
 
-const char *utf8_iterate(const char *buffer, size_t bufsize, int32_t *codepoint)
-{
+const char *utf8_iterate(const char *buffer, size_t bufsize, int32_t *codepoint) {
     size_t count;
     int32_t value;
 
-    if(!bufsize)
+    if (!bufsize)
         return buffer;
 
     count = utf8_check_first(buffer[0]);
-    if(count <= 0)
+    if (count <= 0)
         return NULL;
 
-    if(count == 1)
+    if (count == 1)
         value = (unsigned char)buffer[0];
-    else
-    {
-        if(count > bufsize || !utf8_check_full(buffer, count, &value))
+    else {
+        if (count > bufsize || !utf8_check_full(buffer, count, &value))
             return NULL;
     }
 
-    if(codepoint)
+    if (codepoint)
         *codepoint = value;
 
     return buffer + count;
 }
 
-int utf8_check_string(const char *string, size_t length)
-{
+int utf8_check_string(const char *string, size_t length) {
     size_t i;
 
-    for(i = 0; i < length; i++)
-    {
+    for (i = 0; i < length; i++) {
         size_t count = utf8_check_first(string[i]);
-        if(count == 0)
+        if (count == 0)
             return 0;
-        else if(count > 1)
-        {
-            if(count > length - i)
+        else if (count > 1) {
+            if (count > length - i)
                 return 0;
 
-            if(!utf8_check_full(&string[i], count, NULL))
+            if (!utf8_check_full(&string[i], count, NULL))
                 return 0;
 
             i += count - 1;

+ 1 - 0
jansson.mod/jansson/src/utf.h

@@ -12,6 +12,7 @@
 #include <jansson_private_config.h>
 #endif
 
+#include <stddef.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 231 - 233
jansson.mod/jansson/src/value.c


+ 2 - 6
jansson.mod/jansson/src/version.c

@@ -11,13 +11,9 @@
 
 #include "jansson.h"
 
-const char *jansson_version_str(void)
-{
-    return JANSSON_VERSION;
-}
+const char *jansson_version_str(void) { return JANSSON_VERSION; }
 
-int jansson_version_cmp(int major, int minor, int micro)
-{
+int jansson_version_cmp(int major, int minor, int micro) {
     int diff;
 
     if ((diff = JANSSON_MAJOR_VERSION - major)) {

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.