mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
refactor(option.c): remove goto
This commit is contained in:
@@ -1414,75 +1414,73 @@ int do_set(char *arg, int opt_flags)
|
|||||||
if (*arg == NUL) {
|
if (*arg == NUL) {
|
||||||
showoptions(false, opt_flags);
|
showoptions(false, opt_flags);
|
||||||
did_show = true;
|
did_show = true;
|
||||||
goto theend;
|
} else {
|
||||||
}
|
while (*arg != NUL) { // loop to process all options
|
||||||
|
if (strncmp(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3])
|
||||||
while (*arg != NUL) { // loop to process all options
|
&& !(opt_flags & OPT_MODELINE)) {
|
||||||
if (strncmp(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3])
|
// ":set all" show all options.
|
||||||
&& !(opt_flags & OPT_MODELINE)) {
|
// ":set all&" set all options to their default value.
|
||||||
// ":set all" show all options.
|
arg += 3;
|
||||||
// ":set all&" set all options to their default value.
|
if (*arg == '&') {
|
||||||
arg += 3;
|
arg++;
|
||||||
if (*arg == '&') {
|
// Only for :set command set global value of local options.
|
||||||
arg++;
|
set_options_default(OPT_FREE | opt_flags);
|
||||||
// Only for :set command set global value of local options.
|
didset_options();
|
||||||
set_options_default(OPT_FREE | opt_flags);
|
didset_options2();
|
||||||
didset_options();
|
ui_refresh_options();
|
||||||
didset_options2();
|
redraw_all_later(UPD_CLEAR);
|
||||||
ui_refresh_options();
|
} else {
|
||||||
redraw_all_later(UPD_CLEAR);
|
showoptions(true, opt_flags);
|
||||||
|
did_show = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showoptions(true, opt_flags);
|
char *startarg = arg; // remember for error message
|
||||||
did_show = true;
|
char *errmsg = NULL;
|
||||||
}
|
char errbuf[80];
|
||||||
} else {
|
|
||||||
char *startarg = arg; // remember for error message
|
|
||||||
char *errmsg = NULL;
|
|
||||||
char errbuf[80];
|
|
||||||
|
|
||||||
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.
|
||||||
// - skip until a blank found, taking care of backslashes
|
// - skip until a blank found, taking care of backslashes
|
||||||
// - skip blanks
|
// - skip blanks
|
||||||
// - skip one "=val" argument (for hidden options ":set gfn =xx")
|
// - skip one "=val" argument (for hidden options ":set gfn =xx")
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
while (*arg != NUL && !ascii_iswhite(*arg)) {
|
while (*arg != NUL && !ascii_iswhite(*arg)) {
|
||||||
if (*arg++ == '\\' && *arg != NUL) {
|
if (*arg++ == '\\' && *arg != NUL) {
|
||||||
arg++;
|
arg++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arg = skipwhite(arg);
|
||||||
|
if (*arg != '=') {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arg = skipwhite(arg);
|
|
||||||
if (*arg != '=') {
|
if (errmsg != NULL) {
|
||||||
break;
|
xstrlcpy(IObuff, _(errmsg), IOSIZE);
|
||||||
|
int i = (int)strlen(IObuff) + 2;
|
||||||
|
if (i + (arg - startarg) < IOSIZE) {
|
||||||
|
// append the argument with the error
|
||||||
|
STRCAT(IObuff, ": ");
|
||||||
|
assert(arg >= startarg);
|
||||||
|
memmove(IObuff + i, startarg, (size_t)(arg - startarg));
|
||||||
|
IObuff[i + (arg - startarg)] = NUL;
|
||||||
|
}
|
||||||
|
// make sure all characters are printable
|
||||||
|
trans_characters(IObuff, IOSIZE);
|
||||||
|
|
||||||
|
no_wait_return++; // wait_return() done later
|
||||||
|
emsg(IObuff); // show error highlighted
|
||||||
|
no_wait_return--;
|
||||||
|
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errmsg != NULL) {
|
arg = skipwhite(arg);
|
||||||
xstrlcpy(IObuff, _(errmsg), IOSIZE);
|
|
||||||
int i = (int)strlen(IObuff) + 2;
|
|
||||||
if (i + (arg - startarg) < IOSIZE) {
|
|
||||||
// append the argument with the error
|
|
||||||
STRCAT(IObuff, ": ");
|
|
||||||
assert(arg >= startarg);
|
|
||||||
memmove(IObuff + i, startarg, (size_t)(arg - startarg));
|
|
||||||
IObuff[i + (arg - startarg)] = NUL;
|
|
||||||
}
|
|
||||||
// make sure all characters are printable
|
|
||||||
trans_characters(IObuff, IOSIZE);
|
|
||||||
|
|
||||||
no_wait_return++; // wait_return() done later
|
|
||||||
emsg(IObuff); // show error highlighted
|
|
||||||
no_wait_return--;
|
|
||||||
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arg = skipwhite(arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
theend:
|
|
||||||
if (silent_mode && did_show) {
|
if (silent_mode && did_show) {
|
||||||
// After displaying option values in silent mode.
|
// After displaying option values in silent mode.
|
||||||
silent_mode = false;
|
silent_mode = false;
|
||||||
|
Reference in New Issue
Block a user