1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-23 02:50:08 +03:00

globals: Move remaining globals back to correct header files

This undoes a lot of damage.
This commit is contained in:
Nick Wellnhofer 2023-09-20 17:54:48 +02:00
parent 7909ff08e2
commit 11a1839ddd
15 changed files with 159 additions and 121 deletions

View File

@ -14,18 +14,17 @@
#include <ctype.h>
#include <stdlib.h>
#include <libxml/HTMLparser.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include <libxml/entities.h>
#include <libxml/encoding.h>
#include <libxml/valid.h>
#include <libxml/xmlIO.h>
#include <libxml/globals.h>
#include <libxml/uri.h>
#include "private/buf.h"

View File

@ -19,7 +19,11 @@
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlmemory.h>
#include <libxml/xmlIO.h>
#include <libxml/HTMLparser.h>
#include <libxml/parser.h>
#include <libxml/threads.h>
#include <libxml/tree.h>
#include <libxml/SAX.h>
#include <libxml/SAX2.h>
@ -80,9 +84,13 @@ struct _xmlGlobalState {
#endif
#define XML_OP XML_DECLARE_MEMBER
XML_GLOBALS
XML_GLOBALS_ALLOC
XML_GLOBALS_ERROR
XML_GLOBALS_HTML
XML_GLOBALS_IO
XML_GLOBALS_PARSER
XML_GLOBALS_SAVE
XML_GLOBALS_TREE
#undef XML_OP
};
@ -389,6 +397,7 @@ void *xmlStructuredErrorContext = NULL;
static void *xmlStructuredErrorContextThrDef = NULL;
xmlError xmlLastError;
#ifdef LIBXML_OUTPUT_ENABLED
/*
* output defaults
*/
@ -419,6 +428,7 @@ static const char *xmlTreeIndentStringThrDef = " ";
*/
int xmlSaveNoEmptyTags = 0;
static int xmlSaveNoEmptyTagsThrDef = 0;
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_SAX1_ENABLED
/**
@ -980,6 +990,7 @@ int xmlThrDefGetWarningsDefaultValue(int v) {
return ret;
}
#ifdef LIBXML_OUTPUT_ENABLED
int xmlThrDefIndentTreeOutput(int v) {
int ret;
xmlMutexLock(&xmlThrDefMutex);
@ -998,6 +1009,16 @@ const char * xmlThrDefTreeIndentString(const char * v) {
return ret;
}
int xmlThrDefSaveNoEmptyTags(int v) {
int ret;
xmlMutexLock(&xmlThrDefMutex);
ret = xmlSaveNoEmptyTagsThrDef;
xmlSaveNoEmptyTagsThrDef = v;
xmlMutexUnlock(&xmlThrDefMutex);
return ret;
}
#endif
int xmlThrDefKeepBlanksDefaultValue(int v) {
int ret;
xmlMutexLock(&xmlThrDefMutex);
@ -1043,15 +1064,6 @@ int xmlThrDefPedanticParserDefaultValue(int v) {
return ret;
}
int xmlThrDefSaveNoEmptyTags(int v) {
int ret;
xmlMutexLock(&xmlThrDefMutex);
ret = xmlSaveNoEmptyTagsThrDef;
xmlSaveNoEmptyTagsThrDef = v;
xmlMutexUnlock(&xmlThrDefMutex);
return ret;
}
int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
int ret;
xmlMutexLock(&xmlThrDefMutex);
@ -1138,9 +1150,13 @@ xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc fun
}
#define XML_OP XML_DEFINE_GLOBAL_WRAPPER
XML_GLOBALS
XML_GLOBALS_ALLOC
XML_GLOBALS_ERROR
XML_GLOBALS_HTML
XML_GLOBALS_IO
XML_GLOBALS_PARSER
XML_GLOBALS_SAVE
XML_GLOBALS_TREE
#undef XML_OP
/* For backward compatibility */

View File

@ -80,6 +80,17 @@ struct _htmlEntityDesc {
const char *desc; /* the description */
};
#define XML_GLOBALS_HTML \
XML_OP(htmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
#define XML_OP XML_DECLARE_GLOBAL
XML_GLOBALS_HTML
#undef XML_OP
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
#define htmlDefaultSAXHandler XML_GLOBAL_MACRO(htmlDefaultSAXHandler)
#endif
/*
* There is only few public functions.
*/
@ -316,5 +327,9 @@ XMLPUBFUN htmlStatus htmlNodeStatus(const htmlNodePtr, int) ;
}
#endif
#else /* LIBXML_HTML_ENABLED */
#define XML_GLOBALS_HTML
#endif /* LIBXML_HTML_ENABLED */
#endif /* __HTML_PARSER_H__ */

View File

@ -12,8 +12,11 @@
#define __XML_GLOBALS_H
#include <libxml/xmlversion.h>
#include <libxml/HTMLparser.h>
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlIO.h>
#include <libxml/xmlsave.h>
#ifdef __cplusplus
extern "C" {
@ -83,86 +86,6 @@ xmlDllMain(void *hinstDLL, unsigned long fdwReason,
#endif
/** DOC_ENABLE */
/* Declare globals with macro magic */
#define XML_GLOBALS_CORE \
/* output options */ \
XML_OP(xmlIndentTreeOutput, int, XML_EMPTY) \
XML_OP(xmlTreeIndentString, const char *, XML_EMPTY) \
XML_OP(xmlSaveNoEmptyTags, int, XML_EMPTY) \
/* deprecated */ \
XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \
XML_OP(xmlBufferAllocScheme, xmlBufferAllocationScheme, XML_DEPRECATED) \
XML_OP(xmlDefaultBufferSize, int, XML_DEPRECATED) \
XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED) \
XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc, XML_DEPRECATED) \
XML_OP(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc, \
XML_DEPRECATED) \
XML_OP(xmlParserInputBufferCreateFilenameValue, \
xmlParserInputBufferCreateFilenameFunc, XML_DEPRECATED) \
XML_OP(xmlOutputBufferCreateFilenameValue, \
xmlOutputBufferCreateFilenameFunc, XML_DEPRECATED)
#ifdef LIBXML_HTML_ENABLED
#define XML_GLOBALS_HTML \
XML_OP(htmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED)
#else
#define XML_GLOBALS_HTML
#endif
#define XML_GLOBALS \
XML_GLOBALS_CORE \
XML_GLOBALS_HTML
#define XML_OP XML_DECLARE_GLOBAL
XML_GLOBALS
#undef XML_OP
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
#define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility)
#define xmlBufferAllocScheme XML_GLOBAL_MACRO(xmlBufferAllocScheme)
#define xmlDefaultBufferSize XML_GLOBAL_MACRO(xmlDefaultBufferSize)
#define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler)
#define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator)
#define xmlDoValidityCheckingDefaultValue \
XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
#define xmlGetWarningsDefaultValue \
XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
#define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
#define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
#define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
#define xmlLineNumbersDefaultValue \
XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
#define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
#define xmlParserDebugEntities XML_GLOBAL_MACRO(xmlParserDebugEntities)
#define xmlPedanticParserDefaultValue \
XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
#define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
#define xmlSubstituteEntitiesDefaultValue \
XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
#define xmlRegisterNodeDefaultValue \
XML_GLOBAL_MACRO(xmlRegisterNodeDefaultValue)
#define xmlDeregisterNodeDefaultValue \
XML_GLOBAL_MACRO(xmlDeregisterNodeDefaultValue)
#define xmlParserInputBufferCreateFilenameValue \
XML_GLOBAL_MACRO(xmlParserInputBufferCreateFilenameValue)
#define xmlOutputBufferCreateFilenameValue \
XML_GLOBAL_MACRO(xmlOutputBufferCreateFilenameValue)
#ifdef LIBXML_HTML_ENABLED
#define htmlDefaultSAXHandler XML_GLOBAL_MACRO(htmlDefaultSAXHandler)
#endif
#endif
#ifdef __cplusplus
}
#endif

View File

@ -19,6 +19,8 @@
#include <libxml/xmlerror.h>
#include <libxml/xmlstring.h>
#include <libxml/xmlmemory.h>
#include <libxml/encoding.h>
#include <libxml/xmlIO.h>
#ifdef __cplusplus
extern "C" {
@ -810,26 +812,48 @@ typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
* Variables
*/
XMLPUBVAR const char *const
xmlParserVersion;
XMLPUBVAR const char *const xmlParserVersion;
#ifdef LIBXML_THREAD_ENABLED
XMLPUBFUN const char *const *
__xmlParserVersion(void);
/* backward compatibility */
XMLPUBFUN const char *const *__xmlParserVersion(void);
#endif
#ifdef __cplusplus
}
#define XML_GLOBALS_PARSER \
XML_OP(oldXMLWDcompatibility, int, XML_DEPRECATED) \
XML_OP(xmlDefaultSAXHandler, xmlSAXHandlerV1, XML_DEPRECATED) \
XML_OP(xmlDefaultSAXLocator, xmlSAXLocator, XML_DEPRECATED) \
XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlParserDebugEntities, int, XML_DEPRECATED) \
XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
#define XML_OP XML_DECLARE_GLOBAL
XML_GLOBALS_PARSER
#undef XML_OP
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
#define oldXMLWDcompatibility XML_GLOBAL_MACRO(oldXMLWDcompatibility)
#define xmlDefaultSAXHandler XML_GLOBAL_MACRO(xmlDefaultSAXHandler)
#define xmlDefaultSAXLocator XML_GLOBAL_MACRO(xmlDefaultSAXLocator)
#define xmlDoValidityCheckingDefaultValue \
XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
#define xmlGetWarningsDefaultValue \
XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
#define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
#define xmlLineNumbersDefaultValue \
XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
#define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
#define xmlParserDebugEntities XML_GLOBAL_MACRO(xmlParserDebugEntities)
#define xmlPedanticParserDefaultValue \
XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
#define xmlSubstituteEntitiesDefaultValue \
XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
#endif
#include <libxml/encoding.h>
#include <libxml/xmlIO.h>
#include <libxml/globals.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Init/Cleanup
*/

View File

@ -669,6 +669,26 @@ typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
* Variables.
*/
#define XML_GLOBALS_TREE \
XML_OP(xmlBufferAllocScheme, xmlBufferAllocationScheme, XML_DEPRECATED) \
XML_OP(xmlDefaultBufferSize, int, XML_DEPRECATED) \
XML_OP(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc, XML_DEPRECATED) \
XML_OP(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc, \
XML_DEPRECATED)
#define XML_OP XML_DECLARE_GLOBAL
XML_GLOBALS_TREE
#undef XML_OP
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
#define xmlBufferAllocScheme XML_GLOBAL_MACRO(xmlBufferAllocScheme)
#define xmlDefaultBufferSize XML_GLOBAL_MACRO(xmlDefaultBufferSize)
#define xmlRegisterNodeDefaultValue \
XML_GLOBAL_MACRO(xmlRegisterNodeDefaultValue)
#define xmlDeregisterNodeDefaultValue \
XML_GLOBAL_MACRO(xmlDeregisterNodeDefaultValue)
#endif
/*
* Some helper functions
*/

View File

@ -171,6 +171,23 @@ struct _xmlOutputBuffer {
};
#endif /* LIBXML_OUTPUT_ENABLED */
#define XML_GLOBALS_IO \
XML_OP(xmlParserInputBufferCreateFilenameValue, \
xmlParserInputBufferCreateFilenameFunc, XML_DEPRECATED) \
XML_OP(xmlOutputBufferCreateFilenameValue, \
xmlOutputBufferCreateFilenameFunc, XML_DEPRECATED)
#define XML_OP XML_DECLARE_GLOBAL
XML_GLOBALS_IO
#undef XML_OP
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
#define xmlParserInputBufferCreateFilenameValue \
XML_GLOBAL_MACRO(xmlParserInputBufferCreateFilenameValue)
#define xmlOutputBufferCreateFilenameValue \
XML_GLOBAL_MACRO(xmlOutputBufferCreateFilenameValue)
#endif
/*
* Interfaces for input
*/

View File

@ -41,6 +41,21 @@ typedef enum {
typedef struct _xmlSaveCtxt xmlSaveCtxt;
typedef xmlSaveCtxt *xmlSaveCtxtPtr;
#define XML_GLOBALS_SAVE \
XML_OP(xmlIndentTreeOutput, int, XML_EMPTY) \
XML_OP(xmlTreeIndentString, const char *, XML_EMPTY) \
XML_OP(xmlSaveNoEmptyTags, int, XML_EMPTY)
#define XML_OP XML_DECLARE_GLOBAL
XML_GLOBALS_SAVE
#undef XML_OP
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
#define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
#define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
#define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
#endif
XMLPUBFUN xmlSaveCtxtPtr
xmlSaveToFd (int fd,
const char *encoding,
@ -82,6 +97,11 @@ XMLPUBFUN int
#ifdef __cplusplus
}
#endif
#else /* LIBXML_OUTPUT_ENABLED */
#define XML_GLOBALS_SAVE
#endif /* LIBXML_OUTPUT_ENABLED */
#endif /* __XML_XMLSAVE_H__ */

View File

@ -51,10 +51,9 @@
#include <stddef.h>
#include <ctype.h>
#include <stdlib.h>
#include <libxml/xmlmemory.h>
#include <libxml/globals.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parserInternals.h>
#include <libxml/valid.h>
#include <libxml/entities.h>

View File

@ -2518,7 +2518,10 @@ xmlKeepBlanksDefault(int val) {
int old = xmlKeepBlanksDefaultValue;
xmlKeepBlanksDefaultValue = val;
if (!val) xmlIndentTreeOutput = 1;
#ifdef LIBXML_OUTPUT_ENABLED
if (!val)
xmlIndentTreeOutput = 1;
#endif
return(old);
}

View File

@ -26,6 +26,7 @@
#include <libxml/c14n.h>
#include <libxml/xmlreader.h>
#include <libxml/xmlsave.h>
#include <libxml/globals.h>
#include "libxml_wrap.h"
#include "libxml2-py.h"

View File

@ -18,6 +18,7 @@
#include <libxml/xmlregexp.h>
#include <libxml/xmlautomata.h>
#include <libxml/xmlreader.h>
#include <libxml/globals.h>
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/relaxng.h>
#include <libxml/xmlschemas.h>

3
tree.c
View File

@ -28,15 +28,14 @@
#include <zlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/uri.h>
#include <libxml/entities.h>
#include <libxml/valid.h>
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
#include <libxml/globals.h>
#ifdef LIBXML_HTML_ENABLED
#include <libxml/HTMLtree.h>
#endif

View File

@ -50,10 +50,10 @@
# endif
#endif
#include <libxml/xmlIO.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlIO.h>
#include <libxml/uri.h>
#include <libxml/nanohttp.h>
#include <libxml/nanoftp.h>
@ -61,7 +61,6 @@
#ifdef LIBXML_CATALOG_ENABLED
#include <libxml/catalog.h>
#endif
#include <libxml/globals.h>
#include "private/buf.h"
#include "private/enc.h"

View File

@ -3135,7 +3135,6 @@ main(int argc, char **argv) {
int i, acount;
int files = 0;
int version = 0;
const char* indent;
if (argc <= 1) {
usage(stderr, argv[0]);
@ -3525,11 +3524,14 @@ main(int argc, char **argv) {
xmlDeregisterNodeDefault(deregisterNode);
}
indent = getenv("XMLLINT_INDENT");
if(indent != NULL) {
xmlTreeIndentString = indent;
#ifdef LIBXML_OUTPUT_ENABLED
{
const char *indent = getenv("XMLLINT_INDENT");
if (indent != NULL) {
xmlTreeIndentString = indent;
}
}
#endif
defaultEntityLoader = xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(xmllintExternalEntityLoader);