always build gpi_vsnprintf, as we use it unconditionally in libgphoto2

fixes https://github.com/gphoto/libgphoto2/issues/174
This commit is contained in:
Marcus Meissner
2022-11-07 09:19:08 +01:00
parent 3067c978af
commit c03aa04db0

View File

@@ -35,6 +35,35 @@
#include "libgphoto2_port/i18n.h"
char*
gpi_vsnprintf (const char* format, va_list args)
{
va_list xargs;
int strsize;
char *str;
#ifdef HAVE_VA_COPY
va_copy (xargs, args);
#else
/* according to 'the web', the only interesting compiler without va_copy is MSVC
* and there a simple assignment is the way to go */
xargs = args;
#endif
/* query the size necessary for the string, add the terminating '\0' */
strsize = vsnprintf (NULL, 0, format, xargs) + 1;
va_end (xargs);
str = malloc(strsize);
if (!str)
return NULL;
/* actually print the string into the buffer */
vsnprintf (str, strsize, format, args);
return str;
}
#ifndef DISABLE_DEBUGGING
/**
* \brief Internal logging function entry.
@@ -85,35 +114,6 @@ gp_log_add_func (GPLogLevel level, GPLogFunc func, void *data)
}
char*
gpi_vsnprintf (const char* format, va_list args)
{
va_list xargs;
int strsize;
char *str;
#ifdef HAVE_VA_COPY
va_copy (xargs, args);
#else
/* according to 'the web', the only interesting compiler without va_copy is MSVC
* and there a simple assignment is the way to go */
xargs = args;
#endif
/* query the size necessary for the string, add the terminating '\0' */
strsize = vsnprintf (NULL, 0, format, xargs) + 1;
va_end (xargs);
str = malloc(strsize);
if (!str)
return NULL;
/* actually print the string into the buffer */
vsnprintf (str, strsize, format, args);
return str;
}
/**
* \brief Remove a logging receiving function
* \param id an id (return value of #gp_log_add_func)