mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
src/nvim/eval.c
src/nvim/eval/typval.c src/nvim/fileio.c src/nvim/main.c src/nvim/regexp_nfa.c src/nvim/spellfile.c changed some EMSG[..] Macros to emsgf
This commit is contained in:
@@ -1940,7 +1940,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv,
|
||||
} else if (*arg == '@') {
|
||||
arg++;
|
||||
if (op != NULL && (*op == '+' || *op == '-')) {
|
||||
EMSG2(_(e_letwrong), op);
|
||||
emsgf(_(e_letwrong), op);
|
||||
} else if (endchars != NULL
|
||||
&& vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) {
|
||||
EMSG(_(e_letunexp));
|
||||
@@ -2083,7 +2083,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
||||
(flags & GLV_READ_ONLY) ? NULL : &ht,
|
||||
flags & GLV_NO_AUTOLOAD);
|
||||
if (v == NULL && !quiet) {
|
||||
EMSG3(_("E121: Undefined variable: %.*s"),
|
||||
emsgf(_("E121: Undefined variable: %.*s"),
|
||||
(int)lp->ll_name_len, lp->ll_name);
|
||||
}
|
||||
if (v == NULL) {
|
||||
@@ -2234,7 +2234,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
|
||||
/* Key does not exist in dict: may need to add it. */
|
||||
if (*p == '[' || *p == '.' || unlet) {
|
||||
if (!quiet) {
|
||||
EMSG2(_(e_dictkey), key);
|
||||
emsgf(_(e_dictkey), key);
|
||||
}
|
||||
tv_clear(&var1);
|
||||
return NULL;
|
||||
@@ -3036,7 +3036,7 @@ static int do_lock_var(lval_T *lp, char_u *const name_end, const int deep,
|
||||
&& di->di_tv.v_type != VAR_LIST) {
|
||||
// For historical reasons this error is not given for Lists and
|
||||
// Dictionaries. E.g. b: dictionary may be locked/unlocked.
|
||||
EMSG2(_("E940: Cannot lock or unlock variable %s"), lp->ll_name);
|
||||
emsgf(_("E940: Cannot lock or unlock variable %s"), lp->ll_name);
|
||||
} else {
|
||||
if (lock) {
|
||||
di->di_flags |= DI_FLAGS_LOCK;
|
||||
@@ -3254,7 +3254,7 @@ int eval0(char_u *arg, typval_T *rettv, char_u **nextcmd, int evaluate)
|
||||
// been cancelled due to an aborting error, an interrupt, or an
|
||||
// exception.
|
||||
if (!aborting()) {
|
||||
EMSG2(_(e_invexpr2), arg);
|
||||
emsgf(_(e_invexpr2), arg);
|
||||
}
|
||||
ret = FAIL;
|
||||
}
|
||||
@@ -4553,7 +4553,7 @@ eval_index(
|
||||
(const char *)key, len);
|
||||
|
||||
if (item == NULL && verbose) {
|
||||
EMSG2(_(e_dictkey), key);
|
||||
emsgf(_(e_dictkey), key);
|
||||
}
|
||||
if (len == -1) {
|
||||
tv_clear(&var1);
|
||||
@@ -4890,14 +4890,14 @@ static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate)
|
||||
break;
|
||||
}
|
||||
if (**arg != ',') {
|
||||
EMSG2(_("E696: Missing comma in List: %s"), *arg);
|
||||
emsgf(_("E696: Missing comma in List: %s"), *arg);
|
||||
goto failret;
|
||||
}
|
||||
*arg = skipwhite(*arg + 1);
|
||||
}
|
||||
|
||||
if (**arg != ']') {
|
||||
EMSG2(_("E697: Missing end of List ']': %s"), *arg);
|
||||
emsgf(_("E697: Missing end of List ']': %s"), *arg);
|
||||
failret:
|
||||
if (evaluate) {
|
||||
tv_list_free(l);
|
||||
@@ -7823,7 +7823,7 @@ static void f_delete(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
// delete a directory recursively
|
||||
rettv->vval.v_number = delete_recursive(name);
|
||||
} else {
|
||||
EMSG2(_(e_invexpr2), flags);
|
||||
emsgf(_(e_invexpr2), flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7835,17 +7835,17 @@ static void f_dictwatcheradd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
|
||||
if (argvars[0].v_type != VAR_DICT) {
|
||||
EMSG2(_(e_invarg2), "dict");
|
||||
emsgf(_(e_invarg2), "dict");
|
||||
return;
|
||||
} else if (argvars[0].vval.v_dict == NULL) {
|
||||
const char *const arg_errmsg = _("dictwatcheradd() argument");
|
||||
const size_t arg_errmsg_len = strlen(arg_errmsg);
|
||||
EMSG3(_(e_readonlyvar), (int)arg_errmsg_len, arg_errmsg);
|
||||
emsgf(_(e_readonlyvar), (int)arg_errmsg_len, arg_errmsg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (argvars[1].v_type != VAR_STRING && argvars[1].v_type != VAR_NUMBER) {
|
||||
EMSG2(_(e_invarg2), "key");
|
||||
emsgf(_(e_invarg2), "key");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7857,7 +7857,7 @@ static void f_dictwatcheradd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
Callback callback;
|
||||
if (!callback_from_typval(&callback, &argvars[2])) {
|
||||
EMSG2(_(e_invarg2), "funcref");
|
||||
emsgf(_(e_invarg2), "funcref");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7873,12 +7873,12 @@ static void f_dictwatcherdel(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
|
||||
if (argvars[0].v_type != VAR_DICT) {
|
||||
EMSG2(_(e_invarg2), "dict");
|
||||
emsgf(_(e_invarg2), "dict");
|
||||
return;
|
||||
}
|
||||
|
||||
if (argvars[2].v_type != VAR_FUNC && argvars[2].v_type != VAR_STRING) {
|
||||
EMSG2(_(e_invarg2), "funcref");
|
||||
emsgf(_(e_invarg2), "funcref");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8643,7 +8643,7 @@ static int filter_map_one(typval_T *tv, typval_T *expr, int map, int *remp)
|
||||
}
|
||||
|
||||
if (*s != NUL) { // check for trailing chars after expr
|
||||
EMSG2(_(e_invexpr2), s);
|
||||
emsgf(_(e_invexpr2), s);
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
@@ -8944,14 +8944,14 @@ static void common_function(typval_T *argvars, typval_T *rettv,
|
||||
}
|
||||
if (s == NULL || *s == NUL || (use_string && ascii_isdigit(*s))
|
||||
|| (is_funcref && trans_name == NULL)) {
|
||||
EMSG2(_(e_invarg2), (use_string
|
||||
emsgf(_(e_invarg2), (use_string
|
||||
? tv_get_string(&argvars[0])
|
||||
: (const char *)s));
|
||||
// Don't check an autoload name for existence here.
|
||||
} else if (trans_name != NULL
|
||||
&& (is_funcref ? find_func(trans_name) == NULL
|
||||
: !translated_function_exists((const char *)trans_name))) {
|
||||
EMSG2(_("E700: Unknown function: %s"), s);
|
||||
emsgf(_("E700: Unknown function: %s"), s);
|
||||
} else {
|
||||
int dict_idx = 0;
|
||||
int arg_idx = 0;
|
||||
@@ -11917,7 +11917,7 @@ static void f_json_decode(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
}
|
||||
if (json_decode_string(s, len, rettv) == FAIL) {
|
||||
EMSG3(_("E474: Failed to parse %.*s"), (int)len, s);
|
||||
emsgf(_("E474: Failed to parse %.*s"), (int)len, s);
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
rettv->vval.v_number = 0;
|
||||
}
|
||||
@@ -12911,7 +12911,7 @@ static void f_nr2char(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
return;
|
||||
}
|
||||
if (num > INT_MAX) {
|
||||
EMSG2(_("E5071: Character number must not be greater than INT_MAX (%i)"),
|
||||
emsgf(_("E5071: Character number must not be greater than INT_MAX (%i)"),
|
||||
INT_MAX);
|
||||
return;
|
||||
}
|
||||
@@ -13683,7 +13683,7 @@ static int get_search_arg(typval_T *varp, int *flagsp)
|
||||
}
|
||||
}
|
||||
if (mask == 0) {
|
||||
EMSG2(_(e_invarg2), flags);
|
||||
emsgf(_(e_invarg2), flags);
|
||||
dir = 0;
|
||||
} else {
|
||||
*flagsp |= mask;
|
||||
@@ -13934,7 +13934,7 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
int i = 0;
|
||||
TV_LIST_ITER_CONST(args, arg, {
|
||||
if (TV_LIST_ITEM_TV(arg)->v_type != VAR_STRING) {
|
||||
EMSG2(_("E5010: List item %d of the second argument is not a string"),
|
||||
emsgf(_("E5010: List item %d of the second argument is not a string"),
|
||||
i);
|
||||
return;
|
||||
}
|
||||
@@ -14753,7 +14753,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
TV_LIST_ITER_CONST(l, li, {
|
||||
if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT
|
||||
|| (d = TV_LIST_ITEM_TV(li)->vval.v_dict) == NULL) {
|
||||
EMSG2(_("E474: List item %d is either not a dictionary "
|
||||
emsgf(_("E474: List item %d is either not a dictionary "
|
||||
"or an empty one"), i);
|
||||
return;
|
||||
}
|
||||
@@ -14762,7 +14762,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|| tv_dict_find(d, S_LEN("pos1")) != NULL)
|
||||
&& tv_dict_find(d, S_LEN("priority")) != NULL
|
||||
&& tv_dict_find(d, S_LEN("id")) != NULL)) {
|
||||
EMSG2(_("E474: List item %d is missing one of the required keys"), i);
|
||||
emsgf(_("E474: List item %d is missing one of the required keys"), i);
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
@@ -16199,7 +16199,7 @@ static void f_submatch(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
|
||||
if (no < 0 || no >= NSUBEXP) {
|
||||
EMSG2(_("E935: invalid submatch number: %d"), no);
|
||||
emsgf(_("E935: invalid submatch number: %d"), no);
|
||||
return;
|
||||
}
|
||||
int retList = 0;
|
||||
@@ -17680,7 +17680,7 @@ static bool write_list(FileDescriptor *const fp, const list_T *const list,
|
||||
}
|
||||
return true;
|
||||
write_list_error:
|
||||
EMSG2(_("E80: Error while writing: %s"), os_strerror(error));
|
||||
emsgf(_("E80: Error while writing: %s"), os_strerror(error));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17829,7 +17829,7 @@ static void f_writefile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
case 'S': { do_fsync = false; break; }
|
||||
default: {
|
||||
// Using %s, p and not %c, *p to preserve multibyte characters
|
||||
EMSG2(_("E5060: Unknown flag: %s"), p);
|
||||
emsgf(_("E5060: Unknown flag: %s"), p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -17848,14 +17848,14 @@ static void f_writefile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
} else if ((error = file_open(&fp, fname,
|
||||
((append ? kFileAppend : kFileTruncate)
|
||||
| kFileCreate), 0666)) != 0) {
|
||||
EMSG3(_("E482: Can't open file %s for writing: %s"),
|
||||
emsgf(_("E482: Can't open file %s for writing: %s"),
|
||||
fname, os_strerror(error));
|
||||
} else {
|
||||
if (write_list(&fp, list, binary)) {
|
||||
rettv->vval.v_number = 0;
|
||||
}
|
||||
if ((error = file_close(&fp, do_fsync)) != 0) {
|
||||
EMSG3(_("E80: Error when closing file %s: %s"),
|
||||
emsgf(_("E80: Error when closing file %s: %s"),
|
||||
fname, os_strerror(error));
|
||||
}
|
||||
}
|
||||
@@ -18588,7 +18588,7 @@ static int get_var_tv(
|
||||
|
||||
if (tv == NULL) {
|
||||
if (rettv != NULL && verbose) {
|
||||
EMSG3(_("E121: Undefined variable: %.*s"), len, name);
|
||||
emsgf(_("E121: Undefined variable: %.*s"), len, name);
|
||||
}
|
||||
ret = FAIL;
|
||||
} else if (rettv != NULL) {
|
||||
@@ -19236,7 +19236,7 @@ static void set_var(const char *name, const size_t name_len, typval_T *const tv,
|
||||
} else { // Add a new variable.
|
||||
// Can't add "v:" variable.
|
||||
if (ht == &vimvarht) {
|
||||
EMSG2(_(e_illvar), name);
|
||||
emsgf(_(e_illvar), name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19315,7 +19315,7 @@ bool var_check_ro(const int flags, const char *name,
|
||||
name_len = strlen(name);
|
||||
}
|
||||
|
||||
EMSG3(_(error_message), (int)name_len, name);
|
||||
emsgf(_(error_message), (int)name_len, name);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -19400,7 +19400,7 @@ bool valid_varname(const char *varname)
|
||||
if (!eval_isnamec1((int)(uint8_t)(*p))
|
||||
&& (p == varname || !ascii_isdigit(*p))
|
||||
&& *p != AUTOLOAD_CHAR) {
|
||||
EMSG2(_(e_illvar), varname);
|
||||
emsgf(_(e_illvar), varname);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -20378,7 +20378,7 @@ trans_function_name(
|
||||
*/
|
||||
if (!aborting()) {
|
||||
if (end != NULL) {
|
||||
EMSG2(_(e_invarg2), start);
|
||||
emsgf(_(e_invarg2), start);
|
||||
}
|
||||
} else {
|
||||
*pp = (char_u *)find_name_end(start, NULL, NULL, FNE_INCL_BR);
|
||||
|
@@ -61,7 +61,7 @@ void list_write_log(const char *const fname)
|
||||
FileDescriptor fp;
|
||||
const int fo_ret = file_open(&fp, fname, kFileCreate|kFileAppend, 0600);
|
||||
if (fo_ret != 0) {
|
||||
EMSG3(_("E5142: Failed to open file %s: %s"), fname, os_strerror(fo_ret));
|
||||
emsgf(_("E5142: Failed to open file %s: %s"), fname, os_strerror(fo_ret));
|
||||
return;
|
||||
}
|
||||
for (ListLog *chunk = list_log_first; chunk != NULL;) {
|
||||
@@ -83,7 +83,7 @@ void list_write_log(const char *const fname)
|
||||
sizeof(chunk->entries[0]) * (chunk->size - i));
|
||||
chunk->size -= i;
|
||||
}
|
||||
EMSG3(_("E5143: Failed to write to file %s: %s"),
|
||||
emsgf(_("E5143: Failed to write to file %s: %s"),
|
||||
fname, os_strerror((int)fw_ret));
|
||||
return;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ void list_write_log(const char *const fname)
|
||||
}
|
||||
const int fc_ret = file_close(&fp, true);
|
||||
if (fc_ret != 0) {
|
||||
EMSG3(_("E5144: Failed to close file %s: %s"), fname, os_strerror(fc_ret));
|
||||
emsgf(_("E5144: Failed to close file %s: %s"), fname, os_strerror(fc_ret));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1286,7 +1286,7 @@ void tv_dict_item_remove(dict_T *const dict, dictitem_T *const item)
|
||||
{
|
||||
hashitem_T *const hi = hash_find(&dict->dv_hashtab, item->di_key);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
EMSG2(_(e_intern2), "tv_dict_item_remove()");
|
||||
emsgf(_(e_intern2), "tv_dict_item_remove()");
|
||||
} else {
|
||||
hash_remove(&dict->dv_hashtab, hi);
|
||||
}
|
||||
@@ -1759,7 +1759,7 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2,
|
||||
NULL);
|
||||
}
|
||||
} else if (*action == 'e') {
|
||||
EMSG2(_("E737: Key already exists: %s"), di2->di_key);
|
||||
emsgf(_("E737: Key already exists: %s"), di2->di_key);
|
||||
break;
|
||||
} else if (*action == 'f' && di2 != di1) {
|
||||
typval_T oldtv;
|
||||
@@ -2278,7 +2278,7 @@ void tv_copy(const typval_T *const from, typval_T *const to)
|
||||
break;
|
||||
}
|
||||
case VAR_UNKNOWN: {
|
||||
EMSG2(_(e_intern2), "tv_copy(UNKNOWN)");
|
||||
emsgf(_(e_intern2), "tv_copy(UNKNOWN)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2426,7 +2426,7 @@ bool tv_check_lock(const VarLockStatus lock, const char *name,
|
||||
name_len = strlen(name);
|
||||
}
|
||||
|
||||
EMSG3(_(error_message), (int)name_len, name);
|
||||
emsgf(_(error_message), (int)name_len, name);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2728,7 +2728,7 @@ varnumber_T tv_get_number_chk(const typval_T *const tv, bool *const ret_error)
|
||||
break;
|
||||
}
|
||||
case VAR_UNKNOWN: {
|
||||
EMSG2(_(e_intern2), "tv_get_number(UNKNOWN)");
|
||||
emsgf(_(e_intern2), "tv_get_number(UNKNOWN)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2798,7 +2798,7 @@ float_T tv_get_float(const typval_T *const tv)
|
||||
break;
|
||||
}
|
||||
case VAR_UNKNOWN: {
|
||||
EMSG2(_(e_intern2), "tv_get_float(UNKNOWN)");
|
||||
emsgf(_(e_intern2), "tv_get_float(UNKNOWN)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -6216,7 +6216,7 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
|
||||
/* refuse to add buffer-local ap if buffer number is invalid */
|
||||
if (is_buflocal && (buflocal_nr == 0
|
||||
|| buflist_findnr(buflocal_nr) == NULL)) {
|
||||
EMSG2(_("E680: <buffer=%d>: invalid buffer number "),
|
||||
emsgf(_("E680: <buffer=%d>: invalid buffer number "),
|
||||
buflocal_nr);
|
||||
return FAIL;
|
||||
}
|
||||
|
@@ -828,7 +828,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write);
|
||||
|
||||
if (fof_ret != 0) {
|
||||
EMSG2(_("E5421: Failed to open stdin: %s"), os_strerror(fof_ret));
|
||||
emsgf(_("E5421: Failed to open stdin: %s"), os_strerror(fof_ret));
|
||||
}
|
||||
|
||||
if (p == NULL) {
|
||||
|
@@ -1384,7 +1384,7 @@ static int nfa_regatom(void)
|
||||
re_has_z = REX_SET;
|
||||
break;
|
||||
default:
|
||||
EMSG2(_("E867: (NFA) Unknown operator '\\z%c'"),
|
||||
emsgf(_("E867: (NFA) Unknown operator '\\z%c'"),
|
||||
no_Magic(c));
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1524,7 +1524,7 @@ static int nfa_regatom(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
EMSG2(_("E867: (NFA) Unknown operator '\\%%%c'"),
|
||||
emsgf(_("E867: (NFA) Unknown operator '\\%%%c'"),
|
||||
no_Magic(c));
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1937,7 +1937,7 @@ static int nfa_regpiece(void)
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
EMSG2(_("E869: (NFA) Unknown operator '\\@%c'"), op);
|
||||
emsgf(_("E869: (NFA) Unknown operator '\\@%c'"), op);
|
||||
return FAIL;
|
||||
}
|
||||
EMIT(i);
|
||||
|
@@ -5136,7 +5136,7 @@ mkspell (
|
||||
} else if (vim_strchr(path_tail(wfname), '_') != NULL) {
|
||||
EMSG(_("E751: Output file name must not have region name"));
|
||||
} else if (incount > MAXREGIONS) {
|
||||
EMSG2(_("E754: Only up to %d regions supported"), MAXREGIONS);
|
||||
emsgf(_("E754: Only up to %d regions supported"), MAXREGIONS);
|
||||
} else {
|
||||
// Check for overwriting before doing things that may take a lot of
|
||||
// time.
|
||||
|
Reference in New Issue
Block a user