1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

parser: Don't use deprecated xmlCopyChar

This commit is contained in:
Nick Wellnhofer 2024-07-02 04:02:16 +02:00
parent 751ba00e00
commit 30ef77554b
5 changed files with 16 additions and 12 deletions

View File

@ -289,9 +289,9 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
#define CUR_CHAR(l) htmlCurrentChar(ctxt, &l)
#define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = v; \
else i += xmlCopyChar(l,&b[i],v)
#define COPY_BUF(b, i, v) \
if (v < 0x80) b[i++] = v; \
else i += xmlCopyCharMultiByte(&b[i],v)
/**
* htmlFindEncoding:
@ -3034,7 +3034,7 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
}
}
if (IS_CHAR(cur)) {
COPY_BUF(l,buf,nbchar,cur);
COPY_BUF(buf,nbchar,cur);
} else {
htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
"Invalid char in CDATA 0x%X\n", cur);
@ -3099,7 +3099,7 @@ htmlParseCharDataInternal(htmlParserCtxtPtr ctxt, int readahead) {
htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
"Invalid char in CDATA 0x%X\n", cur);
} else {
COPY_BUF(l,buf,nbchar,cur);
COPY_BUF(buf,nbchar,cur);
}
NEXTL(l);
if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
@ -3298,7 +3298,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
buf = tmp;
}
if (IS_CHAR(cur)) {
COPY_BUF(l,buf,len,cur);
COPY_BUF(buf,len,cur);
} else {
htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
"Invalid char in processing instruction "
@ -3420,7 +3420,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
buf = tmp;
}
if (IS_CHAR(q)) {
COPY_BUF(ql,buf,len,q);
COPY_BUF(buf,len,q);
} else {
htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
"Invalid char in comment 0x%X\n", q);

View File

@ -620,6 +620,7 @@ XMLPUBFUN int xmlCurrentChar (xmlParserCtxtPtr ctxt,
int *len);
XMLPUBFUN int xmlCopyCharMultiByte (xmlChar *out,
int val);
XML_DEPRECATED
XMLPUBFUN int xmlCopyChar (int len,
xmlChar *out,
int val);

View File

@ -1056,6 +1056,8 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
* @out: pointer to an array of xmlChar
* @val: the char value
*
* DEPRECATED: Don't use.
*
* append the char value in the array
*
* Returns the number of xmlChar written

View File

@ -303,6 +303,7 @@ deprecated_funcs = {
'xmlCheckLanguageID': True,
'xmlCleanupCharEncodingHandlers': True,
'xmlCleanupGlobals': True,
'xmlCopyChar': True,
'xmlDefaultSAXHandlerInit': True,
'xmlDictCleanup': True,
'xmlFileMatch': True,

10
xpath.c
View File

@ -2198,9 +2198,9 @@ xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
#define CUR_PTR ctxt->cur
#define CUR_CHAR(l) xmlXPathCurrentChar(ctxt, &l)
#define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = v; \
else i += xmlCopyChar(l,&b[i],v)
#define COPY_BUF(b, i, v) \
if (v < 0x80) b[i++] = v; \
else i += xmlCopyCharMultiByte(&b[i],v)
#define NEXTL(l) ctxt->cur += l
@ -8772,7 +8772,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
(c == '_') || ((qualified) && (c == ':')) ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
COPY_BUF(l,buf,len,c);
COPY_BUF(buf,len,c);
NEXTL(l);
c = CUR_CHAR(l);
if (len >= XML_MAX_NAMELEN) {
@ -8812,7 +8812,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
}
buffer = tmp;
}
COPY_BUF(l,buffer,len,c);
COPY_BUF(buffer,len,c);
NEXTL(l);
c = CUR_CHAR(l);
}