mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	vim-patch:8.0.0709: libvterm cannot use vsnprintf()
Problem:    Libvterm cannot use vsnprintf(), it does not exist in C90.
Solution:   Use vim_vsnprintf() instead.
8327d1df17
			
			
This commit is contained in:
		@@ -11639,10 +11639,11 @@ static void dict_list(typval_T *const tv, typval_T *const rettv,
 | 
			
		||||
static void f_id(typval_T *argvars, typval_T *rettv, FunPtr fptr)
 | 
			
		||||
  FUNC_ATTR_NONNULL_ALL
 | 
			
		||||
{
 | 
			
		||||
  const int len = vim_vsnprintf(NULL, 0, "%p", dummy_ap, argvars);
 | 
			
		||||
  const int len = vim_vsnprintf_typval(NULL, 0, "%p", dummy_ap, argvars);
 | 
			
		||||
  rettv->v_type = VAR_STRING;
 | 
			
		||||
  rettv->vval.v_string = xmalloc(len + 1);
 | 
			
		||||
  vim_vsnprintf((char *)rettv->vval.v_string, len + 1, "%p", dummy_ap, argvars);
 | 
			
		||||
  vim_vsnprintf_typval((char *)rettv->vval.v_string, len + 1, "%p",
 | 
			
		||||
                       dummy_ap, argvars);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -13106,11 +13107,11 @@ static void f_printf(typval_T *argvars, typval_T *rettv, FunPtr fptr)
 | 
			
		||||
    did_emsg = false;
 | 
			
		||||
    char buf[NUMBUFLEN];
 | 
			
		||||
    const char *fmt = tv_get_string_buf(&argvars[0], buf);
 | 
			
		||||
    len = vim_vsnprintf(NULL, 0, fmt, dummy_ap, argvars + 1);
 | 
			
		||||
    len = vim_vsnprintf_typval(NULL, 0, fmt, dummy_ap, argvars + 1);
 | 
			
		||||
    if (!did_emsg) {
 | 
			
		||||
      char *s = xmalloc(len + 1);
 | 
			
		||||
      rettv->vval.v_string = (char_u *)s;
 | 
			
		||||
      (void)vim_vsnprintf(s, len + 1, fmt, dummy_ap, argvars + 1);
 | 
			
		||||
      (void)vim_vsnprintf_typval(s, len + 1, fmt, dummy_ap, argvars + 1);
 | 
			
		||||
    }
 | 
			
		||||
    did_emsg |= saved_did_emsg;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -384,7 +384,7 @@ int smsg(char *s, ...)
 | 
			
		||||
  va_list arglist;
 | 
			
		||||
 | 
			
		||||
  va_start(arglist, s);
 | 
			
		||||
  vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist, NULL);
 | 
			
		||||
  vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
 | 
			
		||||
  va_end(arglist);
 | 
			
		||||
  return msg(IObuff);
 | 
			
		||||
}
 | 
			
		||||
@@ -395,7 +395,7 @@ int smsg_attr(int attr, char *s, ...)
 | 
			
		||||
  va_list arglist;
 | 
			
		||||
 | 
			
		||||
  va_start(arglist, s);
 | 
			
		||||
  vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist, NULL);
 | 
			
		||||
  vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
 | 
			
		||||
  va_end(arglist);
 | 
			
		||||
  return msg_attr((const char *)IObuff, attr);
 | 
			
		||||
}
 | 
			
		||||
@@ -662,7 +662,7 @@ bool emsgf_multiline(const char *const fmt, ...)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  va_start(ap, fmt);
 | 
			
		||||
  vim_vsnprintf(errbuf, sizeof(errbuf), fmt, ap, NULL);
 | 
			
		||||
  vim_vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
 | 
			
		||||
  va_end(ap);
 | 
			
		||||
 | 
			
		||||
  ret = emsg_multiline(errbuf, true);
 | 
			
		||||
@@ -678,7 +678,7 @@ static bool emsgfv(const char *fmt, va_list ap)
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  vim_vsnprintf(errbuf, sizeof(errbuf), fmt, ap, NULL);
 | 
			
		||||
  vim_vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
 | 
			
		||||
 | 
			
		||||
  return emsg((const char_u *)errbuf);
 | 
			
		||||
}
 | 
			
		||||
@@ -726,7 +726,7 @@ void msg_schedule_emsgf(const char *const fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
  va_list ap;
 | 
			
		||||
  va_start(ap, fmt);
 | 
			
		||||
  vim_vsnprintf((char *)IObuff, IOSIZE, fmt, ap, NULL);
 | 
			
		||||
  vim_vsnprintf((char *)IObuff, IOSIZE, fmt, ap);
 | 
			
		||||
  va_end(ap);
 | 
			
		||||
 | 
			
		||||
  char *s = xstrdup((char *)IObuff);
 | 
			
		||||
@@ -1826,7 +1826,7 @@ void msg_printf_attr(const int attr, const char *const fmt, ...)
 | 
			
		||||
 | 
			
		||||
  va_list ap;
 | 
			
		||||
  va_start(ap, fmt);
 | 
			
		||||
  const size_t len = vim_vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap, NULL);
 | 
			
		||||
  const size_t len = vim_vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
 | 
			
		||||
  va_end(ap);
 | 
			
		||||
 | 
			
		||||
  msg_scroll = true;
 | 
			
		||||
 
 | 
			
		||||
@@ -678,12 +678,12 @@ static float_T tv_float(typval_T *const tvs, int *const idxp)
 | 
			
		||||
// are discarded. If "str_m" is greater than zero it is guaranteed
 | 
			
		||||
// the resulting string will be NUL-terminated.
 | 
			
		||||
 | 
			
		||||
// vim_vsnprintf() can be invoked with either "va_list" or a list of
 | 
			
		||||
// vim_vsnprintf_typval() can be invoked with either "va_list" or a list of
 | 
			
		||||
// "typval_T".  When the latter is not used it must be NULL.
 | 
			
		||||
 | 
			
		||||
/// Append a formatted value to the string
 | 
			
		||||
///
 | 
			
		||||
/// @see vim_vsnprintf().
 | 
			
		||||
/// @see vim_vsnprintf_typval().
 | 
			
		||||
int vim_snprintf_add(char *str, size_t str_m, char *fmt, ...)
 | 
			
		||||
  FUNC_ATTR_PRINTF(3, 4)
 | 
			
		||||
{
 | 
			
		||||
@@ -697,7 +697,7 @@ int vim_snprintf_add(char *str, size_t str_m, char *fmt, ...)
 | 
			
		||||
  }
 | 
			
		||||
  va_list ap;
 | 
			
		||||
  va_start(ap, fmt);
 | 
			
		||||
  const int str_l = vim_vsnprintf(str + len, space, fmt, ap, NULL);
 | 
			
		||||
  const int str_l = vim_vsnprintf(str + len, space, fmt, ap);
 | 
			
		||||
  va_end(ap);
 | 
			
		||||
  return str_l;
 | 
			
		||||
}
 | 
			
		||||
@@ -715,7 +715,7 @@ int vim_snprintf(char *str, size_t str_m, const char *fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
  va_list ap;
 | 
			
		||||
  va_start(ap, fmt);
 | 
			
		||||
  const int str_l = vim_vsnprintf(str, str_m, fmt, ap, NULL);
 | 
			
		||||
  const int str_l = vim_vsnprintf(str, str_m, fmt, ap);
 | 
			
		||||
  va_end(ap);
 | 
			
		||||
  return str_l;
 | 
			
		||||
}
 | 
			
		||||
@@ -736,6 +736,10 @@ static const char *infinity_str(bool positive, char fmt_spec,
 | 
			
		||||
  return table[idx];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap)
 | 
			
		||||
{
 | 
			
		||||
  return vim_vsnprintf_typval(str, str_m, fmt, ap, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Write formatted value to the string
 | 
			
		||||
///
 | 
			
		||||
@@ -748,8 +752,8 @@ static const char *infinity_str(bool positive, char fmt_spec,
 | 
			
		||||
///
 | 
			
		||||
/// @return Number of bytes excluding NUL byte that would be written to the
 | 
			
		||||
///         string if str_m was greater or equal to the return value.
 | 
			
		||||
int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap,
 | 
			
		||||
                  typval_T *const tvs)
 | 
			
		||||
int vim_vsnprintf_typval(
 | 
			
		||||
    char *str, size_t str_m, const char *fmt, va_list ap, typval_T *const tvs)
 | 
			
		||||
{
 | 
			
		||||
  size_t str_l = 0;
 | 
			
		||||
  bool str_avail = str_l < str_m;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user