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

View File

@ -73,6 +73,16 @@
#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
*/

View File

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

View File

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

View File

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

View File

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