From 537b0b1af03cc6c53eada6df7afb4b4283f6dadb Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Thu, 19 Mar 2009 18:27:11 +0100 Subject: [PATCH] hdt: Skip heading spaces Impact: Allow user to put some space char before the real command Before that patch, it was required not having any space before the command. That's not so user friendly ;o) --- com32/hdt/hdt-cli.c | 2 +- com32/hdt/hdt-common.c | 10 ++++++++++ com32/hdt/hdt-common.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c index 3550f79..5f25b4c 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -370,7 +370,7 @@ void start_cli_mode(struct s_hardware *hardware) break; case KEY_ENTER: more_printf("\n"); - exec_command(cli.input, &cli, hardware); + exec_command(skipspace(cli.input), &cli, hardware); reset_prompt(&cli); break; case KEY_BACKSPACE: diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c index fb0c4c9..a2802f8 100644 --- a/com32/hdt/hdt-common.c +++ b/com32/hdt/hdt-common.c @@ -391,3 +391,13 @@ void clear_screen(void) fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout); display_line_nb = 0; } + +/* searching the next char that is not a space */ +char *skipspace(char *p) +{ + while (*p && *p <= ' ') + p++; + + return p; +} + diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h index 8f5da7b..bb18ca2 100644 --- a/com32/hdt/hdt-common.h +++ b/com32/hdt/hdt-common.h @@ -120,6 +120,7 @@ struct s_hardware { }; const char *find_argument(const char **argv, const char *argument); +char *skipspace(char *p); int detect_dmi(struct s_hardware *hardware); void detect_disks(struct s_hardware *hardware); void detect_pci(struct s_hardware *hardware); -- 2.7.4