Skip to content

Fixed XML_ExpatVersion not found if you have LibXML2 #2680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MonkeybreadSoftware
Copy link
Contributor

We have Expat and LibXML2, so we need to include expat.h to get XML_ExpatVersion() function. But if elif is used, it won't get included, so it won't compile. The fix is to include both if available.

We have Expat and LibXML2, so we need to include expat.h to get XML_ExpatVersion() function.
But if elif is used, it won't get included, so it won't compile.
The fix is to include both if available.
@@ -53,7 +53,8 @@
#endif
#if HAVE_LIBXML_XMLVERSION_H
#include <libxml/xmlversion.h>
#elif HAVE_BSDXML_H
#endif
#if HAVE_BSDXML_H
#include <bsdxml.h>
#elif HAVE_EXPAT_H
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be changed to #endif/#if as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, not sure. Further changes were not needed for me to compile.

@kientzle
Copy link
Contributor

I'm not sure this is actually the right fix. I think that archive_libexpat_version should only return non-NULL if libarchive is actually using it. In archive_read_support_format_xar.c, we use libexpat only if neither libxml2 nor libbsdxml is available.

What if we instead adjusted archive_libbsdxml_version and archive_libexpat_version to something like this:

const char *
archive_libbsdxml_version(void)
{
#if HAVE_LIBXML_XMLREADER_H && HAVE_LIBXML2
        return NULL;
#elif HAVE_BSDXML_H && HAVE_LIBBSDXML
        return XML_ExpatVersion();
#else
        return NULL;
#endif
}

const char *
archive_libexpat_version(void)
{
#if HAVE_LIBXML_XMLREADER_H && HAVE_LIBXML2
        return NULL;
#elif HAVE_BSDXML_H && HAVE_LIBBSDXML
        return NULL;
#elif HAVE_EXPAT_H && HAVE_LIBEXPAT
        return XML_ExpatVersion();
#else
        return NULL;
#endif
}

@MonkeybreadSoftware
Copy link
Contributor Author

That is also a possible solution.
I build it here and expat and libxml2 are both available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants