From 8eb8c7c4b70da9ab16e2c8ecef627aa201417b14 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 15 Jan 2024 21:06:05 +1000 Subject: [PATCH] Apply CRAN submission feedback. Round 1 --- DESCRIPTION | 2 +- NEWS.md | 7 +++++++ R/json-opts.R | 2 +- man/yyjson_read_flag.Rd | 2 +- src/R-yyjson-parse.c | 27 ++++++++++++++++++++------- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b93d758..574fc58 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: yyjsonr Type: Package Title: Fast JSON Parser and Generator -Version: 0.1.14 +Version: 0.1.15 Authors@R: c( person("Mike", "Cheng", role = c("aut", "cre", 'cph'), email = "mikefc@coolbutuseless.com"), diff --git a/NEWS.md b/NEWS.md index 391ab8e..e0f25c2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,11 @@ + +# yyjson4 0.1.15 2024-01-15 + +* Fixes for CRAN + * Simply example to remove checkRd NOTE + * Platform specific handling of error location format string to fix WARNING + # yyjson4 0.1.14 2024-01-13 * Add `int64 = "double"` option to `opts_read_json()` diff --git a/R/json-opts.R b/R/json-opts.R index 1f83574..ebc4f05 100644 --- a/R/json-opts.R +++ b/R/json-opts.R @@ -42,7 +42,7 @@ #' #' \item{YYJSON_READ_ALLOW_TRAILING_COMMAS}{ #' Allow single trailing comma at the end of an object or array, -#' such as \code{"[1,2,3,]"}, '{"a":1,"b":2,}' (non-standard). +#' such as \code{"[1,2,3,]"} #' } #' #' \item{YYJSON_READ_ALLOW_COMMENTS}{ diff --git a/man/yyjson_read_flag.Rd b/man/yyjson_read_flag.Rd index 5b32bd4..4b1d054 100644 --- a/man/yyjson_read_flag.Rd +++ b/man/yyjson_read_flag.Rd @@ -51,7 +51,7 @@ in larger data, such as "NDJSON" \item{YYJSON_READ_ALLOW_TRAILING_COMMAS}{ Allow single trailing comma at the end of an object or array, -such as \code{"[1,2,3,]"}, '{"a":1,"b":2,}' (non-standard). +such as \code{"[1,2,3,]"} } \item{YYJSON_READ_ALLOW_COMMENTS}{ diff --git a/src/R-yyjson-parse.c b/src/R-yyjson-parse.c index 06da855..ce8cea0 100644 --- a/src/R-yyjson-parse.c +++ b/src/R-yyjson-parse.c @@ -1846,7 +1846,11 @@ SEXP parse_json_from_str(const char *str, parse_options *opt) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (doc == NULL) { output_verbose_error(str, err); - error("Error parsing JSON: %s code: %u at position: %ld\n", err.msg, err.code, err.pos); +#if defined(__APPLE__) || defined(_WIN32) + error("Error parsing JSON: %s code: %u at position: %llu\n", err.msg, err.code, err.pos); +#else + error("Error parsing JSON: %s code: %u at position: %lu\n", err.msg, err.code, err.pos); +#endif } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1879,8 +1883,11 @@ SEXP parse_json_from_file(const char *filename, parse_options *opt) { // If doc is NULL, then an error occurred during parsing. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (doc == NULL) { - error("Error parsing JSON file '%s': %s code: %u at position: %ld\n", - filename, err.msg, err.code, err.pos); +#if defined(__APPLE__) || defined(_WIN32) + error("Error parsing JSON file '%s': %s code: %u at position: %llu\n", filename, err.msg, err.code, err.pos); +#else + error("Error parsing JSON file '%s': %s code: %u at position: %lu\n", filename, err.msg, err.code, err.pos); +#endif } @@ -1961,8 +1968,11 @@ SEXP validate_json_file_(SEXP filename_, SEXP verbose_, SEXP parse_opts_) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (doc == NULL) { if (asLogical(verbose_)) { - warning("Error parsing JSON file '%s': %s code: %u at position: %ld\n", - filename, err.msg, err.code, err.pos); +#if defined(__APPLE__) || defined(_WIN32) + warning("Error parsing JSON file '%s': %s code: %u at position: %llu\n", filename, err.msg, err.code, err.pos); +#else + warning("Error parsing JSON file '%s': %s code: %u at position: %lu\n", filename, err.msg, err.code, err.pos); +#endif } return ScalarLogical(0); @@ -1990,8 +2000,11 @@ SEXP validate_json_str_(SEXP str_, SEXP verbose_, SEXP parse_opts_) { if (doc == NULL) { if (asLogical(verbose_)) { output_verbose_error(str, err); - warning("Error parsing JSON: %s code: %u at position: %ld\n", - err.msg, err.code, err.pos); +#if defined(__APPLE__) || defined(_WIN32) + warning("Error parsing JSON: %s code: %u at position: %llu\n", err.msg, err.code, err.pos); +#else + warning("Error parsing JSON: %s code: %u at position: %lu\n", err.msg, err.code, err.pos); +#endif } return ScalarLogical(0); }