@@ -15217,46 +15217,41 @@ f_prevnonblank(typval_T *argvars, typval_T *rettv)
1521715217 rettv->vval.v_number = lnum;
1521815218}
1521915219
15220- #ifdef HAVE_STDARG_H
1522115220/* This dummy va_list is here because:
1522215221 * - passing a NULL pointer doesn't work when va_list isn't a pointer
1522315222 * - locally in the function results in a "used before set" warning
1522415223 * - using va_start() to initialize it gives "function with fixed args" error */
1522515224static va_list ap;
15226- #endif
1522715225
1522815226/*
1522915227 * "printf()" function
1523015228 */
1523115229 static void
1523215230f_printf(typval_T *argvars, typval_T *rettv)
1523315231{
15232+ char_u buf[NUMBUFLEN];
15233+ int len;
15234+ char_u *s;
15235+ int saved_did_emsg = did_emsg;
15236+ char *fmt;
15237+
1523415238 rettv->v_type = VAR_STRING;
1523515239 rettv->vval.v_string = NULL;
15236- #ifdef HAVE_STDARG_H /* only very old compilers can't do this */
15237- {
15238- char_u buf[NUMBUFLEN];
15239- int len;
15240- char_u *s;
15241- int saved_did_emsg = did_emsg;
15242- char *fmt;
1524315240
15244- /* Get the required length, allocate the buffer and do it for real. */
15245- did_emsg = FALSE;
15246- fmt = (char *)get_tv_string_buf(&argvars[0], buf);
15247- len = vim_vsnprintf(NULL, 0, fmt, ap, argvars + 1);
15248- if (!did_emsg)
15241+ /* Get the required length, allocate the buffer and do it for real. */
15242+ did_emsg = FALSE;
15243+ fmt = (char *)get_tv_string_buf(&argvars[0], buf);
15244+ len = vim_vsnprintf(NULL, 0, fmt, ap, argvars + 1);
15245+ if (!did_emsg)
15246+ {
15247+ s = alloc(len + 1);
15248+ if (s != NULL)
1524915249 {
15250- s = alloc(len + 1);
15251- if (s != NULL)
15252- {
15253- rettv->vval.v_string = s;
15254- (void)vim_vsnprintf((char *)s, len + 1, fmt, ap, argvars + 1);
15255- }
15250+ rettv->vval.v_string = s;
15251+ (void)vim_vsnprintf((char *)s, len + 1, fmt, ap, argvars + 1);
1525615252 }
15257- did_emsg |= saved_did_emsg;
1525815253 }
15259- #endif
15254+ did_emsg |= saved_did_emsg;
1526015255}
1526115256
1526215257/*
0 commit comments