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:
MichaHoffmann
2018-10-07 12:24:29 +02:00
parent 8cb04c2230
commit 2c84421de2
6 changed files with 49 additions and 49 deletions

View File

@@ -1940,7 +1940,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv,
} else if (*arg == '@') { } else if (*arg == '@') {
arg++; arg++;
if (op != NULL && (*op == '+' || *op == '-')) { if (op != NULL && (*op == '+' || *op == '-')) {
EMSG2(_(e_letwrong), op); emsgf(_(e_letwrong), op);
} else if (endchars != NULL } else if (endchars != NULL
&& vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) { && vim_strchr(endchars, *skipwhite(arg + 1)) == NULL) {
EMSG(_(e_letunexp)); 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_READ_ONLY) ? NULL : &ht,
flags & GLV_NO_AUTOLOAD); flags & GLV_NO_AUTOLOAD);
if (v == NULL && !quiet) { if (v == NULL && !quiet) {
EMSG3(_("E121: Undefined variable: %.*s"), emsgf(_("E121: Undefined variable: %.*s"),
(int)lp->ll_name_len, lp->ll_name); (int)lp->ll_name_len, lp->ll_name);
} }
if (v == NULL) { 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. */ /* Key does not exist in dict: may need to add it. */
if (*p == '[' || *p == '.' || unlet) { if (*p == '[' || *p == '.' || unlet) {
if (!quiet) { if (!quiet) {
EMSG2(_(e_dictkey), key); emsgf(_(e_dictkey), key);
} }
tv_clear(&var1); tv_clear(&var1);
return NULL; 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) { && di->di_tv.v_type != VAR_LIST) {
// For historical reasons this error is not given for Lists and // For historical reasons this error is not given for Lists and
// Dictionaries. E.g. b: dictionary may be locked/unlocked. // 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 { } else {
if (lock) { if (lock) {
di->di_flags |= DI_FLAGS_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 // been cancelled due to an aborting error, an interrupt, or an
// exception. // exception.
if (!aborting()) { if (!aborting()) {
EMSG2(_(e_invexpr2), arg); emsgf(_(e_invexpr2), arg);
} }
ret = FAIL; ret = FAIL;
} }
@@ -4553,7 +4553,7 @@ eval_index(
(const char *)key, len); (const char *)key, len);
if (item == NULL && verbose) { if (item == NULL && verbose) {
EMSG2(_(e_dictkey), key); emsgf(_(e_dictkey), key);
} }
if (len == -1) { if (len == -1) {
tv_clear(&var1); tv_clear(&var1);
@@ -4890,14 +4890,14 @@ static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate)
break; break;
} }
if (**arg != ',') { if (**arg != ',') {
EMSG2(_("E696: Missing comma in List: %s"), *arg); emsgf(_("E696: Missing comma in List: %s"), *arg);
goto failret; goto failret;
} }
*arg = skipwhite(*arg + 1); *arg = skipwhite(*arg + 1);
} }
if (**arg != ']') { if (**arg != ']') {
EMSG2(_("E697: Missing end of List ']': %s"), *arg); emsgf(_("E697: Missing end of List ']': %s"), *arg);
failret: failret:
if (evaluate) { if (evaluate) {
tv_list_free(l); tv_list_free(l);
@@ -7823,7 +7823,7 @@ static void f_delete(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// delete a directory recursively // delete a directory recursively
rettv->vval.v_number = delete_recursive(name); rettv->vval.v_number = delete_recursive(name);
} else { } 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) { if (argvars[0].v_type != VAR_DICT) {
EMSG2(_(e_invarg2), "dict"); emsgf(_(e_invarg2), "dict");
return; return;
} else if (argvars[0].vval.v_dict == NULL) { } else if (argvars[0].vval.v_dict == NULL) {
const char *const arg_errmsg = _("dictwatcheradd() argument"); const char *const arg_errmsg = _("dictwatcheradd() argument");
const size_t arg_errmsg_len = strlen(arg_errmsg); 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; return;
} }
if (argvars[1].v_type != VAR_STRING && argvars[1].v_type != VAR_NUMBER) { if (argvars[1].v_type != VAR_STRING && argvars[1].v_type != VAR_NUMBER) {
EMSG2(_(e_invarg2), "key"); emsgf(_(e_invarg2), "key");
return; return;
} }
@@ -7857,7 +7857,7 @@ static void f_dictwatcheradd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
Callback callback; Callback callback;
if (!callback_from_typval(&callback, &argvars[2])) { if (!callback_from_typval(&callback, &argvars[2])) {
EMSG2(_(e_invarg2), "funcref"); emsgf(_(e_invarg2), "funcref");
return; return;
} }
@@ -7873,12 +7873,12 @@ static void f_dictwatcherdel(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
if (argvars[0].v_type != VAR_DICT) { if (argvars[0].v_type != VAR_DICT) {
EMSG2(_(e_invarg2), "dict"); emsgf(_(e_invarg2), "dict");
return; return;
} }
if (argvars[2].v_type != VAR_FUNC && argvars[2].v_type != VAR_STRING) { if (argvars[2].v_type != VAR_FUNC && argvars[2].v_type != VAR_STRING) {
EMSG2(_(e_invarg2), "funcref"); emsgf(_(e_invarg2), "funcref");
return; 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 if (*s != NUL) { // check for trailing chars after expr
EMSG2(_(e_invexpr2), s); emsgf(_(e_invexpr2), s);
goto theend; 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)) if (s == NULL || *s == NUL || (use_string && ascii_isdigit(*s))
|| (is_funcref && trans_name == NULL)) { || (is_funcref && trans_name == NULL)) {
EMSG2(_(e_invarg2), (use_string emsgf(_(e_invarg2), (use_string
? tv_get_string(&argvars[0]) ? tv_get_string(&argvars[0])
: (const char *)s)); : (const char *)s));
// Don't check an autoload name for existence here. // Don't check an autoload name for existence here.
} else if (trans_name != NULL } else if (trans_name != NULL
&& (is_funcref ? find_func(trans_name) == NULL && (is_funcref ? find_func(trans_name) == NULL
: !translated_function_exists((const char *)trans_name))) { : !translated_function_exists((const char *)trans_name))) {
EMSG2(_("E700: Unknown function: %s"), s); emsgf(_("E700: Unknown function: %s"), s);
} else { } else {
int dict_idx = 0; int dict_idx = 0;
int arg_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) { 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->v_type = VAR_NUMBER;
rettv->vval.v_number = 0; rettv->vval.v_number = 0;
} }
@@ -12911,7 +12911,7 @@ static void f_nr2char(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return; return;
} }
if (num > INT_MAX) { 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); INT_MAX);
return; return;
} }
@@ -13683,7 +13683,7 @@ static int get_search_arg(typval_T *varp, int *flagsp)
} }
} }
if (mask == 0) { if (mask == 0) {
EMSG2(_(e_invarg2), flags); emsgf(_(e_invarg2), flags);
dir = 0; dir = 0;
} else { } else {
*flagsp |= mask; *flagsp |= mask;
@@ -13934,7 +13934,7 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
int i = 0; int i = 0;
TV_LIST_ITER_CONST(args, arg, { TV_LIST_ITER_CONST(args, arg, {
if (TV_LIST_ITEM_TV(arg)->v_type != VAR_STRING) { 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); i);
return; return;
} }
@@ -14753,7 +14753,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
TV_LIST_ITER_CONST(l, li, { TV_LIST_ITER_CONST(l, li, {
if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT
|| (d = TV_LIST_ITEM_TV(li)->vval.v_dict) == NULL) { || (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); "or an empty one"), i);
return; 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("pos1")) != NULL)
&& tv_dict_find(d, S_LEN("priority")) != NULL && tv_dict_find(d, S_LEN("priority")) != NULL
&& tv_dict_find(d, S_LEN("id")) != 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; return;
} }
i++; i++;
@@ -16199,7 +16199,7 @@ static void f_submatch(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
if (no < 0 || no >= NSUBEXP) { if (no < 0 || no >= NSUBEXP) {
EMSG2(_("E935: invalid submatch number: %d"), no); emsgf(_("E935: invalid submatch number: %d"), no);
return; return;
} }
int retList = 0; int retList = 0;
@@ -17680,7 +17680,7 @@ static bool write_list(FileDescriptor *const fp, const list_T *const list,
} }
return true; return true;
write_list_error: write_list_error:
EMSG2(_("E80: Error while writing: %s"), os_strerror(error)); emsgf(_("E80: Error while writing: %s"), os_strerror(error));
return false; return false;
} }
@@ -17829,7 +17829,7 @@ static void f_writefile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
case 'S': { do_fsync = false; break; } case 'S': { do_fsync = false; break; }
default: { default: {
// Using %s, p and not %c, *p to preserve multibyte characters // Using %s, p and not %c, *p to preserve multibyte characters
EMSG2(_("E5060: Unknown flag: %s"), p); emsgf(_("E5060: Unknown flag: %s"), p);
return; return;
} }
} }
@@ -17848,14 +17848,14 @@ static void f_writefile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} else if ((error = file_open(&fp, fname, } else if ((error = file_open(&fp, fname,
((append ? kFileAppend : kFileTruncate) ((append ? kFileAppend : kFileTruncate)
| kFileCreate), 0666)) != 0) { | 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)); fname, os_strerror(error));
} else { } else {
if (write_list(&fp, list, binary)) { if (write_list(&fp, list, binary)) {
rettv->vval.v_number = 0; rettv->vval.v_number = 0;
} }
if ((error = file_close(&fp, do_fsync)) != 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)); fname, os_strerror(error));
} }
} }
@@ -18588,7 +18588,7 @@ static int get_var_tv(
if (tv == NULL) { if (tv == NULL) {
if (rettv != NULL && verbose) { if (rettv != NULL && verbose) {
EMSG3(_("E121: Undefined variable: %.*s"), len, name); emsgf(_("E121: Undefined variable: %.*s"), len, name);
} }
ret = FAIL; ret = FAIL;
} else if (rettv != NULL) { } 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. } else { // Add a new variable.
// Can't add "v:" variable. // Can't add "v:" variable.
if (ht == &vimvarht) { if (ht == &vimvarht) {
EMSG2(_(e_illvar), name); emsgf(_(e_illvar), name);
return; return;
} }
@@ -19315,7 +19315,7 @@ bool var_check_ro(const int flags, const char *name,
name_len = strlen(name); name_len = strlen(name);
} }
EMSG3(_(error_message), (int)name_len, name); emsgf(_(error_message), (int)name_len, name);
return true; return true;
} }
@@ -19400,7 +19400,7 @@ bool valid_varname(const char *varname)
if (!eval_isnamec1((int)(uint8_t)(*p)) if (!eval_isnamec1((int)(uint8_t)(*p))
&& (p == varname || !ascii_isdigit(*p)) && (p == varname || !ascii_isdigit(*p))
&& *p != AUTOLOAD_CHAR) { && *p != AUTOLOAD_CHAR) {
EMSG2(_(e_illvar), varname); emsgf(_(e_illvar), varname);
return false; return false;
} }
} }
@@ -20378,7 +20378,7 @@ trans_function_name(
*/ */
if (!aborting()) { if (!aborting()) {
if (end != NULL) { if (end != NULL) {
EMSG2(_(e_invarg2), start); emsgf(_(e_invarg2), start);
} }
} else { } else {
*pp = (char_u *)find_name_end(start, NULL, NULL, FNE_INCL_BR); *pp = (char_u *)find_name_end(start, NULL, NULL, FNE_INCL_BR);

View File

@@ -61,7 +61,7 @@ void list_write_log(const char *const fname)
FileDescriptor fp; FileDescriptor fp;
const int fo_ret = file_open(&fp, fname, kFileCreate|kFileAppend, 0600); const int fo_ret = file_open(&fp, fname, kFileCreate|kFileAppend, 0600);
if (fo_ret != 0) { 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; return;
} }
for (ListLog *chunk = list_log_first; chunk != NULL;) { 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)); sizeof(chunk->entries[0]) * (chunk->size - i));
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)); fname, os_strerror((int)fw_ret));
return; return;
} }
@@ -94,7 +94,7 @@ void list_write_log(const char *const fname)
} }
const int fc_ret = file_close(&fp, true); const int fc_ret = file_close(&fp, true);
if (fc_ret != 0) { 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); hashitem_T *const hi = hash_find(&dict->dv_hashtab, item->di_key);
if (HASHITEM_EMPTY(hi)) { if (HASHITEM_EMPTY(hi)) {
EMSG2(_(e_intern2), "tv_dict_item_remove()"); emsgf(_(e_intern2), "tv_dict_item_remove()");
} else { } else {
hash_remove(&dict->dv_hashtab, hi); hash_remove(&dict->dv_hashtab, hi);
} }
@@ -1759,7 +1759,7 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2,
NULL); NULL);
} }
} else if (*action == 'e') { } else if (*action == 'e') {
EMSG2(_("E737: Key already exists: %s"), di2->di_key); emsgf(_("E737: Key already exists: %s"), di2->di_key);
break; break;
} else if (*action == 'f' && di2 != di1) { } else if (*action == 'f' && di2 != di1) {
typval_T oldtv; typval_T oldtv;
@@ -2278,7 +2278,7 @@ void tv_copy(const typval_T *const from, typval_T *const to)
break; break;
} }
case VAR_UNKNOWN: { case VAR_UNKNOWN: {
EMSG2(_(e_intern2), "tv_copy(UNKNOWN)"); emsgf(_(e_intern2), "tv_copy(UNKNOWN)");
break; break;
} }
} }
@@ -2426,7 +2426,7 @@ bool tv_check_lock(const VarLockStatus lock, const char *name,
name_len = strlen(name); name_len = strlen(name);
} }
EMSG3(_(error_message), (int)name_len, name); emsgf(_(error_message), (int)name_len, name);
return true; return true;
} }
@@ -2728,7 +2728,7 @@ varnumber_T tv_get_number_chk(const typval_T *const tv, bool *const ret_error)
break; break;
} }
case VAR_UNKNOWN: { case VAR_UNKNOWN: {
EMSG2(_(e_intern2), "tv_get_number(UNKNOWN)"); emsgf(_(e_intern2), "tv_get_number(UNKNOWN)");
break; break;
} }
} }
@@ -2798,7 +2798,7 @@ float_T tv_get_float(const typval_T *const tv)
break; break;
} }
case VAR_UNKNOWN: { case VAR_UNKNOWN: {
EMSG2(_(e_intern2), "tv_get_float(UNKNOWN)"); emsgf(_(e_intern2), "tv_get_float(UNKNOWN)");
break; break;
} }
} }

View File

@@ -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 */ /* refuse to add buffer-local ap if buffer number is invalid */
if (is_buflocal && (buflocal_nr == 0 if (is_buflocal && (buflocal_nr == 0
|| buflist_findnr(buflocal_nr) == NULL)) { || buflist_findnr(buflocal_nr) == NULL)) {
EMSG2(_("E680: <buffer=%d>: invalid buffer number "), emsgf(_("E680: <buffer=%d>: invalid buffer number "),
buflocal_nr); buflocal_nr);
return FAIL; return FAIL;
} }

View File

@@ -828,7 +828,7 @@ static void command_line_scan(mparm_T *parmp)
msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write); msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write);
if (fof_ret != 0) { 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) { if (p == NULL) {

View File

@@ -1384,7 +1384,7 @@ static int nfa_regatom(void)
re_has_z = REX_SET; re_has_z = REX_SET;
break; break;
default: default:
EMSG2(_("E867: (NFA) Unknown operator '\\z%c'"), emsgf(_("E867: (NFA) Unknown operator '\\z%c'"),
no_Magic(c)); no_Magic(c));
return FAIL; return FAIL;
} }
@@ -1524,7 +1524,7 @@ static int nfa_regatom(void)
break; break;
} }
} }
EMSG2(_("E867: (NFA) Unknown operator '\\%%%c'"), emsgf(_("E867: (NFA) Unknown operator '\\%%%c'"),
no_Magic(c)); no_Magic(c));
return FAIL; return FAIL;
} }
@@ -1937,7 +1937,7 @@ static int nfa_regpiece(void)
break; break;
} }
if (i == 0) { if (i == 0) {
EMSG2(_("E869: (NFA) Unknown operator '\\@%c'"), op); emsgf(_("E869: (NFA) Unknown operator '\\@%c'"), op);
return FAIL; return FAIL;
} }
EMIT(i); EMIT(i);

View File

@@ -5136,7 +5136,7 @@ mkspell (
} else if (vim_strchr(path_tail(wfname), '_') != NULL) { } else if (vim_strchr(path_tail(wfname), '_') != NULL) {
EMSG(_("E751: Output file name must not have region name")); EMSG(_("E751: Output file name must not have region name"));
} else if (incount > MAXREGIONS) { } else if (incount > MAXREGIONS) {
EMSG2(_("E754: Only up to %d regions supported"), MAXREGIONS); emsgf(_("E754: Only up to %d regions supported"), MAXREGIONS);
} else { } else {
// Check for overwriting before doing things that may take a lot of // Check for overwriting before doing things that may take a lot of
// time. // time.