[core] remove excess counts from print config

remove excess counts from print config
simplify double-quoted string printing
personal/stbuehler/tests-path
Glenn Strauss 2021-05-19 16:41:53 -04:00
parent 0329e765a3
commit 942c2f6722
2 changed files with 6 additions and 23 deletions

View File

@ -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, ")");

View File

@ -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);