From 079f92a31281573b8a7b152b1730e7a349ac6365 Mon Sep 17 00:00:00 2001 From: Pierre-Alexandre Meyer Date: Sun, 1 Nov 2009 00:12:16 -0700 Subject: [PATCH] hdt: use plain printf for help, not more_printf (CLI) The help prints several elements on the same line. This can't work with more_printf() as the macro assumes each call contains one and only one \n. Signed-off-by: Pierre-Alexandre Meyer --- com32/hdt/hdt-cli-hdt.c | 31 +++++++++++++++---------------- com32/hdt/hdt-common.h | 6 +++++- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c index 5034725..1a2df78 100644 --- a/com32/hdt/hdt-cli-hdt.c +++ b/com32/hdt/hdt-cli-hdt.c @@ -53,12 +53,12 @@ static void main_show_modes(int argc __unused, char** argv __unused, int i = 0; reset_more_printf(); - more_printf("Available modes:\n"); + printf("Available modes:\n"); while (list_modes[i]) { - more_printf("%s ", list_modes[i]->name); + printf("%s ", list_modes[i]->name); i++; } - more_printf("\n"); + printf("\n"); } /** @@ -119,44 +119,43 @@ static void show_cli_help(int argc __unused, char** argv __unused, find_cli_mode_descr(hdt_cli.mode, ¤t_mode); - reset_more_printf(); - more_printf("Available commands are:\n"); + printf("Available commands are:\n"); /* List first default modules of the mode */ if (current_mode->default_modules && current_mode->default_modules->modules) { while (current_mode->default_modules->modules[j].name) { - more_printf("%s ", + printf("%s ", current_mode->default_modules->modules[j].name); j++; } - more_printf("\n"); + printf("\n"); } /* List secondly the show modules of the mode */ if (current_mode->show_modules && current_mode->show_modules->modules) { - more_printf("\nshow commands:\n"); + printf("\nshow commands:\n"); j = 0; while (current_mode->show_modules->modules[j].name) { - more_printf("%s ", + printf("%s ", current_mode->show_modules->modules[j].name); j++; } - more_printf("\n"); + printf("\n"); } /* List thirdly the set modules of the mode */ if (current_mode->set_modules && current_mode->set_modules->modules) { - more_printf("\nset commands:\n"); + printf("\nset commands:\n"); j = 0; while (current_mode->set_modules->modules[j].name) { - more_printf("%s ", + printf("%s ", current_mode->set_modules->modules[j].name); j++; } - more_printf("\n"); + printf("\n"); } /* List finally the default modules of the hdt mode */ @@ -176,14 +175,14 @@ static void show_cli_help(int argc __unused, char** argv __unused, current_mode->default_modules, &associated_module); if (associated_module == NULL) - more_printf("%s ", + printf("%s ", hdt_mode.default_modules->modules[j].name); j++; } - more_printf("\n"); + printf("\n"); } - more_printf("\n"); + printf("\n"); main_show_modes(argc, argv, hardware); } diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h index dddcb55..c84c0fe 100644 --- a/com32/hdt/hdt-common.h +++ b/com32/hdt/hdt-common.h @@ -65,6 +65,10 @@ extern int display_line_nb; printf("\033[2K\033[1G\033[1F\n");\ } while (0); +/* The brokeness of that macro is that + * it assumes that __VA_ARGS__ contains + * one \n (and only one) + */ #define more_printf(...) do {\ if (display_line_nb == 20) {\ printf("\n--More--");\ @@ -73,7 +77,7 @@ extern int display_line_nb; printf("\033[2K\033[1G\033[1F");\ }\ printf(__VA_ARGS__);\ - display_line_nb++; \ + display_line_nb++;\ } while (0); /* Display CPU registers for debugging purposes */ -- 2.7.4