From f8a9ab124593f070199f54f3c2de1aa670f2fca8 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Tue, 24 Jan 2012 13:34:36 +0100 Subject: [PATCH] * grub-core/commands/wildcard.c (match_files): Handle filenames without explicit device. (wildcard_expand): Don't add explicit device if not already present. * tests/grub_script_echo1.in: Add a new expansion test. --- ChangeLog | 7 +++++++ grub-core/commands/wildcard.c | 32 ++++++++++---------------------- tests/grub_script_echo1.in | 2 ++ 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f3b10818..0c97dd314 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-01-24 Vladimir Serbinenko + + * grub-core/commands/wildcard.c (match_files): Handle filenames + without explicit device. + (wildcard_expand): Don't add explicit device if not already present. + * tests/grub_script_echo1.in: Add a new expansion test. + 2012-01-24 Vladimir Serbinenko Replace single-linked with double-linked lists. It results in more diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c index d991b2010..8afda3c99 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -326,10 +326,15 @@ match_files (const char *prefix, const char *suffix, const char *end, if (! fs) goto fail; - path = grub_strchr (dir, ')'); - if (! path) - goto fail; - path++; + if (dir[0] == '(') + { + path = grub_strchr (dir, ')'); + if (!path) + goto fail; + path++; + } + else + path = dir; if (fs->dir (dev, path, match)) goto fail; @@ -431,25 +436,8 @@ wildcard_expand (const char *s, char ***strs) if (start == noregexop) /* device part has regexop */ paths = match_devices (®exp, *start != '('); - else if (*start == '(') /* device part explicit wo regexop */ + else /* device part explicit wo regexop */ paths = match_files ("", start, noregexop, ®exp); - - else if (*start == '/') /* no device part */ - { - const char *root; - char *prefix; - - root = grub_env_get ("root"); - if (! root) - goto fail; - - prefix = grub_xasprintf ("(%s)", root); - if (! prefix) - goto fail; - - paths = match_files (prefix, start, noregexop, ®exp); - grub_free (prefix); - } } else { diff --git a/tests/grub_script_echo1.in b/tests/grub_script_echo1.in index 9415a3f73..54395774f 100644 --- a/tests/grub_script_echo1.in +++ b/tests/grub_script_echo1.in @@ -99,3 +99,5 @@ echo one'two # # two" +if test x$grubshell = xyes; then insmod regexp; fi +echo /boot/grub/i386-pc/normal.mod