mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 22:08:18 +00:00
eval: Move remaining get_tv_string* functions to eval/typval.c
This commit is contained in:
@@ -598,22 +598,21 @@ static varnumber_T tv_nr(typval_T *tvs, int *idxp)
|
||||
/// free "*tofree".
|
||||
///
|
||||
/// @return String value or NULL in case of error.
|
||||
static char *tv_str(typval_T *tvs, int *idxp, char ** const tofree)
|
||||
static const char *tv_str(typval_T *tvs, int *idxp, char **const tofree)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
int idx = *idxp - 1;
|
||||
char *s = NULL;
|
||||
const char *s = NULL;
|
||||
|
||||
if (tvs[idx].v_type == VAR_UNKNOWN) {
|
||||
EMSG(_(e_printf));
|
||||
} else {
|
||||
(*idxp)++;
|
||||
if (tvs[idx].v_type == VAR_STRING || tvs[idx].v_type == VAR_NUMBER) {
|
||||
s = (char *)get_tv_string_chk(&tvs[idx]);
|
||||
s = tv_get_string_chk(&tvs[idx]);
|
||||
*tofree = NULL;
|
||||
} else {
|
||||
s = encode_tv2echo(&tvs[idx], NULL);
|
||||
*tofree = s;
|
||||
s = *tofree = encode_tv2echo(&tvs[idx], NULL);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
@@ -953,7 +952,7 @@ int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap,
|
||||
case 's':
|
||||
case 'S':
|
||||
str_arg = tvs ? tv_str(tvs, &arg_idx, &tofree)
|
||||
: va_arg(ap, char *);
|
||||
: va_arg(ap, const char *);
|
||||
if (!str_arg) {
|
||||
str_arg = "[NULL]";
|
||||
str_arg_l = 6;
|
||||
|
Reference in New Issue
Block a user