1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-09 04:58:16 +03:00

Remove or annotate char casts

This commit is contained in:
Nick Wellnhofer 2022-09-01 02:58:00 +02:00
parent 2cac626976
commit 6843fc726f
7 changed files with 11 additions and 9 deletions

View File

@ -326,7 +326,7 @@ htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
#define CUR_SCHAR(s, l) xmlStringCurrentChar(ctxt, s, &l)
#define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = (xmlChar) v; \
if (l == 1) b[i++] = v; \
else i += xmlCopyChar(l,&b[i],v)
/**
@ -5924,7 +5924,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
* Handle preparsed entities and charRef
*/
if (ctxt->token != 0) {
chr[0] = (xmlChar) ctxt->token;
chr[0] = ctxt->token;
htmlCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, chr, 1);

View File

@ -2169,7 +2169,7 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
#define CUR_SCHAR(s, l) xmlStringCurrentChar(ctxt, s, &l)
#define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = (xmlChar) v; \
if (l == 1) b[i++] = v; \
else i += xmlCopyCharMultiByte(&b[i],v)
#define CUR_CONSUMED \

View File

@ -812,7 +812,7 @@ encoding_error:
*/
int
xmlCopyCharMultiByte(xmlChar *out, int val) {
if (out == NULL) return(0);
if ((out == NULL) || (val < 0)) return(0);
/*
* We are supposed to handle UTF8, check it's valid
* From rfc2044: encoding of the Unicode values on UTF-8:
@ -838,7 +838,7 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
*out++= ((val >> bits) & 0x3F) | 0x80 ;
return (out - savedout);
}
*out = (xmlChar) val;
*out = val;
return 1;
}
@ -855,12 +855,12 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
int
xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, int val) {
if (out == NULL) return(0);
if ((out == NULL) || (val < 0)) return(0);
/* the len parameter is ignored */
if (val >= 0x80) {
return(xmlCopyCharMultiByte (out, val));
}
*out = (xmlChar) val;
*out = val;
return 1;
}

1
uri.c
View File

@ -1657,6 +1657,7 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
c = c * 16 + (*in - 'A') + 10;
in++;
len -= 3;
/* Explicit sign change */
*out++ = (char) c;
} else {
*out++ = *in++;

View File

@ -1714,7 +1714,7 @@ loaded:
"trying to build relative URI from %s\n", URL);
} else {
/* If the URI doesn't contain a slash, it's not relative */
if (!xmlStrchr(curBase, (xmlChar) '/'))
if (!xmlStrchr(curBase, '/'))
xmlFree(curBase);
else
base = curBase;

View File

@ -97,6 +97,7 @@ xmlCharStrndup(const char *cur, int len) {
return(NULL);
}
for (i = 0;i < len;i++) {
/* Explicit sign change */
ret[i] = (xmlChar) cur[i];
if (ret[i] == 0) return(ret);
}

View File

@ -3098,7 +3098,7 @@ xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
#define CUR_CHAR(l) xmlXPathCurrentChar(ctxt, &l)
#define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = (xmlChar) v; \
if (l == 1) b[i++] = v; \
else i += xmlCopyChar(l,&b[i],v)
#define NEXTL(l) ctxt->cur += l