Skip to content

Commit

Permalink
build-sys: don't call xmlLineNumbersDefault if it is deprecated
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Oct 1, 2024
1 parent ce72512 commit 2703aee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,32 @@ if test "${enable_static}" = "yes"; then
fi
fi

dnl https://stackoverflow.com/questions/40798571/autoconf-detect-deprecated-functions-in-glibc
AH_TEMPLATE([IS_xmlLineNumbersDefault_DEPRECATED],
[Define this value if xmlLineNumbersDefault is marked as a deprecated function.])
AS_VAR_IF([have_libxml], [yes], [
CC_CHECK_WERROR
AS_VAR_IF([cc_cv_werror],[x],[],[
have_deprecated_attr=
CC_CHECK_CFLAGS_APPEND([-Wdeprecated-declarations], [have_deprecated_attr=yes])
AS_VAR_IF([have_deprecated_attr], [yes], [
SAVE_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $LIBXML_CFLAGS $cc_cv_werror -Wdeprecated-declarations"
AC_MSG_CHECKING([whether xmlLineNumbersDefault is deprecated])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <libxml/parser.h>
],[
int main (void) {xmlLineNumbersDefault (1); return 0;}
])],[is_xmlLineNumbersDefault_deprecated=no],[is_xmlLineNumbersDefault_deprecated=yes])
CFLAGS=$SAVE_CFLAGS
AC_MSG_RESULT($is_xmlLineNumbersDefault_deprecated)
AS_VAR_IF([is_xmlLineNumbersDefault_deprecated],[yes],[
AC_DEFINE(IS_xmlLineNumbersDefault_DEPRECATED)
])
])
])
])

AC_ARG_ENABLE([json],
[AS_HELP_STRING([--disable-json],
[disable json support])])
Expand Down
2 changes: 2 additions & 0 deletions main/lxpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ static xmlDocPtr makeXMLDoc (void)
if (data)
{
xmlSetGenericErrorFunc (NULL, suppressWarning);
#ifndef IS_xmlLineNumbersDefault_DEPRECATED
xmlLineNumbersDefault (1);
#endif
doc = xmlParseMemory((const char*)data, size);
}

Expand Down
2 changes: 2 additions & 0 deletions main/selectors.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ xmlParseMIO (MIO *input)
Assert (buf);

xmlSetGenericErrorFunc (NULL, suppressWarning);
#ifndef IS_xmlLineNumbersDefault_DEPRECATED
xmlLineNumbersDefault (1);
#endif
return xmlParseMemory((const char *)buf, len);
}

Expand Down

0 comments on commit 2703aee

Please sign in to comment.