Skip to content

Commit

Permalink
table: append newline when printing tables
Browse files Browse the repository at this point in the history
With commit cb139fa ("table: New function table_format() for
formatting a table as a string.") a new mechanism for formatting
tables was introduced, and the table_print method was refactored to
use this.

During that refactor, calls to 'puts' were replaced with
'ds_put_cstr', and table print was changed to use 'fputs(...,
stdout)'.  Unfortunately, fputs() does not append a newline to the
string provided, and changes the output strings of, for example,
ovsdb-client dump to print all on one line.  This means
post-processing scripts that are chained after ovsdb-client would
either block indefinitely (if they don't detect EOF), or process the
entire bundle at once (rather than seeing each table on a separate
line).

Fixes: cb139fa ("table: New function table_format() for formatting a table as a string.")
Cc: Ben Pfaff <[email protected]>
Cc: Jakub Sitnicki <[email protected]>
Reported-by: Terry Wilson <[email protected]>
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1608508
Signed-off-by: Aaron Conole <[email protected]>
Suggested-by: Ben Pfaff <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Terry Wilson <[email protected]>
Tested-by: Terry Wilson <[email protected]>
  • Loading branch information
apconole authored and blp committed Aug 8, 2018
1 parent 111b58c commit 3562353
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ table_print_json__(const struct table *table, const struct table_style *style,
json_object_put(json, "data", data);

json_to_ds(json, style->json_flags, s);
ds_put_char(s, '\n');
json_destroy(json);
}

Expand Down

0 comments on commit 3562353

Please sign in to comment.