* [PATCH] Execute menu editor commands with argument scope
@ 2010-12-08 11:32 BVK Chaitanya
2010-12-18 15:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 2+ messages in thread
From: BVK Chaitanya @ 2010-12-08 11:32 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
Hi,
Jordan_U pointed out that setparams command doesn't work when a
menuentry is executed through menu editor; that is, using Ctrl-x.
This is because menu editor commands execute as individual commands,
outside function/menuentry scopes. So setparams command does not work
as expected.
Attached patch fixes this issue by executing menu editor commands with a scope.
bvk.chaitanya
[-- Attachment #2: menu-editor-cmds.patch --]
[-- Type: text/x-diff, Size: 4076 bytes --]
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: bvk.groups@gmail.com-20101208111311-ot9ui8kuh282ngig
# target_branch: file:///home/bvk/Work/grub2/mainline/
# testament_sha1: d37a1d27068bedcc0c24dd75db2e8bf729af2210
# timestamp: 2010-12-08 16:45:05 +0530
# base_revision_id: cjwatson@ubuntu.com-20101204161926-\
# ekabqjnogaeq0een
#
# Begin patch
=== modified file 'grub-core/normal/menu_entry.c'
--- grub-core/normal/menu_entry.c 2010-11-18 01:08:01 +0000
+++ grub-core/normal/menu_entry.c 2010-12-08 11:13:11 +0000
@@ -1163,37 +1163,35 @@
static int
run (struct screen *screen)
{
- int currline = 0;
- char *nextline;
+ char *script;
int errs_before;
grub_menu_t menu;
-
- auto grub_err_t editor_getline (char **line, int cont);
- grub_err_t editor_getline (char **line, int cont __attribute__ ((unused)))
- {
- struct line *linep = screen->lines + currline;
- char *p;
-
- if (currline > screen->num_lines)
- {
- *line = 0;
- return 0;
- }
-
- /* Trim down space characters. */
- for (p = linep->buf + linep->len - 1;
- p >= linep->buf && grub_isspace (*p);
- p--)
- ;
- *++p = '\0';
-
- linep->len = p - linep->buf;
- for (p = linep->buf; grub_isspace (*p); p++)
- ;
- *line = grub_strdup (p);
- currline++;
- return 0;
- }
+ char *dummy[1] = { NULL };
+
+ auto char * editor_getsource (void);
+ char * editor_getsource (void)
+ {
+ int i;
+ int size = 0;
+ char *source;
+
+ for (i = 0; i < screen->num_lines; i++)
+ size += screen->lines[i].len + 1;
+
+ source = grub_malloc (size + 1);
+ if (! source)
+ return NULL;
+
+ size = 0;
+ for (i = 0; i < screen->num_lines; i++)
+ {
+ grub_strcpy (source + size, screen->lines[i].buf);
+ size += screen->lines[i].len;
+ source[size++] = '\n';
+ }
+ source[size] = '\0';
+ return source;
+ }
grub_cls ();
grub_printf (" ");
@@ -1212,12 +1210,11 @@
}
/* Execute the script, line for line. */
- while (currline < screen->num_lines)
- {
- editor_getline (&nextline, 0);
- if (grub_normal_parse_line (nextline, editor_getline))
- break;
- }
+ script = editor_getsource ();
+ if (! script)
+ return 0;
+ grub_script_execute_sourcecode (script, 0, dummy);
+ grub_free (script);
if (errs_before != grub_err_printed_errors)
grub_wait_after_message ();
# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWTaGGhUAAhFfgFAwcP///1oN
Aw6////6UASd62HoKAAAQ1U9I9Hqh6mjIBppk00ZABkYjRpo0A5piZMmjCYJiaYBMAhgjAjANEpt
PUmT1NNDQAAAAAGgAAaJqaI9IA0AxAAAAA0AAJJCYQTTJonqaYhlNkST8jRT1NqGZNTG1TKsiJZf
YAVSwr8aon9ohhbYYYbxoGISIbr6iYtSCum+QiyTO4Rp3QhghIcgXI+h9PuaHH0/LiCG+zLhVgZm
BbWwGY5F5bduqeOeZVWkacDzhuIOPATAgdUmqCXzwDIYXrlF3UETMEczgFpLuoyg1I6CEALWdlJc
hQmRpN4eOPhw8uNE5kPtrEr9Wky6c6vdDrwoBM4lbx87YS/jE/Ah5ehuidP6LlpSjY7m9WckyXFK
Bpsjf1UqF1sO+7h6zGENBIcavFywzI/D9JrYNIW/WqlBWovmRjV/IopPeL/FfKAj61J2ZfwwFRYC
j/qYrUzE6ShFALDqpj8CEgKILL07A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flat|nested] 2+ messages in thread
* Re: [PATCH] Execute menu editor commands with argument scope
2010-12-08 11:32 [PATCH] Execute menu editor commands with argument scope BVK Chaitanya
@ 2010-12-18 15:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-12-18 15:31 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
On 12/08/2010 12:32 PM, BVK Chaitanya wrote:
> Hi,
>
>
> Jordan_U pointed out that setparams command doesn't work when a
> menuentry is executed through menu editor; that is, using Ctrl-x.
> This is because menu editor commands execute as individual commands,
> outside function/menuentry scopes. So setparams command does not work
> as expected.
>
>
> Attached patch fixes this issue by executing menu editor commands with a scope.
>
>
patch is ok. Go ahead for mainline. (if you can connect to savannah /-: )
>
>
> bvk.chaitanya
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-18 15:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08 11:32 [PATCH] Execute menu editor commands with argument scope BVK Chaitanya
2010-12-18 15:31 ` Vladimir 'φ-coder/phcoder' Serbinenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).