1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-12 09:17:37 +03:00

parser: Deprecate most public struct members

This will probably cause many warnings in downstream code abusing
libxml2 internals, but we can always undeprecate some members later.
This commit is contained in:
Nick Wellnhofer 2024-06-10 23:06:13 +02:00
parent df40f64edf
commit 712a31abe4
6 changed files with 255 additions and 121 deletions

View File

@ -67,24 +67,39 @@ typedef void (* xmlParserInputDeallocate)(xmlChar *str);
struct _xmlParserInput { struct _xmlParserInput {
/* Input buffer */ /* Input buffer */
xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ xmlParserInputBufferPtr buf;
/* The file analyzed, if any */
const char *filename; /* The file analyzed, if any */ const char *filename;
const char *directory; /* unused */ /* unused */
const xmlChar *base; /* Base of the array to parse */ const char *directory XML_DEPRECATED_MEMBER;
const xmlChar *cur; /* Current char being parsed */ /* Base of the array to parse */
const xmlChar *end; /* end of the array to parse */ const xmlChar *base XML_DEPRECATED_MEMBER;
int length; /* unused */ /* Current char being parsed */
int line; /* Current line */ const xmlChar *cur XML_DEPRECATED_MEMBER;
int col; /* Current column */ /* end of the array to parse */
unsigned long consumed; /* How many xmlChars already consumed */ const xmlChar *end XML_DEPRECATED_MEMBER;
xmlParserInputDeallocate free; /* function to deallocate the base */ /* unused */
const xmlChar *encoding; /* unused */ int length XML_DEPRECATED_MEMBER;
const xmlChar *version; /* the version string for entity */ /* Current line */
int flags; /* Flags */ int line XML_DEPRECATED_MEMBER;
int id; /* an unique identifier for the entity */ /* Current column */
unsigned long parentConsumed; /* unused */ int col XML_DEPRECATED_MEMBER;
xmlEntityPtr entity; /* entity, if any */ /* How many xmlChars already consumed */
unsigned long consumed XML_DEPRECATED_MEMBER;
/* function to deallocate the base */
xmlParserInputDeallocate free XML_DEPRECATED_MEMBER;
/* unused */
const xmlChar *encoding XML_DEPRECATED_MEMBER;
/* the version string for entity */
const xmlChar *version XML_DEPRECATED_MEMBER;
/* Flags */
int flags XML_DEPRECATED_MEMBER;
/* an unique identifier for the entity */
int id XML_DEPRECATED_MEMBER;
/* unused */
unsigned long parentConsumed XML_DEPRECATED_MEMBER;
/* entity, if any */
xmlEntityPtr entity XML_DEPRECATED_MEMBER;
}; };
/** /**
@ -186,149 +201,249 @@ typedef int
* to a state based parser for progressive parsing shouldn't be too hard. * to a state based parser for progressive parsing shouldn't be too hard.
*/ */
struct _xmlParserCtxt { struct _xmlParserCtxt {
struct _xmlSAXHandler *sax; /* The SAX handler */ /* The SAX handler */
void *userData; /* For SAX interface only, used by DOM build */ struct _xmlSAXHandler *sax;
xmlDocPtr myDoc; /* the document being built */ /* For SAX interface only, used by DOM build */
int wellFormed; /* is the document well formed */ void *userData;
int replaceEntities; /* shall we replace entities ? */ /* the document being built */
const xmlChar *version; /* the XML version string */ xmlDocPtr myDoc;
const xmlChar *encoding; /* the declared encoding, if any */ /* is the document well formed */
int standalone; /* standalone document */ int wellFormed;
int html; /* an HTML(1) document
/* shall we replace entities ? */
int replaceEntities XML_DEPRECATED_MEMBER;
/* the XML version string */
const xmlChar *version XML_DEPRECATED_MEMBER;
/* the declared encoding, if any */
const xmlChar *encoding XML_DEPRECATED_MEMBER;
/* standalone document */
int standalone XML_DEPRECATED_MEMBER;
/* an HTML(1) document
* 3 is HTML after <head> * 3 is HTML after <head>
* 10 is HTML after <body> * 10 is HTML after <body>
*/ */
int html XML_DEPRECATED_MEMBER;
/* Input stream stack */ /* Input stream stack */
xmlParserInputPtr input; /* Current input stream */
int inputNr; /* Number of current input streams */ /* Current input stream */
int inputMax; /* Max number of input streams */ xmlParserInputPtr input;
xmlParserInputPtr *inputTab; /* stack of inputs */ /* Number of current input streams */
int inputNr;
/* Max number of input streams */
int inputMax XML_DEPRECATED_MEMBER;
/* stack of inputs */
xmlParserInputPtr *inputTab;
/* Node analysis stack only used for DOM building */ /* Node analysis stack only used for DOM building */
xmlNodePtr node; /* Current parsed Node */
int nodeNr; /* Depth of the parsing stack */
int nodeMax; /* Max depth of the parsing stack */
xmlNodePtr *nodeTab; /* array of nodes */
int record_info; /* Whether node info should be kept */ /* Current parsed Node */
xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ xmlNodePtr node XML_DEPRECATED_MEMBER;
/* Depth of the parsing stack */
int nodeNr XML_DEPRECATED_MEMBER;
/* Max depth of the parsing stack */
int nodeMax XML_DEPRECATED_MEMBER;
/* array of nodes */
xmlNodePtr *nodeTab XML_DEPRECATED_MEMBER;
int errNo; /* error code */ /* Whether node info should be kept */
int record_info;
/* info about each node parsed */
xmlParserNodeInfoSeq node_seq XML_DEPRECATED_MEMBER;
int hasExternalSubset; /* reference and external subset */ /* error code */
int hasPErefs; /* the internal subset has PE refs */ int errNo;
int external; /* unused */
int valid; /* is the document valid */ /* reference and external subset */
int validate; /* shall we try to validate ? */ int hasExternalSubset XML_DEPRECATED_MEMBER;
xmlValidCtxt vctxt; /* The validity context */ /* the internal subset has PE refs */
int hasPErefs XML_DEPRECATED_MEMBER;
/* unused */
int external XML_DEPRECATED_MEMBER;
xmlParserInputState instate; /* push parser state */ /* is the document valid */
int token; /* unused */ int valid;
/* shall we try to validate ? */
int validate XML_DEPRECATED_MEMBER;
/* The validity context */
xmlValidCtxt vctxt;
char *directory; /* unused */ /* push parser state */
xmlParserInputState instate XML_DEPRECATED_MEMBER;
/* unused */
int token XML_DEPRECATED_MEMBER;
/* unused */
char *directory XML_DEPRECATED_MEMBER;
/* Node name stack */ /* Node name stack */
const xmlChar *name; /* Current parsed Node */
int nameNr; /* Depth of the parsing stack */
int nameMax; /* Max depth of the parsing stack */
const xmlChar * *nameTab; /* array of nodes */
long nbChars; /* unused */ /* Current parsed Node */
long checkIndex; /* used by progressive parsing lookup */ const xmlChar *name XML_DEPRECATED_MEMBER;
int keepBlanks; /* ugly but ... */ /* Depth of the parsing stack */
int disableSAX; /* SAX callbacks are disabled */ int nameNr XML_DEPRECATED_MEMBER;
int inSubset; /* Parsing is in int 1/ext 2 subset */ /* Max depth of the parsing stack */
const xmlChar * intSubName; /* name of subset */ int nameMax XML_DEPRECATED_MEMBER;
xmlChar * extSubURI; /* URI of external subset */ /* array of nodes */
xmlChar * extSubSystem; /* SYSTEM ID of external subset */ const xmlChar **nameTab XML_DEPRECATED_MEMBER;
/* unused */
long nbChars XML_DEPRECATED_MEMBER;
/* used by progressive parsing lookup */
long checkIndex XML_DEPRECATED_MEMBER;
/* ugly but ... */
int keepBlanks XML_DEPRECATED_MEMBER;
/* SAX callbacks are disabled */
int disableSAX XML_DEPRECATED_MEMBER;
/* Parsing is in int 1/ext 2 subset */
int inSubset XML_DEPRECATED_MEMBER;
/* name of subset */
const xmlChar *intSubName XML_DEPRECATED_MEMBER;
/* URI of external subset */
xmlChar *extSubURI XML_DEPRECATED_MEMBER;
/* SYSTEM ID of external subset */
xmlChar *extSubSystem XML_DEPRECATED_MEMBER;
/* xml:space values */ /* xml:space values */
int * space; /* Should the parser preserve spaces */
int spaceNr; /* Depth of the parsing stack */
int spaceMax; /* Max depth of the parsing stack */
int * spaceTab; /* array of space infos */
int depth; /* to prevent entity substitution loops */ /* Should the parser preserve spaces */
xmlParserInputPtr entity; /* unused */ int *space XML_DEPRECATED_MEMBER;
int charset; /* unused */ /* Depth of the parsing stack */
int nodelen; /* Those two fields are there to */ int spaceNr XML_DEPRECATED_MEMBER;
int nodemem; /* Speed up large node parsing */ /* Max depth of the parsing stack */
int pedantic; /* signal pedantic warnings */ int spaceMax XML_DEPRECATED_MEMBER;
void *_private; /* For user data, libxml won't touch it */ /* array of space infos */
int *spaceTab XML_DEPRECATED_MEMBER;
int loadsubset; /* should the external subset be loaded */ /* to prevent entity substitution loops */
int linenumbers; /* set line number in element content */ int depth XML_DEPRECATED_MEMBER;
void *catalogs; /* document's own catalog */ /* unused */
int recovery; /* run in recovery mode */ xmlParserInputPtr entity XML_DEPRECATED_MEMBER;
int progressive; /* unused */ /* unused */
xmlDictPtr dict; /* dictionary for the parser */ int charset XML_DEPRECATED_MEMBER;
const xmlChar * *atts; /* array for the attributes callbacks */ /* Those two fields are there to */
int maxatts; /* the size of the array */ int nodelen XML_DEPRECATED_MEMBER;
int docdict; /* unused */ /* Speed up large node parsing */
int nodemem XML_DEPRECATED_MEMBER;
/* signal pedantic warnings */
int pedantic XML_DEPRECATED_MEMBER;
/* For user data, libxml won't touch it */
void *_private;
/* should the external subset be loaded */
int loadsubset XML_DEPRECATED_MEMBER;
/* set line number in element content */
int linenumbers XML_DEPRECATED_MEMBER;
/* document's own catalog */
void *catalogs;
/* run in recovery mode */
int recovery XML_DEPRECATED_MEMBER;
/* unused */
int progressive XML_DEPRECATED_MEMBER;
/* dictionary for the parser */
xmlDictPtr dict;
/* array for the attributes callbacks */
const xmlChar **atts XML_DEPRECATED_MEMBER;
/* the size of the array */
int maxatts XML_DEPRECATED_MEMBER;
/* unused */
int docdict XML_DEPRECATED_MEMBER;
/* /*
* pre-interned strings * pre-interned strings
*/ */
const xmlChar *str_xml; const xmlChar *str_xml XML_DEPRECATED_MEMBER;
const xmlChar *str_xmlns; const xmlChar *str_xmlns XML_DEPRECATED_MEMBER;
const xmlChar *str_xml_ns; const xmlChar *str_xml_ns XML_DEPRECATED_MEMBER;
/* /*
* Everything below is used only by the new SAX mode * Everything below is used only by the new SAX mode
*/ */
int sax2; /* operating in the new SAX mode */
int nsNr; /* the number of inherited namespaces */ /* operating in the new SAX mode */
int nsMax; /* the size of the arrays */ int sax2 XML_DEPRECATED_MEMBER;
const xmlChar * *nsTab; /* the array of prefix/namespace name */ /* the number of inherited namespaces */
unsigned *attallocs; /* which attribute were allocated */ int nsNr XML_DEPRECATED_MEMBER;
xmlStartTag *pushTab; /* array of data for push */ /* the size of the arrays */
xmlHashTablePtr attsDefault; /* defaulted attributes if any */ int nsMax XML_DEPRECATED_MEMBER;
xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */ /* the array of prefix/namespace name */
int nsWellFormed; /* is the document XML Namespace okay */ const xmlChar **nsTab XML_DEPRECATED_MEMBER;
int options; /* Extra options */ /* which attribute were allocated */
unsigned *attallocs XML_DEPRECATED_MEMBER;
/* array of data for push */
xmlStartTag *pushTab XML_DEPRECATED_MEMBER;
/* defaulted attributes if any */
xmlHashTablePtr attsDefault XML_DEPRECATED_MEMBER;
/* non-CDATA attributes if any */
xmlHashTablePtr attsSpecial XML_DEPRECATED_MEMBER;
/* is the document XML Namespace okay */
int nsWellFormed;
/* Extra options */
int options XML_DEPRECATED_MEMBER;
/* /*
* Those fields are needed only for streaming parsing so far * Those fields are needed only for streaming parsing so far
*/ */
int dictNames; /* Use dictionary names for the tree */
int freeElemsNr; /* number of freed element nodes */ /* Use dictionary names for the tree */
xmlNodePtr freeElems; /* List of freed element nodes */ int dictNames XML_DEPRECATED_MEMBER;
int freeAttrsNr; /* number of freed attributes nodes */ /* number of freed element nodes */
xmlAttrPtr freeAttrs; /* List of freed attributes nodes */ int freeElemsNr XML_DEPRECATED_MEMBER;
/* List of freed element nodes */
xmlNodePtr freeElems XML_DEPRECATED_MEMBER;
/* number of freed attributes nodes */
int freeAttrsNr XML_DEPRECATED_MEMBER;
/* List of freed attributes nodes */
xmlAttrPtr freeAttrs XML_DEPRECATED_MEMBER;
/* /*
* the complete error information for the last error. * the complete error information for the last error.
*/ */
xmlError lastError; xmlError lastError;
xmlParserMode parseMode; /* the parser mode */ /* the parser mode */
unsigned long nbentities; /* unused */ xmlParserMode parseMode XML_DEPRECATED_MEMBER;
unsigned long sizeentities; /* size of external entities */ /* unused */
unsigned long nbentities XML_DEPRECATED_MEMBER;
/* size of external entities */
unsigned long sizeentities XML_DEPRECATED_MEMBER;
/* for use by HTML non-recursive parser */ /* for use by HTML non-recursive parser */
xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */ /* Current NodeInfo */
int nodeInfoNr; /* Depth of the parsing stack */ xmlParserNodeInfo *nodeInfo XML_DEPRECATED_MEMBER;
int nodeInfoMax; /* Max depth of the parsing stack */ /* Depth of the parsing stack */
xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */ int nodeInfoNr XML_DEPRECATED_MEMBER;
/* Max depth of the parsing stack */
int nodeInfoMax XML_DEPRECATED_MEMBER;
/* array of nodeInfos */
xmlParserNodeInfo *nodeInfoTab XML_DEPRECATED_MEMBER;
int input_id; /* we need to label inputs */ /* we need to label inputs */
unsigned long sizeentcopy; /* volume of entity copy */ int input_id XML_DEPRECATED_MEMBER;
/* volume of entity copy */
unsigned long sizeentcopy XML_DEPRECATED_MEMBER;
int endCheckState; /* quote state for push parser */ /* quote state for push parser */
unsigned short nbErrors; /* number of errors */ int endCheckState XML_DEPRECATED_MEMBER;
unsigned short nbWarnings; /* number of warnings */ /* number of errors */
unsigned maxAmpl; /* maximum amplification factor */ unsigned short nbErrors XML_DEPRECATED_MEMBER;
/* number of warnings */
unsigned short nbWarnings XML_DEPRECATED_MEMBER;
/* maximum amplification factor */
unsigned maxAmpl XML_DEPRECATED_MEMBER;
xmlParserNsData *nsdb; /* namespace database */ /* namespace database */
unsigned attrHashMax; /* allocated size */ xmlParserNsData *nsdb XML_DEPRECATED_MEMBER;
xmlAttrHashBucket *attrHash; /* atttribute hash table */ /* allocated size */
unsigned attrHashMax XML_DEPRECATED_MEMBER;
/* atttribute hash table */
xmlAttrHashBucket *attrHash XML_DEPRECATED_MEMBER;
xmlStructuredErrorFunc errorHandler; xmlStructuredErrorFunc errorHandler XML_DEPRECATED_MEMBER;
void *errorCtxt; void *errorCtxt XML_DEPRECATED_MEMBER;
xmlResourceLoader resourceLoader; xmlResourceLoader resourceLoader XML_DEPRECATED_MEMBER;
void *resourceCtxt; void *resourceCtxt XML_DEPRECATED_MEMBER;
}; };
/** /**

View File

@ -73,6 +73,16 @@
#endif #endif
#endif #endif
#ifndef XML_DEPRECATED_MEMBER
#if defined(IN_LIBXML)
#define XML_DEPRECATED_MEMBER
#elif __GNUC__ * 100 + __GNUC_MINOR__ >= 301
#define XML_DEPRECATED_MEMBER __attribute__((deprecated))
#else
#define XML_DEPRECATED_MEMBER
#endif
#endif
/* /*
* Warnings pragmas, should be moved from public headers * Warnings pragmas, should be moved from public headers
*/ */

View File

@ -367,6 +367,11 @@ deprecated_funcs = {
'xmlParseXMLDecl': True, 'xmlParseXMLDecl': True,
'xmlParserHandlePEReference': True, 'xmlParserHandlePEReference': True,
'xmlParserHandleReference': True, 'xmlParserHandleReference': True,
'xmlParserSetLineNumbers': True,
'xmlParserSetLoadSubset': True,
'xmlParserSetPedantic': True,
'xmlParserSetReplaceEntities': True,
'xmlParserSetValidate': True,
'xmlPedanticParserDefault': True, 'xmlPedanticParserDefault': True,
'xmlRecoverDoc': True, 'xmlRecoverDoc': True,
'xmlRecoverFile': True, 'xmlRecoverFile': True,

View File

@ -12,6 +12,7 @@
*/ */
#define XML_DEPRECATED #define XML_DEPRECATED
#define XML_DEPRECATED_MEMBER
#include "libxml.h" #include "libxml.h"
#include <stdio.h> #include <stdio.h>

View File

@ -6,6 +6,7 @@
*/ */
#define XML_DEPRECATED #define XML_DEPRECATED
#define XML_DEPRECATED_MEMBER
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -10,6 +10,8 @@
* daniel@veillard.com * daniel@veillard.com
*/ */
#define XML_DEPRECATED_MEMBER
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>