Commit Graph

1018 Commits

Author SHA1 Message Date
Petri Lehtinen
55ea6d44dd doc: Rename "Portability" to "Thread-safety"
Fixes #545
2020-11-19 17:27:03 +02:00
Petri Lehtinen
9a0fc069bf
Merge pull request #520 from Mephistophiles/getn
Add support getn, setn functions
2020-11-19 17:21:12 +02:00
Petri Lehtinen
cc318fc042
Merge pull request #555 from kiyolee/size_t-warnings
Fix size_t related MSVC compiler warnings
2020-11-15 06:32:29 +02:00
Kelvin Lee
638449c43d C11 %zd is bit overkill here. Especially requiring conditional compile. 2020-11-06 15:51:14 +11:00
Kelvin Lee
38c4b80ab7 Fix hashsize() should return size_t. 2020-11-06 08:40:20 +11:00
Kelvin Lee
ec1b6318e4 Use size_t to receive result from fread()/ftell(). 2020-11-05 22:06:38 +11:00
Kelvin Lee
1d8201c656 Print size_t properly with C11 %zd support. 2020-11-05 22:05:54 +11:00
Maxim Zhukov
0758caaac0 reuse key len from loop check for better performance
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-09-01 10:22:14 +03:00
Maxim Zhukov
16a3899a9e conformance: remove U+0000 restriction for object keys
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-09-01 10:22:14 +03:00
Maxim Zhukov
ca6775dee4 introduce new fixed-size key API
This commit added functions working with fixed-size strings (non null-terminated also).
It's helpful for the following cases:
* getting key from substring without copying to separate buffer (better perfomance)
* using pure UTF-8 keys for the objets
* hack: set binary structs as the keys (see test_binary_keys)

added functions:
 * json_object_getn
 * json_object_setn
 * json_object_setn_nocheck
 * json_object_setn_new
 * json_object_setn_new_nocheck
 * json_object_deln
 * json_object_iter_key_len

added iterators:
 * json_object_keylen_foreach
 * json_object_keylen_foreach_safe

Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-09-01 10:22:14 +03:00
Maxim Zhukov
ba4503804b pass length of the key to internal API
Use key length for internal API

Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-08-12 09:57:14 +03:00
Maxim Zhukov
966f9cc20a sort tests by alpha order
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-08-12 09:57:07 +03:00
Petri Lehtinen
a740f15c17
Merge pull request #546 from i-ky/patch-1
Fix couple of typos
2020-08-09 10:28:12 +03:00
i-ky
601b568b8d
Fix couple of typos
"This sections describes" -> "This section describes"
2020-08-09 00:19:39 +03:00
Petri Lehtinen
1112580f4a
Merge pull request #544 from i-ky/patch-1
Lift "Depth of nested values" to a higher level
2020-08-08 20:25:37 +03:00
i-ky
d9c5b1d4df
Lift "Depth of nested values" to a higher level
Currently this section is under "Numbers" which seems to be wrong.
2020-08-08 14:10:16 +03:00
Petri Lehtinen
a154389827
Merge pull request #543 from ploxiln/sphinx3
doc: compatibility with Sphinx-3
2020-08-08 13:15:23 +03:00
Pierce Lopez
c329fd7bc8 doc: add return types for function-like macros
The Sphinx-3.0 c:function:: directive requires the return type.

Sphinx-3.0 also adds function-like macro support to the c:macro::
directive, which Sphinx-1.x and Sphinx-2.x do not support, but it
is probably a good idea to keep compatibility with slightly older
Sphinx for now.
2020-08-07 02:35:27 -04:00
Pierce Lopez
94318890c0 doc: do not use references for standard C types or file names
Use double-backtick quoting instead. It has the same effect
(because these links had nowhere to link to) but it does not
result in loud warnings about broken references by default with Sphinx-3.x.
2020-08-07 02:34:25 -04:00
Pierce Lopez
798d40c3f3 doc: convert refcounting directive to a class
Directive functions are no longer supported in Sphinx-3.0
but directive classes have been supported since early 1.x
2020-08-07 01:54:45 -04:00
Petri Lehtinen
73ccec0601
Merge pull request #540 from smcv/default-symver
build: Add a symbol version to all exported symbols
2020-07-20 13:01:34 +03:00
Simon McVittie
ca80d5127e build: Add a symbol version to all exported symbols for glibc
The --default-symver linker option attaches a default version definition
(the SONAME) to every exported symbol. It is supported since at least
GNU binutils 2.22 in 2011 (older versions not tested).

With this version definition, newly-linked binaries that depend on the
jansson shared library will refer to its symbols in a versioned form,
preventing their references from being resolved to a symbol of the same
name exported by json-c or json-glib if those libraries appear in
dependency search order before jansson, which will usually result in
a crash. This is necessary because ELF symbol resolution normally uses
a single flat namespace, not a tree like Windows symbol resolution.
At least one symbol (json_object_iter_next()) is exported by all three
JSON libraries.

Linking with -Bsymbolic is not enough to have this effect in all cases,
because -Bsymbolic only affects symbol lookup within a shared object,
for example when parse_json() calls json_decref(). It does not affect
calls from external code into jansson, unless jansson was statically
linked into the external caller.

This change will also not prevent code that depends on json-c or
json-glib from finding jansson's symbols and crashing; to prevent
that, a corresponding change in json-c or json-glib would be needed.

Adding a symbol-version is a backwards-compatible change, but once
added, removing or changing the symbol-version would be an incompatible
change that requires a SONAME bump.

Resolves: https://github.com/akheron/jansson/issues/523
(when combined with an equivalent change to json-c).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-02 09:54:40 +01:00
Petri Lehtinen
52dfc3dd4a
Merge pull request #537 from stoeckmann/vsnprintf
Handle vsnprintf corner cases.
2020-05-23 20:42:25 +03:00
Tobias Stoeckmann
38b001edbd Handle vsnprintf corner cases.
The function vsnprintf returns a negative value on error, e.g. on
an invalid format. It's best to return NULL in such a case.

Also avoid a signed integer overflow if vsnprintf returns INT_MAX.
This is undefined behaviour in C and has to be avoided.

A negative value is returned with a call like:
json_sprintf("%111111111111111s", "", "");

INT_MAX is returned with a call like:
json_sprintf("%647s%2147483000s", "", "");
2020-05-23 12:34:40 +02:00
Petri Lehtinen
e9ebfa7e77 jansson 2.13.1 2020-05-07 21:38:59 +03:00
Petri Lehtinen
3f4d948652
Merge pull request #535 from xry111/clang-format-check-dist-fix
add `scripts` directory to EXTRA_DIST
2020-05-07 21:29:30 +03:00
Petri Lehtinen
a839d3cad6
Merge pull request #534 from xry111/shared_lib_interface_fix
add jansson_* to shared library exports
2020-05-07 21:28:47 +03:00
Xℹ Ruoyao
2d2efde34a add scripts directory to EXTRA_DIST 2020-05-06 18:01:19 +08:00
Xℹ Ruoyao
bcb6b6f3fd add jansson_* to shared library exports 2020-05-06 17:31:48 +08:00
Petri Lehtinen
2882ead5bb jansson 2.13 2020-05-05 07:07:16 +03:00
Petri Lehtinen
4c9018cc4c
Merge pull request #521 from NanXiao/patch-1
Update apiref.rst
2020-01-21 10:15:01 +02:00
Nan Xiao
e15fd861e1
Update apiref.rst 2020-01-21 14:27:52 +08:00
Petri Lehtinen
ca88677bdd
Merge pull request #510 from AllenX2018/improve-build-doc
add MinGW build guideline and tips to disable building docs
2019-10-24 11:23:00 +03:00
Petri Lehtinen
6e211b24fe
Fix the length of a section heading 2019-10-24 11:22:46 +03:00
Petri Lehtinen
50c9623e37
Merge pull request #509 from AllenX2018/update-CHANGES
add changes since v2.12
2019-10-24 11:19:52 +03:00
Petri Lehtinen
3704e1cd78
Small modifications to CHANGES 2019-10-24 11:19:34 +03:00
allen
67900c85d3 add changes since v2.12 2019-10-22 18:52:55 +08:00
Petri Lehtinen
d288cc157e
Merge pull request #508 from akheron/clang-format
Format code with clang-format
2019-10-21 11:07:53 +03:00
AllenX2018
5b8ff675b3 add MinGW build guideline, add new version of Visual Studio 2019-10-21 15:53:33 +08:00
Petri Lehtinen
78da35682a Set autoconf bug-report param to point to github issues 2019-10-21 08:56:03 +03:00
Petri Lehtinen
bb4f99e919 Fix clang-format version checking 2019-10-21 08:56:03 +03:00
Petri Lehtinen
f912430cda Run clang-format with make check 2019-10-21 08:56:03 +03:00
Petri Lehtinen
a8f5fa5f5a Tweak clang-format configuration a bit
Set ColumnLimit to 90, remove AllowShortCaseLabelsOnASingleLine.
2019-10-21 08:56:03 +03:00
Petri Lehtinen
7c0297abe8 Support running a specific clang-format version in CI 2019-10-21 08:55:01 +03:00
Petri Lehtinen
1a95a60f80 Run clang-format in CI, fail the build if everything's not formatted 2019-10-21 08:55:01 +03:00
Petri Lehtinen
be0fca914e Add scripts for running clang-format 2019-10-21 08:55:01 +03:00
Petri Lehtinen
79fe8c3435 Run clang-format on *.c, *.h 2019-10-21 08:55:01 +03:00
Petri Lehtinen
7dc463ee4e Add clang-format configuration 2019-10-21 08:53:03 +03:00
Petri Lehtinen
79075d5393
Merge pull request #498 from AllenX2018/fix-issue441
fix issue #441: remove strtod definition in strconv.c
2019-10-21 08:51:36 +03:00
willson-chen
c3958a326c remove undef __NO_ISOCEXT for strtod compatiblity 2019-10-21 11:13:39 +08:00