Update JSON parser to latest version from https://github.com/udp/json-parser

This commit is contained in:
Dianne Skoll
2025-03-22 12:09:30 -04:00
parent caf5f81eb0
commit ed15b7deb5
2 changed files with 122 additions and 102 deletions
+22 -14
View File
@@ -1,7 +1,8 @@
/* vim: set et ts=3 sw=3 sts=3 ft=c:
*
* Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved.
* https://github.com/udp/json-parser
* Copyright (C) 2012-2021 the json-parser authors All rights reserved.
* https://github.com/json-parser/json-parser
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,15 +36,22 @@
#endif
#ifndef json_int_t
#ifndef _MSC_VER
#include <inttypes.h>
#define json_int_t int64_t
#else
#undef JSON_INT_T_OVERRIDDEN
#if defined(_MSC_VER)
#define json_int_t __int64
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__cplusplus) && __cplusplus >= 201103L)
/* C99 and C++11 */
#include <stdint.h>
#define json_int_t int_fast64_t
#else
/* C89 */
#define json_int_t long
#endif
#else
#define JSON_INT_T_OVERRIDDEN 1
#endif
#include <stdlib.h>
#include <stddef.h>
#ifdef __cplusplus
@@ -56,7 +64,7 @@
typedef struct
{
unsigned long max_memory;
unsigned long max_memory; /* should be size_t, but would modify the API */
int settings;
/* Custom allocator support (leave null to use malloc/free)
@@ -122,11 +130,11 @@ typedef struct _json_value
json_object_entry * values;
#if defined(__cplusplus) && __cplusplus >= 201103L
decltype(values) begin () const
#if defined(__cplusplus)
json_object_entry * begin () const
{ return values;
}
decltype(values) end () const
json_object_entry * end () const
{ return values + length;
}
#endif
@@ -138,11 +146,11 @@ typedef struct _json_value
unsigned int length;
struct _json_value ** values;
#if defined(__cplusplus) && __cplusplus >= 201103L
decltype(values) begin () const
#if defined(__cplusplus)
_json_value ** begin () const
{ return values;
}
decltype(values) end () const
_json_value ** end () const
{ return values + length;
}
#endif