From ff5fb7910a5f1cf6327ac47939d4fadc117a4701 Mon Sep 17 00:00:00 2001 From: bde Date: Sun, 8 Oct 2006 18:15:08 +0000 Subject: Fixed formatting of printing of command tables. WIth the default max output width of 79, only 6 columns of width 12 each fit, but 7 columns were printed. The fix is to pass the width of the next output to db_end_line() and not assume there that this width is always 1. Related unfixed bugs: - 1 character is wasted for a space after the last column - suppression of trailing spaces used to limit the misformatting, but seems to have been lost - in db_examine(), the width of the next output is not know and is still assumed to be 1. --- sys/ddb/db_command.c | 4 ++-- sys/ddb/db_examine.c | 2 +- sys/ddb/db_output.c | 4 ++-- sys/ddb/db_output.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sys/ddb') diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 5494c84..79143f1 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -266,14 +266,14 @@ db_cmd_list(table) for (cmd = table->table; cmd->name != 0; cmd++) { db_printf("%-12s", cmd->name); - db_end_line(); + db_end_line(12); } if (table->aux_tablep == NULL) return; for (aux_cmdp = table->aux_tablep; aux_cmdp < table->aux_tablep_end; aux_cmdp++) { db_printf("%-12s", (*aux_cmdp)->name); - db_end_line(); + db_end_line(12); } } diff --git a/sys/ddb/db_examine.c b/sys/ddb/db_examine.c index 9be98e4..b9d4353 100644 --- a/sys/ddb/db_examine.c +++ b/sys/ddb/db_examine.c @@ -176,7 +176,7 @@ db_examine(addr, fmt, count) break; } if (db_print_position() != 0) - db_end_line(); + db_end_line(1); break; } } diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c index e9f0c82..a349241 100644 --- a/sys/ddb/db_output.c +++ b/sys/ddb/db_output.c @@ -304,8 +304,8 @@ db_iprintf(fmt) * End line if too long. */ void -db_end_line() +db_end_line(int field_width) { - if (db_output_position >= db_max_width) + if (db_output_position + field_width > db_max_width) db_printf("\n"); } diff --git a/sys/ddb/db_output.h b/sys/ddb/db_output.h index 480c40d..cbf9f0e 100644 --- a/sys/ddb/db_output.h +++ b/sys/ddb/db_output.h @@ -40,7 +40,7 @@ void db_disable_pager(void); void db_enable_pager(void); -void db_end_line(void); +void db_end_line(int); void db_force_whitespace(void); int db_print_position(void); -- cgit v1.1