diff --git a/CMakeLists.txt b/CMakeLists.txt index b34fcbf..e2f4434 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(parson C) include (GNUInstallDirs) -set(PARSON_VERSION 1.5.2) +set(PARSON_VERSION 1.5.3) add_library(parson parson.c) target_include_directories(parson PUBLIC $) diff --git a/Makefile b/Makefile index 5e6bdfd..0803434 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ CC = gcc -CFLAGS = -O0 -g -Wall -Wextra -Wno-deprecated-declarations -std=c89 -pedantic-errors -DTESTS_MAIN +CFLAGS = -O0 -g -Wall -Wextra -std=c89 -pedantic-errors -DTESTS_MAIN CPPC = g++ -CPPFLAGS = -O0 -g -Wall -Wextra -Wno-deprecated-declarations -DTESTS_MAIN +CPPFLAGS = -O0 -g -Wall -Wextra -DTESTS_MAIN all: test testcpp test_hash_collisions diff --git a/meson.build b/meson.build index 5885a7f..ab6fb93 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('parson', 'c', - version : '1.5.2', + version : '1.5.3', license : 'MIT', meson_version : '>=0.46.0', default_options : [ diff --git a/package.json b/package.json index cce306f..8267dc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "parson", - "version": "1.5.2", + "version": "1.5.3", "repo": "kgabis/parson", "description": "Small json parser and reader", "keywords": [ "json", "parser" ], diff --git a/parson.c b/parson.c index 4a18fe9..526aab4 100644 --- a/parson.c +++ b/parson.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: MIT - Parson 1.5.2 (https://github.com/kgabis/parson) + Parson 1.5.3 (https://github.com/kgabis/parson) Copyright (c) 2012 - 2023 Krzysztof Gabis Permission is hereby granted, free of charge, to any person obtaining a copy @@ -32,7 +32,7 @@ #define PARSON_IMPL_VERSION_MAJOR 1 #define PARSON_IMPL_VERSION_MINOR 5 -#define PARSON_IMPL_VERSION_PATCH 2 +#define PARSON_IMPL_VERSION_PATCH 3 #if (PARSON_VERSION_MAJOR != PARSON_IMPL_VERSION_MAJOR)\ || (PARSON_VERSION_MINOR != PARSON_IMPL_VERSION_MINOR)\ @@ -40,6 +40,7 @@ #error "parson version mismatch between parson.c and parson.h" #endif +#include #include #include #include @@ -152,6 +153,8 @@ static char * read_file(const char *filename); static void remove_comments(char *string, const char *start_token, const char *end_token); static char * parson_strndup(const char *string, size_t n); static char * parson_strdup(const char *string); +static int parson_sprintf(char * s, const char * format, ...); + static int hex_char_to_int(char c); static JSON_Status parse_utf16_hex(const char *string, unsigned int *result); static int num_bytes_in_utf8_sequence(unsigned char c); @@ -283,6 +286,25 @@ static char * parson_strdup(const char *string) { return parson_strndup(string, strlen(string)); } +static int parson_sprintf(char * s, const char * format, ...) { + int result; + va_list args; + va_start(args, format); + + #if defined(__APPLE__) && defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #endif + result = vsprintf(s, format, args); + #if defined(__APPLE__) && defined(__clang__) + #pragma clang diagnostic pop + #endif + + va_end(args); + return result; + +} + static int hex_char_to_int(char c) { if (c >= '0' && c <= '9') { return c - '0'; @@ -1243,10 +1265,9 @@ static int json_serialize_to_buffer_r(const JSON_Value *value, char *buf, int le } if (parson_number_serialization_function) { written = parson_number_serialization_function(num, num_buf); - } else if (parson_float_format) { - written = sprintf(num_buf, parson_float_format, num); } else { - written = sprintf(num_buf, PARSON_DEFAULT_FLOAT_FORMAT, num); + const char *float_format = parson_float_format ? parson_float_format : PARSON_DEFAULT_FLOAT_FORMAT; + written = parson_sprintf(num_buf, float_format, num); } if (written < 0) { return -1; diff --git a/parson.h b/parson.h index 77b451e..40be490 100644 --- a/parson.h +++ b/parson.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: MIT - Parson 1.5.2 (https://github.com/kgabis/parson) + Parson 1.5.3 (https://github.com/kgabis/parson) Copyright (c) 2012 - 2023 Krzysztof Gabis Permission is hereby granted, free of charge, to any person obtaining a copy @@ -36,9 +36,9 @@ extern "C" #define PARSON_VERSION_MAJOR 1 #define PARSON_VERSION_MINOR 5 -#define PARSON_VERSION_PATCH 2 +#define PARSON_VERSION_PATCH 3 -#define PARSON_VERSION_STRING "1.5.2" +#define PARSON_VERSION_STRING "1.5.3" #include /* size_t */ diff --git a/tests.c b/tests.c index 60ac579..3cf97b5 100644 --- a/tests.c +++ b/tests.c @@ -26,6 +26,10 @@ #define _CRT_SECURE_NO_WARNINGS #endif +#if defined(__APPLE__) && defined(__clang__) + #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + #include "parson.h" #include