Browse Source

[core] remove excess counts from print config

remove excess counts from print config
simplify double-quoted string printing
master
Glenn Strauss 7 months ago
parent
commit
942c2f6722
  1. 9
      src/array.c
  2. 20
      src/data_string.c

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

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

Loading…
Cancel
Save