PERFORCE change 122687 for review
Marko Zec
zec at FreeBSD.org
Mon Jul 2 01:22:41 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122687
Change 122687 by zec at zec_tpx32 on 2007/07/02 01:21:52
Sort command lists in DDB before printing them out on console.
Affected files ...
.. //depot/projects/vimage/src/sys/ddb/db_command.c#3 edit
Differences ...
==== //depot/projects/vimage/src/sys/ddb/db_command.c#3 (text+ko) ====
@@ -262,24 +262,40 @@
return (result);
}
+/*
+ * Print out a sorted command table.
+ */
static void
db_cmd_list(table)
struct command_table *table;
{
- register struct command *cmd;
- register struct command **aux_cmdp;
+ struct command *cmd;
+ struct command **aux_cmdp;
+ char *last;
+ char *next = "";
- for (cmd = table->table; cmd->name != 0; cmd++) {
- db_printf("%-12s", cmd->name);
- 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(12);
- }
+ do {
+ last = next;
+ for (cmd = table->table; cmd->name != 0; cmd++) {
+ if (strcmp(cmd->name, last) > 0 &&
+ (last == next || strcmp(cmd->name, next) < 0))
+ next = cmd->name;
+ }
+ if (table->aux_tablep != NULL) {
+ for (aux_cmdp = table->aux_tablep;
+ aux_cmdp < table->aux_tablep_end; aux_cmdp++) {
+ cmd = *aux_cmdp;
+ if (strcmp(cmd->name, last) > 0 &&
+ (last == next ||
+ strcmp(cmd->name, next) < 0))
+ next = cmd->name;
+ }
+ }
+ if (next != last) {
+ db_printf("%-12s", next);
+ db_end_line(12);
+ }
+ } while (next != last);
}
static void
More information about the p4-projects
mailing list