* kern/parser.c: Indented.
This commit is contained in:
parent
ed0e3d30cd
commit
f84afb2775
2 changed files with 74 additions and 70 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2010-03-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/parser.c: Indented.
|
||||||
|
|
||||||
2010-03-17 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-03-17 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* term/i386/pc/vesafb.c: Removed (orphaned, deprecated and broken).
|
* term/i386/pc/vesafb.c: Removed (orphaned, deprecated and broken).
|
||||||
|
|
|
@ -26,32 +26,31 @@
|
||||||
/* All the possible state transitions on the command line. If a
|
/* All the possible state transitions on the command line. If a
|
||||||
transition can not be found, it is assumed that there is no
|
transition can not be found, it is assumed that there is no
|
||||||
transition and keep_value is assumed to be 1. */
|
transition and keep_value is assumed to be 1. */
|
||||||
static struct grub_parser_state_transition state_transitions[] =
|
static struct grub_parser_state_transition state_transitions[] = {
|
||||||
{
|
{GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_QUOTE, '\'', 0},
|
||||||
{ GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_QUOTE, '\'', 0},
|
{GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_DQUOTE, '\"', 0},
|
||||||
{ GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_DQUOTE, '\"', 0},
|
{GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_VAR, '$', 0},
|
||||||
{ GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_VAR, '$', 0},
|
{GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_ESC, '\\', 0},
|
||||||
{ GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_ESC, '\\', 0},
|
|
||||||
|
|
||||||
{ GRUB_PARSER_STATE_ESC, GRUB_PARSER_STATE_TEXT, 0, 1},
|
{GRUB_PARSER_STATE_ESC, GRUB_PARSER_STATE_TEXT, 0, 1},
|
||||||
|
|
||||||
{ GRUB_PARSER_STATE_QUOTE, GRUB_PARSER_STATE_TEXT, '\'', 0},
|
{GRUB_PARSER_STATE_QUOTE, GRUB_PARSER_STATE_TEXT, '\'', 0},
|
||||||
|
|
||||||
{ GRUB_PARSER_STATE_DQUOTE, GRUB_PARSER_STATE_TEXT, '\"', 0},
|
{GRUB_PARSER_STATE_DQUOTE, GRUB_PARSER_STATE_TEXT, '\"', 0},
|
||||||
{ GRUB_PARSER_STATE_DQUOTE, GRUB_PARSER_STATE_QVAR, '$', 0},
|
{GRUB_PARSER_STATE_DQUOTE, GRUB_PARSER_STATE_QVAR, '$', 0},
|
||||||
|
|
||||||
{ GRUB_PARSER_STATE_VAR, GRUB_PARSER_STATE_VARNAME2, '{', 0},
|
{GRUB_PARSER_STATE_VAR, GRUB_PARSER_STATE_VARNAME2, '{', 0},
|
||||||
{ GRUB_PARSER_STATE_VAR, GRUB_PARSER_STATE_VARNAME, 0, 1},
|
{GRUB_PARSER_STATE_VAR, GRUB_PARSER_STATE_VARNAME, 0, 1},
|
||||||
{ GRUB_PARSER_STATE_VARNAME, GRUB_PARSER_STATE_TEXT, ' ', 1},
|
{GRUB_PARSER_STATE_VARNAME, GRUB_PARSER_STATE_TEXT, ' ', 1},
|
||||||
{ GRUB_PARSER_STATE_VARNAME2, GRUB_PARSER_STATE_TEXT, '}', 0},
|
{GRUB_PARSER_STATE_VARNAME2, GRUB_PARSER_STATE_TEXT, '}', 0},
|
||||||
|
|
||||||
{ GRUB_PARSER_STATE_QVAR, GRUB_PARSER_STATE_QVARNAME2, '{', 0},
|
{GRUB_PARSER_STATE_QVAR, GRUB_PARSER_STATE_QVARNAME2, '{', 0},
|
||||||
{ GRUB_PARSER_STATE_QVAR, GRUB_PARSER_STATE_QVARNAME, 0, 1},
|
{GRUB_PARSER_STATE_QVAR, GRUB_PARSER_STATE_QVARNAME, 0, 1},
|
||||||
{ GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_TEXT, '\"', 0},
|
{GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_TEXT, '\"', 0},
|
||||||
{ GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_DQUOTE, ' ', 1},
|
{GRUB_PARSER_STATE_QVARNAME, GRUB_PARSER_STATE_DQUOTE, ' ', 1},
|
||||||
{ GRUB_PARSER_STATE_QVARNAME2, GRUB_PARSER_STATE_DQUOTE, '}', 0},
|
{GRUB_PARSER_STATE_QVARNAME2, GRUB_PARSER_STATE_DQUOTE, '}', 0},
|
||||||
|
|
||||||
{ 0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,8 +73,8 @@ grub_parser_cmdline_state (grub_parser_state_t state, char c, char *result)
|
||||||
if (transition->input == c)
|
if (transition->input == c)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (transition->input == ' ' && ! grub_isalpha (c)
|
if (transition->input == ' ' && !grub_isalpha (c)
|
||||||
&& ! grub_isdigit (c) && c != '_')
|
&& !grub_isdigit (c) && c != '_')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* A less perfect match was found, use this one if no exact
|
/* A less perfect match was found, use this one if no exact
|
||||||
|
@ -84,7 +83,7 @@ grub_parser_cmdline_state (grub_parser_state_t state, char c, char *result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! transition->from_state)
|
if (!transition->from_state)
|
||||||
transition = &default_transition;
|
transition = &default_transition;
|
||||||
|
|
||||||
if (transition->keep_value)
|
if (transition->keep_value)
|
||||||
|
@ -128,13 +127,13 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
|
||||||
|
|
||||||
/* Check if a variable was being read in and the end of the name
|
/* Check if a variable was being read in and the end of the name
|
||||||
was reached. */
|
was reached. */
|
||||||
if (! (check_varstate (state) && !check_varstate (newstate)))
|
if (!(check_varstate (state) && !check_varstate (newstate)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
*(vp++) = '\0';
|
*(vp++) = '\0';
|
||||||
val = grub_env_get (varname);
|
val = grub_env_get (varname);
|
||||||
vp = varname;
|
vp = varname;
|
||||||
if (! val)
|
if (!val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Insert the contents of the variable in the buffer. */
|
/* Insert the contents of the variable in the buffer. */
|
||||||
|
@ -145,11 +144,12 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
|
||||||
*argc = 0;
|
*argc = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (! rd || !*rd)
|
if (!rd || !*rd)
|
||||||
{
|
{
|
||||||
if (getline)
|
if (getline)
|
||||||
getline (&rd, 1);
|
getline (&rd, 1);
|
||||||
else break;
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rd)
|
if (!rd)
|
||||||
|
@ -190,7 +190,8 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
|
||||||
}
|
}
|
||||||
state = newstate;
|
state = newstate;
|
||||||
}
|
}
|
||||||
} while (state != GRUB_PARSER_STATE_TEXT && !check_varstate (state));
|
}
|
||||||
|
while (state != GRUB_PARSER_STATE_TEXT && !check_varstate (state));
|
||||||
|
|
||||||
/* 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. */
|
||||||
|
@ -204,12 +205,12 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
|
||||||
|
|
||||||
/* Reserve memory for the return values. */
|
/* Reserve memory for the return values. */
|
||||||
args = grub_malloc (bp - buffer);
|
args = grub_malloc (bp - buffer);
|
||||||
if (! args)
|
if (!args)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
grub_memcpy (args, buffer, bp - buffer);
|
grub_memcpy (args, buffer, bp - buffer);
|
||||||
|
|
||||||
*argv = grub_malloc (sizeof (char *) * (*argc + 1));
|
*argv = grub_malloc (sizeof (char *) * (*argc + 1));
|
||||||
if (! *argv)
|
if (!*argv)
|
||||||
{
|
{
|
||||||
grub_free (args);
|
grub_free (args);
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
@ -229,10 +230,9 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct grub_handler_class grub_parser_class =
|
struct grub_handler_class grub_parser_class = {
|
||||||
{
|
|
||||||
.name = "parser"
|
.name = "parser"
|
||||||
};
|
};
|
||||||
|
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_parser_execute (char *source)
|
grub_parser_execute (char *source)
|
||||||
|
@ -242,7 +242,7 @@ grub_parser_execute (char *source)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (! source)
|
if (!source)
|
||||||
{
|
{
|
||||||
*line = 0;
|
*line = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue