Skip to contentSkip to conversation

Bug fix in GRUB script word expansion

PATCH New BVK Chaitanya 1 participant 1 message Dec 25, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bug fix in GRUB script word expansion

Hi,

This patch fixes a GRUB script bug in expanding (and splitting into parameters) words like, aaa${foo}bbb, aaa"bbb ${foo} ccc"ddd, etc. forms.

thanks,

Signature · 1 line
bvk.chaitanya

=== modified file 'ChangeLog.scripting'

ChangeLog.scripting +20 -0
@@ -1,5 +1,25 @@
 2009-12-25  BVK Chaitanya  <[email protected]>
 
+	* include/grub/script_sh.h (grub_script_arg_type_t): New types
+	added.
+	(grub_script_execute_arglist_to_arg): Function proptotype added.
+	(grub_script_execute_argument_to_string): Prototype is removed.
+	* script/execute.c (grub_script_execute_arglist_to_arg): New
+	function to convert arglist to argv.
+	(grub_script_execute_cmdfor): Updated to make use of arglist to
+	argv conversion function.
+	(grub_script_execute_cmdline): Likewise.
+	(grub_script_execute_menuentry): Likewise.
+	(grub_script_execute_argument_to_string): Removed.
+	* script/function.c (grub_script_function_create): Removed
+	unnecessary reference to removed function
+	grub_script_execute_argument_to_string.
+	* script/lexer.c (grub_script_yylex): Fixed grub_script_arg
+	argument construction.
+	* script/yylex.l: Likewise.
+
+2009-12-25  BVK Chaitanya  <[email protected]>
+
 	* conf/tests.rmk: Makerules for new unit tests.
 	* include/grub/script_sh.h: Function prototypes for for statement
 	functions.

=== modified file 'include/grub/script_sh.h'

grub/script_sh.h +10 -4
@@ -45,8 +45,11 @@
 
 typedef enum
 {
-  GRUB_SCRIPT_ARG_TYPE_STR,
-  GRUB_SCRIPT_ARG_TYPE_VAR
+  GRUB_SCRIPT_ARG_TYPE_VAR,
+  GRUB_SCRIPT_ARG_TYPE_TEXT,
+  GRUB_SCRIPT_ARG_TYPE_DQVAR,
+  GRUB_SCRIPT_ARG_TYPE_DQSTR,
+  GRUB_SCRIPT_ARG_TYPE_SQSTR
 } grub_script_arg_type_t;
 
 /* A part of an argument.  */
@@ -172,6 +175,9 @@
   /* Text of current token.  */
   char *text;
 
+  /* Type of text.  */
+  grub_script_arg_type_t type;
+
   /* Flex scanner.  */
   void *yyscanner;
 
@@ -316,7 +322,7 @@
 int grub_script_function_call (grub_script_function_t func,
 			       int argc, char **args);
 
-char *
-grub_script_execute_argument_to_string (struct grub_script_arg *arg);
+char **
+grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist);
 
 #endif /* ! GRUB_NORMAL_PARSER_HEADER */

=== modified file 'script/execute.c'

execute.c +151 -115

320 lines not on this page · raw message

=== modified file 'script/function.c'

function.c +1 -1
@@ -34,7 +34,7 @@
   if (! func)
     return 0;
 
-  func->name = grub_script_execute_argument_to_string (functionname_arg);
+  func->name = grub_strdup (functionname_arg->str);
   if (! func->name)
     {
       grub_free (func);

=== modified file 'script/lexer.c'

lexer.c +2 -3
@@ -302,13 +302,12 @@
 	{
 	  lexerstate->text[lexerstate->size] = '\0';
 	  str = lexerstate->text;
-	  type = (token == GRUB_PARSER_TOKEN_NAME ?
-		  GRUB_SCRIPT_ARG_TYPE_VAR : GRUB_SCRIPT_ARG_TYPE_STR);
+	  type = lexerstate->type;
 	}
       else
 	{
 	  str = yyget_text (lexerstate->yyscanner);
-	  type = GRUB_SCRIPT_ARG_TYPE_STR;
+	  type = GRUB_SCRIPT_ARG_TYPE_TEXT;
 	}
       /* grub_printf ("tok %u, txt [%s] size %u\n", token, str, lexerstate->size); */
 

=== modified file 'script/yylex.l'

yylex.l +37 -12

100 lines not on this page · raw message