mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
encoding: Stop using XML_ENC_ERR_PARTIAL
This commit is contained in:
parent
221df37529
commit
501e5d195d
34
encoding.c
34
encoding.c
@ -1863,8 +1863,12 @@ xmlIconvConvert(void *vctxt, unsigned char *out, int *outlen,
|
||||
return(XML_ENC_ERR_INPUT);
|
||||
if (errno == E2BIG)
|
||||
return(XML_ENC_ERR_SPACE);
|
||||
/*
|
||||
* EINVAL means a truncated multi-byte sequence at the end
|
||||
* of the input buffer. We treat this as success.
|
||||
*/
|
||||
if (errno == EINVAL)
|
||||
return(XML_ENC_ERR_PARTIAL);
|
||||
return(XML_ENC_ERR_SUCCESS);
|
||||
return(XML_ENC_ERR_INTERNAL);
|
||||
}
|
||||
return(XML_ENC_ERR_SUCCESS);
|
||||
@ -2027,7 +2031,7 @@ xmlUconvConvert(void *vctxt, unsigned char *out, int *outlen,
|
||||
return(XML_ENC_ERR_SPACE);
|
||||
if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND)
|
||||
return(XML_ENC_ERR_INPUT);
|
||||
return(XML_ENC_ERR_PARTIAL);
|
||||
return(XML_ENC_ERR_INTERNAL);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -2195,11 +2199,8 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
|
||||
/*
|
||||
* The built-in converters don't signal XML_ENC_ERR_SPACE.
|
||||
*/
|
||||
if (*inlen < oldinlen) {
|
||||
if (*outlen > 0)
|
||||
ret = XML_ENC_ERR_SPACE;
|
||||
else
|
||||
ret = XML_ENC_ERR_PARTIAL;
|
||||
if ((*inlen < oldinlen) && (*outlen > 0)) {
|
||||
ret = XML_ENC_ERR_SPACE;
|
||||
} else {
|
||||
ret = XML_ENC_ERR_SUCCESS;
|
||||
}
|
||||
@ -2214,10 +2215,6 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
|
||||
ret = XML_ENC_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
/* Ignore partial errors when reading. */
|
||||
if (ret == XML_ENC_ERR_PARTIAL)
|
||||
ret = XML_ENC_ERR_SUCCESS;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -2248,11 +2245,8 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
|
||||
/*
|
||||
* The built-in converters don't signal XML_ENC_ERR_SPACE.
|
||||
*/
|
||||
if (*inlen < oldinlen) {
|
||||
if (*outlen > 0)
|
||||
ret = XML_ENC_ERR_SPACE;
|
||||
else
|
||||
ret = XML_ENC_ERR_PARTIAL;
|
||||
if ((*inlen < oldinlen) && (*outlen > 0)) {
|
||||
ret = XML_ENC_ERR_SPACE;
|
||||
} else {
|
||||
ret = XML_ENC_ERR_SUCCESS;
|
||||
}
|
||||
@ -2267,10 +2261,6 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
|
||||
ret = XML_ENC_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
/* We shouldn't generate partial sequences when writing. */
|
||||
if (ret == XML_ENC_ERR_PARTIAL)
|
||||
ret = XML_ENC_ERR_INTERNAL;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -2785,7 +2775,7 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
|
||||
/* trailing byte not in input buffer */
|
||||
*outlen = out - outstart;
|
||||
*inlen = processed - instart;
|
||||
return(XML_ENC_ERR_PARTIAL);
|
||||
return(XML_ENC_ERR_SUCCESS);
|
||||
}
|
||||
c = *in++;
|
||||
if ((c & 0xC0) != 0x80) {
|
||||
@ -2811,7 +2801,7 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
|
||||
/* trailing bytes not in input buffer */
|
||||
*outlen = out - outstart;
|
||||
*inlen = processed - instart;
|
||||
return(XML_ENC_ERR_PARTIAL);
|
||||
return(XML_ENC_ERR_SUCCESS);
|
||||
}
|
||||
c1 = *in++;
|
||||
if ((c1 & 0xC0) != 0x80) {
|
||||
|
@ -36,11 +36,15 @@ typedef enum {
|
||||
XML_ENC_ERR_SUCCESS = 0,
|
||||
XML_ENC_ERR_SPACE = -1,
|
||||
XML_ENC_ERR_INPUT = -2,
|
||||
XML_ENC_ERR_PARTIAL = -3,
|
||||
XML_ENC_ERR_INTERNAL = -4,
|
||||
XML_ENC_ERR_MEMORY = -5
|
||||
} xmlCharEncError;
|
||||
|
||||
/** DOC_DISABLE */
|
||||
/* deprecated */
|
||||
#define XMLENC_ERR_PARTIAL -3
|
||||
/** DOC_ENABLE */
|
||||
|
||||
/*
|
||||
* xmlCharEncoding:
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user