mirror of
https://github.com/neovim/neovim.git
synced 2025-12-02 06:53:05 +00:00
refactor: replace char_u variables and functions with char
Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
@@ -1407,7 +1407,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
|
||||
argend--;
|
||||
}
|
||||
expr = skipwhite(argend);
|
||||
if (*expr != '=' && !((vim_strchr((char_u *)"+-*/%.", *expr) != NULL
|
||||
if (*expr != '=' && !((vim_strchr("+-*/%.", *expr) != NULL
|
||||
&& expr[1] == '=') || STRNCMP(expr, "..=", 3) == 0)) {
|
||||
// ":let" without "=": list variables
|
||||
if (*arg == '[') {
|
||||
@@ -1443,7 +1443,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
|
||||
op[0] = '=';
|
||||
op[1] = NUL;
|
||||
if (*expr != '=') {
|
||||
if (vim_strchr((char_u *)"+-*/%.", *expr) != NULL) {
|
||||
if (vim_strchr("+-*/%.", *expr) != NULL) {
|
||||
op[0] = *expr; // +=, -=, *=, /=, %= or .=
|
||||
if (expr[0] == '.' && expr[1] == '.') { // ..=
|
||||
expr++;
|
||||
@@ -1809,10 +1809,10 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
|
||||
if (len == 0) {
|
||||
semsg(_(e_invarg2), name - 1);
|
||||
} else {
|
||||
if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) {
|
||||
if (op != NULL && vim_strchr("+-*/%", *op) != NULL) {
|
||||
semsg(_(e_letwrong), op);
|
||||
} else if (endchars != NULL
|
||||
&& vim_strchr((char_u *)endchars, *skipwhite(arg)) == NULL) {
|
||||
&& vim_strchr(endchars, *skipwhite(arg)) == NULL) {
|
||||
emsg(_(e_letunexp));
|
||||
} else if (!check_secure()) {
|
||||
const char c1 = name[len];
|
||||
@@ -1855,7 +1855,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
|
||||
char *const p = (char *)find_option_end((const char **)&arg, &opt_flags);
|
||||
if (p == NULL
|
||||
|| (endchars != NULL
|
||||
&& vim_strchr((char_u *)endchars, *skipwhite(p)) == NULL)) {
|
||||
&& vim_strchr(endchars, *skipwhite(p)) == NULL)) {
|
||||
emsg(_(e_letunexp));
|
||||
} else {
|
||||
int opt_type;
|
||||
@@ -1914,10 +1914,10 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
|
||||
return NULL;
|
||||
}
|
||||
arg++;
|
||||
if (op != NULL && vim_strchr((char_u *)"+-*/%", *op) != NULL) {
|
||||
if (op != NULL && vim_strchr("+-*/%", *op) != NULL) {
|
||||
semsg(_(e_letwrong), op);
|
||||
} else if (endchars != NULL
|
||||
&& vim_strchr((char_u *)endchars, *skipwhite(arg + 1)) == NULL) {
|
||||
&& vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) {
|
||||
emsg(_(e_letunexp));
|
||||
} else {
|
||||
char *s;
|
||||
@@ -1949,7 +1949,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
|
||||
|
||||
char *const p = get_lval(arg, tv, &lv, false, false, 0, FNE_CHECK_START);
|
||||
if (p != NULL && lv.ll_name != NULL) {
|
||||
if (endchars != NULL && vim_strchr((char_u *)endchars, *skipwhite(p)) == NULL) {
|
||||
if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL) {
|
||||
emsg(_(e_letunexp));
|
||||
} else {
|
||||
set_var_lval(&lv, p, tv, copy, is_const, op);
|
||||
@@ -2752,7 +2752,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
|
||||
break;
|
||||
} else if ((c == '<' || c == '#')
|
||||
&& xp->xp_context == EXPAND_FUNCTIONS
|
||||
&& vim_strchr((char_u *)xp->xp_pattern, '(') == NULL) {
|
||||
&& vim_strchr(xp->xp_pattern, '(') == NULL) {
|
||||
// Function name can start with "<SNR>" and contain '#'.
|
||||
break;
|
||||
} else if (cmdidx != CMD_let || got_eq) {
|
||||
@@ -3263,15 +3263,15 @@ int pattern_match(char *pat, char *text, bool ic)
|
||||
regmatch_T regmatch;
|
||||
|
||||
// avoid 'l' flag in 'cpoptions'
|
||||
char *save_cpo = (char *)p_cpo;
|
||||
p_cpo = (char_u *)"";
|
||||
regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING);
|
||||
char *save_cpo = p_cpo;
|
||||
p_cpo = "";
|
||||
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
||||
if (regmatch.regprog != NULL) {
|
||||
regmatch.rm_ic = ic;
|
||||
matches = vim_regexec_nl(®match, (char_u *)text, (colnr_T)0);
|
||||
vim_regfree(regmatch.regprog);
|
||||
}
|
||||
p_cpo = (char_u *)save_cpo;
|
||||
p_cpo = save_cpo;
|
||||
return matches;
|
||||
}
|
||||
|
||||
@@ -5872,7 +5872,7 @@ static int get_env_tv(char **arg, typval_T *rettv, int evaluate)
|
||||
xfree(string);
|
||||
|
||||
// Next try expanding things like $VIM and ${HOME}.
|
||||
string = (char *)expand_env_save((char_u *)name - 1);
|
||||
string = expand_env_save(name - 1);
|
||||
if (string != NULL && *string == '$') {
|
||||
XFREE_CLEAR(string);
|
||||
}
|
||||
@@ -6141,7 +6141,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr
|
||||
use_string = true;
|
||||
}
|
||||
|
||||
if ((use_string && vim_strchr((char_u *)s, AUTOLOAD_CHAR) == NULL) || is_funcref) {
|
||||
if ((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref) {
|
||||
name = s;
|
||||
trans_name = (char *)trans_function_name((char_u **)&name, false,
|
||||
TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD
|
||||
@@ -7958,7 +7958,7 @@ int get_id_len(const char **const arg)
|
||||
// slice "[n:]". Also "xx:" is not a namespace.
|
||||
len = (int)(p - *arg);
|
||||
if (len > 1
|
||||
|| (len == 1 && vim_strchr((char_u *)namespace_char, **arg) == NULL)) {
|
||||
|| (len == 1 && vim_strchr(namespace_char, **arg) == NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -8089,7 +8089,7 @@ const char *find_name_end(const char *arg, const char **expr_start, const char *
|
||||
// slice "[n:]". Also "xx:" is not a namespace. But {ns}: is.
|
||||
len = (int)(p - arg);
|
||||
if ((len > 1 && p[-1] != '}')
|
||||
|| (len == 1 && vim_strchr((char_u *)namespace_char, *arg) == NULL)) {
|
||||
|| (len == 1 && vim_strchr(namespace_char, *arg) == NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -9279,7 +9279,7 @@ bool var_check_func_name(const char *const name, const bool new_var)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
// Allow for w: b: s: and t:.
|
||||
if (!(vim_strchr((char_u *)"wbst", name[0]) != NULL && name[1] == ':')
|
||||
if (!(vim_strchr("wbst", name[0]) != NULL && name[1] == ':')
|
||||
&& !ASCII_ISUPPER((name[0] != NUL && name[1] == ':')
|
||||
? name[2] : name[0])) {
|
||||
semsg(_("E704: Funcref variable name must start with a capital: %s"), name);
|
||||
@@ -10110,7 +10110,7 @@ repeat:
|
||||
|| (*fnamep)[1] == NUL)
|
||||
#endif
|
||||
&& !(tilde_file && (*fnamep)[1] == NUL)) {
|
||||
*fnamep = (char *)expand_env_save((char_u *)(*fnamep));
|
||||
*fnamep = expand_env_save(*fnamep);
|
||||
xfree(*bufp); // free any allocated file name
|
||||
*bufp = *fnamep;
|
||||
if (*fnamep == NULL) {
|
||||
@@ -10163,7 +10163,7 @@ repeat:
|
||||
// Need full path first (use expand_env() to remove a "~/")
|
||||
if (!has_fullname && !has_homerelative) {
|
||||
if (**fnamep == '~') {
|
||||
p = pbuf = (char *)expand_env_save((char_u *)(*fnamep));
|
||||
p = pbuf = expand_env_save(*fnamep);
|
||||
} else {
|
||||
p = pbuf = FullName_save(*fnamep, false);
|
||||
}
|
||||
@@ -10325,12 +10325,12 @@ repeat:
|
||||
sep = (char_u)(*s++);
|
||||
if (sep) {
|
||||
// find end of pattern
|
||||
p = (char *)vim_strchr((char_u *)s, sep);
|
||||
p = vim_strchr(s, sep);
|
||||
if (p != NULL) {
|
||||
char *const pat = xstrnsave(s, p - s);
|
||||
s = p + 1;
|
||||
// find end of substitution
|
||||
p = (char *)vim_strchr((char_u *)s, sep);
|
||||
p = vim_strchr(s, sep);
|
||||
if (p != NULL) {
|
||||
char *const sub = xstrnsave(s, p - s);
|
||||
char *const str = xstrnsave(*fnamep, *fnamelen);
|
||||
@@ -10389,15 +10389,15 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags
|
||||
char *zero_width = NULL;
|
||||
|
||||
// Make 'cpoptions' empty, so that the 'l' flag doesn't work here
|
||||
save_cpo = (char *)p_cpo;
|
||||
p_cpo = empty_option;
|
||||
save_cpo = p_cpo;
|
||||
p_cpo = (char *)empty_option;
|
||||
|
||||
ga_init(&ga, 1, 200);
|
||||
|
||||
do_all = (flags[0] == 'g');
|
||||
|
||||
regmatch.rm_ic = p_ic;
|
||||
regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING);
|
||||
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
||||
if (regmatch.regprog != NULL) {
|
||||
tail = str;
|
||||
end = str + STRLEN(str);
|
||||
@@ -10449,8 +10449,8 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, char *flags
|
||||
|
||||
char *ret = xstrdup(ga.ga_data == NULL ? str : ga.ga_data);
|
||||
ga_clear(&ga);
|
||||
if (p_cpo == empty_option) {
|
||||
p_cpo = (char_u *)save_cpo;
|
||||
if ((char_u *)p_cpo == empty_option) {
|
||||
p_cpo = save_cpo;
|
||||
} else {
|
||||
// Darn, evaluating {sub} expression or {expr} changed the value.
|
||||
free_string_option((char_u *)save_cpo);
|
||||
|
||||
Reference in New Issue
Block a user