Skip to content

Commit 1526c84

Browse files
authored
Merge pull request json-c#606 from davidjmccann/master
Improved support for IBM operating systems
2 parents d414d3e + add7b13 commit 1526c84

8 files changed

+39
-11
lines changed

json_c_version.h

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#ifndef _json_c_version_h_
1313
#define _json_c_version_h_
1414

15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
1519
#define JSON_C_MAJOR_VERSION 0
1620
#define JSON_C_MINOR_VERSION 14
1721
#define JSON_C_MICRO_VERSION 99
@@ -44,4 +48,8 @@ JSON_EXPORT const char *json_c_version(void); /* Returns JSON_C_VERSION */
4448
*/
4549
JSON_EXPORT int json_c_version_num(void); /* Returns JSON_C_VERSION_NUM */
4650

51+
#ifdef __cplusplus
52+
}
53+
#endif
54+
4755
#endif

json_object.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ static json_object_to_json_string_fn _json_object_userdata_to_json_string;
5858
#ifndef JSON_NORETURN
5959
#if defined(_MSC_VER)
6060
#define JSON_NORETURN __declspec(noreturn)
61+
#elif defined(__OS400__)
62+
#define JSON_NORETURN
6163
#else
6264
/* 'cold' attribute is for optimization, telling the computer this code
6365
* path is unlikely.
@@ -901,18 +903,23 @@ static int json_object_double_to_json_string_format(struct json_object *jso, str
901903
* ECMA 262 section 9.8.1 defines
902904
* how to handle these cases as strings
903905
*/
906+
#ifdef HAVE_DECL_ISNAN
904907
if (isnan(jso->o.c_double))
905908
{
906909
size = snprintf(buf, sizeof(buf), "NaN");
907910
}
908-
else if (isinf(jso->o.c_double))
911+
else
912+
#endif
913+
#ifdef HAVE_DECL_ISINF
914+
if (isinf(jso->o.c_double))
909915
{
910916
if (jso->o.c_double > 0)
911917
size = snprintf(buf, sizeof(buf), "Infinity");
912918
else
913919
size = snprintf(buf, sizeof(buf), "-Infinity");
914920
}
915921
else
922+
#endif
916923
{
917924
const char *std_format = "%.17g";
918925
int format_drops_decimals = 0;

json_tokener.c

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
#ifdef HAVE_XLOCALE_H
4141
#include <xlocale.h>
4242
#endif
43+
#ifdef HAVE_STRINGS_H
44+
#include <strings.h>
45+
#endif /* HAVE_STRINGS_H */
4346

4447
#define jt_hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x)&7) + 9)
4548

json_visit.h

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
*/
99
#include "json_object.h"
1010

11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
1115
typedef int(json_c_visit_userfunc)(json_object *jso, int flags, json_object *parent_jso,
1216
const char *jso_key, size_t *jso_index, void *userarg);
1317

@@ -90,4 +94,8 @@ JSON_EXPORT int json_c_visit(json_object *jso, int future_flags, json_c_visit_us
9094
*/
9195
#define JSON_C_VISIT_RETURN_ERROR -1
9296

97+
#ifdef __cplusplus
98+
}
99+
#endif
100+
93101
#endif /* _json_c_json_visit_h_ */

strerror_override.c

+2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ static struct
2020
ENTRY(EIO),
2121
ENTRY(ENXIO),
2222
ENTRY(E2BIG),
23+
#ifdef ENOEXEC
2324
ENTRY(ENOEXEC),
25+
#endif
2426
ENTRY(EBADF),
2527
ENTRY(ECHILD),
2628
ENTRY(EDEADLK),

tests/test_json_pointer.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static const char *rec_input_json_str =
6060
/* clang-format on */
6161

6262
/* Example from RFC */
63-
static void test_example_get()
63+
static void test_example_get(void)
6464
{
6565
int i;
6666
struct json_object *jo1, *jo2, *jo3;
@@ -126,7 +126,7 @@ static void test_example_get()
126126
}
127127

128128
/* I'm not too happy with the RFC example to test the recusion of the json_pointer_get() function */
129-
static void test_recursion_get()
129+
static void test_recursion_get(void)
130130
{
131131
struct json_object *jo2, *jo1 = json_tokener_parse(rec_input_json_str);
132132

@@ -161,7 +161,7 @@ static void test_recursion_get()
161161
json_object_put(jo1);
162162
}
163163

164-
static void test_wrong_inputs_get()
164+
static void test_wrong_inputs_get(void)
165165
{
166166
struct json_object *jo2, *jo1 = json_tokener_parse(input_json_str);
167167

@@ -231,7 +231,7 @@ static void test_wrong_inputs_get()
231231
json_object_put(jo1);
232232
}
233233

234-
static void test_example_set()
234+
static void test_example_set(void)
235235
{
236236
struct json_object *jo2, *jo1 = json_tokener_parse(input_json_str);
237237

@@ -272,7 +272,7 @@ static void test_example_set()
272272
json_object_put(jo1);
273273
}
274274

275-
static void test_wrong_inputs_set()
275+
static void test_wrong_inputs_set(void)
276276
{
277277
struct json_object *jo2, *jo1 = json_tokener_parse(input_json_str);
278278

tests/test_parse.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ static void test_utf8_parse()
149149
// json_tokener_parse doesn't support checking for byte order marks.
150150
// It's the responsibility of the caller to detect and skip a BOM.
151151
// Both of these checks return null.
152-
char utf8_bom[] = {0xEF, 0xBB, 0xBF, 0x00};
153-
char utf8_bom_and_chars[] = {0xEF, 0xBB, 0xBF, '{', '}', 0x00};
152+
char* utf8_bom = "\xEF\xBB\xBF";
153+
char* utf8_bom_and_chars = "\xEF\xBB\xBF{}";
154154
single_basic_parse(utf8_bom, 0);
155155
single_basic_parse(utf8_bom_and_chars, 0);
156156
}
@@ -446,7 +446,7 @@ static void test_incremental_parse()
446446
json_tokener_set_flags(tok, step->tok_flags);
447447

448448
if (length == -1)
449-
length = strlen(step->string_to_parse);
449+
length = (int)strlen(step->string_to_parse);
450450
if (step->char_offset == -1)
451451
expected_char_offset = length;
452452
else

tests/test_util_file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
static void test_read_valid_with_fd(const char *testdir);
2626
static void test_read_valid_nested_with_fd(const char *testdir);
27-
static void test_read_nonexistant();
27+
static void test_read_nonexistant(void);
2828
static void test_read_closed(void);
2929

30-
static void test_write_to_file();
30+
static void test_write_to_file(void);
3131
static void stat_and_cat(const char *file);
3232
static void test_read_fd_equal(const char *testdir);
3333

0 commit comments

Comments
 (0)