aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-01-25 14:53:42 +0000
committerLewis Russell <lewis6991@gmail.com>2023-01-26 09:53:14 +0000
commit3ae3e47d541db6e2cbf7c42b1ccce9cf48b0e4c9 (patch)
tree1d74cc2a398288864e2749515e6c56d177d78842
parente368560c80f162a67dd1ef5369ebaf57fb937de6 (diff)
downloadrneovim-3ae3e47d541db6e2cbf7c42b1ccce9cf48b0e4c9.tar.gz
rneovim-3ae3e47d541db6e2cbf7c42b1ccce9cf48b0e4c9.tar.bz2
rneovim-3ae3e47d541db6e2cbf7c42b1ccce9cf48b0e4c9.zip
refactor(option.c): reduce scope or errmsg
-rw-r--r--src/nvim/option.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 5326251d2d..f19d1d1517 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1420,7 +1420,6 @@ int do_set(char *arg, int opt_flags)
char errbuf[80];
while (*arg != NUL) { // loop to process all options
- char *errmsg = NULL;
char *startarg = arg; // remember for error message
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;
}
} else {
+ char *errmsg = NULL;
do_set_option(opt_flags, &arg, &did_show, errbuf, sizeof(errbuf), &errmsg);
// Advance to next argument.
@@ -1458,26 +1458,26 @@ int do_set(char *arg, int opt_flags)
break;
}
}
- }
- if (errmsg != NULL) {
- 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);
+ if (errmsg != NULL) {
+ 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--;
+ no_wait_return++; // wait_return() done later
+ emsg(IObuff); // show error highlighted
+ no_wait_return--;
- return FAIL;
+ return FAIL;
+ }
}
arg = skipwhite(arg);