mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
- error.c: attempt to fix the xmlGetVarStr breakage once and for
good. Use a macro and based on the solution provided in vsnprintf manual page from GNU. Daniel
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
Tue Jun 5 19:11:02 CEST 2001 Bjorn Reese <breese@users.sourceforge.net>
|
||||
|
||||
* error.c: attempt to fix the xmlGetVarStr breakage once and for
|
||||
good. Use a macro and based on the solution provided in
|
||||
vsnprintf manual page from GNU.
|
||||
|
||||
Tue Jun 5 14:46:10 CEST 2001 Bjorn Reese <breese@users.sourceforge.net>
|
||||
|
||||
* error.c: Workaround for non-preserving variadic list.
|
||||
|
40
aclocal.m4
vendored
40
aclocal.m4
vendored
@ -620,31 +620,35 @@ esac
|
||||
])
|
||||
|
||||
# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
|
||||
# the libltdl convenience library, adds --enable-ltdl-convenience to
|
||||
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
|
||||
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
|
||||
# to be `${top_builddir}/libltdl'. Make sure you start DIR with
|
||||
# '${top_builddir}/' (note the single quotes!) if your package is not
|
||||
# flat, and, if you're not using automake, define top_builddir as
|
||||
# appropriate in the Makefiles.
|
||||
# the libltdl convenience library and INCLTDL to the include flags for
|
||||
# the libltdl header and adds --enable-ltdl-convenience to the
|
||||
# configure arguments. Note that LIBLTDL and INCLTDL are not
|
||||
# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not
|
||||
# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed
|
||||
# with '${top_builddir}/' and INCLTDL will be prefixed with
|
||||
# '${top_srcdir}/' (note the single quotes!). If your package is not
|
||||
# flat and you're not using automake, define top_builddir and
|
||||
# top_srcdir appropriately in the Makefiles.
|
||||
AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||
case "$enable_ltdl_convenience" in
|
||||
no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
|
||||
"") enable_ltdl_convenience=yes
|
||||
ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
|
||||
esac
|
||||
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
|
||||
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
|
||||
LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
|
||||
INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
|
||||
])
|
||||
|
||||
# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
|
||||
# the libltdl installable library, and adds --enable-ltdl-install to
|
||||
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
|
||||
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
|
||||
# to be `${top_builddir}/libltdl'. Make sure you start DIR with
|
||||
# '${top_builddir}/' (note the single quotes!) if your package is not
|
||||
# flat, and, if you're not using automake, define top_builddir as
|
||||
# appropriate in the Makefiles.
|
||||
# the libltdl installable library and INCLTDL to the include flags for
|
||||
# the libltdl header and adds --enable-ltdl-install to the configure
|
||||
# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
|
||||
# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed
|
||||
# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will
|
||||
# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
|
||||
# with '${top_srcdir}/' (note the single quotes!). If your package is
|
||||
# not flat and you're not using automake, define top_builddir and
|
||||
# top_srcdir appropriately in the Makefiles.
|
||||
# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
|
||||
AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||
AC_CHECK_LIB(ltdl, main,
|
||||
@ -657,8 +661,8 @@ AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||
])
|
||||
if test x"$enable_ltdl_install" = x"yes"; then
|
||||
ac_configure_args="$ac_configure_args --enable-ltdl-install"
|
||||
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
|
||||
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
|
||||
LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
|
||||
INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
|
||||
else
|
||||
ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
|
||||
LIBLTDL="-lltdl"
|
||||
|
67
error.c
67
error.c
@ -13,15 +13,35 @@
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
|
||||
#if defined(__STDC__) && defined(__STDC_VERSION__)
|
||||
# if (__STDC_VERSION__ >= 199901L)
|
||||
# define HAVE_VA_COPY
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(HAVE_VA_COPY)
|
||||
# include <string.h>
|
||||
# define va_copy(x,y) memcpy((x),(y),sizeof(va_list))
|
||||
#endif
|
||||
#define XML_GET_VAR_STR(msg, str) { \
|
||||
int size; \
|
||||
int chars; \
|
||||
char *larger; \
|
||||
va_list ap; \
|
||||
\
|
||||
str = (char *) xmlMalloc(150); \
|
||||
if (str == NULL) \
|
||||
return; \
|
||||
\
|
||||
size = 150; \
|
||||
\
|
||||
while (1) { \
|
||||
va_start(ap, msg); \
|
||||
chars = vsnprintf(str, size, msg, ap); \
|
||||
va_end(ap); \
|
||||
if ((chars > -1) && (chars < size)) \
|
||||
break; \
|
||||
if (chars > -1) \
|
||||
size += chars + 1; \
|
||||
else \
|
||||
size += 100; \
|
||||
if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
|
||||
xmlFree(str); \
|
||||
return; \
|
||||
} \
|
||||
str = larger; \
|
||||
} \
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
@ -157,6 +177,7 @@ xmlParserPrintFileContext(xmlParserInputPtr input) {
|
||||
xmlGenericError(xmlGenericErrorContext,"%s\n", content);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* xmlGetVarStr:
|
||||
* @msg: the message format
|
||||
@ -172,7 +193,7 @@ xmlGetVarStr(const char * msg, va_list args) {
|
||||
int length;
|
||||
int chars, left;
|
||||
char *str, *larger;
|
||||
va_list argscopy;
|
||||
va_list ap;
|
||||
|
||||
str = (char *) xmlMalloc(150);
|
||||
if (str == NULL)
|
||||
@ -184,8 +205,9 @@ xmlGetVarStr(const char * msg, va_list args) {
|
||||
while (1) {
|
||||
left = size - length;
|
||||
/* Try to print in the allocated space. */
|
||||
va_copy(argscopy, args);
|
||||
chars = vsnprintf(str + length, left, msg, argscopy);
|
||||
va_start(msg, ap);
|
||||
chars = vsnprintf(str + length, left, msg, ap);
|
||||
va_end(ap);
|
||||
/* If that worked, we're done. */
|
||||
if ((chars > -1) && (chars < left ))
|
||||
break;
|
||||
@ -202,6 +224,7 @@ xmlGetVarStr(const char * msg, va_list args) {
|
||||
}
|
||||
return(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlParserError:
|
||||
@ -219,7 +242,6 @@ xmlParserError(void *ctx, const char *msg, ...)
|
||||
xmlParserInputPtr input = NULL;
|
||||
xmlParserInputPtr cur = NULL;
|
||||
char * str;
|
||||
va_list args;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
@ -232,9 +254,7 @@ xmlParserError(void *ctx, const char *msg, ...)
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "error: ");
|
||||
va_start(args, msg);
|
||||
str = xmlGetVarStr(msg, args);
|
||||
va_end(args);
|
||||
XML_GET_VAR_STR(msg, str);
|
||||
xmlGenericError(xmlGenericErrorContext, str);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
@ -265,7 +285,6 @@ xmlParserWarning(void *ctx, const char *msg, ...)
|
||||
xmlParserInputPtr input = NULL;
|
||||
xmlParserInputPtr cur = NULL;
|
||||
char * str;
|
||||
va_list args;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
@ -278,9 +297,7 @@ xmlParserWarning(void *ctx, const char *msg, ...)
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "warning: ");
|
||||
va_start(args, msg);
|
||||
str = xmlGetVarStr(msg, args);
|
||||
va_end(args);
|
||||
XML_GET_VAR_STR(msg, str);
|
||||
xmlGenericError(xmlGenericErrorContext, str);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
@ -316,7 +333,6 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlParserInputPtr input = NULL;
|
||||
char * str;
|
||||
va_list args;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
@ -327,9 +343,7 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
||||
va_start(args, msg);
|
||||
str = xmlGetVarStr(msg, args);
|
||||
va_end(args);
|
||||
XML_GET_VAR_STR(msg, str);
|
||||
xmlGenericError(xmlGenericErrorContext, str);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
@ -354,7 +368,6 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlParserInputPtr input = NULL;
|
||||
char * str;
|
||||
va_list args;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
@ -365,9 +378,7 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
|
||||
va_start(args, msg);
|
||||
str = xmlGetVarStr(msg, args);
|
||||
va_end(args);
|
||||
XML_GET_VAR_STR(msg, str);
|
||||
xmlGenericError(xmlGenericErrorContext, str);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
|
Reference in New Issue
Block a user