Bug fix for parser
PATCH 1/1 Bug fix for parser
Hi,
I write a patch for parser related bug, it fix the following problems:
1, major modification for parse.y, now it should work better. For example,
if echo aa; echo bb; then echo cc; fi
it works properly now.
2, Check for undefined variable. for example, if AA is not defined,
echo $AA
caused problem in the old version. Now it shows blank line.
3, This following commands:
function aa { echo bb; }
aa
Shows
bb
error: unknown command `aa'
Now it is ok.
4, If an command return error in grub.cfg, the following content is not parsed, for example
test A=B
menuentry aa {
set root=(hd0,1)
chainloader +1
}
The menu is not parsed as test A=B set errno to 1.
This bug can be quite tricky, for example, i remember someone report that update-grub has problem as the menu is not showed at all, but in fact, the problem is caused by the font command.
5, echo module not included in command.lst
yes, this is problem is very old, but nobody seems to be fixing it.
Signature · 1 line
Bean
2007-12-31 Bean <[email protected]>
* normal/execute.c (grub_script_exec_argument_to_string): Check for undefined variable. (grub_script_execute_cmdline): Reset grub_errno.
* normal/main.c (read_config_file): Reset grub_errno.
* normal/parse.y (script): Changed.
(script_1): New.
(delimiter): New.
(command): Changed.
(commands): Changed.
(commandblock): Changed.
(menuentry): Changed.
(if): Changed.
* conf/common.rmk (pkgdata_MODULES): Add echo.mod.
conf/common.rmk +1 -1
@@ -208,7 +208,7 @@ lvm_mod_LDFLAGS = $(COMMON_LDFLAGS) # Commands. pkglib_MODULES += hello.mod boot.mod terminal.mod ls.mod \ cmp.mod cat.mod help.mod font.mod search.mod \ - loopback.mod configfile.mod \ + loopback.mod configfile.mod echo.mod \ terminfo.mod test.mod blocklist.mod hexdump.mod # For hello.mod.
normal/execute.c +7 -2
@@ -49,7 +49,8 @@ grub_script_execute_argument_to_string (struct grub_script_arg *arg)if (argi->type ==1 ) { val =grub_env_get (argi->str); - size +=grub_strlen (val); +if (val) + size +=grub_strlen (val); }else size +=grub_strlen (argi->str);
@@ -67,7 +68,8 @@ grub_script_execute_argument_to_string (struct grub_script_arg *arg)if (argi->type ==1 ) { val =grub_env_get (argi->str); -grub_strcat (chararg, val); +if (val) +grub_strcat (chararg, val); }else grub_strcat (chararg, argi->str);
@@ -99,6 +101,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grubcmd =grub_command_find (cmdline->cmdname);if (! grubcmd) { +/* Ignore errors. */ + grub_errno =GRUB_ERR_NONE ; +/* It's not a GRUB command, try all functions. */ func =grub_script_function_find (cmdline->cmdname);if (! func)
normal/main.c +3 -0
@@ -261,6 +261,9 @@ read_config_file (const char *config, int nested)/* Execute the command(s). */ grub_script_execute (parsed_script); +/* Ignore errors. */ + grub_errno =GRUB_ERR_NONE ; +/* The parsed script was executed, throw it away. */ grub_script_free (parsed_script); }
normal/parser.y +39 -33
128 lines not on this page · raw message
Bean <[email protected]> writes:
Hi,
Quoted 7 lines
I write a patch for parser related bug, it fix the following problems:
1, major modification for parse.y, now it should work better. For example,
if echo aa; echo bb; then echo cc; fi
it works properly now.
Nice :-)
Quoted 5 lines
2, Check for undefined variable. for example, if AA is not defined,
echo $AA
caused problem in the old version. Now it shows blank line.
Ah, good :)
Quoted 11 lines
3, This following commands:
function aa { echo bb; }
aaShows
bb
error: unknown command `aa'Now it is ok.
:-)
Quoted 9 lines
4, If an command return error in grub.cfg, the following content is not parsed, for example
test A=B
menuentry aa {
set root=(hd0,1)
chainloader +1
}
Quoted 5 lines
The menu is not parsed as test A=B set errno to 1.
This bug can be quite tricky, for example, i remember someone report that update-grub has problem as the menu is not showed at all, but in fact, the problem is caused by the font command.
How did you deal with this? It's hard to determine if errors should mean the script is stopped or should continue.
Quoted 2 lines
5, echo module not included in command.lst
yes, this is problem is very old, but nobody seems to be fixing it.
:-)
Quoted 9 lines
Signature · 8 lines
Bean 2007-12-31 Bean <[email protected]> * normal/execute.c (grub_script_exec_argument_to_string): Check for undefined variable. (grub_script_execute_cmdline): Reset grub_errno. * normal/main.c (read_config_file): Reset grub_errno.
I am not sure if you do not introduce new problems this way...?
Quoted 8 lines
* normal/parse.y (script): Changed. (script_1): New. (delimiter): New. (command): Changed. (commands): Changed. (commandblock): Changed. (menuentry): Changed. (if): Changed.
Please describe what was changed.
Quoted 42 lines
* conf/common.rmk (
pkgdata_MODULES): Add echo.mod.conf/common.rmk +1
-1@@ -208,7 +208,7 @@ lvm_mod_LDFLAGS = $(COMMON_LDFLAGS) # Commands. pkglib_MODULES += hello.mod boot.mod terminal.mod ls.mod \ cmp.mod cat.mod help.mod font.mod search.mod \ - loopback.mod configfile.mod \ + loopback.mod configfile.mod echo.mod \ terminfo.mod test.mod blocklist.mod hexdump.mod # For hello.mod.normal/execute.c +4
-2@@ -49,7 +49,8 @@ grub_script_execute_argument_to_string (struct grub_script_arg *arg)if (argi->type ==1 ) { val =grub_env_get (argi->str); - size +=grub_strlen (val); +if (val) + size +=grub_strlen (val); }else size +=grub_strlen (argi->str);@@ -67,7 +68,8 @@ grub_script_execute_argument_to_string (struct grub_script_arg *arg)if (argi->type ==1 ) { val =grub_env_get (argi->str); -grub_strcat (chararg, val); +if (val) +grub_strcat (chararg, val); }else grub_strcat (chararg, argi->str);
normal/execute.c grub_script_execute_cmdline (struct grub_script_cmd *cmd) · line 106
Quoted 6 lines
normal/execute.c +3
-0@@ -99,6 +101,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grubcmd =grub_command_find (cmdline->cmdname);if (! grubcmd) { +/* Ignore errors. */ + grub_errno =GRUB_ERR_NONE ; +
What are the implications of this?
normal/main.c read_config_file (const char *config, int nested) · line 265
Quoted 13 lines
normal/execute.c +0
-0/* It's not a GRUB command, try all functions. */ func =grub_script_function_find (cmdline->cmdname);if (! func)normal/main.c +2
-0@@ -261,6 +261,9 @@ read_config_file (const char *config, int nested)/* Execute the command(s). */ grub_script_execute (parsed_script); +/* Ignore errors. */ + grub_errno =GRUB_ERR_NONE ;
Same for this. Errors are not shown this way, for example.
Quoted 22 lines
normal/main.c +0
-0/* The parsed script was executed, throw it away. */ grub_script_free (parsed_script); }normal/parser.y +2
-2@@ -43,7 +43,7 @@ %token GRUB_PARSER_TOKEN_FI "fi" %token GRUB_PARSER_TOKEN_NAME %token GRUB_PARSER_TOKEN_VAR -%type <cmd> script grubcmd command commands commandblock menuentry if +%type <cmd> script script_1 grubcmd command commands commandblock menuentry if %type <arglist> arguments; %type <arg> argument; %type <string> "if" "while" "function" "else" "then" "fi"@@ -55,12 +55,22 @@ %% /* It should be possible to do this in a clean way... */ -script: { state->err = 0} newlines commands +script: { state->err = 0} script_1
normal/parser.y line 67
Quoted 10 lines
normal/parser.y +5
-1{ - state->parsed = $3; + state->parsed = $2; } ; +script_1: commands { $$ = $1; } + | function '\n' { $$ = 0; } + | menuentry '\n' { $$ = $1; } +;
I do not like the name "script_1".
normal/parser.y line 72
Quoted 4 lines
normal/parser.y +4
-0+delimiter: '\n' + | ';' + | delimiter '\n' +;
ok
Quoted 12 lines
normal/parser.y +1
-4newlines: /* Empty */ | newlines '\n' ;@@ -124,39 +134,29 @@ grubcmd: GRUB_PARSER_TOKEN_NAME arguments ; /* A single command. */ -command: grubcmd { $$ = $1; } - | if { $$ = $1; } - | function { $$ = 0; } - | menuentry { $$ = $1; } +command: grubcmd delimiter { $$ = $1; }
normal/parser.y grubcmd: GRUB_PARSER_TOKEN_NAME arguments · line 147
Quoted 10 lines
normal/parser.y +9
-0+ | if delimiter { $$ = $1; } + | commandblock delimiter { $$ = $1; } + | error delimiter + { + $$ = 0; + yyerror (state, "Incorrect command"); + state->err = 1; + yyerrok; + } ;
Ok.
Quoted 23 lines
normal/parser.y +4
-15/* A block of commands. */ -commands: command '\n' - { - $$ = grub_script_add_cmd (state, 0, $1); - } - | command - { +commands: command + { $$ = grub_script_add_cmd (state, 0, $1); } - | command ';' commands - { - struct grub_script_cmdblock *cmd; - cmd = (struct grub_script_cmdblock *) $3; - $$ = grub_script_add_cmd (state, cmd, $1); - } - | command '\n' newlines commands - { + | command commands + { struct grub_script_cmdblock *cmd; - cmd = (struct grub_script_cmdblock *) $4;
normal/parser.y grubcmd: GRUB_PARSER_TOKEN_NAME arguments · line 160
Quoted 10 lines
normal/parser.y +1
-6+ cmd = (struct grub_script_cmdblock *) $2; $$ = grub_script_add_cmd (state, cmd, $1); } - | error - { - yyerror (state, "Incorrect command"); - state->err = 1; - yyerrok; - } ;
Looks fine to me at first sight.
normal/parser.y function: "function" GRUB_PARSER_TOKEN_NAME · line 197
Quoted 6 lines
normal/parser.y +0
-1/* A function. Carefully save the memory that is allocated. Don't@@ -194,7 +194,6 @@ function: "function" GRUB_PARSER_TOKEN_NAME commandblock: '{' { grub_script_lexer_ref (state->lexerstate); - grub_script_lexer_record_start (state->lexerstate);
Ehm? Can you explain this? If I am not mistaken, this will result in a memory leak.
Quoted 5 lines
normal/parser.y +0
-0} newlines commands '}' {@@ -204,10 +203,17 @@ commandblock: '{' ;
normal/parser.y commandblock: '{' · line 212
Quoted 10 lines
normal/parser.y +7
-1/* A menu entry. Carefully save the memory that is allocated. */ -menuentry: "menuentry" argument newlines commandblock +menuentry: "menuentry" argument + { + grub_script_lexer_ref (state->lexerstate); + } newlines '{' + { + grub_script_lexer_record_start (state->lexerstate); + } newlines commands '}'
What was the problem here?
Quoted 29 lines
normal/parser.y +4
-3{ char *menu_entry; menu_entry = grub_script_lexer_record_stop (state->lexerstate); + grub_script_lexer_deref (state->lexerstate); $$ = grub_script_create_cmdmenu (state, $2, menu_entry, 0); } ;@@ -218,14 +224,14 @@ if_statement: "if" { grub_script_lexer_ref (state->lexerstate); } ; /* The if statement. */ -if: if_statement grubcmd ';' "then" commands "fi" +if: if_statement commands "then" newlines commands "fi" { $$ = grub_script_create_cmdif (state, $2, $5, 0); grub_script_lexer_deref (state->lexerstate); } - | if_statement grubcmd ';' "then" commands "else" commands "fi" + | if_statement commands "then" newlines commands "else" newlines commands "fi" { - $$ = grub_script_create_cmdif (state, $2, $5, $7); + $$ = grub_script_create_cmdif (state, $2, $5, $8); grub_script_lexer_deref (state->lexerstate); } ;_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 9 lines · Marco Gerards
normal/execute.c grub_script_execute_cmdline (struct grub_script_cmd *cmd) · line 106
Quoted 7 lines
normal/execute.c +3
-0@@ -99,6 +101,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grubcmd =grub_command_find (cmdline->cmdname);if (! grubcmd) { +/* Ignore errors. */ + grub_errno =GRUB_ERR_NONE ; +What are the implications of this?
here is the function :
/* Lookup the command. */
grubcmd = grub_command_find (cmdline->cmdname);
if (! grubcmd)
{
/* Ignore errors. */+ grub_errno = GRUB_ERR_NONE;
/* It's not a GRUB command, try all functions. */
func = grub_script_function_find (cmdline->cmdname);
if (! func)
{if the command is not found, grub_errno would be set, this will effect the later grub_script_function_find when it try to load the module from disk.
Quoted 11 lines
Quoted 11 lines
normal/execute.c +0
-0/* It's not a GRUB command, try all functions. */ func =grub_script_function_find (cmdline->cmdname);if (! func)normal/main.c +0
-0@@ -261,6 +261,9 @@ read_config_file (const char *config, int nested)/* Execute the command(s). */ grub_script_execute (parsed_script);
Quoted 4 lines
normal/main.c read_config_file (const char *config, int nested) · line 265
Quoted 2 lines
normal/main.c +2
-0+/* Ignore errors. */ + grub_errno =GRUB_ERR_NONE ;Same for this. Errors are not shown this way, for example.
if grub_error is set, it will effect the parser, caused menu not to be showed, etc.
Quoted 29 lines
Quoted 29 lines
normal/main.c +0
-0/* The parsed script was executed, throw it away. */ grub_script_free (parsed_script); }normal/parser.y +3
-3@@ -43,7 +43,7 @@ %token GRUB_PARSER_TOKEN_FI "fi" %token GRUB_PARSER_TOKEN_NAME %token GRUB_PARSER_TOKEN_VAR -%type <cmd> script grubcmd command commands commandblock menuentry if +%type <cmd> script script_1 grubcmd command commands commandblock menuentry if %type <arglist> arguments; %type <arg> argument; %type <string> "if" "while" "function" "else" "then" "fi"@@ -55,12 +55,22 @@ %% /* It should be possible to do this in a clean way... */ -script: { state->err = 0} newlines commands +script: { state->err = 0} script_1 { - state->parsed = $3; + state->parsed = $2; } ;
Quoted 6 lines
normal/parser.y line 67
Quoted 4 lines
normal/parser.y +4
-0+script_1: commands { $$ = $1; } + | function '\n' { $$ = 0; } + | menuentry '\n' { $$ = $1; } +;I do not like the name "
script_1".
what do you suggest ?
Quoted 12 lines
Looks fine to me at first sight.
normal/parser.y function: "function" GRUB_PARSER_TOKEN_NAME · line 197
Quoted 6 lines
normal/parser.y +0
-1/* A function. Carefully save the memory that is allocated. Don't@@ -194,7 +194,6 @@ function: "function" GRUB_PARSER_TOKEN_NAME commandblock: '{' { grub_script_lexer_ref (state->lexerstate); - grub_script_lexer_record_start (state->lexerstate);Ehm? Can you explain this? If I am not mistaken, this will result in a memory leak.
I split commandblock from menuentry, now it's a standalone statement.
commandblock: '{'
{
grub_script_lexer_ref (state->lexerstate);
}
newlines commands '}'
{
grub_script_lexer_deref (state->lexerstate);
$$ = $4;
}Quoted 7 lines
Quoted 7 lines
normal/parser.y +0
-0} newlines commands '}' {@@ -204,10 +203,17 @@ commandblock: '{' ;
Quoted 12 lines
normal/parser.y commandblock: '{' · line 212
Quoted 9 lines
normal/parser.y +7
-1/* A menu entry. Carefully save the memory that is allocated. */ -menuentry: "menuentry" argument newlines commandblock +menuentry: "menuentry" argument + { + grub_script_lexer_ref (state->lexerstate); + } newlines '{' + { + grub_script_lexer_record_start (state->lexerstate); + } newlines commands '}'What was the problem here?
I don't like the idea of deref in another statement, and now we can use {} separately.
Signature · 1 line
Bean
Quoted 19 lines · Bean
Quoted 9 lines · Marco Gerards
normal/execute.c grub_script_execute_cmdline (struct grub_script_cmd *cmd) · line 106
Quoted 7 lines
normal/execute.c +3
-0@@ -99,6 +101,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grubcmd =grub_command_find (cmdline->cmdname);if (! grubcmd) { +/* Ignore errors. */ + grub_errno =GRUB_ERR_NONE ; +What are the implications of this?
here is the function :
/* Lookup the command. */
grubcmd =grub_command_find(cmdline->cmdname);
if (! grubcmd){ /* Ignore errors. */+
grub_errno=GRUB_ERR_NONE;
Quoted 8 lines
/* It's not a GRUB command, try all functions. */ func = grub_script_function_find (cmdline->cmdname); if (! func) {if the command is not found,
grub_errnowould be set, this will effect the latergrub_script_function_findwhen it try to load the module from disk.
Ah, ok. Anyways, it looks fine to me in this context.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
normal/execute.c +0
-0/* It's not a GRUB command, try all functions. */ func =grub_script_function_find (cmdline->cmdname);if (! func)normal/main.c +0
-0@@ -261,6 +261,9 @@ read_config_file (const char *config, int nested)/* Execute the command(s). */ grub_script_execute (parsed_script);
Quoted 7 lines
Quoted 4 lines
normal/main.c read_config_file (const char *config, int nested) · line 265
Quoted 2 lines
normal/main.c +2
-0+/* Ignore errors. */ + grub_errno =GRUB_ERR_NONE ;Same for this. Errors are not shown this way, for example.
if
grub_erroris set, it will effect the parser, caused menu not to be showed, etc.
Right, but do you want to see a menu if not everything is correctly executed?
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
normal/main.c +0
-0/* The parsed script was executed, throw it away. */ grub_script_free (parsed_script); }normal/parser.y +3
-3@@ -43,7 +43,7 @@ %token GRUB_PARSER_TOKEN_FI "fi" %token GRUB_PARSER_TOKEN_NAME %token GRUB_PARSER_TOKEN_VAR -%type <cmd> script grubcmd command commands commandblock menuentry if +%type <cmd> script script_1 grubcmd command commands commandblock menuentry if %type <arglist> arguments; %type <arg> argument; %type <string> "if" "while" "function" "else" "then" "fi"@@ -55,12 +55,22 @@ %% /* It should be possible to do this in a clean way... */ -script: { state->err = 0} newlines commands +script: { state->err = 0} script_1 { - state->parsed = $3; + state->parsed = $2; } ;
Quoted 8 lines
Quoted 6 lines
normal/parser.y line 67
Quoted 4 lines
normal/parser.y +4
-0+script_1: commands { $$ = $1; } + | function '\n' { $$ = 0; } + | menuentry '\n' { $$ = $1; } +;I do not like the name "
script_1".what do you suggest ?
Hopefully someone else knows a better name? :-)
Quoted 13 lines
Quoted 12 lines
Looks fine to me at first sight.
normal/parser.y function: "function" GRUB_PARSER_TOKEN_NAME · line 197
Quoted 6 lines
normal/parser.y +0
-1/* A function. Carefully save the memory that is allocated. Don't@@ -194,7 +194,6 @@ function: "function" GRUB_PARSER_TOKEN_NAME commandblock: '{' { grub_script_lexer_ref (state->lexerstate); - grub_script_lexer_record_start (state->lexerstate);Ehm? Can you explain this? If I am not mistaken, this will result in a memory leak.
Quoted 1 line
I split commandblock from menuentry, now it's a standalone statement.
Ah ok, so there is a grub_script_lexer_record_start elsewhere that forfills the same role?
Quoted 31 lines
commandblock: '{'
{ grub_script_lexer_ref (state->lexerstate); } newlines commands '}' { grub_script_lexer_deref (state->lexerstate); $$ = $4; }Quoted 7 lines
Quoted 7 lines
normal/parser.y +0
-0} newlines commands '}' {@@ -204,10 +203,17 @@ commandblock: '{' ;Quoted 12 lines
normal/parser.y commandblock: '{' · line 212
Quoted 9 lines
normal/parser.y +7
-1/* A menu entry. Carefully save the memory that is allocated. */ -menuentry: "menuentry" argument newlines commandblock +menuentry: "menuentry" argument + { + grub_script_lexer_ref (state->lexerstate); + } newlines '{' + { + grub_script_lexer_record_start (state->lexerstate); + } newlines commands '}'What was the problem here?
Quoted 2 lines
I don't like the idea of deref in another statement, and now we can use {} separately.
Of deref? Can you explain? The idea of commandblock was that this structure might show up more often. But I have no objections for now if a bug is fixed this way.
Btw, does this patch incorporate the previous patch you sent in regarding scripting?
--
Marco
Quoted 4 lines
Quoted 2 lines
if
grub_erroris set, it will effect the parser, caused menu not to be showed, etc.Right, but do you want to see a menu if not everything is correctly executed?
the problem is that it's not always an error when grub_errno is set, for example, the test command use it to report whether or not two strings equals.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I do not like the name "
script_1".what do you suggest ?
Hopefully someone else knows a better name? :-)
how about script_init for the old script, and script here.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
commandblock: '{'
{ grub_script_lexer_ref (state->lexerstate);-
grub_script_lexer_record_start(state->lexerstate);
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Ehm? Can you explain this? If I am not mistaken, this will result in a memory leak.
I split commandblock from menuentry, now it's a standalone statement.
Ah ok, so there is a
grub_script_lexer_record_startelsewhere that forfills the same role?
yes, the grub_script_lexer_record_start is in menuentry.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
What was the problem here?
I don't like the idea of deref in another statement, and now we can use {} separately.
Of deref? Can you explain? The idea of commandblock was that this structure might show up more often. But I have no objections for now if a bug is fixed this way.
in the old implementation,
commandblock: '{'
{
grub_script_lexer_ref (state->lexerstate);
}
newlines commands '}'
{
grub_script_lexer_deref (state->lexerstate);
grub_script_lexer_record_start (state->lexerstate);
$$ = $4;
};
menuentry: "menuentry" argument newlines commandblock
{
char *menu_entry;
menu_entry = grub_script_lexer_record_stop (state->lexerstate);
$$ = grub_script_create_cmdmenu (state, $2, menu_entry, 0);
}it calls grub_script_lexer_record_start in commandblock, and grub_script_lexer_record_stop in menuentry, but now it's both inside menuentry. i think it's better this way. besides, if you use commandblock alone in old implemenation, it will cause problem becuase there is no matching grub_script_lexer_record_stop.
Quoted 3 lines
Btw, does this patch incorporate the previous patch you sent in regarding scripting?
I didn't include the fix on the lexer, for example. ${AA}${BB} should expand to one token instead of two. I think it's better to use a separate patch.
Signature · 1 line
Bean
Quoted 8 lines · Bean
Quoted 4 lines
Quoted 2 lines
if
grub_erroris set, it will effect the parser, caused menu not to be showed, etc.Right, but do you want to see a menu if not everything is correctly executed?
the problem is that it's not always an error when
grub_errnois set, for example, the test command use it to report whether or not two strings equals.
Agreed.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I do not like the name "
script_1".what do you suggest ?
Hopefully someone else knows a better name? :-)
how about
script_initfor the old script, and script here.
Fine for me. Besides that, we can always change this and in the meanwhile these names will do.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
commandblock: '{'
{ grub_script_lexer_ref (state->lexerstate);-
grub_script_lexer_record_start(state->lexerstate);Ehm? Can you explain this? If I am not mistaken, this will result in a memory leak.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
I split commandblock from menuentry, now it's a standalone statement.
Ah ok, so there is a
grub_script_lexer_record_startelsewhere that forfills the same role?yes, the
grub_script_lexer_record_startis in menuentry.
Good :-)
Quoted 30 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
What was the problem here?
I don't like the idea of deref in another statement, and now we can use {} separately.
Of deref? Can you explain? The idea of commandblock was that this structure might show up more often. But I have no objections for now if a bug is fixed this way.
in the old implementation,
commandblock: '{'
{ grub_script_lexer_ref (state->lexerstate); } newlines commands '}' { grub_script_lexer_deref (state->lexerstate); grub_script_lexer_record_start (state->lexerstate); $$ = $4; };
menuentry: "menuentry" argument newlines commandblock
{ char *menu_entry; menu_entry = grub_script_lexer_record_stop (state->lexerstate); $$ = grub_script_create_cmdmenu (state, $2, menu_entry, 0); }
Quoted 5 lines
it calls
grub_script_lexer_record_startin commandblock, andgrub_script_lexer_record_stopin menuentry, but now it's both inside menuentry. i think it's better this way. besides, if you use commandblock alone in old implemenation, it will cause problem becuase there is no matchinggrub_script_lexer_record_stop.
For now your approach is ok. But perhaps I will reintroduce this properly some day. We'll see :-)
Quoted 6 lines
Quoted 2 lines
Btw, does this patch incorporate the previous patch you sent in regarding scripting?
I didn't include the fix on the lexer, for example. ${AA}${BB} should expand to one token instead of two. I think it's better to use a separate patch.
Right. I am completely unhappy with the lexer as it is now... :-/ The main reason for writing it manually is that flex depends on all kinds of stuff I do not want in GRUB. Like reading files, etc.
Thanks a lot for fixing bugs related to scripting. Lately I am rather busy and I was the only person who worked on it. More testing, better error handling, etc is appriciated.
I still have an unfinished "test" command on my HD.
--
Marco
Quoted 9 lines · Marco Gerards
Right. I am completely unhappy with the lexer as it is now... :-/ The main reason for writing it manually is that flex depends on all kinds of stuff I do not want in GRUB. Like reading files, etc.
Thanks a lot for fixing bugs related to scripting. Lately I am rather busy and I was the only person who worked on it. More testing, better error handling, etc is appriciated.
I still have an unfinished "test" command on my HD.
thanks, if there is no problem, i would commit this now.
Signature · 1 line
Bean
Quoted 5 lines · Bean
Quoted 4 lines · Marco Gerards
Right. I am completely unhappy with the lexer as it is now... :-/ The main reason for writing it manually is that flex depends on all kinds of stuff I do not want in GRUB. Like reading files, etc.
Quoted 7 lines
Quoted 5 lines
Thanks a lot for fixing bugs related to scripting. Lately I am rather busy and I was the only person who worked on it. More testing, better error handling, etc is appriciated.
I still have an unfinished "test" command on my HD.
thanks, if there is no problem, i would commit this now.
If you mean your patch, that's fine for me. Please do not forget to rename script_1. Are there any other issues I brought up?
--
Marco
Quoted 12 lines · Marco Gerards
Quoted 9 lines · Bean
Quoted 8 lines · Marco Gerards
Right. I am completely unhappy with the lexer as it is now... :-/ The main reason for writing it manually is that flex depends on all kinds of stuff I do not want in GRUB. Like reading files, etc.
Thanks a lot for fixing bugs related to scripting. Lately I am rather busy and I was the only person who worked on it. More testing, better error handling, etc is appriciated.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
I still have an unfinished "test" command on my HD.
thanks, if there is no problem, i would commit this now.
If you mean your patch, that's fine for me. Please do not forget to rename
script_1. Are there any other issues I brought up?
ok, commited.
Signature · 1 line
Bean
Bean <[email protected]> writes:
[...]
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
thanks, if there is no problem, i would commit this now.
If you mean your patch, that's fine for me. Please do not forget to rename
script_1. Are there any other issues I brought up?ok, commited.
Thanks! :-)
--
Marco