Fix rescue parser
Signature · 4 lines
-- Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
ChangeLog +6 -0
@@ -1,5 +1,11 @@ 2009-10-15 Vladimir Serbinenko <[email protected]> + * kern/parser.c (grub_parser_split_cmdline): Fix incorrect counting + of arguments. Return number of tokens and not arguments. All users + updated. + +2009-10-15 Vladimir Serbinenko <[email protected]> + * loader/i386/pc/xnu.c (grub_xnu_set_video): Fix loading splash image. 2009-10-15 Vladimir Serbinenko <[email protected]>
kern/parser.c +6 -4
@@ -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 ; }
kern/rescue_parser.c +5 -2
@@ -35,9 +35,12 @@ grub_rescue_parse_line (char *line, grub_reader_getline_t getline)if (grub_parser_split_cmdline (line, getline, &n, &args) || n <0 )return grub_errno; +if (n ==0 ) +return GRUB_ERR_NONE ; +/* In case of an assignment set the environment accordingly instead of calling a function. */ -if (n ==0 &&grub_strchr (line,'=' )) +if (n ==1 &&grub_strchr (line,'=' )) {char *val =grub_strchr (args[0 ],'=' ); val[0 ] =0 ;
@@ -56,7 +59,7 @@ grub_rescue_parse_line (char *line, grub_reader_getline_t getline) cmd =grub_command_find (name);if (cmd) { - (cmd->func) (cmd, n, &args[1 ]); + (cmd->func) (cmd, n -1 , &args[1 ]); }else {
normal/completion.c +9 -4
@@ -409,13 +409,16 @@ grub_normal_do_completion (char *buf, int *restore,if (grub_parser_split_cmdline (buf,0 , &argc, &argv))return 0 ; - current_word = argv[argc]; +if (argc ==0 ) + current_word ="" ; +else + current_word = argv[argc -1 ];/* Determine the state the command line is in, depending on the state, it can be determined how to complete. */ cmdline_state =get_state (buf); -if (argc ==0 ) +if (argc ==1 || argc ==0 ) {/* Complete a command. */ if (grub_command_iterate (iterate_command))
@@ -485,13 +488,15 @@ grub_normal_do_completion (char *buf, int *restore, goto fail; } -grub_free (argv[0 ]); +if (argc !=0 ) +grub_free (argv[0 ]);grub_free (match);return ret; } fail: -grub_free (argv[0 ]); +if (argc !=0 ) +grub_free (argv[0 ]);grub_free (match); grub_errno =GRUB_ERR_NONE ;
Quoted 12 lines · Vladimir 'phcoder' Serbinenko
Signature · 4 lines
-- Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.gitChangeLog +0
-0
ChangeLog line 6
Quoted 6 lines
ChangeLog +4
-0@@ -1,5 +1,11 @@ 2009-10-15 Vladimir Serbinenko <[email protected]> + * kern/parser.c (grub_parser_split_cmdline): Fix incorrect counting + of arguments. Return number of tokens and not arguments. All users + updated. +
Sorry, this change is too scary for 1.97. I'd rather release with a known minor bug than with potential for major one.
After 1.97 is released, feel free to commit this.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."