eval: Move remaining get_tv_string* functions to eval/typval.c

This commit is contained in:
ZyX
2016-09-04 02:25:24 +03:00
parent 50ebd1dff5
commit c8e63a8db8
26 changed files with 1244 additions and 1055 deletions

View File

@@ -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;