mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-18 04:59:31 +03:00
Rework va_copy fallback
va_copy is a macro, so it can be detected without a feature test. Fallback to __va_copy or memcpy.
This commit is contained in:
@ -157,19 +157,7 @@ if (NOT MSVC)
|
|||||||
check_include_files(sys/timeb.h HAVE_SYS_TIMEB_H)
|
check_include_files(sys/timeb.h HAVE_SYS_TIMEB_H)
|
||||||
check_include_files(sys/time.h HAVE_SYS_TIME_H)
|
check_include_files(sys/time.h HAVE_SYS_TIME_H)
|
||||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||||
check_symbol_exists(va_copy stdarg.h HAVE_VA_COPY)
|
|
||||||
check_symbol_exists(__va_copy stdarg.h HAVE___VA_COPY)
|
|
||||||
set(LT_OBJDIR ".libs/")
|
set(LT_OBJDIR ".libs/")
|
||||||
check_c_source_compiles("
|
|
||||||
#include <stdarg.h>
|
|
||||||
void a(va_list* ap) {};
|
|
||||||
int main() { va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1; return 0; }
|
|
||||||
" VA_LIST_IS_ARRAY_TEST)
|
|
||||||
if(VA_LIST_IS_ARRAY_TEST)
|
|
||||||
set(VA_LIST_IS_ARRAY FALSE)
|
|
||||||
else()
|
|
||||||
set(VA_LIST_IS_ARRAY TRUE)
|
|
||||||
endif()
|
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
@ -90,15 +90,9 @@
|
|||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#cmakedefine HAVE_UNISTD_H 1
|
#cmakedefine HAVE_UNISTD_H 1
|
||||||
|
|
||||||
/* Whether va_copy() is available */
|
|
||||||
#cmakedefine HAVE_VA_COPY 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <zlib.h> header file. */
|
/* Define to 1 if you have the <zlib.h> header file. */
|
||||||
#cmakedefine HAVE_ZLIB_H 1
|
#cmakedefine HAVE_ZLIB_H 1
|
||||||
|
|
||||||
/* Whether __va_copy() is available */
|
|
||||||
#cmakedefine HAVE___VA_COPY 1
|
|
||||||
|
|
||||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||||
#cmakedefine LT_OBJDIR "@LT_OBJDIR@"
|
#cmakedefine LT_OBJDIR "@LT_OBJDIR@"
|
||||||
|
|
||||||
@ -126,9 +120,6 @@
|
|||||||
/* Support for IPv6 */
|
/* Support for IPv6 */
|
||||||
#cmakedefine SUPPORT_IP6 1
|
#cmakedefine SUPPORT_IP6 1
|
||||||
|
|
||||||
/* Define if va_list is an array type */
|
|
||||||
#cmakedefine VA_LIST_IS_ARRAY 1
|
|
||||||
|
|
||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#cmakedefine VERSION "@VERSION@"
|
#cmakedefine VERSION "@VERSION@"
|
||||||
|
|
||||||
|
31
configure.ac
31
configure.ac
@ -317,37 +317,6 @@ AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */
|
|||||||
# undef /**/ HAVE_MMAP
|
# undef /**/ HAVE_MMAP
|
||||||
#endif])
|
#endif])
|
||||||
|
|
||||||
dnl Checking for va_copy availability
|
|
||||||
AC_MSG_CHECKING([for va_copy])
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
|
|
||||||
va_list ap1,ap2;]], [[va_copy(ap1,ap2);]])],
|
|
||||||
have_va_copy=yes,
|
|
||||||
have_va_copy=no)
|
|
||||||
AC_MSG_RESULT($have_va_copy)
|
|
||||||
if test x"$have_va_copy" = x"yes"; then
|
|
||||||
AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
|
|
||||||
else
|
|
||||||
AC_MSG_CHECKING([for __va_copy])
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
|
|
||||||
va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],
|
|
||||||
have___va_copy=yes,
|
|
||||||
have___va_copy=no)
|
|
||||||
AC_MSG_RESULT($have___va_copy)
|
|
||||||
if test x"$have___va_copy" = x"yes"; then
|
|
||||||
AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl Checking whether va_list is an array type
|
|
||||||
AC_MSG_CHECKING([whether va_list is an array type])
|
|
||||||
AC_TRY_COMPILE2([
|
|
||||||
#include <stdarg.h>
|
|
||||||
void a(va_list * ap) {}],[
|
|
||||||
va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1],[
|
|
||||||
AC_MSG_RESULT(no)],[
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
AC_DEFINE([VA_LIST_IS_ARRAY], [1],[Define if va_list is an array type])])
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Checks for inet libraries
|
dnl Checks for inet libraries
|
||||||
dnl
|
dnl
|
||||||
|
25
xmlreader.c
25
xmlreader.c
@ -54,26 +54,11 @@
|
|||||||
#define MAX_FREE_NODES 100
|
#define MAX_FREE_NODES 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
#ifndef va_copy
|
||||||
* The following VA_COPY was coded following an example in
|
#ifdef __va_copy
|
||||||
* the Samba project. It may not be sufficient for some
|
#define va_copy(dest, src) __va_copy(dest, src)
|
||||||
* esoteric implementations of va_list but (hopefully) will
|
|
||||||
* be sufficient for libxml2.
|
|
||||||
*/
|
|
||||||
#ifndef VA_COPY
|
|
||||||
#ifdef HAVE_VA_COPY
|
|
||||||
#define VA_COPY(dest, src) va_copy(dest, src)
|
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE___VA_COPY
|
#define va_copy(dest, src) memcpy(dest, src, sizeof(va_list))
|
||||||
#define VA_COPY(dest,src) __va_copy(dest, src)
|
|
||||||
#else
|
|
||||||
#ifndef VA_LIST_IS_ARRAY
|
|
||||||
#define VA_COPY(dest,src) (dest) = (src)
|
|
||||||
#else
|
|
||||||
#include <string.h>
|
|
||||||
#define VA_COPY(dest,src) memcpy((char *)(dest),(char *)(src),sizeof(va_list))
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4590,7 +4575,7 @@ xmlTextReaderBuildMessage(const char *msg, va_list ap) {
|
|||||||
va_list aq;
|
va_list aq;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
VA_COPY(aq, ap);
|
va_copy(aq, ap);
|
||||||
chars = vsnprintf(str, size, msg, aq);
|
chars = vsnprintf(str, size, msg, aq);
|
||||||
va_end(aq);
|
va_end(aq);
|
||||||
if (chars < 0) {
|
if (chars < 0) {
|
||||||
|
28
xmlwriter.c
28
xmlwriter.c
@ -11,6 +11,7 @@
|
|||||||
#define IN_LIBXML
|
#define IN_LIBXML
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
@ -30,26 +31,11 @@
|
|||||||
#define B64LINELEN 72
|
#define B64LINELEN 72
|
||||||
#define B64CRLF "\r\n"
|
#define B64CRLF "\r\n"
|
||||||
|
|
||||||
/*
|
#ifndef va_copy
|
||||||
* The following VA_COPY was coded following an example in
|
#ifdef __va_copy
|
||||||
* the Samba project. It may not be sufficient for some
|
#define va_copy(dest, src) __va_copy(dest, src)
|
||||||
* esoteric implementations of va_list but (hopefully) will
|
|
||||||
* be sufficient for libxml2.
|
|
||||||
*/
|
|
||||||
#ifndef VA_COPY
|
|
||||||
#ifdef HAVE_VA_COPY
|
|
||||||
#define VA_COPY(dest, src) va_copy(dest, src)
|
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE___VA_COPY
|
#define va_copy(dest, src) memcpy(dest, src, sizeof(va_list))
|
||||||
#define VA_COPY(dest,src) __va_copy(dest, src)
|
|
||||||
#else
|
|
||||||
#ifndef VA_LIST_IS_ARRAY
|
|
||||||
#define VA_COPY(dest,src) (dest) = (src)
|
|
||||||
#else
|
|
||||||
#include <string.h>
|
|
||||||
#define VA_COPY(dest,src) memcpy((char *)(dest),(char *)(src),sizeof(va_list))
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4486,7 +4472,7 @@ xmlTextWriterVSprintf(const char *format, va_list argptr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VA_COPY(locarg, argptr);
|
va_copy(locarg, argptr);
|
||||||
while (((count = vsnprintf((char *) buf, size, format, locarg)) < 0)
|
while (((count = vsnprintf((char *) buf, size, format, locarg)) < 0)
|
||||||
|| (count == size - 1) || (count == size) || (count > size)) {
|
|| (count == size - 1) || (count == size) || (count > size)) {
|
||||||
va_end(locarg);
|
va_end(locarg);
|
||||||
@ -4498,7 +4484,7 @@ xmlTextWriterVSprintf(const char *format, va_list argptr)
|
|||||||
"xmlTextWriterVSprintf : out of memory!\n");
|
"xmlTextWriterVSprintf : out of memory!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
VA_COPY(locarg, argptr);
|
va_copy(locarg, argptr);
|
||||||
}
|
}
|
||||||
va_end(locarg);
|
va_end(locarg);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user