summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-06-20 11:23:54 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-06-20 11:23:54 +0000
commitcac98897c1edfd9477ded7553a2726764c4e2df6 (patch)
tree8d95325541f8d4ca61e8573275f75d9cdadcc042
parent6a2a07c99eeea78247971a3c7dd9dc5a03b69434 (diff)
downloadlibparserutils-cac98897c1edfd9477ded7553a2726764c4e2df6.tar.gz
libparserutils-cac98897c1edfd9477ded7553a2726764c4e2df6.tar.bz2
Reasons I hate TCPIPLibs:
1) You need to include sys/types.h yourself 2) You need to ensure that netinet/in.h is included before arpa/inet.h 3) Neither arpa/inet.h nor netinet/in.h define htonl/ntohl -- it's in machine/endian.h which, fortunately, is included from sys/types.h Add a bunch of explicit casts to uint32_t to the results of calls to ntohl/htonl to appease Norcroft's "implicit narrowing cast" warning. svn path=/trunk/libparserutils/; revision=7891
-rw-r--r--src/charset/codecs/codec_8859.c42
-rw-r--r--src/charset/codecs/codec_ascii.c34
-rw-r--r--src/charset/codecs/codec_ext8.c42
-rw-r--r--src/charset/codecs/codec_utf16.c32
-rw-r--r--src/charset/codecs/codec_utf8.c32
5 files changed, 96 insertions, 86 deletions
diff --git a/src/charset/codecs/codec_8859.c b/src/charset/codecs/codec_8859.c
index ee5f8ce..6d53b86 100644
--- a/src/charset/codecs/codec_8859.c
+++ b/src/charset/codecs/codec_8859.c
@@ -9,9 +9,10 @@
#include <stdlib.h>
#include <string.h>
-/* These two are for htonl / ntohl */
-#include <arpa/inet.h>
+/* These three are for htonl / ntohl */
+#include <sys/types.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <parserutils/charset/mibenum.h>
@@ -104,12 +105,12 @@ bool charset_8859_codec_handles_charset(const char *charset)
uint32_t i;
uint16_t match = parserutils_charset_mibenum_from_name(charset,
strlen(charset));
-
+
if (known_charsets[0].mib == 0) {
for (i = 0; i < N_ELEMENTS(known_charsets); i++) {
- known_charsets[i].mib =
+ known_charsets[i].mib =
parserutils_charset_mibenum_from_name(
- known_charsets[i].name,
+ known_charsets[i].name,
known_charsets[i].len);
}
}
@@ -230,7 +231,7 @@ parserutils_error charset_8859_codec_encode(parserutils_charset_codec *codec,
uint32_t *pwrite = c->write_buf;
while (c->write_len > 0) {
- error = charset_8859_from_ucs4(c, pwrite[0],
+ error = charset_8859_from_ucs4(c, pwrite[0],
dest, destlen);
if (error != PARSERUTILS_OK) {
uint32_t len;
@@ -250,13 +251,13 @@ parserutils_error charset_8859_codec_encode(parserutils_charset_codec *codec,
/* Now process the characters for this call */
while (*sourcelen > 0) {
- ucs4 = ntohl(*((uint32_t *) (void *) *source));
+ ucs4 = (uint32_t) ntohl(*((uint32_t *) (void *) *source));
towrite = &ucs4;
towritelen = 1;
/* Output current characters */
while (towritelen > 0) {
- error = charset_8859_from_ucs4(c, towrite[0], dest,
+ error = charset_8859_from_ucs4(c, towrite[0], dest,
destlen);
if (error != PARSERUTILS_OK) {
uint32_t len;
@@ -311,9 +312,9 @@ parserutils_error charset_8859_codec_encode(parserutils_charset_codec *codec,
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* Note that, if failure occurs whilst attempting to write any output
@@ -347,7 +348,8 @@ parserutils_error charset_8859_codec_decode(parserutils_charset_codec *codec,
uint32_t *pread = c->read_buf;
while (c->read_len > 0 && *destlen >= c->read_len * 4) {
- *((uint32_t *) (void *) *dest) = htonl(pread[0]);
+ *((uint32_t *) (void *) *dest) =
+ (uint32_t) htonl(pread[0]);
*dest += 4;
*destlen -= 4;
@@ -417,9 +419,9 @@ parserutils_error charset_8859_codec_reset(parserutils_charset_codec *codec)
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* ::sourcelen will be reduced appropriately on exit.
@@ -453,9 +455,9 @@ parserutils_error charset_8859_codec_read_char(charset_8859_codec *c,
return error;
} else if (error == PARSERUTILS_INVALID) {
/* Illegal input sequence */
-
+
/* Strict errormode; simply flag invalid character */
- if (c->base.errormode ==
+ if (c->base.errormode ==
PARSERUTILS_CHARSET_CODEC_ERROR_STRICT) {
return PARSERUTILS_INVALID;
}
@@ -496,7 +498,7 @@ parserutils_error charset_8859_codec_output_decoded_char(charset_8859_codec *c,
return PARSERUTILS_NOMEM;
}
- *((uint32_t *) (void *) *dest) = htonl(ucs4);
+ *((uint32_t *) (void *) *dest) = (uint32_t) htonl(ucs4);
*dest += 4;
*destlen -= 4;
@@ -539,14 +541,14 @@ parserutils_error charset_8859_from_ucs4(charset_8859_codec *c,
}
if (i == 96) {
- if (c->base.errormode ==
+ if (c->base.errormode ==
PARSERUTILS_CHARSET_CODEC_ERROR_STRICT)
return PARSERUTILS_INVALID;
else
out = '?';
} else {
out = 0xA0 + i;
- }
+ }
}
*(*s) = out;
diff --git a/src/charset/codecs/codec_ascii.c b/src/charset/codecs/codec_ascii.c
index f91b1e9..318e7f0 100644
--- a/src/charset/codecs/codec_ascii.c
+++ b/src/charset/codecs/codec_ascii.c
@@ -9,9 +9,10 @@
#include <stdlib.h>
#include <string.h>
-/* These two are for htonl / ntohl */
-#include <arpa/inet.h>
+/* These three are for htonl / ntohl */
+#include <sys/types.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <parserutils/charset/mibenum.h>
@@ -77,7 +78,7 @@ bool charset_ascii_codec_handles_charset(const char *charset)
static uint16_t ascii;
uint16_t match = parserutils_charset_mibenum_from_name(charset,
strlen(charset));
-
+
if (ascii == 0) {
ascii = parserutils_charset_mibenum_from_name(
"US-ASCII", SLEN("US-ASCII"));
@@ -184,7 +185,7 @@ parserutils_error charset_ascii_codec_encode(parserutils_charset_codec *codec,
uint32_t *pwrite = c->write_buf;
while (c->write_len > 0) {
- error = charset_ascii_from_ucs4(c, pwrite[0],
+ error = charset_ascii_from_ucs4(c, pwrite[0],
dest, destlen);
if (error != PARSERUTILS_OK) {
uint32_t len;
@@ -204,13 +205,13 @@ parserutils_error charset_ascii_codec_encode(parserutils_charset_codec *codec,
/* Now process the characters for this call */
while (*sourcelen > 0) {
- ucs4 = ntohl(*((uint32_t *) (void *) *source));
+ ucs4 = (uint32_t) ntohl(*((uint32_t *) (void *) *source));
towrite = &ucs4;
towritelen = 1;
/* Output current characters */
while (towritelen > 0) {
- error = charset_ascii_from_ucs4(c, towrite[0], dest,
+ error = charset_ascii_from_ucs4(c, towrite[0], dest,
destlen);
if (error != PARSERUTILS_OK) {
uint32_t len;
@@ -265,9 +266,9 @@ parserutils_error charset_ascii_codec_encode(parserutils_charset_codec *codec,
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* Note that, if failure occurs whilst attempting to write any output
@@ -301,7 +302,8 @@ parserutils_error charset_ascii_codec_decode(parserutils_charset_codec *codec,
uint32_t *pread = c->read_buf;
while (c->read_len > 0 && *destlen >= c->read_len * 4) {
- *((uint32_t *) (void *) *dest) = htonl(pread[0]);
+ *((uint32_t *) (void *) *dest) =
+ (uint32_t) htonl(pread[0]);
*dest += 4;
*destlen -= 4;
@@ -371,9 +373,9 @@ parserutils_error charset_ascii_codec_reset(parserutils_charset_codec *codec)
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* ::sourcelen will be reduced appropriately on exit.
@@ -407,9 +409,9 @@ parserutils_error charset_ascii_codec_read_char(charset_ascii_codec *c,
return error;
} else if (error == PARSERUTILS_INVALID) {
/* Illegal input sequence */
-
+
/* Strict errormode; simply flag invalid character */
- if (c->base.errormode ==
+ if (c->base.errormode ==
PARSERUTILS_CHARSET_CODEC_ERROR_STRICT) {
return PARSERUTILS_INVALID;
}
@@ -451,7 +453,7 @@ parserutils_error charset_ascii_codec_output_decoded_char(
return PARSERUTILS_NOMEM;
}
- *((uint32_t *) (void *) *dest) = htonl(ucs4);
+ *((uint32_t *) (void *) *dest) = (uint32_t) htonl(ucs4);
*dest += 4;
*destlen -= 4;
diff --git a/src/charset/codecs/codec_ext8.c b/src/charset/codecs/codec_ext8.c
index 82fef3d..54ee854 100644
--- a/src/charset/codecs/codec_ext8.c
+++ b/src/charset/codecs/codec_ext8.c
@@ -9,9 +9,10 @@
#include <stdlib.h>
#include <string.h>
-/* These two are for htonl / ntohl */
-#include <arpa/inet.h>
+/* These three are for htonl / ntohl */
+#include <sys/types.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <parserutils/charset/mibenum.h>
@@ -98,12 +99,12 @@ bool charset_ext8_codec_handles_charset(const char *charset)
uint32_t i;
uint16_t match = parserutils_charset_mibenum_from_name(charset,
strlen(charset));
-
+
if (known_charsets[0].mib == 0) {
for (i = 0; i < N_ELEMENTS(known_charsets); i++) {
- known_charsets[i].mib =
+ known_charsets[i].mib =
parserutils_charset_mibenum_from_name(
- known_charsets[i].name,
+ known_charsets[i].name,
known_charsets[i].len);
}
}
@@ -224,7 +225,7 @@ parserutils_error charset_ext8_codec_encode(parserutils_charset_codec *codec,
uint32_t *pwrite = c->write_buf;
while (c->write_len > 0) {
- error = charset_ext8_from_ucs4(c, pwrite[0],
+ error = charset_ext8_from_ucs4(c, pwrite[0],
dest, destlen);
if (error != PARSERUTILS_OK) {
uint32_t len;
@@ -244,13 +245,13 @@ parserutils_error charset_ext8_codec_encode(parserutils_charset_codec *codec,
/* Now process the characters for this call */
while (*sourcelen > 0) {
- ucs4 = ntohl(*((uint32_t *) (void *) *source));
+ ucs4 = (uint32_t) ntohl(*((uint32_t *) (void *) *source));
towrite = &ucs4;
towritelen = 1;
/* Output current characters */
while (towritelen > 0) {
- error = charset_ext8_from_ucs4(c, towrite[0], dest,
+ error = charset_ext8_from_ucs4(c, towrite[0], dest,
destlen);
if (error != PARSERUTILS_OK) {
uint32_t len;
@@ -305,9 +306,9 @@ parserutils_error charset_ext8_codec_encode(parserutils_charset_codec *codec,
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* Note that, if failure occurs whilst attempting to write any output
@@ -341,7 +342,8 @@ parserutils_error charset_ext8_codec_decode(parserutils_charset_codec *codec,
uint32_t *pread = c->read_buf;
while (c->read_len > 0 && *destlen >= c->read_len * 4) {
- *((uint32_t *) (void *) *dest) = htonl(pread[0]);
+ *((uint32_t *) (void *) *dest) =
+ (uint32_t) htonl(pread[0]);
*dest += 4;
*destlen -= 4;
@@ -411,9 +413,9 @@ parserutils_error charset_ext8_codec_reset(parserutils_charset_codec *codec)
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* ::sourcelen will be reduced appropriately on exit.
@@ -447,9 +449,9 @@ parserutils_error charset_ext8_codec_read_char(charset_ext8_codec *c,
return error;
} else if (error == PARSERUTILS_INVALID) {
/* Illegal input sequence */
-
+
/* Strict errormode; simply flag invalid character */
- if (c->base.errormode ==
+ if (c->base.errormode ==
PARSERUTILS_CHARSET_CODEC_ERROR_STRICT) {
return PARSERUTILS_INVALID;
}
@@ -490,7 +492,7 @@ parserutils_error charset_ext8_codec_output_decoded_char(charset_ext8_codec *c,
return PARSERUTILS_NOMEM;
}
- *((uint32_t *) (void *) *dest) = htonl(ucs4);
+ *((uint32_t *) (void *) *dest) = (uint32_t) htonl(ucs4);
*dest += 4;
*destlen -= 4;
@@ -533,14 +535,14 @@ parserutils_error charset_ext8_from_ucs4(charset_ext8_codec *c,
}
if (i == 128) {
- if (c->base.errormode ==
+ if (c->base.errormode ==
PARSERUTILS_CHARSET_CODEC_ERROR_STRICT)
return PARSERUTILS_INVALID;
else
out = '?';
} else {
out = 0x80 + i;
- }
+ }
}
*(*s) = out;
diff --git a/src/charset/codecs/codec_utf16.c b/src/charset/codecs/codec_utf16.c
index c2a91ed..0b8379a 100644
--- a/src/charset/codecs/codec_utf16.c
+++ b/src/charset/codecs/codec_utf16.c
@@ -8,9 +8,10 @@
#include <stdlib.h>
#include <string.h>
-/* These two are for htonl / ntohl */
-#include <arpa/inet.h>
+/* These three are for htonl / ntohl */
+#include <sys/types.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <parserutils/charset/mibenum.h>
#include <parserutils/charset/utf16.h>
@@ -76,7 +77,7 @@ static inline parserutils_error charset_utf16_codec_output_decoded_char(
*/
bool charset_utf16_codec_handles_charset(const char *charset)
{
- return parserutils_charset_mibenum_from_name(charset, strlen(charset))
+ return parserutils_charset_mibenum_from_name(charset, strlen(charset))
==
parserutils_charset_mibenum_from_name("UTF-16", SLEN("UTF-16"));
}
@@ -152,7 +153,7 @@ parserutils_error charset_utf16_codec_destroy (parserutils_charset_codec *codec)
*
* On exit, ::source will point immediately _after_ the last input character
* read. Any remaining output for the character will be buffered by the
- * codec for writing on the next call.
+ * codec for writing on the next call.
*
* Note that, if failure occurs whilst attempting to write any output
* buffered by the last call, then ::source and ::sourcelen will remain
@@ -206,7 +207,7 @@ parserutils_error charset_utf16_codec_encode(parserutils_charset_codec *codec,
/* Now process the characters for this call */
while (*sourcelen > 0) {
- ucs4 = ntohl(*((uint32_t *) (void *) *source));
+ ucs4 = (uint32_t) ntohl(*((uint32_t *) (void *) *source));
towrite = &ucs4;
towritelen = 1;
@@ -273,9 +274,9 @@ parserutils_error charset_utf16_codec_encode(parserutils_charset_codec *codec,
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* Note that, if failure occurs whilst attempting to write any output
@@ -309,7 +310,8 @@ parserutils_error charset_utf16_codec_decode(parserutils_charset_codec *codec,
uint32_t *pread = c->read_buf;
while (c->read_len > 0 && *destlen >= c->read_len * 4) {
- *((uint32_t *) (void *) *dest) = htonl(pread[0]);
+ *((uint32_t *) (void *) *dest) =
+ (uint32_t) htonl(pread[0]);
*dest += 4;
*destlen -= 4;
@@ -416,9 +418,9 @@ parserutils_error charset_utf16_codec_reset(parserutils_charset_codec *codec)
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* ::sourcelen will be reduced appropriately on exit.
@@ -436,7 +438,7 @@ parserutils_error charset_utf16_codec_read_char(charset_utf16_codec *c,
parserutils_error error;
/* Convert a single character */
- error = parserutils_charset_utf16_to_ucs4(*source, *sourcelen,
+ error = parserutils_charset_utf16_to_ucs4(*source, *sourcelen,
&ucs4, &sucs4);
if (error == PARSERUTILS_OK) {
/* Read a character */
@@ -475,7 +477,7 @@ parserutils_error charset_utf16_codec_read_char(charset_utf16_codec *c,
c->inval_len = 0;
/* Strict errormode; simply flag invalid character */
- if (c->base.errormode ==
+ if (c->base.errormode ==
PARSERUTILS_CHARSET_CODEC_ERROR_STRICT) {
return PARSERUTILS_INVALID;
}
@@ -540,7 +542,7 @@ parserutils_error charset_utf16_codec_output_decoded_char(charset_utf16_codec *c
return PARSERUTILS_NOMEM;
}
- *((uint32_t *) (void *) *dest) = htonl(ucs4);
+ *((uint32_t *) (void *) *dest) = (uint32_t) htonl(ucs4);
*dest += 4;
*destlen -= 4;
diff --git a/src/charset/codecs/codec_utf8.c b/src/charset/codecs/codec_utf8.c
index ad46766..ea192a6 100644
--- a/src/charset/codecs/codec_utf8.c
+++ b/src/charset/codecs/codec_utf8.c
@@ -8,9 +8,10 @@
#include <stdlib.h>
#include <string.h>
-/* These two are for htonl / ntohl */
-#include <arpa/inet.h>
+/* These three are for htonl / ntohl */
+#include <sys/types.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <parserutils/charset/mibenum.h>
@@ -76,9 +77,9 @@ static inline parserutils_error charset_utf8_codec_output_decoded_char(
*/
bool charset_utf8_codec_handles_charset(const char *charset)
{
- return parserutils_charset_mibenum_from_name(charset,
+ return parserutils_charset_mibenum_from_name(charset,
strlen(charset)) ==
- parserutils_charset_mibenum_from_name("UTF-8",
+ parserutils_charset_mibenum_from_name("UTF-8",
SLEN("UTF-8"));
}
@@ -201,7 +202,7 @@ parserutils_error charset_utf8_codec_encode(parserutils_charset_codec *codec,
/* Now process the characters for this call */
while (*sourcelen > 0) {
- ucs4 = ntohl(*((uint32_t *) (void *) *source));
+ ucs4 = (uint32_t) ntohl(*((uint32_t *) (void *) *source));
towrite = &ucs4;
towritelen = 1;
@@ -260,9 +261,9 @@ parserutils_error charset_utf8_codec_encode(parserutils_charset_codec *codec,
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* Note that, if failure occurs whilst attempting to write any output
@@ -296,7 +297,8 @@ parserutils_error charset_utf8_codec_decode(parserutils_charset_codec *codec,
uint32_t *pread = c->read_buf;
while (c->read_len > 0 && *destlen >= c->read_len * 4) {
- *((uint32_t *) (void *) *dest) = htonl(pread[0]);
+ *((uint32_t *) (void *) *dest) =
+ (uint32_t) htonl(pread[0]);
*dest += 4;
*destlen -= 4;
@@ -403,9 +405,9 @@ parserutils_error charset_utf8_codec_reset(parserutils_charset_codec *codec)
* read, if the result is _OK or _NOMEM. Any remaining output for the
* character will be buffered by the codec for writing on the next call.
*
- * In the case of the result being _INVALID, ::source will point _at_ the
- * last input character read; nothing will be written or buffered for the
- * failed character. It is up to the client to fix the cause of the failure
+ * In the case of the result being _INVALID, ::source will point _at_ the
+ * last input character read; nothing will be written or buffered for the
+ * failed character. It is up to the client to fix the cause of the failure
* and retry the decoding process.
*
* ::sourcelen will be reduced appropriately on exit.
@@ -461,9 +463,9 @@ parserutils_error charset_utf8_codec_read_char(charset_utf8_codec *c,
} else if (error == PARSERUTILS_INVALID) {
/* Illegal input sequence */
uint32_t nextchar;
-
+
/* Strict errormode; simply flag invalid character */
- if (c->base.errormode ==
+ if (c->base.errormode ==
PARSERUTILS_CHARSET_CODEC_ERROR_STRICT) {
/* Clear inval buffer */
c->inval_buf[0] = '\0';
@@ -542,7 +544,7 @@ parserutils_error charset_utf8_codec_output_decoded_char(charset_utf8_codec *c,
return PARSERUTILS_NOMEM;
}
- *((uint32_t *) (void *) *dest) = htonl(ucs4);
+ *((uint32_t *) (void *) *dest) = (uint32_t) htonl(ucs4);
*dest += 4;
*destlen -= 4;