minor fixes
This commit is contained in:
parent
a0b20aad47
commit
50cd44693d
2 changed files with 19 additions and 45 deletions
|
@ -662,7 +662,7 @@ normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
# For sh.mod.
|
# For sh.mod.
|
||||||
sh_mod_SOURCES = script/main.c script/script.c script/argv.c script/execute.c \
|
sh_mod_SOURCES = script/main.c script/script.c script/argv.c script/execute.c \
|
||||||
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
|
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
|
||||||
sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error
|
sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) $(GNULIB_CFLAGS) -Wno-error
|
||||||
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
ifneq (, $(FONT_SOURCE))
|
ifneq (, $(FONT_SOURCE))
|
||||||
|
|
|
@ -373,47 +373,38 @@ match_devices (const regex_t *regexp)
|
||||||
int i;
|
int i;
|
||||||
int ndev;
|
int ndev;
|
||||||
char **devs;
|
char **devs;
|
||||||
char *buffer;
|
|
||||||
|
|
||||||
auto int match (const char *name);
|
auto int match (const char *name);
|
||||||
int match (const char *name)
|
int match (const char *name)
|
||||||
{
|
{
|
||||||
void *t;
|
char **t;
|
||||||
unsigned n;
|
char *buffer = grub_xasprintf ("(%s)", name);
|
||||||
|
if (! buffer)
|
||||||
n = grub_strlen (name);
|
|
||||||
t = grub_realloc (buffer, n + 3);
|
|
||||||
if (! t)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
buffer = (char *) t;
|
|
||||||
grub_snprintf (buffer, n + 3, "(%s)", name);
|
|
||||||
|
|
||||||
grub_dprintf ("expand", "matching: %s\n", buffer);
|
grub_dprintf ("expand", "matching: %s\n", buffer);
|
||||||
if (regexec (regexp, buffer, 0, 0, 0))
|
if (regexec (regexp, buffer, 0, 0, 0))
|
||||||
return 0;
|
{
|
||||||
|
grub_free (buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
t = grub_realloc (devs, sizeof (char*) * (ndev + 2));
|
t = grub_realloc (devs, sizeof (char*) * (ndev + 2));
|
||||||
if (! t)
|
if (! t)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
devs = (char **) t;
|
devs = t;
|
||||||
devs[ndev++] = buffer;
|
devs[ndev++] = buffer;
|
||||||
devs[ndev] = 0;
|
devs[ndev] = 0;
|
||||||
buffer = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ndev = 0;
|
ndev = 0;
|
||||||
devs = 0;
|
devs = 0;
|
||||||
buffer = 0;
|
|
||||||
|
|
||||||
if (grub_device_iterate (match))
|
if (grub_device_iterate (match))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (buffer)
|
|
||||||
grub_free (buffer);
|
|
||||||
|
|
||||||
return devs;
|
return devs;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
@ -424,9 +415,6 @@ match_devices (const regex_t *regexp)
|
||||||
if (devs)
|
if (devs)
|
||||||
grub_free (devs);
|
grub_free (devs);
|
||||||
|
|
||||||
if (buffer)
|
|
||||||
grub_free (buffer);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,10 +425,8 @@ match_files (const char *prefix, const char *suffix, const char *end,
|
||||||
int i;
|
int i;
|
||||||
int error;
|
int error;
|
||||||
char **files;
|
char **files;
|
||||||
char *buffer;
|
|
||||||
unsigned nfile;
|
unsigned nfile;
|
||||||
char *dir;
|
char *dir;
|
||||||
unsigned dirlen;
|
|
||||||
const char *path;
|
const char *path;
|
||||||
char *device_name;
|
char *device_name;
|
||||||
grub_fs_t fs;
|
grub_fs_t fs;
|
||||||
|
@ -449,8 +435,8 @@ match_files (const char *prefix, const char *suffix, const char *end,
|
||||||
auto int match (const char *name, const struct grub_dirhook_info *info);
|
auto int match (const char *name, const struct grub_dirhook_info *info);
|
||||||
int match (const char *name, const struct grub_dirhook_info *info)
|
int match (const char *name, const struct grub_dirhook_info *info)
|
||||||
{
|
{
|
||||||
void *t;
|
char **t;
|
||||||
unsigned n;
|
char *buffer;
|
||||||
|
|
||||||
/* skip hidden files, . and .. */
|
/* skip hidden files, . and .. */
|
||||||
if (name[0] == '.')
|
if (name[0] == '.')
|
||||||
|
@ -460,36 +446,32 @@ match_files (const char *prefix, const char *suffix, const char *end,
|
||||||
if (regexec (regexp, name, 0, 0, 0))
|
if (regexec (regexp, name, 0, 0, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
n = dirlen + grub_strlen (name);
|
buffer = grub_xasprintf ("%s%s", dir, name);
|
||||||
t = grub_realloc (buffer, n + 1);
|
if (! buffer)
|
||||||
if (! t)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
buffer = (char *) t;
|
|
||||||
grub_snprintf (buffer, n + 1, "%s%s", dir, name);
|
|
||||||
|
|
||||||
t = grub_realloc (files, sizeof (char*) * (nfile + 2));
|
t = grub_realloc (files, sizeof (char*) * (nfile + 2));
|
||||||
if (! t)
|
if (! t)
|
||||||
return 1;
|
{
|
||||||
|
grub_free (buffer);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
files = (char **) t;
|
files = t;
|
||||||
files[nfile++] = buffer;
|
files[nfile++] = buffer;
|
||||||
files[nfile] = 0;
|
files[nfile] = 0;
|
||||||
buffer = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nfile = 0;
|
nfile = 0;
|
||||||
files = 0;
|
files = 0;
|
||||||
dev = 0;
|
dev = 0;
|
||||||
buffer = 0;
|
|
||||||
device_name = 0;
|
device_name = 0;
|
||||||
grub_error_push ();
|
grub_error_push ();
|
||||||
|
|
||||||
dir = make_dir (prefix, suffix, end);
|
dir = make_dir (prefix, suffix, end);
|
||||||
if (! dir)
|
if (! dir)
|
||||||
goto fail;
|
goto fail;
|
||||||
dirlen = grub_strlen (dir);
|
|
||||||
|
|
||||||
device_name = grub_file_get_device_name (dir);
|
device_name = grub_file_get_device_name (dir);
|
||||||
dev = grub_device_open (device_name);
|
dev = grub_device_open (device_name);
|
||||||
|
@ -508,9 +490,6 @@ match_files (const char *prefix, const char *suffix, const char *end,
|
||||||
if (fs->dir (dev, path, match))
|
if (fs->dir (dev, path, match))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (buffer)
|
|
||||||
grub_free (buffer);
|
|
||||||
|
|
||||||
grub_free (dir);
|
grub_free (dir);
|
||||||
grub_device_close (dev);
|
grub_device_close (dev);
|
||||||
grub_free (device_name);
|
grub_free (device_name);
|
||||||
|
@ -534,9 +513,6 @@ match_files (const char *prefix, const char *suffix, const char *end,
|
||||||
if (device_name)
|
if (device_name)
|
||||||
grub_free (device_name);
|
grub_free (device_name);
|
||||||
|
|
||||||
if (buffer)
|
|
||||||
grub_free (buffer);
|
|
||||||
|
|
||||||
grub_error_pop ();
|
grub_error_pop ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -563,12 +539,10 @@ match_paths_with_escaped_suffix (char **paths,
|
||||||
if (! root)
|
if (! root)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
n = grub_strlen (root) + 2;
|
prefix = grub_xasprintf ("(%s)", root);
|
||||||
prefix = grub_malloc (n + 1);
|
|
||||||
if (! prefix)
|
if (! prefix)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
grub_snprintf (prefix, n + 1, "(%s)", root);
|
|
||||||
r = match_files (prefix, suffix, end, regexp);
|
r = match_files (prefix, suffix, end, regexp);
|
||||||
grub_free (prefix);
|
grub_free (prefix);
|
||||||
return r;
|
return r;
|
||||||
|
|
Loading…
Reference in a new issue