vim-patch:8.2.0067: ERROR_UNKNOWN clashes on some systems (#20212)

Problem:    ERROR_UNKNOWN clashes on some systems.
Solution:   Rename ERROR_ to FCERR_. (Ola Söder, closes vim/vim#5415)
ef140544f6

Remove ERROR_BOTH which was removed from Vim in patch 7.4.1582.
This commit is contained in:
zeertzjq 2022-09-16 16:37:37 +08:00 committed by GitHub
parent 0b7a3c173c
commit b98de0e0e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 42 deletions

View File

@ -195,15 +195,15 @@ int call_internal_func(const char_u *const fname, const int argcount, typval_T *
{
const EvalFuncDef *const fdef = find_internal_func((const char *)fname);
if (fdef == NULL) {
return ERROR_UNKNOWN;
return FCERR_UNKNOWN;
} else if (argcount < fdef->min_argc) {
return ERROR_TOOFEW;
return FCERR_TOOFEW;
} else if (argcount > fdef->max_argc) {
return ERROR_TOOMANY;
return FCERR_TOOMANY;
}
argvars[argcount].v_type = VAR_UNKNOWN;
fdef->func(argvars, rettv, fdef->data);
return ERROR_NONE;
return FCERR_NONE;
}
/// Invoke a method for base->method().
@ -213,13 +213,13 @@ int call_internal_method(const char_u *const fname, const int argcount, typval_T
{
const EvalFuncDef *const fdef = find_internal_func((const char *)fname);
if (fdef == NULL) {
return ERROR_UNKNOWN;
return FCERR_UNKNOWN;
} else if (fdef->base_arg == BASE_NONE) {
return ERROR_NOTMETHOD;
return FCERR_NOTMETHOD;
} else if (argcount + 1 < fdef->min_argc) {
return ERROR_TOOFEW;
return FCERR_TOOFEW;
} else if (argcount + 1 > fdef->max_argc) {
return ERROR_TOOMANY;
return FCERR_TOOMANY;
}
typval_T argv[MAX_FUNC_ARGS + 1];
@ -231,7 +231,7 @@ int call_internal_method(const char_u *const fname, const int argcount, typval_T
argv[argcount + 1].v_type = VAR_UNKNOWN;
fdef->func(argv, rettv, fdef->data);
return ERROR_NONE;
return FCERR_NONE;
}
/// @return true for a non-zero Number and a non-empty String.

View File

@ -524,7 +524,7 @@ static char *fname_trans_sid(const char *const name, char *const fname_buf, char
int i = 3;
if (eval_fname_sid(name)) { // "<SID>" or "s:"
if (current_sctx.sc_sid <= 0) {
*error = ERROR_SCRIPT;
*error = FCERR_SCRIPT;
} else {
snprintf(fname_buf + i, (size_t)(FLEN_FIXED + 1 - i), "%" PRId64 "_",
(int64_t)current_sctx.sc_sid);
@ -1361,27 +1361,27 @@ static void user_func_error(int error, const char_u *name)
FUNC_ATTR_NONNULL_ALL
{
switch (error) {
case ERROR_UNKNOWN:
case FCERR_UNKNOWN:
emsg_funcname(N_("E117: Unknown function: %s"), name);
break;
case ERROR_NOTMETHOD:
case FCERR_NOTMETHOD:
emsg_funcname(N_("E276: Cannot use function as a method: %s"), name);
break;
case ERROR_DELETED:
case FCERR_DELETED:
emsg_funcname(N_("E933: Function was deleted: %s"), name);
break;
case ERROR_TOOMANY:
case FCERR_TOOMANY:
emsg_funcname(_(e_toomanyarg), name);
break;
case ERROR_TOOFEW:
case FCERR_TOOFEW:
emsg_funcname(N_("E119: Not enough arguments for function: %s"),
name);
break;
case ERROR_SCRIPT:
case FCERR_SCRIPT:
emsg_funcname(N_("E120: Using <SID> not in a script context: %s"),
name);
break;
case ERROR_DICT:
case FCERR_DICT:
emsg_funcname(N_("E725: Calling dict function without Dictionary: %s"),
name);
break;
@ -1421,7 +1421,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
FUNC_ATTR_NONNULL_ARG(1, 3, 5, 6)
{
int ret = FAIL;
int error = ERROR_NONE;
int error = FCERR_NONE;
ufunc_T *fp = NULL;
char fname_buf[FLEN_FIXED + 1];
char *tofree = NULL;
@ -1464,10 +1464,10 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
if (partial->pt_dict != NULL && (selfdict == NULL || !partial->pt_auto)) {
selfdict = partial->pt_dict;
}
if (error == ERROR_NONE && partial->pt_argc > 0) {
if (error == FCERR_NONE && partial->pt_argc > 0) {
for (argv_clear = 0; argv_clear < partial->pt_argc; argv_clear++) {
if (argv_clear + argcount_in >= MAX_FUNC_ARGS) {
error = ERROR_TOOMANY;
error = FCERR_TOOMANY;
goto theend;
}
tv_copy(&partial->pt_argv[argv_clear], &argv[argv_clear]);
@ -1480,7 +1480,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
}
}
if (error == ERROR_NONE && funcexe->evaluate) {
if (error == FCERR_NONE && funcexe->evaluate) {
char *rfname = fname;
// Ignore "g:" before a function name.
@ -1490,11 +1490,11 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
rettv->v_type = VAR_NUMBER; // default rettv is number zero
rettv->vval.v_number = 0;
error = ERROR_UNKNOWN;
error = FCERR_UNKNOWN;
if (is_luafunc(partial)) {
if (len > 0) {
error = ERROR_NONE;
error = FCERR_NONE;
argv_add_base(funcexe->basetv, &argvars, &argcount, argv, &argv_base);
nlua_typval_call(funcname, (size_t)len, argvars, argcount, rettv);
} else {
@ -1523,7 +1523,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
}
if (fp != NULL && (fp->uf_flags & FC_DELETED)) {
error = ERROR_DELETED;
error = FCERR_DELETED;
} else if (fp != NULL && (fp->uf_flags & FC_LUAREF)) {
error = typval_exec_lua_callable(fp->uf_luaref, argcount, argvars, rettv);
} else if (fp != NULL) {
@ -1539,17 +1539,17 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
*funcexe->doesrange = true;
}
if (argcount < fp->uf_args.ga_len - fp->uf_def_args.ga_len) {
error = ERROR_TOOFEW;
error = FCERR_TOOFEW;
} else if (!fp->uf_varargs && argcount > fp->uf_args.ga_len) {
error = ERROR_TOOMANY;
error = FCERR_TOOMANY;
} else if ((fp->uf_flags & FC_DICT) && selfdict == NULL) {
error = ERROR_DICT;
error = FCERR_DICT;
} else {
// Call the user function.
call_user_func(fp, argcount, argvars, rettv, funcexe->firstline,
funcexe->lastline,
(fp->uf_flags & FC_DICT) ? selfdict : NULL);
error = ERROR_NONE;
error = FCERR_NONE;
}
}
} else if (funcexe->basetv != NULL) {
@ -1571,7 +1571,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
// update that flag first to make aborting() reliable.
update_force_abort();
}
if (error == ERROR_NONE) {
if (error == FCERR_NONE) {
ret = OK;
}
@ -3515,7 +3515,7 @@ bool set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID)
{
ufunc_T *fp = fp_in;
funccall_T *fc;
int error = ERROR_NONE;
int error = FCERR_NONE;
char_u fname_buf[FLEN_FIXED + 1];
char_u *tofree = NULL;
char_u *fname;

View File

@ -38,16 +38,15 @@ struct funccal_entry {
/// errors for when calling a function
typedef enum {
ERROR_UNKNOWN = 0,
ERROR_TOOMANY,
ERROR_TOOFEW,
ERROR_SCRIPT,
ERROR_DICT,
ERROR_NONE,
ERROR_OTHER,
ERROR_BOTH,
ERROR_DELETED,
ERROR_NOTMETHOD,
FCERR_UNKNOWN = 0,
FCERR_TOOMANY = 1,
FCERR_TOOFEW = 2,
FCERR_SCRIPT = 3,
FCERR_DICT = 4,
FCERR_NONE = 5,
FCERR_OTHER = 6,
FCERR_DELETED = 7,
FCERR_NOTMETHOD = 8, ///< function cannot be used as a method
} FnameTransError;
/// Used in funcexe_T. Returns the new argcount.

View File

@ -1435,12 +1435,12 @@ int typval_exec_lua_callable(LuaRef lua_cb, int argcount, typval_T *argvars, typ
if (nlua_pcall(lstate, argcount, 1)) {
nlua_print(lstate);
return ERROR_OTHER;
return FCERR_OTHER;
}
nlua_pop_typval(lstate, rettv);
return ERROR_NONE;
return FCERR_NONE;
}
/// Execute Lua string