patch 9.0.0544: minor issues with setting a string option
Problem: Minor issues with setting a string option.
Solution: Adjust the code, add a test. (closes #11192)
diff --git a/src/option.c b/src/option.c
index 5867962..6052b38 100644
--- a/src/option.c
+++ b/src/option.c
@@ -1323,13 +1323,11 @@
/*
* Set 'keywordprg' to ":help" if an empty
* value was passed to :set by the user.
- * Misuse errbuf[] for the resulting string.
*/
if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' '))
{
- STRCPY(errbuf, ":help");
save_arg = arg;
- arg = (char_u *)errbuf;
+ arg = (char_u *)":help";
}
/*
* Convert 'backspace' number to string, for
@@ -1417,7 +1415,7 @@
* but do remove it for "\\\\machine\\path".
* The reverse is found in ExpandOldSetting().
*/
- while (*arg && !VIM_ISWHITE(*arg))
+ while (*arg != NUL && !VIM_ISWHITE(*arg))
{
int i;
@@ -1427,7 +1425,7 @@
&& vim_isfilec(arg[1])
&& !VIM_ISWHITE(arg[1])
&& (arg[1] != '\\'
- || (s == newval && arg[2] != '\\')))
+ || (s == newval && arg[2] != '\\')))
#endif
)
++arg; // remove backslash
@@ -1565,8 +1563,8 @@
}
}
- if (save_arg != NULL) // number for 'whichwrap'
- arg = save_arg;
+ if (save_arg != NULL)
+ arg = save_arg; // arg was temporarily changed, restore it
}
/*