refactor(option.c): reduce scope or errmsg

This commit is contained in:
Lewis Russell
2023-01-25 14:53:42 +00:00
parent e368560c80
commit 3ae3e47d54

View File

@@ -1420,7 +1420,6 @@ int do_set(char *arg, int opt_flags)
char errbuf[80]; char errbuf[80];
while (*arg != NUL) { // loop to process all options while (*arg != NUL) { // loop to process all options
char *errmsg = NULL;
char *startarg = arg; // remember for error message char *startarg = arg; // remember for error message
if (strncmp(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3]) if (strncmp(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3])
@@ -1441,6 +1440,7 @@ int do_set(char *arg, int opt_flags)
did_show = true; did_show = true;
} }
} else { } else {
char *errmsg = NULL;
do_set_option(opt_flags, &arg, &did_show, errbuf, sizeof(errbuf), &errmsg); do_set_option(opt_flags, &arg, &did_show, errbuf, sizeof(errbuf), &errmsg);
// Advance to next argument. // Advance to next argument.
@@ -1458,7 +1458,6 @@ int do_set(char *arg, int opt_flags)
break; break;
} }
} }
}
if (errmsg != NULL) { if (errmsg != NULL) {
xstrlcpy(IObuff, _(errmsg), IOSIZE); xstrlcpy(IObuff, _(errmsg), IOSIZE);
@@ -1479,6 +1478,7 @@ int do_set(char *arg, int opt_flags)
return FAIL; return FAIL;
} }
}
arg = skipwhite(arg); arg = skipwhite(arg);
} }