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.
This commit is contained in:
Bruce Evans 2006-10-08 18:15:08 +00:00
parent 0f85b689a5
commit 2481da7487
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163134
4 changed files with 6 additions and 6 deletions

View File

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

View File

@ -176,7 +176,7 @@ db_examine(addr, fmt, count)
break;
}
if (db_print_position() != 0)
db_end_line();
db_end_line(1);
break;
}
}

View File

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

View File

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