Skip to content

Sync jparse repo #1248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Major changes to the IOCCC entry toolkit


## Release 2.4.4 2025-03-15

Sync [jparse repo](https://github.com/xexyl/jparse/) to `jparse/`. This updates
jparse.3 with additional functions (with two new files added), adds to all the
tools (early on `main()` - no libraries) `setlocale(LC_ALL, "");` to use the
system's default locale based on LANG. Additionally a macro and variable were
renamed to better reflect what they are (this does not affect any code in
mkiocccentry however).


## Release 2.4.4 2025-03-14

**IMPORTANT NOTE**:
Expand Down
2 changes: 1 addition & 1 deletion chkentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static const char * const usage_msg =
"\t\t\t NOTE: -q will also silence msg(), warn(), warnp() if -v 0\n"
"\t-i path\t\tadd path to (to file or directory) under directory to check\n"
"\t\t\t NOTE: you can ignore more than one file or directory with multiple -i args\n"
"\t-P\t\tIgnore permissions\n"
"\t-P\t\tignore permissions\n"
"\t-w\t\twinning entry checks\n"
"\n"
"Exit codes:\n"
Expand Down
51 changes: 51 additions & 0 deletions jparse/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
# Significant changes in the JSON parser repo


## Release 2.2.38 2025-03-15

Add `setlocale(LC_ALL, "");` to all `main()` functions.

After a discussion and review now early on in every `main()` we do a
`setlocale(LC_ALL, "");` so that the default locale (in the system) based on
`LANG` will be used.

NOTE: this is not done in the library for very good reasons.

Updated `JSEMTBLGEN_VERSION` to `"2.0.1 2025-03-15"`.
Updated `JSTRDECODE_VERSION` to `"2.2.2 2025-03-15"`.
Updated `JSTRENCODE_VERSION` to `"2.2.2 2025-03-15"`.
Updated `JNUM_CHK_VERSION` to `"2.0.1 2025-03-15"`.
Updated `JNUM_GEN_VERSION` to `"2.0.1 2025-03-15"`.
Updated `PR_JPARSE_TEST_VERSION` to `"2.0.1 2025-03-15"`.
Updated `UTIL_TEST_VERSION` to `"2.0.3 2025-03-15"`.
Updated `VERGE_VERSION` to `"2.0.2 2025-03-15"`.
Updated `JPARSE_TOOL_VERSION` to `"2.0.1 2025-03-15"`.

Undo the variable swap (`< 0` check) in `sum_and_count()` and add a comment
about it so that when we don't stupidly change it again.

Updated `JPARSE_UTILS_VERSION` to `"2.0.8 2025-03-15"`.


## Release 2.2.37 2025-03-14

Add man pages for `json_tree_walk()` and `vjson_tree_walk()` (symlinked to
`jparse.3` which is under `man/man3`). The `jparse.3` has been updated to have
these two functions.

Changed the macro `JPARSE_VERSION` to `JPARSE_TOOL_VERSION` and the string
`jparse_version` to `jparse_tool_version` to better reflect that it's the tool
`jparse(1)` version, not something else.

Don't use `setlocale(3)` in `jstrencode(1)` or `jstrdecode(3)`.

Updated `JSTRENCODE_VERSION` to `"2.2.1 2025-03-15"` (yes that was a typo).
Updated `JSTRDECODE_VERSION` to `"2.2.1 2025-03-14"`.

Typo fix in at least one place.

In places (in `json_util.c`) where the debug output can be confusing a link to
the jparse library README.md file is now in a comment, although for
`json_string` it is not so much about the debug output as the struct itself.

Fix bad bug in `sum_and_count()` - wrong value checked for < 0.

Updated `JPARSE_UTILS_VERSION` to `"2.0.7 2025-03-14"`.

## Release 2.2.36 2025-03-11

Fix bugs in `resolve_path()`. If one had the path of `./foo` or even `/foo` then
Expand Down
2 changes: 1 addition & 1 deletion jparse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ MAN1_PAGES= man/man1/jparse.1 man/man1/jstrdecode.1 man/man1/jstrencode.1 man/ma
MAN3_PAGES= man/man3/jparse.3 man/man3/json_dbg.3 man/man3/json_dbg_allowed.3 \
man/man3/json_err_allowed.3 man/man3/json_warn_allowed.3 man/man3/parse_json.3 \
man/man3/parse_json_file.3 man/man3/parse_json_stream.3 man/man3/json_tree_free.3 \
man/man3/parse_json_str.3
man/man3/parse_json_str.3 man/man3/json_tree_walk.3 man/man3/vjson_tree_walk.3
MAN8_PAGES= man/man8/jnum_chk.8 man/man8/jnum_gen.8 man/man8/jparse_test.8 man/man8/jsemcgen.8 \
man/man8/jsemtblgen.8 man/man8/jstr_test.8 man/man8/verge.8 \
man/man8/run_bison.8 man/man8/run_bison.sh.8 man/man8/run_flex.8 man/man8/run_flex.sh.8 \
Expand Down
2 changes: 1 addition & 1 deletion jparse/jparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
extern const char *const jparse_library_version; /* library version format: major.minor YYYY-MM-DD */
extern const char *const jparse_utils_version; /* jparse utils (util.c) version format: major.minor YYYY-MM-DD */
extern const char *const jparse_utf8_version; /* jparse utf8 version format: major.minor YYYY-MM-DD */
extern const char *const jparse_version; /* jparse version format: major.minor YYYY-MM-DD */
extern const char *const jparse_tool_version; /* jparse version format: major.minor YYYY-MM-DD */
/* lexer and parser specific variables */
extern int jparse_debug;

Expand Down
2 changes: 1 addition & 1 deletion jparse/jparse.tab.ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ int jparse_debug = 0; /* 0 ==> verbose bison debug off, 1 ==> verbose bison debu
const char *const jparse_library_version = JPARSE_LIBRARY_VERSION; /* jparse library version */
const char *const jparse_utils_version = JPARSE_UTILS_VERSION; /* jparse utils (util.c) version */
const char *const jparse_utf8_version = JPARSE_UTF8_VERSION; /* jparse utf8 version */
const char *const jparse_version = JPARSE_VERSION; /* jparse tool version */
const char *const jparse_tool_version = JPARSE_TOOL_VERSION; /* jparse tool version */


#line 114 "jparse.tab.c"
Expand Down
2 changes: 1 addition & 1 deletion jparse/jparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int jparse_debug = 0; /* 0 ==> verbose bison debug off, 1 ==> verbose bison debu
const char *const jparse_library_version = JPARSE_LIBRARY_VERSION; /* jparse library version */
const char *const jparse_utils_version = JPARSE_UTILS_VERSION; /* jparse utils (util.c) version */
const char *const jparse_utf8_version = JPARSE_UTF8_VERSION; /* jparse utf8 version */
const char *const jparse_version = JPARSE_VERSION; /* jparse tool version */
const char *const jparse_tool_version = JPARSE_TOOL_VERSION; /* jparse tool version */

%}

Expand Down
10 changes: 8 additions & 2 deletions jparse/jparse_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

#include <stdio.h>
#include <unistd.h>
#include <locale.h>

/*
* jparse_main - tool that parses a block of JSON input
Expand Down Expand Up @@ -104,6 +105,11 @@ main(int argc, char **argv)
int arg_count = 0; /* number of args to process */
int i;

/*
* use default locale based on LANG
*/
(void) setlocale(LC_ALL, "");

/*
* parse args
*/
Expand Down Expand Up @@ -138,7 +144,7 @@ main(int argc, char **argv)
msg_warn_silent = true;
break;
case 'V': /* -V - print version strings and exit */
print("%s version: %s\n", JPARSE_BASENAME, JPARSE_VERSION);
print("%s version: %s\n", JPARSE_BASENAME, JPARSE_TOOL_VERSION);
print("jparse utils version: %s\n", JPARSE_UTILS_VERSION);
print("jparse UTF-8 version: %s\n", JPARSE_UTF8_VERSION);
print("jparse library version: %s\n", JPARSE_LIBRARY_VERSION);
Expand Down Expand Up @@ -250,7 +256,7 @@ usage(int exitcode, char const *prog, char const *str)
fprintf_usage(DO_NOT_EXIT, stderr, "%s\n", str);
}
fprintf_usage(exitcode, stderr, usage_msg, prog,
DBG_DEFAULT, JSON_DBG_DEFAULT, JPARSE_BASENAME, JPARSE_VERSION, JPARSE_UTILS_VERSION, JPARSE_UTF8_VERSION,
DBG_DEFAULT, JSON_DBG_DEFAULT, JPARSE_BASENAME, JPARSE_TOOL_VERSION, JPARSE_UTILS_VERSION, JPARSE_UTF8_VERSION,
JPARSE_LIBRARY_VERSION);
exit(exitcode); /*ooo*/
not_reached();
Expand Down
6 changes: 6 additions & 0 deletions jparse/jsemtblgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

#include <stdio.h>
#include <unistd.h>
#include <locale.h>

/*
* jsemtblgen - generate JSON semantics table
Expand Down Expand Up @@ -288,6 +289,11 @@ main(int argc, char **argv)
int i;
size_t c;

/*
* use default locale based on LANG
*/
(void) setlocale(LC_ALL, "");

/*
* parse args
*/
Expand Down
2 changes: 1 addition & 1 deletion jparse/jsemtblgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
/*
* official jsemtblgen version
*/
#define JSEMTBLGEN_VERSION "2.0.0 2025-02-28" /* format: major.minor YYYY-MM-DD */
#define JSEMTBLGEN_VERSION "2.0.1 2025-03-15" /* format: major.minor YYYY-MM-DD */

/*
* jsemtblgen tool basename
Expand Down
17 changes: 15 additions & 2 deletions jparse/json_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ open_json_dir_file(char const *dir, char const *filename)
* It is up to the caller to free the struct json if needed.
*
* This function does NOT walk the JSON parse tree, so it will
* ignore links form this node to other JSON parse tree nodes.
* ignore links from this node to other JSON parse tree nodes.
*
* NOTE: If the pointer to allocated storage == NULL,
* this function does nothing.
Expand Down Expand Up @@ -1509,7 +1509,11 @@ fprnumber(FILE *stream, char *prestr, struct json_number *item, char *midstr, ch
/*
* print struct json_number information
*
* At -J 4 or higher, we print all struct json_number
* At -J 4 or higher, we print all struct json_number details.
*
* NOTE: see
* https://github.com/xexyl/jparse/blob/master/jparse_library_README.md for
* how to parse the string.
*/
if (json_verbosity_level > JSON_DBG_MED) {

Expand Down Expand Up @@ -1549,6 +1553,11 @@ fprnumber(FILE *stream, char *prestr, struct json_number *item, char *midstr, ch
item->as_longdouble_int?"ldi":"");
} else {

/*
* NOTE: see
* https://github.com/xexyl/jparse/blob/master/jparse_library_README.md for
* how to parse the string.
*/
/* -J 3 */ fprint(stream, "%s%s%s%s%s%s%s",
PARSED_JSON_NODE(item)?"p":"",
CONVERTED_PARSED_JSON_NODE(item)?",":":",
Expand Down Expand Up @@ -1638,6 +1647,10 @@ fprstring(FILE *stream, struct json_string *item)

/*
* print string preamble
*
* NOTE: see
* https://github.com/xexyl/jparse/blob/master/jparse_library_README.md
* for how to parse the string.
*/
fprint(stream, "\tlen{%s%s%s%s%s%s%s%s%s}: %ju\tvalue:\t",
PARSED_JSON_NODE(item)?"p":"",
Expand Down
11 changes: 4 additions & 7 deletions jparse/jstrdecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,9 @@ main(int argc, char **argv)
char *dup_input = NULL; /* duplicate of arg string */

/*
* set locale
* use default locale based on LANG
*/
if (setlocale(LC_ALL, "") == NULL) {
err(13, __func__, "failed to set locale");
not_reached();
}
(void) setlocale(LC_ALL, "");

/*
* parse args
Expand Down Expand Up @@ -551,7 +548,7 @@ main(int argc, char **argv)
*/
dup_input = dup_without_nl(input, &inputlen);
if (dup_input == NULL) {
err(14, __func__, "dup_without_nl failed");
err(13, __func__, "dup_without_nl failed");
not_reached();
}

Expand All @@ -569,7 +566,7 @@ main(int argc, char **argv)
if (json_parse) {
tree = parse_json_str(input, inputlen, &is_valid);
if (!is_valid || tree == NULL) {
err(15, __func__, "invalid JSON");
err(14, __func__, "invalid JSON");
not_reached();
} else {
json_tree_free(tree, JSON_INFINITE_DEPTH);
Expand Down
2 changes: 1 addition & 1 deletion jparse/jstrdecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
/*
* official jstrdecode version
*/
#define JSTRDECODE_VERSION "2.2.0 2025-02-28" /* format: major.minor YYYY-MM-DD */
#define JSTRDECODE_VERSION "2.2.2 2025-03-15" /* format: major.minor YYYY-MM-DD */


/*
Expand Down
9 changes: 3 additions & 6 deletions jparse/jstrencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,9 @@ main(int argc, char **argv)
char *dup_input = NULL; /* duplicate of input w/o newlines */

/*
* set locale
* use default locale based on LANG
*/
if (setlocale(LC_ALL, "") == NULL) {
err(12, __func__, "failed to set locale");
not_reached();
}
(void) setlocale(LC_ALL, "");

/*
* parse args
Expand Down Expand Up @@ -570,7 +567,7 @@ main(int argc, char **argv)
*/
dup_input = dup_without_nl(input, &inputlen);
if (dup_input == NULL) {
err(13, __func__, "dup_without_nl failed");
err(12, __func__, "dup_without_nl failed");
not_reached();
}

Expand Down
2 changes: 1 addition & 1 deletion jparse/jstrencode.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
/*
* official jstrencode version
*/
#define JSTRENCODE_VERSION "2.2.0 2025-02-28" /* format: major.minor YYYY-MM-DD */
#define JSTRENCODE_VERSION "2.2.2 2025-03-15" /* format: major.minor YYYY-MM-DD */


/*
Expand Down
Loading