summaryrefslogtreecommitdiff
path: root/json_util.c
Commit message (Collapse)AuthorAgeFilesLines
* fix json_parse_uint64() usage of errnoPierce Lopez2020-05-101-5/+3
| | | | | introduced in #542 fixes #601
* Re-do clang-format.Eric Haszlakiewicz2020-04-181-1/+0
|
* Make json_abort() internal to json_object.cEric Haszlakiewicz2020-04-181-6/+0
|
* Issue #568: fix the strtoll and strtoull handing so config.h ends up ↵Eric Haszlakiewicz2020-04-091-5/+0
| | | | creating defines for those only when needed, which should exclude mingw environments.
* clang-format the filesdota172020-04-031-71/+87
|
* add the disabling formatting coments and adjust the partial code manulydota172020-04-031-10/+13
|
* Fixes various Wreturn-type and Wimplicit-fallthrough errors on Mingw-w64Jehan2020-03-161-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a recent regression since commit 6359b798479d379a3202e02c6a938d9b40c0d856 which added various assert(0) calls (often replacing return-s). With Ming-W64 compiler, json-c build was failing with various errors of the sort: > /home/jehan/dev/src/json-c/json_object.c: In function 'json_object_int_inc': > /home/jehan/dev/src/json-c/json_object.c:841:1: error: control reaches end of non-void function [-Werror=return-type] > 841 | } > | ^ > In file included from /home/jehan/dev/src/json-c/json_object.c:17: > /home/jehan/dev/src/json-c/json_object.c: In function 'json_object_get_double': > /home/jehan/.local/share/crossroad/roads/w64/json-c/include/assert.h:76:4: error: this statement may fall through [-Werror=implicit-fallthrough=] > 76 | (_assert(#_Expression,__FILE__,__LINE__),0)) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > /home/jehan/dev/src/json-c/json_object.c:1070:7: note: in expansion of macro 'assert' > 1070 | assert(0); > | ^~~~~~ > /home/jehan/dev/src/json-c/json_object.c:1072:3: note: here > 1072 | case json_type_boolean: > | ^~~~ The problem is that Mingw-w64 does not consider assert() as a noreturn (even assert(0)), because it has to be compatible by Microsoft libraries. See the discussion here: https://sourceforge.net/p/mingw-w64/bugs/306/ Instead let's create a new json_abort() function which is basically just an abort() function with an optional message, for such cases where abortion was non-conditional (using assert() and using the assertion condition as a message here was clearly a misuse of the function). And mark json_abort() as 'noreturn', as well as 'cold' for optimization purpose (this is code we expect to never run, unless there is a bug, that is). Finally let's use this json_abort() instead of previous misused assert() calls.
* modify the json_object, replace c_int64/c_uint64 with struct{union{int64, ↵dota172020-02-271-1/+0
| | | | uint64},...}
* add uint64 data to json-cdota172020-02-251-1/+20
|
* Define vars earlier to fix old Windows builds.Eric Haszlakiewicz2019-11-101-2/+3
|
* Add a json_object_from_fd_ex() function, to allow the max nesting depth to ↵Eric Haszlakiewicz2019-11-101-3/+25
| | | | be specified.
* Rename _set_last_err() to _json_c_set_last_err().Eric Haszlakiewicz2017-11-291-9/+9
|
* On VS 2013 and newer, actually use strtoll instead of redefining it to ↵Eric Haszlakiewicz2017-11-261-1/+4
| | | | _strtoi64.
* json_util: define `strtoll` as _strtoi64 for MSVCAlexandru Ardelean2017-11-071-0/+1
| | | | | | | | | Got the idea from this blog post: http://www.enchantedage.com/node/231 Simple & concise stuff :) Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* Use strtoll to parse intsJason King2017-09-071-115/+8
|
* Issue #173: since some sscanf implementations return 0 for non-zero inputs, ↵Eric Haszlakiewicz2017-09-051-1/+3
| | | | directly check for "0" in the input.
* PR#331: for Visual Studio, use a snprintf/vsnprintf wrapper that ensures the ↵Eric Haszlakiewicz2017-08-251-6/+1
| | | | string is terminated.
* Fix parsing doubles for mingwtopilski2017-07-301-1/+3
|
* build: make `strerror()` override-ableAlexandru Ardelean2017-07-131-1/+2
| | | | | | | | | | | | | | | If we want to override `strerror()` in libjson-c to make tests consistent across platforms, we need to do it build-wide as configure/build option. Apple linkers make it really hard to override functions at link-time, and this seems to be locked down on travis-ci.org [ for security reasons I assume ]. While I got it to work locally, it did not work when running on travis. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* Issue #161: add a json_object_to_fd() function.Eric Haszlakiewicz2017-06-181-30/+51
|
* Make _set_last_err() non-static so it can be used outside of json_util.cEric Haszlakiewicz2017-06-181-2/+1
|
* Issue #189: Eliminate use of MC_ERROR from json_util.c, and add a ↵Eric Haszlakiewicz2016-06-261-15/+27
| | | | | | json_util_get_last_err() function to retrieve the error for those callers that care about it. Add tests and descriptions for the functions in json_util.c
* Introduce json_object_from_fdMichael Heimpold2014-07-211-11/+26
| | | | | | | Also refactor json_object_from_file to use json_object_from_fd internally. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
* Move the json_min() and json_max() macros to json_util.h and mark everything ↵Eric Haszlakiewicz2014-05-041-1/+0
| | | | | | else in bits.h deprecated. Eliminate all uses of bits.h within the json-c code.
* Update json_utilPascal Bach2013-08-131-2/+2
| | | | | filename should be passed as const char* to functions json_object_to_file and json_object_to_file
* Eliminate use of MC_ABORT in json-c code, and mark MC_ABORT/mc_abort deprecated.Eric Haszlakiewicz2013-06-291-2/+2
| | | | Also adjust an error message in json_util to make it unique. Fixes #87.
* Fix C89 compat needed by MSVCAnatol Belski2013-06-041-4/+5
|
* Merge branch 'remicollet-issue-float'Eric Haszlakiewicz2013-02-261-0/+5
|\ | | | | | | | | Conflicts: json_util.c
| * move locale change to be global for perfRemi Collet2012-12-131-21/+1
| |
| * float parsing must be locale independentRemi Collet2012-11-271-0/+25
| |
* | Add a runtime check to see if parse_int64 needs to workaround sscanf bugs. ↵Eric Haszlakiewicz2013-02-091-18/+63
| | | | | | | | If that workaround is not needed parsing is nearly twice as fast.
* | Enable -Werror and fix a number of minor warnings that existed.Eric Haszlakiewicz2013-02-091-2/+3
| |
* | rename _errnoGreg Hazel2013-01-031-5/+5
|/
* Initialize errno before calling sscanf in json_parse_int64() so parsing ↵Eric Haszlakiewicz2012-07-291-3/+6
| | | | valid numbers after parsing an out of range number works.
* Remove unnecessary comment from json_util.cEric Haszlakiewicz2012-07-081-1/+1
|
* Replaced #if HAVE_X with #ifdef HAVE_X as the former test is troublemaker ↵Mateusz Loskot2012-05-211-6/+12
| | | | with #define HAVE_X where #define HAVE_X 1|0 is meant.
* Add a json_object_to_json_string_ext() function to allow the formatting of ↵Eric Haszlakiewicz2012-04-281-5/+14
| | | | | | | | | output to be selected. There are now three options: JSON_C_TO_STRING_SPACED, JSON_C_TO_STRING_PLAIN and JSON_C_TO_STRING_PRETTY. This also add a json_object_to_file_ext() that takes the same flags. Existing output of json_object_to_json_string() is unchanged, and uses JSON_C_TO_STRING_SPACED. Thanks fo Grant Edwards for the initial patches.
* Some updates to make the code compatible with VC 9 (2008)John Arbash Meinel2012-02-011-3/+6
| | | | | VC 9 doesn't support late variable declarations, and doesn't have inttypes so we need some direct definitions of a couple of more types.
* Add a json_type_to_name() function which returns a string that describes the ↵Eric Haszlakiewicz2011-05-031-0/+23
| | | | | | type. Useful for logging. git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@67 327403b1-1117-474d-bef2-5cb71233fd97
* Simplify things by storing integer values only as int64_t's internally, andehaszla2010-12-071-4/+18
| | | | | | | | | | omit the range check during parsing since we already have the checks when accessing the value. There is no longer a json_type_int64, only json_type_int. Fix some problems with parsing 0 and -0 values, and add a couple of tests. Fix some minor compile issues on HPUX environments. git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@60 327403b1-1117-474d-bef2-5cb71233fd97
* * Fix file descriptor leak if memory allocation fails in json_utilMichael Clark2010-10-131-2/+4
| | | | | | | | Zachary Blair, zack_blair at hotmail dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@59 327403b1-1117-474d-bef2-5cb71233fd97
* * Fix file descriptor leak if memory allocation fails in json_utilMichael Clark2010-10-131-0/+1
| | | | | | | | Zachary Blair, zack_blair at hotmail dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@58 327403b1-1117-474d-bef2-5cb71233fd97
* * Add int64 support. Two new functions json_object_net_int64 andMichael Clark2010-10-061-0/+65
| | | | | | | | | | json_object_get_int64. Binary compatibility preserved. Eric Haszlakiewicz, EHASZLA at transunion com Rui Miguel Silva Seabra, rms at 1407 dot org git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@56 327403b1-1117-474d-bef2-5cb71233fd97
* * Make json_object_from_file take const char *filenameMichael Clark2009-08-271-1/+1
| | | | | | | Spotted by Vikram Raj V, vsagar at attinteractive dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@55 327403b1-1117-474d-bef2-5cb71233fd97
* * Don't use this as a variable, so we can compile with a C++ compilerMichael Clark2009-02-251-3/+3
| | | | | | | | | | * Add casts from void* to type of assignment when using malloc * Add #ifdef __cplusplus guards to all of the headers * Add typedefs for json_object, json_tokener, array_list, printbuf, lh_table Michael Clark, <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@33 327403b1-1117-474d-bef2-5cb71233fd97
* Add const correctness to public interfacesMichael Clark2009-01-061-1/+1
| | | | | | | | | | Gerard Krol, g dot c dot krol at student dot tudelft dot nl Update version number to 0.9 git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@27 327403b1-1117-474d-bef2-5cb71233fd97
* * Fix bug with use of capital E in numbers with exponentsMichael Clark2007-12-071-0/+1
| | | | | | | | | Mateusz Loskot, mateusz at loskot dot net * Add stddef.h include git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@19 327403b1-1117-474d-bef2-5cb71233fd97
* * Add macros to enable compiling out debug codeMichael Clark2007-10-251-6/+6
| | | | | | | Geoffrey Young, geoff at modperlcookbook dot org git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@18 327403b1-1117-474d-bef2-5cb71233fd97
* * Fix bug in escaping of control charactersMichael Clark2007-03-131-1/+6
| | | | | | | | | | Johan Bj�rklund, johbjo09 at kth dot se * Remove include "config.h" from headers (should only be included from .c files) Michael Clark <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@12 327403b1-1117-474d-bef2-5cb71233fd97
* * Make headers C++ compatible by change *this to *objMichael Clark2007-03-131-11/+4
| | | | | | | | | | | | | | | * Add ifdef C++ extern "C" to headers * Use simpler definition of min and max in bits.h Larry Lansing, llansing at fuzzynerd dot com * Remove automake 1.6 requirement * Move autogen commands into autogen.sh. Update README * Remove error pointer special case for Windows * Change license from LGPL to MIT Michael Clark <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@10 327403b1-1117-474d-bef2-5cb71233fd97