summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2006-04-29 21:57:40 +0200
committerMike Hommey <glandium@debian.org>2006-04-29 21:57:40 +0200
commit07a67fa4bcc1b8bf2651ab41e5fc54a05059cf7e (patch)
tree7b377fd8e804a983cb2c57a43be1093ef179c5fd /encoding.c
parentc5d565931c4823dc8f62fffcb65aecfec516f7b9 (diff)
downloadlibxml2-07a67fa4bcc1b8bf2651ab41e5fc54a05059cf7e.tar.gz
Load /tmp/libxml2-2.6.24 intoupstream/2.6.24.dfsg
libxml2/branches/upstream/current.
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/encoding.c b/encoding.c
index c6cfe91..dc1c205 100644
--- a/encoding.c
+++ b/encoding.c
@@ -126,27 +126,21 @@ asciiToUTF8(unsigned char* out, int *outlen,
unsigned char* outend = out + *outlen;
const unsigned char* inend;
unsigned int c;
- int bits;
inend = in + (*inlen);
while ((in < inend) && (out - outstart + 5 < *outlen)) {
c= *in++;
- /* assertion: c is a single UTF-4 value */
if (out >= outend)
break;
- if (c < 0x80) { *out++= c; bits= -6; }
- else {
+ if (c < 0x80) {
+ *out++ = c;
+ } else {
*outlen = out - outstart;
*inlen = processed - base;
return(-1);
}
- for ( ; bits >= 0; bits-= 6) {
- if (out >= outend)
- break;
- *out++= ((c >> bits) & 0x3F) | 0x80;
- }
processed = (const unsigned char*) in;
}
*outlen = out - outstart;
@@ -529,7 +523,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
const unsigned char *const instart = in;
unsigned short* outstart= out;
unsigned short* outend;
- const unsigned char* inend= in+*inlen;
+ const unsigned char* inend;
unsigned int c, d;
int trailing;
unsigned char *tmp;
@@ -542,6 +536,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
*inlen = 0;
return(0);
}
+ inend= in + *inlen;
outend = out + (*outlen / 2);
while (in < inend) {
d= *in++;
@@ -770,7 +765,7 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
const unsigned char *const instart = in;
unsigned short* outstart= out;
unsigned short* outend;
- const unsigned char* inend= in+*inlen;
+ const unsigned char* inend;
unsigned int c, d;
int trailing;
unsigned char *tmp;
@@ -783,6 +778,7 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
*inlen = 0;
return(0);
}
+ inend= in + *inlen;
outend = out + (*outlen / 2);
while (in < inend) {
d= *in++;
@@ -1702,13 +1698,8 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
icv_inlen = *inlen;
icv_outlen = *outlen;
ret = iconv(cd, (char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
- if (in != NULL) {
- *inlen -= icv_inlen;
- *outlen -= icv_outlen;
- } else {
- *inlen = 0;
- *outlen = 0;
- }
+ *inlen -= icv_inlen;
+ *outlen -= icv_outlen;
if ((icv_inlen != 0) || (ret == -1)) {
#ifdef EILSEQ
if (errno == EILSEQ) {