diff options
author | Mattias Andrée <maandree@kth.se> | 2016-07-17 21:34:24 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-07-17 21:34:24 +0200 |
commit | aca30fd7dac4d02721508e31c51656773f78a6b7 (patch) | |
tree | 271dc144fe0f5a81a01aef20089fa4d85b3ade67 | |
parent | m (diff) | |
download | coopgammad-aca30fd7dac4d02721508e31c51656773f78a6b7.tar.gz coopgammad-aca30fd7dac4d02721508e31c51656773f78a6b7.tar.bz2 coopgammad-aca30fd7dac4d02721508e31c51656773f78a6b7.tar.xz |
Ungeneralise verify_utf8
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | src/util.c | 8 | ||||
-rw-r--r-- | src/util.h | 2 |
2 files changed, 4 insertions, 6 deletions
@@ -195,11 +195,10 @@ void msleep(unsigned ms) /** * Check whether a NUL-terminated string is encoded in UTF-8 * - * @param string The string - * @param allow_modified_nul Whether Modified UTF-8 is allowed, which allows a two-byte encoding for NUL - * @return Zero if good, -1 on encoding error + * @param string The string + * @return Zero if good, -1 on encoding error */ -int verify_utf8(const char* restrict string, int allow_modified_nul) +int verify_utf8(const char* restrict string) { static long BYTES_TO_MIN_BITS[] = {0, 0, 8, 12, 17, 22, 37}; static long BYTES_TO_MAX_BITS[] = {0, 7, 11, 16, 21, 26, 31}; @@ -256,7 +255,6 @@ int verify_utf8(const char* restrict string, int allow_modified_nul) /* Check that the character is not unnecessarily long. */ while (character) character >>= 1, bits++; - bits = ((bits == 0) && (bytes == 2) && allow_modified_nul) ? 8 : bits; if ((bits < BYTES_TO_MIN_BITS[bytes]) || (BYTES_TO_MAX_BITS[bytes] < bits)) return -1; @@ -99,7 +99,7 @@ void msleep(unsigned ms); * @return Zero if good, -1 on encoding error */ GCC_ONLY(__attribute__((pure, nonnull))) -int verify_utf8(const char* restrict string, int allow_modified_nul); +int verify_utf8(const char* restrict string); /** * Make identity mapping ramps |