Package init

This commit is contained in:
overweight 2019-09-30 10:54:03 -04:00
commit bdc61b2c1e
11 changed files with 774 additions and 0 deletions

View File

@ -0,0 +1,68 @@
From 485f2a02c79da8a7b31e972f0c652f06094bcfb9 Mon Sep 17 00:00:00 2001
From: Eric Haszlakiewicz <erh+git@nimenees.com>
Date: Tue, 28 May 2019 02:44:22 +0000
Subject: [PATCH 2/5] Issue #486: append a missing ".0" to negative double
values too.
---
json_object.c | 11 ++++++++---
tests/test_double_serializer.c | 4 ++++
tests/test_double_serializer.expected | 1 +
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/json_object.c b/json_object.c
index 344af51..026dab3 100644
--- a/json_object.c
+++ b/json_object.c
@@ -810,6 +810,7 @@ static int json_object_double_to_json_string_format(struct json_object* jso,
{
const char *std_format = "%.17g";
int format_drops_decimals = 0;
+ int looks_numeric = 0;
if (!format)
{
@@ -837,11 +838,15 @@ static int json_object_double_to_json_string_format(struct json_object* jso,
if (format == std_format || strstr(format, ".0f") == NULL)
format_drops_decimals = 1;
+ looks_numeric = /* Looks like *some* kind of number */
+ isdigit((unsigned char)buf[0]) ||
+ (size > 1 && buf[0] == '-' && isdigit((unsigned char)buf[1]));
+
if (size < (int)sizeof(buf) - 2 &&
- isdigit((unsigned char)buf[0]) && /* Looks like *some* kind of number */
- !p && /* Has no decimal point */
+ looks_numeric &&
+ !p && /* Has no decimal point */
strchr(buf, 'e') == NULL && /* Not scientific notation */
- format_drops_decimals)
+ format_drops_decimals)
{
// Ensure it looks like a float, even if snprintf didn't,
// unless a custom format is set to omit the decimal.
diff --git a/tests/test_double_serializer.c b/tests/test_double_serializer.c
index 0f7a60e..21612c8 100644
--- a/tests/test_double_serializer.c
+++ b/tests/test_double_serializer.c
@@ -74,4 +74,8 @@ int main()
printf("ERROR: json_c_set_serialization_double_format() failed");
json_object_put(obj);
+
+ obj = json_object_new_double(-12.0);
+ printf("obj(-12.0).to_string(default format)=%s\n", json_object_to_json_string(obj));
+
}
diff --git a/tests/test_double_serializer.expected b/tests/test_double_serializer.expected
index 98eea1e..d3aef72 100644
--- a/tests/test_double_serializer.expected
+++ b/tests/test_double_serializer.expected
@@ -16,3 +16,4 @@ obj(12.0).to_string(default format)=12.0
obj(12.0).to_string(%.0f)=12
obj(12.0).to_string(%.0g)=1e+01
obj(12.0).to_string(%.1g)=12.0
+obj(-12.0).to_string(default format)=-12.0
--
1.8.3.1

View File

@ -0,0 +1,41 @@
From c233f5c05e92909a764973524a03471bfad78f09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
Date: Sat, 16 Dec 2017 17:09:39 +0100
Subject: [PATCH 12/56] json_object_private: Use unsigned 32-bit integer type
for refcount
---
json_object.c | 3 +++
json_object_private.h | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/json_object.c b/json_object.c
index 7c7438d..da96f4c 100644
--- a/json_object.c
+++ b/json_object.c
@@ -169,6 +169,9 @@ extern struct json_object* json_object_get(struct json_object *jso)
{
if (!jso) return jso;
+ // Don't overflow the refcounter.
+ assert(jso->_ref_count < UINT_FAST32_MAX);
+
#if defined(HAVE_ATOMIC_BUILTINS) && defined(ENABLE_THREADING)
__sync_add_and_fetch(&jso->_ref_count, 1);
#else
diff --git a/json_object_private.h b/json_object_private.h
index 53be70d..51134b6 100644
--- a/json_object_private.h
+++ b/json_object_private.h
@@ -29,7 +29,7 @@ struct json_object
enum json_type o_type;
json_object_private_delete_fn *_delete;
json_object_to_json_string_fn *_to_json_string;
- int _ref_count;
+ uint_fast32_t _ref_count;
struct printbuf *_pb;
union data {
json_bool c_boolean;
--
1.8.3.1

View File

@ -0,0 +1,36 @@
From e8cec5c9e47676ebc51f1ab0af904fc4417b2166 Mon Sep 17 00:00:00 2001
From: Darjan Krijan <darjan_krijan@gmx.de>
Date: Tue, 20 Nov 2018 22:21:27 +0100
Subject: [PATCH 40/56] Fixed misalignment in JSON string due to space after \n
being printed when choosing JSON_C_TO_STRING_SPACED together with
JSON_C_TO_STRING_PRETTY in json_object_array_to_json_string
---
json_object.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/json_object.c b/json_object.c
index 8a86bc6..19f9c83 100644
--- a/json_object.c
+++ b/json_object.c
@@ -395,7 +395,7 @@ static int json_object_object_to_json_string(struct json_object* jso,
printbuf_strappend(pb, "\n");
}
had_children = 1;
- if (flags & JSON_C_TO_STRING_SPACED)
+ if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
printbuf_strappend(pb, " ");
indent(pb, level+1, flags);
printbuf_strappend(pb, "\"");
@@ -416,7 +416,7 @@ static int json_object_object_to_json_string(struct json_object* jso,
printbuf_strappend(pb, "\n");
indent(pb,level,flags);
}
- if (flags & JSON_C_TO_STRING_SPACED)
+ if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
return printbuf_strappend(pb, /*{*/ " }");
else
return printbuf_strappend(pb, /*{*/ "}");
--
1.8.3.1

View File

@ -0,0 +1,63 @@
From 506a32d4ab2acbdf2315719c2ae74c40c616670b Mon Sep 17 00:00:00 2001
From: andy5995 <andy400-dev@yahoo.com>
Date: Mon, 26 Nov 2018 21:12:06 -0600
Subject: [PATCH 48/56] json_object.c:set errno in json_object_get_double()
closes #422
---
json_object.c | 11 +++++++++--
json_tokener.h | 2 +-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/json_object.c b/json_object.c
index 8a86bc6..4b2b014 100644
--- a/json_object.c
+++ b/json_object.c
@@ -951,7 +951,10 @@ double json_object_get_double(const struct json_object *jso)
/* if conversion stopped at the first character, return 0.0 */
if (errPtr == get_string_component(jso))
- return 0.0;
+ {
+ errno = EINVAL;
+ return 0.0;
+ }
/*
* Check that the conversion terminated on something sensible
@@ -959,7 +962,10 @@ double json_object_get_double(const struct json_object *jso)
* For example, { "pay" : 123AB } would parse as 123.
*/
if (*errPtr != '\0')
- return 0.0;
+ {
+ errno = EINVAL;
+ return 0.0;
+ }
/*
* If strtod encounters a string which would exceed the
@@ -977,6 +983,7 @@ double json_object_get_double(const struct json_object *jso)
cdouble = 0.0;
return cdouble;
default:
+ errno = EINVAL;
return 0.0;
}
}
diff --git a/json_tokener.h b/json_tokener.h
index 8bcc6b6..4801c65 100644
--- a/json_tokener.h
+++ b/json_tokener.h
@@ -122,7 +122,7 @@ const char *json_tokener_error_desc(enum json_tokener_error jerr);
* When parsing a JSON string in pieces, if the tokener is in the middle
* of parsing this will return json_tokener_continue.
*
- * See also json_tokener_error_desc().
+ * @see json_tokener_error_desc().
*/
JSON_EXPORT enum json_tokener_error json_tokener_get_error(struct json_tokener *tok);
--
1.8.3.1

View File

@ -0,0 +1,138 @@
From 3003161effc3286b749010ada9182b79dbfe8c57 Mon Sep 17 00:00:00 2001
From: Rubasri Kalidas <rubasri.kalidas@intel.com>
Date: Tue, 18 Dec 2018 11:30:57 -0600
Subject: [PATCH 53/56] Fix compiler warnings
---
linkhash.c | 4 ++++
random_seed.c | 24 ++++++++++++------------
random_seed.h | 2 +-
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/linkhash.c b/linkhash.c
index b1223c4..f324a10 100644
--- a/linkhash.c
+++ b/linkhash.c
@@ -36,6 +36,10 @@ static unsigned long lh_char_hash(const void *k);
static unsigned long lh_perllike_str_hash(const void *k);
static lh_hash_fn *char_hash_fn = lh_char_hash;
+/* comparison functions */
+int lh_char_equal(const void *k1, const void *k2);
+int lh_ptr_equal(const void *k1, const void *k2);
+
int
json_global_set_string_hash(const int h)
{
diff --git a/random_seed.c b/random_seed.c
index 3232777..97d9547 100644
--- a/random_seed.c
+++ b/random_seed.c
@@ -53,7 +53,7 @@ static void do_cpuid(int regs[], int h)
#if HAS_X86_CPUID
-static int has_rdrand()
+static int has_rdrand(void)
{
// CPUID.01H:ECX.RDRAND[bit 30] == 1
int regs[4];
@@ -69,7 +69,7 @@ static int has_rdrand()
#define HAVE_RDRAND 1
-static int get_rdrand_seed()
+static int get_rdrand_seed(void)
{
DEBUG_SEED("get_rdrand_seed");
int _eax;
@@ -91,7 +91,7 @@ static int get_rdrand_seed()
/* get_rdrand_seed - Visual Studio 2012 and above */
-static int get_rdrand_seed()
+static int get_rdrand_seed(void)
{
DEBUG_SEED("get_rdrand_seed");
int r;
@@ -104,7 +104,7 @@ static int get_rdrand_seed()
/* get_rdrand_seed - Visual Studio 2010 and below - x86 only */
-static int get_rdrand_seed()
+static int get_rdrand_seed(void)
{
DEBUG_SEED("get_rdrand_seed");
int _eax;
@@ -136,7 +136,7 @@ retry:
static const char *dev_random_file = "/dev/urandom";
-static int has_dev_urandom()
+static int has_dev_urandom(void)
{
struct stat buf;
if (stat(dev_random_file, &buf)) {
@@ -148,7 +148,7 @@ static int has_dev_urandom()
/* get_dev_random_seed */
-static int get_dev_random_seed()
+static int get_dev_random_seed(void)
{
DEBUG_SEED("get_dev_random_seed");
@@ -184,7 +184,7 @@ static int get_dev_random_seed()
#pragma comment(lib, "advapi32.lib")
#endif
-static int get_cryptgenrandom_seed()
+static int get_cryptgenrandom_seed(void)
{
HCRYPTPROV hProvider = 0;
int r;
@@ -213,7 +213,7 @@ static int get_cryptgenrandom_seed()
#include <time.h>
-static int get_time_seed()
+static int get_time_seed(void)
{
DEBUG_SEED("get_time_seed");
@@ -223,15 +223,15 @@ static int get_time_seed()
/* json_c_get_random_seed */
-int json_c_get_random_seed()
+int json_c_get_random_seed(void)
{
-#if HAVE_RDRAND
+#if defined HAVE_RDRAND && HAVE_RDRAND
if (has_rdrand()) return get_rdrand_seed();
#endif
-#if HAVE_DEV_RANDOM
+#if defined HAVE_DEV_RANDOM && HAVE_DEV_RANDOM
if (has_dev_urandom()) return get_dev_random_seed();
#endif
-#if HAVE_CRYPTGENRANDOM
+#if defined HAVE_CRYPTGENRANDOM && HAVE_CRYPTGENRANDOM
return get_cryptgenrandom_seed();
#endif
return get_time_seed();
diff --git a/random_seed.h b/random_seed.h
index 2f43dad..72ee5f6 100644
--- a/random_seed.h
+++ b/random_seed.h
@@ -20,7 +20,7 @@
extern "C" {
#endif
-extern int json_c_get_random_seed();
+extern int json_c_get_random_seed(void);
#ifdef __cplusplus
}
--
1.8.3.1

View File

@ -0,0 +1,11 @@
diff -Nur json-c-json-c-0.11-20130402_orig/config.sub json-c-json-c-0.11-20130402//config.sub
--- json-c-json-c-0.11-20130402_orig/config.sub 2017-10-25 18:54:05.000000000 +0800
+++ json-c-json-c-0.11-20130402//config.sub 2017-10-25 19:25:49.000000000 +0800
@@ -250,6 +250,7 @@
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
+ | aarch64_[bl]e-linux | aarch64_[bl]e-euler \
| bfin \
| c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \

Binary file not shown.

View File

@ -0,0 +1,61 @@
From f8c632f579c71012f9aca81543b880a579f634fc Mon Sep 17 00:00:00 2001
From: Eric Haszlakiewicz <erh+git@nimenees.com>
Date: Sun, 25 Mar 2018 18:25:58 -0400
Subject: [PATCH] Issue #407: fix incorrect casts in calls to ctype functions
(isdigit and isspace) so we don't crash when asserts are enabled on certain
platforms and characters > 128 are parsed.
---
json_object.c | 2 +-
json_pointer.c | 4 ++--
json_tokener.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/json_object.c b/json_object.c
index 8287163a1c..8a86bc6ea0 100644
--- a/json_object.c
+++ b/json_object.c
@@ -838,7 +838,7 @@ static int json_object_double_to_json_string_format(struct json_object* jso,
format_drops_decimals = 1;
if (size < (int)sizeof(buf) - 2 &&
- isdigit((int)buf[0]) && /* Looks like *some* kind of number */
+ isdigit((unsigned char)buf[0]) && /* Looks like *some* kind of number */
!p && /* Has no decimal point */
strchr(buf, 'e') == NULL && /* Not scientific notation */
format_drops_decimals)
diff --git a/json_pointer.c b/json_pointer.c
index 2b2a9ef507..c7e34f76f3 100644
--- a/json_pointer.c
+++ b/json_pointer.c
@@ -44,7 +44,7 @@ static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx
/* this code-path optimizes a bit, for when we reference the 0-9 index range in a JSON array
and because leading zeros not allowed */
if (len == 1) {
- if (isdigit((int)path[0])) {
+ if (isdigit((unsigned char)path[0])) {
*idx = (path[0] - '0');
goto check_oob;
}
@@ -58,7 +58,7 @@ static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx
}
/* RFC states base-10 decimals */
for (i = 0; i < len; i++) {
- if (!isdigit((int)path[i])) {
+ if (!isdigit((unsigned char)path[i])) {
errno = EINVAL;
return 0;
}
diff --git a/json_tokener.c b/json_tokener.c
index 449a82da6f..561f7303b2 100644
--- a/json_tokener.c
+++ b/json_tokener.c
@@ -295,7 +295,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
case json_tokener_state_eatws:
/* Advance until we change state */
- while (isspace((int)c)) {
+ while (isspace((unsigned char)c)) {
if ((!ADVANCE_CHAR(str, tok)) || (!PEEK_CHAR(c, tok)))
goto out;
}

View File

@ -0,0 +1,163 @@
From 8bd62177e796386fb6382db101c90b57b6138afe Mon Sep 17 00:00:00 2001
From: janczer <menshikov.ivn@gmail.com>
Date: Tue, 24 Apr 2018 16:00:38 +0200
Subject: [PATCH] Fixed typos
---
STYLE.txt | 2 +-
json_object.h | 18 +++++++++---------
json_pointer.c | 2 +-
tests/test_compare.c | 12 ++++++------
tests/test_compare.expected | 6 +++---
5 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/STYLE.txt b/STYLE.txt
index e5acd14820..195883c760 100755
--- a/STYLE.txt
+++ b/STYLE.txt
@@ -7,7 +7,7 @@ Official json-c style:
Aim for readability, not strict conformance to fixed style rules.
These rules are not comprehensive. Look to existing code for guidelines.
Indentation is tab based, with continuations of long lines starting with tabs then spaces for alignment.
-Try to line up components of continuation lines with corresponding part of the line above (i.e. "indent -lp" effect), but avoid excessive identation tha causes extra line wraps.
+Try to line up components of continuation lines with corresponding part of the line above (i.e. "indent -lp" effect), but avoid excessive indentation tha causes extra line wraps.
e.g. (T=tab, S=space):
TTTTsome_long_func_call(arg1, arg2,
TTTTSSSSSSSSSSSSSSSSSSSarg3, arg4);
diff --git a/json_object.h b/json_object.h
index a3a86c0912..30341bcdb7 100644
--- a/json_object.h
+++ b/json_object.h
@@ -91,7 +91,7 @@ extern "C" {
/**
* A flag for the json_object_object_add_ex function which
* causes the value to be added without a check if it already exists.
- * Note: it is the responsibilty of the caller to ensure that no
+ * Note: it is the responsibility of the caller to ensure that no
* key is added multiple times. If this is done, results are
* unpredictable. While this option is somewhat dangerous, it
* permits potentially large performance savings in code that
@@ -442,7 +442,7 @@ JSON_EXPORT int json_object_object_add_ex(struct json_object* obj,
*
* This returns NULL if the field is found but its value is null, or if
* the field is not found, or if obj is not a json_type_object. If you
- * need to distinguis between these cases, use json_object_object_get_ex().
+ * need to distinguish between these cases, use json_object_object_get_ex().
*
* *No* reference counts will be changed. There is no need to manually adjust
* reference counts through the json_object_put/json_object_get methods unless
@@ -624,7 +624,7 @@ JSON_EXPORT int json_object_array_add(struct json_object *obj,
JSON_EXPORT int json_object_array_put_idx(struct json_object *obj, size_t idx,
struct json_object *val);
-/** Get the element at specificed index of the array (a json_object of type json_type_array)
+/** Get the element at specified index of the array (a json_object of type json_type_array)
* @param obj the json_object instance
* @param idx the index to get the element at
* @returns the json_object at the specified index (or NULL)
@@ -671,7 +671,7 @@ JSON_EXPORT json_bool json_object_get_boolean(const struct json_object *obj);
*
* The type of obj is checked to be a json_type_boolean and 0 is returned
* if it is not without any further actions. If type of obj is json_type_boolean
- * the obect value is chaned to new_value
+ * the object value is changed to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
@@ -718,7 +718,7 @@ JSON_EXPORT int32_t json_object_get_int(const struct json_object *obj);
*
* The type of obj is checked to be a json_type_int and 0 is returned
* if it is not without any further actions. If type of obj is json_type_int
- * the obect value is changed to new_value
+ * the object value is changed to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
@@ -763,7 +763,7 @@ JSON_EXPORT int64_t json_object_get_int64(const struct json_object *obj);
*
* The type of obj is checked to be a json_type_int and 0 is returned
* if it is not without any further actions. If type of obj is json_type_int
- * the obect value is chaned to new_value
+ * the object value is changed to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
@@ -880,7 +880,7 @@ JSON_EXPORT double json_object_get_double(const struct json_object *obj);
*
* The type of obj is checked to be a json_type_double and 0 is returned
* if it is not without any further actions. If type of obj is json_type_double
- * the obect value is chaned to new_value
+ * the object value is changed to new_value
*
* @param obj the json_object instance
* @param new_value the value to be set
@@ -942,10 +942,10 @@ JSON_EXPORT int json_object_set_string(json_object* obj, const char* new_value);
*
* The type of obj is checked to be a json_type_string and 0 is returned
* if it is not without any further actions. If type of obj is json_type_string
- * the obect value is chaned to new_value
+ * the object value is changed to new_value
*
* @param obj the json_object instance
- * @param new_value the value to be set; Since string legth is given in len this need not be zero terminated
+ * @param new_value the value to be set; Since string length is given in len this need not be zero terminated
* @param len the length of new_value
* @returns 1 if value is set correctly, 0 otherwise
*/
diff --git a/json_pointer.c b/json_pointer.c
index c7e34f76f3..9531c036c8 100644
--- a/json_pointer.c
+++ b/json_pointer.c
@@ -28,7 +28,7 @@
static void string_replace_all_occurrences_with_char(char *s, const char *occur, char repl_char)
{
int slen = strlen(s);
- int skip = strlen(occur) - 1; /* length of the occurence, minus the char we're replacing */
+ int skip = strlen(occur) - 1; /* length of the occurrence, minus the char we're replacing */
char *p = s;
while ((p = strstr(p, occur))) {
*p = repl_char;
diff --git a/tests/test_compare.c b/tests/test_compare.c
index c7e44f6ea6..cba328cf4b 100644
--- a/tests/test_compare.c
+++ b/tests/test_compare.c
@@ -18,19 +18,19 @@ int main()
struct json_object *int3 = json_object_new_int(1);
if (!json_object_equal(int1, int2))
- printf("JSON integer comparision is correct\n");
+ printf("JSON integer comparison is correct\n");
else
- printf("JSON integer comparision failed\n");
+ printf("JSON integer comparison failed\n");
if (json_object_equal(int1, int1))
- printf("JSON same object comparision is correct\n");
+ printf("JSON same object comparison is correct\n");
else
- printf("JSON same object comparision failed\n");
+ printf("JSON same object comparison failed\n");
if (json_object_equal(int2, int3))
- printf("JSON same integer comparision is correct\n");
+ printf("JSON same integer comparison is correct\n");
else
- printf("JSON same integer comparision failed\n");
+ printf("JSON same integer comparison failed\n");
json_object_put(int1);
json_object_put(int2);
diff --git a/tests/test_compare.expected b/tests/test_compare.expected
index 46f03c4101..5468f83d2e 100644
--- a/tests/test_compare.expected
+++ b/tests/test_compare.expected
@@ -1,6 +1,6 @@
-JSON integer comparision is correct
-JSON same object comparision is correct
-JSON same integer comparision is correct
+JSON integer comparison is correct
+JSON same object comparison is correct
+JSON same integer comparison is correct
Comparing equal strings is correct
Comparing different strings is correct
Comparing equal doubles is correct

View File

@ -0,0 +1,75 @@
From da4b34355da023c439e96bc6ca31886cd69d6bdb Mon Sep 17 00:00:00 2001
From: Eric Haszlakiewicz <erh+git@nimenees.com>
Date: Sun, 25 Mar 2018 18:23:42 -0400
Subject: [PATCH] Add an parse test for content starting with a UTF8 BOM, which
is _not_ a valid start to a JSON message.
---
tests/test_parse.c | 16 +++++++++++++++-
tests/test_parse.expected | 5 ++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/tests/test_parse.c b/tests/test_parse.c
index ee1f8387b3..f46651b0a1 100644
--- a/tests/test_parse.c
+++ b/tests/test_parse.c
@@ -9,6 +9,7 @@
#include "json_visit.h"
static void test_basic_parse(void);
+static void test_utf8_parse(void);
static void test_verbose_parse(void);
static void test_incremental_parse(void);
@@ -19,6 +20,8 @@ int main(void)
static const char separator[] = "==================================";
test_basic_parse();
puts(separator);
+ test_utf8_parse();
+ puts(separator);
test_verbose_parse();
puts(separator);
test_incremental_parse();
@@ -107,6 +110,17 @@ static void test_basic_parse()
single_basic_parse("[18446744073709551616]", 1);
}
+static void test_utf8_parse()
+{
+ // json_tokener_parse doesn't support checking for byte order marks.
+ // It's the responsibility of the caller to detect and skip a BOM.
+ // Both of these checks return null.
+ char utf8_bom[] = { 0xEF, 0xBB, 0xBF, 0x00 };
+ char utf8_bom_and_chars[] = { 0xEF, 0xBB, 0xBF, '{', '}', 0x00 };
+ single_basic_parse(utf8_bom, 0);
+ single_basic_parse(utf8_bom_and_chars, 0);
+}
+
// Clear the re-serialization information that the tokener
// saves to ensure that the output reflects the actual
// values we parsed, rather than just the original input.
@@ -145,7 +159,7 @@ static void test_verbose_parse()
/* b/c the string starts with 'f' parsing return a boolean error */
assert (error == json_tokener_error_parse_boolean);
- puts("json_tokener_parse_versbose() OK");
+ puts("json_tokener_parse_verbose() OK");
}
struct incremental_step {
diff --git a/tests/test_parse.expected b/tests/test_parse.expected
index ada61411fe..5d3976a745 100644
--- a/tests/test_parse.expected
+++ b/tests/test_parse.expected
@@ -51,7 +51,10 @@ new_obj.to_string([0e+])=[ 0.0 ]
new_obj.to_string([0e+-1])=null
new_obj.to_string([18446744073709551616])=[ 9223372036854775807 ]
==================================
-json_tokener_parse_versbose() OK
+new_obj.to_string()=null
+new_obj.to_string({})=null
+==================================
+json_tokener_parse_verbose() OK
==================================
Starting incremental tests.
Note: quotes and backslashes seen in the output here are literal values passed

118
json-c.spec Normal file
View File

@ -0,0 +1,118 @@
%{!?_pkgdocdir:%global _pkgdocdir %{_docdir}/%{name}-%{version}}
%global so_ver 4
%global reldate 20180305
Name: json-c
Version: 0.13.1
Release: 4
Summary: JSON implementation in C
License: MIT
URL: https://github.com/%{name}/%{name}
Source0: %{url}/archive/%{name}-%{version}-%{reldate}.tar.gz
# Cherry-picked from upstream.
Patch0: %{url}/commit/da4b34355da023c439e96bc6ca31886cd69d6bdb.patch#/%{name}-0.13.1-parse_test_UTF8_BOM.patch
Patch1: %{url}/commit/f8c632f579c71012f9aca81543b880a579f634fc.patch#/%{name}-0.13.1-fix_incorrect_casts_in_calls_to_ctype_functions.patch
Patch2: %{url}/commit/8bd62177e796386fb6382db101c90b57b6138afe.patch#/%{name}-0.13.1-fix_typos.patch
Patch6000: 0012-json_object_private-Use-unsigned-32-bit-integer-type.patch
Patch6001: 0040-Fixed-misalignment-in-JSON-string-due-to-space-after.patch
Patch6002: 0048-json_object.c-set-errno-in-json_object_get_double.patch
Patch6003: 0053-Fix-compiler-warnings.patch
Patch6004: 0002-Issue-486-append-a-missing-.0-to-negative-double-val.patch
Patch9000: bugfix-json-c-support_aarch64.patch
BuildRequires: libtool
%description
JSON-C implements a reference counting object model that allows you
to easily construct JSON objects in C, output them as JSON formatted
strings and parse JSON formatted strings back into the C representation
of JSON objects. It aims to conform to RFC 7159.
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} == %{version}-%{release}
%description devel
This package contains libraries and header files for
developing applications that use %{name}.
%package help
Summary: Reference manual for json-c
BuildArch: noarch
BuildRequires: doxygen hardlink
Provides: %{name}-doc = %{version}-%{release}
Obsoletes: %{name}-doc = %{version}-%{release}
%description help
This package contains the reference manual for %{name}.
%prep
%autosetup -Tb 0 -n %{name}-%{name}-%{version}-%{reldate} -p 1
for doc in ChangeLog; do
%{_bindir}/iconv -f iso-8859-1 -t utf8 ${doc} > ${doc}.new
/bin/touch -r ${doc} ${doc}.new
%{__mv} -f ${doc}.new ${doc}
done
%{__sed} -i -e 's!#ACLOCAL_AMFLAGS!ACLOCAL_AMFLAGS!g' Makefile.am
%{_bindir}/autoreconf -fiv
%build
%configure --disable-silent-rules --disable-static --enable-rdrand \
--enable-shared --enable-threading
%make_build
%{_bindir}/doxygen Doxyfile
%install
%make_install
%delete_la_and_a
%{__mkdir} -p %{buildroot}%{_pkgdocdir}
%{__cp} -pr doc/html ChangeLog README README.* %{buildroot}%{_pkgdocdir}
%{_sbindir}/hardlink -cvf %{buildroot}%{_pkgdocdir}
%check
%make_build check
%pretrans devel -p <lua>
path = "%{_includedir}/%{name}"
st = posix.stat(path)
if st and st.type == "link" then
os.remove(path)
end
%ldconfig_scriptlets
%files
%license AUTHORS COPYING
%{_libdir}/lib%{name}.so.%{so_ver}*
%files devel
%{_includedir}/%{name}/
%{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%files help
%doc %{_pkgdocdir}
%changelog
* Thu Sep 19 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.13.1-4
- Package init