2009-12-20 Vladimir Serbinenko <phcoder@gmail.com>

* kern/parser.c (grub_parser_split_cmdline): Fix incorrect counting
	of arguments. Return number of tokens and not arguments. All users
	updated.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-12-20 22:54:12 +01:00
parent de15bf8e7f
commit 3041d8989c
4 changed files with 26 additions and 10 deletions

View file

@ -142,7 +142,7 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
*(bp++) = *val;
}
*argc = 1;
*argc = 0;
do
{
if (! *rd)
@ -188,12 +188,16 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
state = newstate;
}
} while (state != GRUB_PARSER_STATE_TEXT && !check_varstate (state));
*(bp++) = '\0';
/* A special case for when the last character was part of a
variable. */
add_var (GRUB_PARSER_STATE_TEXT);
if (bp != buffer && *(bp - 1))
{
*(bp++) = '\0';
(*argc)++;
}
/* Reserve memory for the return values. */
args = grub_malloc (bp - buffer);
@ -219,8 +223,6 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
bp++;
}
(*argc)--;
return 0;
}