Rename some example/json* flags
diff --git a/example/jsonfindptrs/jsonfindptrs.cc b/example/jsonfindptrs/jsonfindptrs.cc
index 298179b..0c3a999 100644
--- a/example/jsonfindptrs/jsonfindptrs.cc
+++ b/example/jsonfindptrs/jsonfindptrs.cc
@@ -107,8 +107,8 @@
"\n"
"Flags:\n"
" -d=NUM -max-output-depth=NUM\n"
- " -s -strict-json-pointer-syntax\n"
" -input-json-extra-comma\n"
+ " -strict-json-pointer-syntax\n"
"\n"
"The input.json filename is optional. If absent, it reads from stdin.\n"
"\n"
@@ -157,14 +157,13 @@
"\n"
"----\n"
"\n"
- "The -s or -strict-json-pointer-syntax flag restricts the output lines\n"
- "to exactly RFC 6901, with only two escape sequences: \"~0\" and \"~1\"\n"
- "for \"~\" and \"/\". Without this flag, this program also lets \"~n\"\n"
- "and \"~r\" escape the New Line and Carriage Return ASCII control\n"
- "characters, which can work better with line oriented Unix tools that\n"
- "assume exactly one value (i.e. one JSON Pointer string) per line. With\n"
- "this flag, the program will fail if the input JSON's object keys contain\n"
- "\"\\u000A\" or \"\\u000D\".\n"
+ "The -strict-json-pointer-syntax flag restricts the output lines to\n"
+ "exactly RFC 6901, with only two escape sequences: \"~0\" and \"~1\" for\n"
+ "\"~\" and \"/\". Without this flag, this program also lets \"~n\" and\n"
+ "\"~r\" escape the New Line and Carriage Return ASCII control characters,\n"
+ "which can work better with line oriented Unix tools that assume exactly\n"
+ "one value (i.e. one JSON Pointer string) per line. With this flag, it\n"
+ "fails if the input JSON's keys contain \"\\u000A\" or \"\\u000D\".\n"
"\n"
"----\n"
"\n"
@@ -233,7 +232,7 @@
g_flags.input_json_extra_comma = true;
continue;
}
- if (!strcmp(arg, "s") || !strcmp(arg, "strict-json-pointer-syntax")) {
+ if (!strcmp(arg, "strict-json-pointer-syntax")) {
g_flags.strict_json_pointer_syntax = true;
continue;
}
diff --git a/example/jsonptr/jsonptr.cc b/example/jsonptr/jsonptr.cc
index 550d060..2bee059 100644
--- a/example/jsonptr/jsonptr.cc
+++ b/example/jsonptr/jsonptr.cc
@@ -152,13 +152,13 @@
"Flags:\n"
" -c -compact-output\n"
" -d=NUM -max-output-depth=NUM\n"
- " -i=NUM -indent=NUM\n"
" -q=STR -query=STR\n"
- " -s -strict-json-pointer-syntax\n"
+ " -s=NUM -spaces=NUM\n"
" -t -tabs\n"
" -fail-if-unsandboxed\n"
" -input-json-extra-comma\n"
" -output-json-extra-comma\n"
+ " -strict-json-pointer-syntax\n"
"\n"
"The input.json filename is optional. If absent, it reads from stdin.\n"
"\n"
@@ -173,8 +173,8 @@
"duplicate keys. Canonicalization does not imply Unicode normalization.\n"
"\n"
"Formatted means that arrays' and objects' elements are indented, each\n"
- "on its own line. Configure this with the -c / -compact-output, -i=NUM /\n"
- "-indent=NUM (for NUM ranging from 0 to 8) and -t / -tabs flags.\n"
+ "on its own line. Configure this with the -c / -compact-output, -s=NUM /\n"
+ "-spaces=NUM (for NUM ranging from 0 to 8) and -t / -tabs flags.\n"
"\n"
"The -input-json-extra-comma flag allows input like \"[1,2,]\", with a\n"
"comma after the final element of a JSON list or dictionary.\n"
@@ -211,12 +211,12 @@
"object has multiple \"foo\" children but the first one doesn't have a\n"
"\"bar\" child, even if later ones do.\n"
"\n"
- "The -s or -strict-json-pointer-syntax flag restricts the -query=STR\n"
- "string to exactly RFC 6901, with only two escape sequences: \"~0\" and\n"
- "\"~1\" for \"~\" and \"/\". Without this flag, this program also lets\n"
- "\"~n\" and \"~r\" escape the New Line and Carriage Return ASCII control\n"
- "characters, which can work better with line oriented Unix tools that\n"
- "assume exactly one value (i.e. one JSON Pointer string) per line.\n"
+ "The -strict-json-pointer-syntax flag restricts the -query=STR string to\n"
+ "exactly RFC 6901, with only two escape sequences: \"~0\" and \"~1\" for\n"
+ "\"~\" and \"/\". Without this flag, this program also lets \"~n\" and\n"
+ "\"~r\" escape the New Line and Carriage Return ASCII control characters,\n"
+ "which can work better with line oriented Unix tools that assume exactly\n"
+ "one value (i.e. one JSON Pointer string) per line.\n"
"\n"
"----\n"
"\n"
@@ -568,18 +568,18 @@
bool compact_output;
bool fail_if_unsandboxed;
- size_t indent;
bool input_json_extra_comma;
uint32_t max_output_depth;
bool output_json_extra_comma;
char* query_c_string;
+ size_t spaces;
bool strict_json_pointer_syntax;
bool tabs;
} g_flags = {0};
const char* //
parse_flags(int argc, char** argv) {
- g_flags.indent = 4;
+ g_flags.spaces = 4;
g_flags.max_output_depth = 0xFFFFFFFF;
int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name.
@@ -626,15 +626,6 @@
g_flags.fail_if_unsandboxed = true;
continue;
}
- if (!strncmp(arg, "i=", 2) || !strncmp(arg, "indent=", 7)) {
- while (*arg++ != '=') {
- }
- if (('0' <= arg[0]) && (arg[0] <= '8') && (arg[1] == '\x00')) {
- g_flags.indent = arg[0] - '0';
- continue;
- }
- return g_usage;
- }
if (!strcmp(arg, "input-json-extra-comma")) {
g_flags.input_json_extra_comma = true;
continue;
@@ -649,7 +640,16 @@
g_flags.query_c_string = arg;
continue;
}
- if (!strcmp(arg, "s") || !strcmp(arg, "strict-json-pointer-syntax")) {
+ if (!strncmp(arg, "s=", 2) || !strncmp(arg, "spaces=", 7)) {
+ while (*arg++ != '=') {
+ }
+ if (('0' <= arg[0]) && (arg[0] <= '8') && (arg[1] == '\x00')) {
+ g_flags.spaces = arg[0] - '0';
+ continue;
+ }
+ return g_usage;
+ }
+ if (!strcmp(arg, "strict-json-pointer-syntax")) {
g_flags.strict_json_pointer_syntax = true;
continue;
}
@@ -901,7 +901,7 @@
for (uint32_t i = 0; i < g_depth; i++) {
TRY(write_dst(
g_flags.tabs ? INDENT_TAB_STRING : INDENT_SPACES_STRING,
- g_flags.tabs ? 1 : g_flags.indent));
+ g_flags.tabs ? 1 : g_flags.spaces));
}
}
@@ -931,7 +931,7 @@
for (size_t i = 0; i < g_depth; i++) {
TRY(write_dst(
g_flags.tabs ? INDENT_TAB_STRING : INDENT_SPACES_STRING,
- g_flags.tabs ? 1 : g_flags.indent));
+ g_flags.tabs ? 1 : g_flags.spaces));
}
}
}