execute menu editor commands with argument scope
This commit is contained in:
		
							parent
							
								
									24b7938b32
								
							
						
					
					
						commit
						393324be7c
					
				
					 1 changed files with 28 additions and 31 deletions
				
			
		|  | @ -1163,37 +1163,35 @@ clear_completions_all (struct screen *screen) | ||||||
| static int | static int | ||||||
| run (struct screen *screen) | run (struct screen *screen) | ||||||
| { | { | ||||||
|   int currline = 0; |   char *script; | ||||||
|   char *nextline; |  | ||||||
|   int errs_before; |   int errs_before; | ||||||
|   grub_menu_t menu; |   grub_menu_t menu; | ||||||
|  |   char *dummy[1] = { NULL }; | ||||||
| 
 | 
 | ||||||
|   auto grub_err_t editor_getline (char **line, int cont); |   auto char * editor_getsource (void); | ||||||
|   grub_err_t editor_getline (char **line, int cont __attribute__ ((unused))) |   char * editor_getsource (void) | ||||||
|     { |   { | ||||||
|       struct line *linep = screen->lines + currline; |     int i; | ||||||
|       char *p; |     int size = 0; | ||||||
|  |     char *source; | ||||||
| 
 | 
 | ||||||
|       if (currline > screen->num_lines) |     for (i = 0; i < screen->num_lines; i++) | ||||||
| 	{ |       size += screen->lines[i].len + 1; | ||||||
| 	  *line = 0; |  | ||||||
| 	  return 0; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
|       /* Trim down space characters.  */ |     source = grub_malloc (size + 1); | ||||||
|       for (p = linep->buf + linep->len - 1; |     if (! source) | ||||||
| 	   p >= linep->buf && grub_isspace (*p); |       return NULL; | ||||||
| 	   p--) |  | ||||||
| 	; |  | ||||||
|       *++p = '\0'; |  | ||||||
| 
 | 
 | ||||||
|       linep->len = p - linep->buf; |     size = 0; | ||||||
|       for (p = linep->buf; grub_isspace (*p); p++) |     for (i = 0; i < screen->num_lines; i++) | ||||||
| 	; |       { | ||||||
|       *line = grub_strdup (p); | 	grub_strcpy (source + size, screen->lines[i].buf); | ||||||
|       currline++; | 	size += screen->lines[i].len; | ||||||
|       return 0; | 	source[size++] = '\n'; | ||||||
|     } |       } | ||||||
|  |     source[size] = '\0'; | ||||||
|  |     return source; | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   grub_cls (); |   grub_cls (); | ||||||
|   grub_printf ("  "); |   grub_printf ("  "); | ||||||
|  | @ -1212,12 +1210,11 @@ run (struct screen *screen) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   /* Execute the script, line for line.  */ |   /* Execute the script, line for line.  */ | ||||||
|   while (currline < screen->num_lines) |   script = editor_getsource (); | ||||||
|     { |   if (! script) | ||||||
|       editor_getline (&nextline, 0); |     return 0; | ||||||
|       if (grub_normal_parse_line (nextline, editor_getline)) |   grub_script_execute_sourcecode (script, 0, dummy); | ||||||
| 	break; |   grub_free (script); | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|   if (errs_before != grub_err_printed_errors) |   if (errs_before != grub_err_printed_errors) | ||||||
|     grub_wait_after_message (); |     grub_wait_after_message (); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue