Skip to content

Commit

Permalink
encoding: Stop using XML_ENC_ERR_PARTIAL
Browse files Browse the repository at this point in the history
  • Loading branch information
nwellnhof committed Jul 1, 2024
1 parent 221df37 commit 501e5d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
34 changes: 12 additions & 22 deletions encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion include/libxml/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down

0 comments on commit 501e5d1

Please sign in to comment.