Skip to content

Commit

Permalink
Add 'ne' to -S/-n help for jval/jnamval
Browse files Browse the repository at this point in the history
Minor fix in jval and jnamval - new version 0.0.15 2023-09-13.

The 'ne' operator for -S and -n already was parsed (by foresight that it would
be needed, maybe) but it was not in the help. Also I decided to change the order
of the enum so that JSON_CMP_OP_NE comes right after JSON_CMP_OP_EQ rather
than at the end.

Man pages updated - added 'ne' to -S and -n options.
  • Loading branch information
xexyl committed Sep 13, 2023
1 parent f73bbaf commit f893b3a
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 25 deletions.
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Major changes to the IOCCC entry toolkit

## Release 1.0.53 2023-09-13

Minor fix in `jval` and `jnamval` - new version `"0.0.15 2023-09-13"`. The `ne`
operator for `-S` and `-n` already was parsed (by foresight that it would
be needed, maybe) but it was not in the help. Also I decided to change the order
of the enum so that `JSON_CMP_OP_NE` comes right after `JSON_CMP_OP_EQ` rather
than at the end.

Man pages updated - added `ne` to `-S` and `-n` options.


## Release 1.0.52 2023-08-09

New version of `jval` and `jnamval`, `"0.0.14 2023-08-09"`.
Expand Down
4 changes: 2 additions & 2 deletions jparse/jnamval.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ static const char * const usage_msg0 =
"\n"
"\t-n op=num\tMatch if numeric op with num is true (def: do not)\n"
"\n"
"\t\t\top may be one of: eq, lt, le, gt, ge\n"
"\t\t\top may be one of: eq, ne, lt, le, gt, ge\n"
"\n"
"\t-S op=str\n"
"\t\t\top may be one of: eq, lt, le, gt, ge\n"
"\t\t\top may be one of: eq, ne, lt, le, gt, ge\n"
"\n"
"\t-o ofile\tWrite to ofile (def: stdout)\n";

Expand Down
2 changes: 1 addition & 1 deletion jparse/jnamval.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#include "jparse.h"

/* jnamval version string */
#define JNAMVAL_VERSION "0.0.14 2023-08-09" /* format: major.minor YYYY-MM-DD */
#define JNAMVAL_VERSION "0.0.15 2023-09-13" /* format: major.minor YYYY-MM-DD */

/* jnamval functions - see jnamval_util.h for most */

Expand Down
24 changes: 12 additions & 12 deletions jparse/json_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2755,18 +2755,20 @@ json_util_parse_cmp_op(struct json_util_name_val *json_name_val, const char *opt

p = strchr(optarg, '=');
if (p == NULL) {
err(31, __func__, "syntax error in -%s: use -%s {eq,lt,le,gt,ge,ne}=%s", option, option, mode);
err(31, __func__, "syntax error in -%s: use -%s {eq,ne,lt,le,gt,ge,ne}=%s", option, option, mode);
not_reached();
} else if (p == optarg) {
err(32, __func__, "syntax error in -%s: use -%s {eq,lt,le,gt,ge,ne}=%s", option, option, mode);
err(32, __func__, "syntax error in -%s: use -%s {eq,ne,lt,le,gt,ge,ne}=%s", option, option, mode);
not_reached();
} else if (p[1] == '\0') {
err(33, __func__, "nothing found after =: use -%s {eq,lt,le,gt,ge,ne}=%s", option, mode);
err(33, __func__, "nothing found after =: use -%s {eq,ne,lt,le,gt,ge,ne}=%s", option, mode);
not_reached();
}

if (!strncmp(optarg, "eq=", 3)) {
op = JSON_CMP_OP_EQ;
} else if (!strncmp(optarg, "ne=", 3)) {
op = JSON_CMP_OP_NE;
} else if (!strncmp(optarg, "lt=", 3)) {
op = JSON_CMP_OP_LT;
} else if (!strncmp(optarg, "le=", 3)) {
Expand All @@ -2775,17 +2777,15 @@ json_util_parse_cmp_op(struct json_util_name_val *json_name_val, const char *opt
op = JSON_CMP_OP_GT;
} else if (!strncmp(optarg, "ge=", 3)) {
op = JSON_CMP_OP_GE;
} else if (!strncmp(optarg, "ne=", 3)) {
op = JSON_CMP_OP_NE;
} else {
err(34, __func__, "invalid op found for -%s: use -%s {eq,lt,le,gt,ge,ne}=%s", option, option, mode);
err(34, __func__, "invalid op found for -%s: use -%s {eq,ne,lt,le,gt,ge,ne}=%s", option, option, mode);
not_reached();
}

errno = 0; /* pre-clear errno for errp() */
cmp = calloc(1, sizeof *cmp);
if (cmp == NULL) {
errp(36, __func__, "failed to allocate struct json_util_cmp_op * for -%s %s=%s", option, optarg, optarg + 3);
errp(35, __func__, "failed to allocate struct json_util_cmp_op * for -%s %s=%s", option, optarg, optarg + 3);
not_reached();
} else {
/* explicitly clear out struct */
Expand All @@ -2804,7 +2804,7 @@ json_util_parse_cmp_op(struct json_util_name_val *json_name_val, const char *opt
errno = 0; /* pre-clear errno for errp() */
cmp->string = strdup(optarg + 3);
if (cmp->string == NULL) {
errp(37, __func__, "failed to strdup string: <%s> for -%s: cmp->string is NULL", optarg + 3, option);
errp(36, __func__, "failed to strdup string: <%s> for -%s: cmp->string is NULL", optarg + 3, option);
not_reached();
}

Expand Down Expand Up @@ -2865,7 +2865,7 @@ free_json_util_cmp_list(struct json_util_name_val *json_name_val)

/* firewall */
if (json_name_val == NULL) {
err(35, __func__, "NULL json_name_val");
err(38, __func__, "NULL json_name_val");
not_reached();
}

Expand Down Expand Up @@ -2920,11 +2920,11 @@ parse_json_util_format(struct json_util *json_util, char const *name, char const

/* name MUST be checked first! */
if (name == NULL) {
err(41, __func__, "name is NULL");
err(39, __func__, "name is NULL");
not_reached();
}
if (json_util == NULL) {
err(42, name?name:__func__, "json_util is NULL");
err(40, name?name:__func__, "json_util is NULL");
not_reached();
}

Expand Down Expand Up @@ -2989,7 +2989,7 @@ json_util_parse_match_types(char *optarg)
errno = 0; /* pre-clear errno for errp() */
dup = strdup(optarg);
if (dup == NULL) {
errp(43, __func__, "strdup(%s) failed", optarg);
errp(41, __func__, "strdup(%s) failed", optarg);
not_reached();
}

Expand Down
10 changes: 5 additions & 5 deletions jparse/json_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ enum JSON_UTIL_CMP_OP
{
JSON_CMP_OP_NONE = 0, /* must be first */
JSON_CMP_OP_EQ = 1, /* equality check */
JSON_CMP_OP_LT = 2, /* less than check */
JSON_CMP_OP_LE = 3, /* less than or equal check */
JSON_CMP_OP_GT = 4, /* greater than check */
JSON_CMP_OP_GE = 5, /* greater than or equal check */
JSON_CMP_OP_NE = 6, /* not equal */
JSON_CMP_OP_NE = 2, /* not equal */
JSON_CMP_OP_LT = 3, /* less than check */
JSON_CMP_OP_LE = 4, /* less than or equal check */
JSON_CMP_OP_GT = 5, /* greater than check */
JSON_CMP_OP_GE = 6, /* greater than or equal check */
};


Expand Down
4 changes: 2 additions & 2 deletions jparse/jval.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ static const char * const usage_msg0 =
"\n"
"\t-n op=num\tMatch if numeric op with num is true (def: do not)\n"
"\n"
"\t\t\top may be one of: eq, lt, le, gt, ge\n"
"\t\t\top may be one of: eq, ne, lt, le, gt, ge\n"
"\n"
"\t-S op=str\n"
"\t\t\top may be one of: eq, lt, le, gt, ge\n"
"\t\t\top may be one of: eq, ne, lt, le, gt, ge\n"
"\n"
"\t-o ofile\tWrite to ofile (def: stdout)\n"
"\n"
Expand Down
2 changes: 1 addition & 1 deletion jparse/jval.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#include "jparse.h"

/* jval version string */
#define JVAL_VERSION "0.0.14 2023-08-09" /* format: major.minor YYYY-MM-DD */
#define JVAL_VERSION "0.0.15 2023-09-13" /* format: major.minor YYYY-MM-DD */

/* jval functions - see jval_util.h for most */

Expand Down
12 changes: 11 additions & 1 deletion jparse/man/man1/jnamval.1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.\" "Share and Enjoy!"
.\" -- Sirius Cybernetics Corporation Complaints Division, JSON spec department. :-)
.\"
.TH jnamval 1 "06 August 2023" "jnamval" "IOCCC tools"
.TH jnamval 1 "13 September 2023" "jnamval" "IOCCC tools"
.SH NAME
.B jnamval
\- IOCCC JSON printer
Expand Down Expand Up @@ -367,6 +367,11 @@ equal to
.RE
.RS
.TQ
.B ne
not equal to
.RE
.RS
.TQ
.B lt
less than
.RE
Expand Down Expand Up @@ -396,6 +401,11 @@ equal to
.RE
.RS
.TQ
.B ne
not equal to
.RE
.RS
.TQ
.B lt
less than
.RE
Expand Down
12 changes: 11 additions & 1 deletion jparse/man/man1/jval.1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.\" "Share and Enjoy!"
.\" -- Sirius Cybernetics Corporation Complaints Division, JSON spec department. :-)
.\"
.TH jval 1 "06 August 2023" "jval" "IOCCC tools"
.TH jval 1 "13 September 2023" "jval" "IOCCC tools"
.SH NAME
.B jval
\- IOCCC JSON printer
Expand Down Expand Up @@ -233,6 +233,11 @@ equal to
.RE
.RS
.TQ
.B ne
not equal to
.RE
.RS
.TQ
.B lt
less than
.RE
Expand Down Expand Up @@ -262,6 +267,11 @@ equal to
.RE
.RS
.TQ
.B ne
not equal to
.RE
.RS
.TQ
.B lt
less than
.RE
Expand Down

0 comments on commit f893b3a

Please sign in to comment.