* grub-core/kern/parser.c (grub_parser_split_cmdline): Remove nested
function.
This commit is contained in:
parent
4bfe934cd1
commit
ac319fbc90
2 changed files with 30 additions and 24 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/kern/parser.c (grub_parser_split_cmdline): Remove nested
|
||||||
|
function.
|
||||||
|
|
||||||
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-11-07 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/kern/misc.c (grub_vsnprintf_real): Remove nested functions.
|
* grub-core/kern/misc.c (grub_vsnprintf_real): Remove nested functions.
|
||||||
|
|
|
@ -106,6 +106,29 @@ check_varstate (grub_parser_state_t s)
|
||||||
|| s == GRUB_PARSER_STATE_QVARNAME2);
|
|| s == GRUB_PARSER_STATE_QVARNAME2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_var (char *varname, char **bp, char **vp,
|
||||||
|
grub_parser_state_t state, grub_parser_state_t newstate)
|
||||||
|
{
|
||||||
|
const char *val;
|
||||||
|
|
||||||
|
/* Check if a variable was being read in and the end of the name
|
||||||
|
was reached. */
|
||||||
|
if (!(check_varstate (state) && !check_varstate (newstate)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
*((*vp)++) = '\0';
|
||||||
|
val = grub_env_get (varname);
|
||||||
|
*vp = varname;
|
||||||
|
if (!val)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Insert the contents of the variable in the buffer. */
|
||||||
|
for (; *val; val++)
|
||||||
|
*((*bp)++) = *val;
|
||||||
|
}
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_parser_split_cmdline (const char *cmdline,
|
grub_parser_split_cmdline (const char *cmdline,
|
||||||
grub_reader_getline_t getline, void *getline_data,
|
grub_reader_getline_t getline, void *getline_data,
|
||||||
|
@ -122,28 +145,6 @@ grub_parser_split_cmdline (const char *cmdline,
|
||||||
char *args;
|
char *args;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
auto void add_var (grub_parser_state_t newstate);
|
|
||||||
|
|
||||||
void add_var (grub_parser_state_t newstate)
|
|
||||||
{
|
|
||||||
const char *val;
|
|
||||||
|
|
||||||
/* Check if a variable was being read in and the end of the name
|
|
||||||
was reached. */
|
|
||||||
if (!(check_varstate (state) && !check_varstate (newstate)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
*(vp++) = '\0';
|
|
||||||
val = grub_env_get (varname);
|
|
||||||
vp = varname;
|
|
||||||
if (!val)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Insert the contents of the variable in the buffer. */
|
|
||||||
for (; *val; val++)
|
|
||||||
*(bp++) = *val;
|
|
||||||
}
|
|
||||||
|
|
||||||
*argc = 0;
|
*argc = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -168,7 +169,7 @@ grub_parser_split_cmdline (const char *cmdline,
|
||||||
/* If a variable was being processed and this character does
|
/* If a variable was being processed and this character does
|
||||||
not describe the variable anymore, write the variable to
|
not describe the variable anymore, write the variable to
|
||||||
the buffer. */
|
the buffer. */
|
||||||
add_var (newstate);
|
add_var (varname, &bp, &vp, state, newstate);
|
||||||
|
|
||||||
if (check_varstate (newstate))
|
if (check_varstate (newstate))
|
||||||
{
|
{
|
||||||
|
@ -198,7 +199,7 @@ grub_parser_split_cmdline (const char *cmdline,
|
||||||
|
|
||||||
/* A special case for when the last character was part of a
|
/* A special case for when the last character was part of a
|
||||||
variable. */
|
variable. */
|
||||||
add_var (GRUB_PARSER_STATE_TEXT);
|
add_var (varname, &bp, &vp, state, GRUB_PARSER_STATE_TEXT);
|
||||||
|
|
||||||
if (bp != buffer && *(bp - 1))
|
if (bp != buffer && *(bp - 1))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue