review comments

This commit is contained in:
BVK Chaitanya 2010-09-03 20:35:23 +05:30
parent 8fdefb9253
commit cc7b1ab4d6
4 changed files with 13 additions and 12 deletions

View file

@ -70,17 +70,16 @@ static grub_command_t cmd;
GRUB_MOD_INIT(regexp)
{
extern struct grub_script_wildcard_translator translator;
cmd = grub_register_command ("regexp", grub_cmd_regexp,
N_("REGEXP STRING"),
N_("Test if REGEXP matches STRING."));
/* Setup GRUB script wildcard translator. */
wildcard_translator = &translator;
grub_wildcard_translator = &grub_filename_translator;
}
GRUB_MOD_FINI(regexp)
{
grub_unregister_command (cmd);
grub_wildcard_translator = 0;
}

View file

@ -40,7 +40,7 @@ static char* wildcard_escape (const char *s);
static char* wildcard_unescape (const char *s);
static grub_err_t wildcard_expand (const char *s, char ***strs);
struct grub_script_wildcard_translator translator = {
struct grub_script_wildcard_translator grub_filename_translator = {
.expand = wildcard_expand,
.escape = wildcard_escape,
.unescape = wildcard_unescape
@ -276,7 +276,7 @@ match_files (const char *prefix, const char *suffix, const char *end,
char **t;
char *buffer;
/* skip hidden files, . and .. */
/* skip . and .. names */
if (grub_strcmp(".", name) == 0 || grub_strcmp("..", name) == 0)
return 0;

View file

@ -42,7 +42,7 @@ struct grub_script_scope
static struct grub_script_scope *scope = 0;
/* Wildcard translator for GRUB script. */
struct grub_script_wildcard_translator *wildcard_translator;
struct grub_script_wildcard_translator *grub_wildcard_translator;
grub_err_t
grub_script_break (grub_command_t cmd, int argc, char *argv[])
@ -233,13 +233,13 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
int r;
char *p = 0;
if (! wildcard_translator || escape_type == 0)
if (! grub_wildcard_translator || escape_type == 0)
return grub_script_argv_append (&result, s);
if (escape_type > 0)
p = wildcard_translator->escape (s);
p = grub_wildcard_translator->escape (s);
else if (escape_type < 0)
p = wildcard_translator->unescape (s);
p = grub_wildcard_translator->unescape (s);
if (! p)
return 1;
@ -304,7 +304,7 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
/* Perform wildcard expansion. */
if (wildcard_translator)
if (grub_wildcard_translator)
{
int j;
int failed = 0;
@ -315,7 +315,8 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
result.args = 0;
for (i = 0; unexpanded.args[i]; i++)
{
if (wildcard_translator->expand (unexpanded.args[i], &expansions))
if (grub_wildcard_translator->expand (unexpanded.args[i],
&expansions))
{
grub_script_argv_free (&unexpanded);
goto fail;

View file

@ -78,7 +78,8 @@ struct grub_script_wildcard_translator
char *(*unescape) (const char *str);
grub_err_t (*expand) (const char *str, char ***expansions);
};
extern struct grub_script_wildcard_translator *wildcard_translator;
extern struct grub_script_wildcard_translator *grub_wildcard_translator;
extern struct grub_script_wildcard_translator *grub_filename_translator;
/* A complete argument. It consists of a list of one or more `struct
grub_script_arg's. */