* grub-core/commands/regexp.c (set_matches): Move setvar out of its
parent.
This commit is contained in:
parent
3188131f72
commit
cb758e96cc
2 changed files with 20 additions and 12 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-03-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/commands/regexp.c (set_matches): Move setvar out of its
|
||||||
|
parent.
|
||||||
|
|
||||||
2013-03-03 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-03-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/kern/env.c, include/grub/env.h: Change iterator through
|
* grub-core/kern/env.c, include/grub/env.h: Change iterator through
|
||||||
|
|
|
@ -46,6 +46,18 @@ static const struct grub_arg_option options[] =
|
||||||
{ 0, 0, 0, 0, 0, 0 }
|
{ 0, 0, 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
setvar (char *str, char *v, regmatch_t *m)
|
||||||
|
{
|
||||||
|
char ch;
|
||||||
|
grub_err_t err;
|
||||||
|
ch = str[m->rm_eo];
|
||||||
|
str[m->rm_eo] = '\0';
|
||||||
|
err = grub_env_set (v, str + m->rm_so);
|
||||||
|
str[m->rm_eo] = ch;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
set_matches (char **varnames, char *str, grub_size_t nmatches,
|
set_matches (char **varnames, char *str, grub_size_t nmatches,
|
||||||
regmatch_t *matches)
|
regmatch_t *matches)
|
||||||
|
@ -56,18 +68,9 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
unsigned long j;
|
unsigned long j;
|
||||||
|
|
||||||
auto void setvar (char *v, regmatch_t *m);
|
|
||||||
void setvar (char *v, regmatch_t *m)
|
|
||||||
{
|
|
||||||
char ch;
|
|
||||||
ch = str[m->rm_eo];
|
|
||||||
str[m->rm_eo] = '\0';
|
|
||||||
err = grub_env_set (v, str + m->rm_so);
|
|
||||||
str[m->rm_eo] = ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; varnames && varnames[i]; i++)
|
for (i = 0; varnames && varnames[i]; i++)
|
||||||
{
|
{
|
||||||
|
err = GRUB_ERR_NONE;
|
||||||
p = grub_strchr (varnames[i], ':');
|
p = grub_strchr (varnames[i], ':');
|
||||||
if (! p)
|
if (! p)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +78,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
|
||||||
if (nmatches < 2 || matches[1].rm_so == -1)
|
if (nmatches < 2 || matches[1].rm_so == -1)
|
||||||
grub_env_unset (varnames[i]);
|
grub_env_unset (varnames[i]);
|
||||||
else
|
else
|
||||||
setvar (varnames[i], &matches[1]);
|
err = setvar (str, varnames[i], &matches[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -87,7 +90,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
|
||||||
if (nmatches <= j || matches[j].rm_so == -1)
|
if (nmatches <= j || matches[j].rm_so == -1)
|
||||||
grub_env_unset (p + 1);
|
grub_env_unset (p + 1);
|
||||||
else
|
else
|
||||||
setvar (p + 1, &matches[j]);
|
err = setvar (str, p + 1, &matches[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err != GRUB_ERR_NONE)
|
if (err != GRUB_ERR_NONE)
|
||||||
|
|
Loading…
Add table
Reference in a new issue