hdt: use plain printf for help, not more_printf (CLI)
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Sun, 1 Nov 2009 07:12:16 +0000 (00:12 -0700)
committerErwan Velu <erwan.velu@free.fr>
Sun, 1 Nov 2009 12:06:00 +0000 (13:06 +0100)
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 <pierre@mouraf.org>
com32/hdt/hdt-cli-hdt.c
com32/hdt/hdt-common.h

index 5034725..1a2df78 100644 (file)
@@ -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, &current_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);
 }
 
index dddcb55..c84c0fe 100644 (file)
@@ -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 */