Redo how example/jsonptr's -indent=N -tabs works
diff --git a/example/jsonptr/jsonptr.cc b/example/jsonptr/jsonptr.cc
index fadbadb..70bc44e 100644
--- a/example/jsonptr/jsonptr.cc
+++ b/example/jsonptr/jsonptr.cc
@@ -162,7 +162,7 @@
#define MAX_INDENT 8
#define INDENT_SPACES_STRING " "
-#define INDENT_TABS_STRING "\t\t\t\t\t\t\t\t"
+#define INDENT_TAB_STRING "\t"
#ifndef DST_BUFFER_SIZE
#define DST_BUFFER_SIZE (32 * 1024)
@@ -445,7 +445,7 @@
const char* //
parse_flags(int argc, char** argv) {
- bool explicit_indent = false;
+ flags.indent = 4;
int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name.
for (; c < argc; c++) {
@@ -480,7 +480,6 @@
}
if (('0' <= arg[0]) && (arg[0] <= '8') && (arg[1] == '\x00')) {
flags.indent = arg[0] - '0';
- explicit_indent = true;
continue;
}
return usage;
@@ -504,9 +503,6 @@
flags.remaining_argc = argc - c;
flags.remaining_argv = argv + c;
- if (!explicit_indent) {
- flags.indent = flags.tabs ? 1 : 4;
- }
return nullptr;
}
@@ -711,8 +707,8 @@
(ctx != context::in_dict_after_brace) && !flags.compact) {
TRY(write_dst("\n", 1));
for (uint32_t i = 0; i < depth; i++) {
- TRY(write_dst(flags.tabs ? INDENT_TABS_STRING : INDENT_SPACES_STRING,
- flags.indent));
+ TRY(write_dst(flags.tabs ? INDENT_TAB_STRING : INDENT_SPACES_STRING,
+ flags.tabs ? 1 : flags.indent));
}
}
@@ -737,9 +733,8 @@
if (!flags.compact) {
TRY(write_dst("\n", 1));
for (size_t i = 0; i < depth; i++) {
- TRY(write_dst(
- flags.tabs ? INDENT_TABS_STRING : INDENT_SPACES_STRING,
- flags.indent));
+ TRY(write_dst(flags.tabs ? INDENT_TAB_STRING : INDENT_SPACES_STRING,
+ flags.tabs ? 1 : flags.indent));
}
}
}
diff --git a/test/c/testlib/testlib.c b/test/c/testlib/testlib.c
index 592c847..68b2172 100644
--- a/test/c/testlib/testlib.c
+++ b/test/c/testlib/testlib.c
@@ -118,8 +118,8 @@
const char* //
parse_flags(int argc, char** argv) {
- bool explicit_iterscale = false;
- bool explicit_reps = false;
+ flags.iterscale = 100;
+ flags.reps = 5;
int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name.
for (; c < argc; c++) {
@@ -165,7 +165,6 @@
return "out-of-range -iterscale=N value";
}
flags.iterscale = n;
- explicit_iterscale = true;
continue;
}
@@ -183,7 +182,6 @@
return "out-of-range -reps=N value";
}
flags.reps = n;
- explicit_reps = true;
continue;
}
@@ -192,12 +190,6 @@
flags.remaining_argc = argc - c;
flags.remaining_argv = argv + c;
- if (!explicit_iterscale) {
- flags.iterscale = 100;
- }
- if (!explicit_reps) {
- flags.reps = 5;
- }
return NULL;
}