From 942c2f67224e75b5153387fd628f91d959425a75 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Wed, 19 May 2021 16:41:53 -0400 Subject: [PATCH] [core] remove excess counts from print config remove excess counts from print config simplify double-quoted string printing --- src/array.c | 9 --------- src/data_string.c | 20 ++++++-------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/array.c b/src/array.c index cfc4f52a..5a74561f 100644 --- a/src/array.c +++ b/src/array.c @@ -625,11 +625,6 @@ int array_print(const array * const a, int depth) { array_print_indent(depth + 1); if (!buffer_is_empty(&du->key)) { int j; - - if (i && (i % 5) == 0) { - fprintf(stdout, "# %u\n", i); - array_print_indent(depth + 1); - } fprintf(stdout, "\"%s\"", du->key.ptr); for (j = maxlen - buffer_string_length(&du->key); j > 0; j--) { fprintf(stdout, " "); @@ -639,10 +634,6 @@ int array_print(const array * const a, int depth) { du->fn->print(du, depth + 1); fprintf(stdout, ",\n"); } - if (!(i && (i - 1 % 5) == 0)) { - array_print_indent(depth + 1); - fprintf(stdout, "# %u\n", i); - } array_print_indent(depth); fprintf(stdout, ")"); diff --git a/src/data_string.c b/src/data_string.c index 9afe6943..4b425332 100644 --- a/src/data_string.c +++ b/src/data_string.c @@ -44,24 +44,16 @@ static int data_string_insert_dup(data_unset *dst, data_unset *src) { __attribute_cold__ static void data_string_print(const data_unset *d, int depth) { data_string *ds = (data_string *)d; - size_t i, len; UNUSED(depth); - /* empty and uninitialized strings */ - if (buffer_string_is_empty(&ds->value)) { - fputs("\"\"", stdout); - return; - } - /* print out the string as is, except prepend " with backslash */ putc('"', stdout); - len = buffer_string_length(&ds->value); - for (i = 0; i < len; i++) { - unsigned char c = ds->value.ptr[i]; - if (c == '"') { - fputs("\\\"", stdout); - } else { - putc(c, stdout); + const char *p = ds->value.ptr; + if (p) { + for (; *p; ++p) { + if (*p == '"') + putc('\\', stdout); + putc(*p, stdout); } } putc('"', stdout);