From: Vladimir 'phcoder' Serbinenko Date: Sun, 3 Mar 2013 14:24:02 +0000 (+0100) Subject: * grub-core/commands/regexp.c (set_matches): Move setvar out of its X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=cb758e96cc988cf9841f3afcd5f9107278acb14a;p=grub2.git * grub-core/commands/regexp.c (set_matches): Move setvar out of its parent. --- diff --git a/ChangeLog b/ChangeLog index 5f9cde5a9..e5e2248eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-03-03 Vladimir Serbinenko + + * grub-core/commands/regexp.c (set_matches): Move setvar out of its + parent. + 2013-03-03 Vladimir Serbinenko * grub-core/kern/env.c, include/grub/env.h: Change iterator through diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c index b0706d069..f00b184c8 100644 --- a/grub-core/commands/regexp.c +++ b/grub-core/commands/regexp.c @@ -46,6 +46,18 @@ static const struct grub_arg_option options[] = { 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 set_matches (char **varnames, char *str, grub_size_t nmatches, regmatch_t *matches) @@ -56,18 +68,9 @@ set_matches (char **varnames, char *str, grub_size_t nmatches, grub_err_t err; 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++) { + err = GRUB_ERR_NONE; p = grub_strchr (varnames[i], ':'); if (! p) { @@ -75,7 +78,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches, if (nmatches < 2 || matches[1].rm_so == -1) grub_env_unset (varnames[i]); else - setvar (varnames[i], &matches[1]); + err = setvar (str, varnames[i], &matches[1]); } else { @@ -87,7 +90,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches, if (nmatches <= j || matches[j].rm_so == -1) grub_env_unset (p + 1); else - setvar (p + 1, &matches[j]); + err = setvar (str, p + 1, &matches[j]); } if (err != GRUB_ERR_NONE)