Skip to content

Commit b06dee4

Browse files
committed
Add gzvprintf() as an undocumented function in zlib.
The function is only available if stdarg.h is available.
1 parent dd5d094 commit b06dee4

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

gzwrite.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,11 @@ int ZEXPORT gzputs(file, str)
307307
#include <stdarg.h>
308308

309309
/* -- see zlib.h -- */
310-
int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
310+
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
311311
{
312312
int size, len;
313313
gz_statep state;
314314
z_streamp strm;
315-
va_list va;
316315

317316
/* get internal structure */
318317
if (file == NULL)
@@ -342,25 +341,20 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
342341
/* do the printf() into the input buffer, put length in len */
343342
size = (int)(state->size);
344343
state->in[size - 1] = 0;
345-
va_start(va, format);
346344
#ifdef NO_vsnprintf
347345
# ifdef HAS_vsprintf_void
348346
(void)vsprintf((char *)(state->in), format, va);
349-
va_end(va);
350347
for (len = 0; len < size; len++)
351348
if (state->in[len] == 0) break;
352349
# else
353350
len = vsprintf((char *)(state->in), format, va);
354-
va_end(va);
355351
# endif
356352
#else
357353
# ifdef HAS_vsnprintf_void
358354
(void)vsnprintf((char *)(state->in), size, format, va);
359-
va_end(va);
360355
len = strlen((char *)(state->in));
361356
# else
362357
len = vsnprintf((char *)(state->in), size, format, va);
363-
va_end(va);
364358
# endif
365359
#endif
366360

@@ -375,6 +369,17 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
375369
return len;
376370
}
377371

372+
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
373+
{
374+
va_list va;
375+
int ret;
376+
377+
va_start(va, format);
378+
ret = gzvprintf(file, format, va);
379+
va_end(va);
380+
return ret;
381+
}
382+
378383
#else /* !STDC && !Z_HAVE_STDARG_H */
379384

380385
/* -- see zlib.h -- */

zconf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ typedef uLong FAR uLongf;
427427
# endif
428428
#endif
429429

430+
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
431+
# ifndef Z_SOLO
432+
# include <stdarg.h> /* for va_list */
433+
# endif
434+
#endif
435+
430436
#ifdef _WIN32
431437
# ifndef Z_SOLO
432438
# include <stddef.h> /* for wchar_t */

zconf.h.cmakein

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ typedef uLong FAR uLongf;
429429
# endif
430430
#endif
431431

432+
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
433+
# ifndef Z_SOLO
434+
# include <stdarg.h> /* for va_list */
435+
# endif
436+
#endif
437+
432438
#ifdef _WIN32
433439
# ifndef Z_SOLO
434440
# include <stddef.h> /* for wchar_t */

zconf.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ typedef uLong FAR uLongf;
427427
# endif
428428
#endif
429429

430+
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
431+
# ifndef Z_SOLO
432+
# include <stdarg.h> /* for va_list */
433+
# endif
434+
#endif
435+
430436
#ifdef _WIN32
431437
# ifndef Z_SOLO
432438
# include <stddef.h> /* for wchar_t */

zlib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,12 @@ ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
17531753
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
17541754
const char *mode));
17551755
#endif
1756+
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
1757+
# ifndef Z_SOLO
1758+
ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, const char *format,
1759+
va_list va));
1760+
# endif
1761+
#endif
17561762

17571763
#ifdef __cplusplus
17581764
}

0 commit comments

Comments
 (0)