2009-08-24 Vladimir Serbinenko <phcoder@gmail.com>
* script/sh/function.c (grub_script_function_find): Cut error message not to flood terminal. * script/sh/lexer.c (grub_script_yylex): Remove command line length limit. * script/sh/script.c (grub_script_arg_add): Duplicate string.
This commit is contained in:
parent
c385bfc37f
commit
48e40bff44
4 changed files with 69 additions and 24 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2009-08-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* script/sh/function.c (grub_script_function_find): Cut error message
|
||||||
|
not to flood terminal.
|
||||||
|
* script/sh/lexer.c (grub_script_yylex): Remove command line length
|
||||||
|
limit.
|
||||||
|
* script/sh/script.c (grub_script_arg_add): Duplicate string.
|
||||||
|
|
||||||
2009-08-24 Colin Watson <cjwatson@ubuntu.com>
|
2009-08-24 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
* term/usb_keyboard.c (grub_usb_keyboard_getreport): Make
|
* term/usb_keyboard.c (grub_usb_keyboard_getreport): Make
|
||||||
|
|
|
@ -99,7 +99,7 @@ grub_script_function_find (char *functionname)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (! func)
|
if (! func)
|
||||||
grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%s'", functionname);
|
grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%.20s'", functionname);
|
||||||
|
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,8 +134,6 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate)
|
||||||
{
|
{
|
||||||
grub_parser_state_t newstate;
|
grub_parser_state_t newstate;
|
||||||
char use;
|
char use;
|
||||||
char *buffer;
|
|
||||||
char *bp;
|
|
||||||
struct grub_lexer_param *state = parsestate->lexerstate;
|
struct grub_lexer_param *state = parsestate->lexerstate;
|
||||||
int firstrun = 1;
|
int firstrun = 1;
|
||||||
|
|
||||||
|
@ -212,6 +210,14 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate)
|
||||||
/* Check if it is a text. */
|
/* Check if it is a text. */
|
||||||
if (check_textstate (newstate))
|
if (check_textstate (newstate))
|
||||||
{
|
{
|
||||||
|
char *buffer = NULL;
|
||||||
|
int bufpos = 0;
|
||||||
|
/* Buffer is initially large enough to hold most commands
|
||||||
|
but extends automatically when needed. */
|
||||||
|
int bufsize = 128;
|
||||||
|
|
||||||
|
buffer = grub_malloc (bufsize);
|
||||||
|
|
||||||
/* In case the string is not quoted, this can be a one char
|
/* In case the string is not quoted, this can be a one char
|
||||||
length symbol. */
|
length symbol. */
|
||||||
if (newstate == GRUB_PARSER_STATE_TEXT)
|
if (newstate == GRUB_PARSER_STATE_TEXT)
|
||||||
|
@ -254,16 +260,12 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doexit)
|
if (doexit)
|
||||||
break;
|
{
|
||||||
|
grub_free (buffer);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: Use a better size. */
|
|
||||||
buffer = grub_script_malloc (parsestate, 2048);
|
|
||||||
if (! buffer)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
bp = buffer;
|
|
||||||
|
|
||||||
/* Read one token, possible quoted. */
|
/* Read one token, possible quoted. */
|
||||||
while (*state->script)
|
while (*state->script)
|
||||||
{
|
{
|
||||||
|
@ -295,32 +297,47 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate)
|
||||||
}
|
}
|
||||||
if (breakout)
|
if (breakout)
|
||||||
break;
|
break;
|
||||||
if (use)
|
|
||||||
*(bp++) = use;
|
|
||||||
}
|
}
|
||||||
else if (use)
|
|
||||||
*(bp++) = use;
|
if (use)
|
||||||
|
{
|
||||||
|
if (bufsize <= bufpos + 1)
|
||||||
|
{
|
||||||
|
bufsize <<= 1;
|
||||||
|
buffer = grub_realloc (buffer, bufsize);
|
||||||
|
}
|
||||||
|
buffer[bufpos++] = use;
|
||||||
|
}
|
||||||
|
|
||||||
state->state = newstate;
|
state->state = newstate;
|
||||||
nextchar (state);
|
nextchar (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A string of text was read in. */
|
/* A string of text was read in. */
|
||||||
*bp = '\0';
|
if (bufsize <= bufpos + 1)
|
||||||
|
{
|
||||||
|
bufsize <<= 1;
|
||||||
|
buffer = grub_realloc (buffer, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[bufpos++] = 0;
|
||||||
|
|
||||||
grub_dprintf ("scripting", "token=`%s'\n", buffer);
|
grub_dprintf ("scripting", "token=`%s'\n", buffer);
|
||||||
yylval->arg = grub_script_arg_add (parsestate, yylval->arg,
|
yylval->arg = grub_script_arg_add (parsestate, yylval->arg,
|
||||||
GRUB_SCRIPT_ARG_TYPE_STR, buffer);
|
GRUB_SCRIPT_ARG_TYPE_STR, buffer);
|
||||||
|
|
||||||
|
grub_free (buffer);
|
||||||
}
|
}
|
||||||
else if (newstate == GRUB_PARSER_STATE_VAR
|
else if (newstate == GRUB_PARSER_STATE_VAR
|
||||||
|| newstate == GRUB_PARSER_STATE_QVAR)
|
|| newstate == GRUB_PARSER_STATE_QVAR)
|
||||||
{
|
{
|
||||||
/* XXX: Use a better size. */
|
char *buffer = NULL;
|
||||||
buffer = grub_script_malloc (parsestate, 2096);
|
int bufpos = 0;
|
||||||
if (! buffer)
|
/* Buffer is initially large enough to hold most commands
|
||||||
return 0;
|
but extends automatically when needed. */
|
||||||
|
int bufsize = 128;
|
||||||
|
|
||||||
bp = buffer;
|
buffer = grub_malloc (bufsize);
|
||||||
|
|
||||||
/* This is a variable, read the variable name. */
|
/* This is a variable, read the variable name. */
|
||||||
while (*state->script)
|
while (*state->script)
|
||||||
|
@ -340,16 +357,33 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use)
|
if (use)
|
||||||
*(bp++) = use;
|
{
|
||||||
|
if (bufsize <= bufpos + 1)
|
||||||
|
{
|
||||||
|
bufsize <<= 1;
|
||||||
|
buffer = grub_realloc (buffer, bufsize);
|
||||||
|
}
|
||||||
|
buffer[bufpos++] = use;
|
||||||
|
}
|
||||||
|
|
||||||
nextchar (state);
|
nextchar (state);
|
||||||
state->state = newstate;
|
state->state = newstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
*bp = '\0';
|
if (bufsize <= bufpos + 1)
|
||||||
|
{
|
||||||
|
bufsize <<= 1;
|
||||||
|
buffer = grub_realloc (buffer, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[bufpos++] = 0;
|
||||||
|
|
||||||
state->state = newstate;
|
state->state = newstate;
|
||||||
yylval->arg = grub_script_arg_add (parsestate, yylval->arg,
|
yylval->arg = grub_script_arg_add (parsestate, yylval->arg,
|
||||||
GRUB_SCRIPT_ARG_TYPE_VAR, buffer);
|
GRUB_SCRIPT_ARG_TYPE_VAR, buffer);
|
||||||
grub_dprintf ("scripting", "vartoken=`%s'\n", buffer);
|
grub_dprintf ("scripting", "vartoken=`%s'\n", buffer);
|
||||||
|
|
||||||
|
grub_free (buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,10 +110,13 @@ grub_script_arg_add (struct grub_parser_param *state, struct grub_script_arg *ar
|
||||||
{
|
{
|
||||||
struct grub_script_arg *argpart;
|
struct grub_script_arg *argpart;
|
||||||
struct grub_script_arg *ll;
|
struct grub_script_arg *ll;
|
||||||
|
int len;
|
||||||
|
|
||||||
argpart = (struct grub_script_arg *) grub_script_malloc (state, sizeof (*arg));
|
argpart = (struct grub_script_arg *) grub_script_malloc (state, sizeof (*arg));
|
||||||
argpart->type = type;
|
argpart->type = type;
|
||||||
argpart->str = str;
|
len = grub_strlen (str) + 1;
|
||||||
|
argpart->str = grub_script_malloc (state, len);
|
||||||
|
grub_memcpy (argpart->str, str, len);
|
||||||
argpart->next = 0;
|
argpart->next = 0;
|
||||||
|
|
||||||
if (! arg)
|
if (! arg)
|
||||||
|
|
Loading…
Reference in a new issue