aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index a59e55121f..9d9e70622a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -533,8 +533,8 @@ static void set_string_default(OptIndex opt_idx, char *val, bool allocated)
/// For an option value that contains comma separated items, find "newval" in
/// "origval". Return NULL if not found.
-static char *find_dup_item(char *origval, const char *newval, const size_t newvallen,
- uint32_t flags)
+static const char *find_dup_item(const char *origval, const char *newval, const size_t newvallen,
+ uint32_t flags)
FUNC_ATTR_NONNULL_ARG(2)
{
if (origval == NULL) {
@@ -543,7 +543,7 @@ static char *find_dup_item(char *origval, const char *newval, const size_t newva
int bs = 0;
- for (char *s = origval; *s != NUL; s++) {
+ for (const char *s = origval; *s != NUL; s++) {
if ((!(flags & kOptFlagComma) || s == origval || (s[-1] == ',' && !(bs & 1)))
&& strncmp(s, newval, newvallen) == 0
&& (!(flags & kOptFlagComma) || s[newvallen] == ',' || s[newvallen] == NUL)) {
@@ -727,7 +727,7 @@ void ex_set(exarg_T *eap)
/// Copy the new string value into allocated memory for the option.
/// Can't use set_option_direct(), because we need to remove the backslashes.
-static char *stropt_copy_value(char *origval, char **argp, set_op_T op,
+static char *stropt_copy_value(const char *origval, char **argp, set_op_T op,
uint32_t flags FUNC_ATTR_UNUSED)
{
char *arg = *argp;
@@ -774,7 +774,7 @@ static char *stropt_copy_value(char *origval, char **argp, set_op_T op,
}
/// Expand environment variables and ~ in string option value 'newval'.
-static char *stropt_expand_envvar(OptIndex opt_idx, char *origval, char *newval, set_op_T op)
+static char *stropt_expand_envvar(OptIndex opt_idx, const char *origval, char *newval, set_op_T op)
{
char *s = option_expand(opt_idx, newval);
if (s == NULL) {
@@ -794,7 +794,7 @@ static char *stropt_expand_envvar(OptIndex opt_idx, char *origval, char *newval,
/// Concatenate the original and new values of a string option, adding a "," if
/// needed.
-static void stropt_concat_with_comma(char *origval, char *newval, set_op_T op, uint32_t flags)
+static void stropt_concat_with_comma(const char *origval, char *newval, set_op_T op, uint32_t flags)
{
int len = 0;
int comma = ((flags & kOptFlagComma) && *origval != NUL && *newval != NUL);
@@ -820,7 +820,8 @@ static void stropt_concat_with_comma(char *origval, char *newval, set_op_T op, u
/// Remove a value from a string option. Copy string option value in "origval"
/// to "newval" and then remove the string "strval" of length "len".
-static void stropt_remove_val(char *origval, char *newval, uint32_t flags, char *strval, int len)
+static void stropt_remove_val(const char *origval, char *newval, uint32_t flags, const char *strval,
+ int len)
{
// Remove newval[] from origval[]. (Note: "len" has been set above
// and is used here).
@@ -872,13 +873,13 @@ static void stropt_remove_dupflags(char *newval, uint32_t flags)
/// set {opt}={val}
/// set {opt}:{val}
static char *stropt_get_newval(int nextchar, OptIndex opt_idx, char **argp, void *varp,
- char *origval, set_op_T *op_arg, uint32_t flags)
+ const char *origval, set_op_T *op_arg, uint32_t flags)
{
char *arg = *argp;
set_op_T op = *op_arg;
char *save_arg = NULL;
char *newval;
- char *s = NULL;
+ const char *s = NULL;
arg++; // jump to after the '=' or ':'
@@ -1194,9 +1195,10 @@ static OptVal get_option_newval(OptIndex opt_idx, int opt_flags, set_prefix_T pr
break;
}
case kOptValTypeString: {
- char *oldval_str = oldval.data.string.data;
+ const char *oldval_str = oldval.data.string.data;
// Get the new value for the option
- char *newval_str = stropt_get_newval(nextchar, opt_idx, argp, varp, oldval_str, &op, flags);
+ const char *newval_str = stropt_get_newval(nextchar, opt_idx, argp, varp, oldval_str, &op,
+ flags);
newval = CSTR_AS_OPTVAL(newval_str);
break;
}
@@ -1568,7 +1570,7 @@ char *find_shada_parameter(int type)
/// These string options cannot be indirect!
/// If "val" is NULL expand the current value of the option.
/// Return pointer to NameBuff, or NULL when not expanded.
-static char *option_expand(OptIndex opt_idx, char *val)
+static char *option_expand(OptIndex opt_idx, const char *val)
{
// if option doesn't need expansion nothing to do
if (!(options[opt_idx].flags & kOptFlagExpand) || is_option_hidden(opt_idx)) {
@@ -4392,7 +4394,7 @@ static int put_set(FILE *fd, char *cmd, OptIndex opt_idx, void *varp)
return FAIL;
}
- char *value_str = value.data.string.data;
+ const char *value_str = value.data.string.data;
char *buf = NULL;
char *part = NULL;