summaryrefslogtreecommitdiff
path: root/src/gb18030.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-11-09 22:19:11 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-11-09 22:19:11 +0100
commitc8573389de0cd20ebaf77db034fc45ec9cbf8534 (patch)
treea8f441060dded6654aaf9069b5d51cafd5708223 /src/gb18030.c
parent5b8fb1cf086c9f74666eed66b2d01cdf21d73880 (diff)
parent81f65b49e828952d496c80a991397fdac96feea9 (diff)
Merge tag 'upstream/6.1.2'
Upstream version 6.1.2
Diffstat (limited to 'src/gb18030.c')
-rw-r--r--src/gb18030.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/gb18030.c b/src/gb18030.c
index 36fc3de..c8b5865 100644
--- a/src/gb18030.c
+++ b/src/gb18030.c
@@ -76,9 +76,43 @@ gb18030_mbc_enc_len(const UChar* p)
}
static int
-is_valid_mbc_string(const UChar* s, const UChar* end)
+is_valid_mbc_string(const UChar* p, const UChar* end)
{
- return onigenc_length_check_is_valid_mbc_string(ONIG_ENCODING_GB18030, s, end);
+ while (p < end) {
+ if (*p < 0x80) {
+ p++;
+ }
+ else if (*p == 0x80 || *p == 0xff) {
+ return FALSE;
+ }
+ else {
+ p++;
+ if (p >= end) return FALSE;
+ if (*p < 0x40) {
+ if (*p < 0x30 || *p > 0x39)
+ return FALSE;
+
+ p++;
+ if (p >= end) return FALSE;
+ if (*p < 0x81 || *p == 0xff) return FALSE;
+
+ p++;
+ if (p >= end) return FALSE;
+ if (*p < 0x30 || *p > 0x39)
+ return FALSE;
+
+ p++;
+ }
+ else if (*p == 0x7f || *p == 0xff) {
+ return FALSE;
+ }
+ else {
+ p++;
+ }
+ }
+ }
+
+ return TRUE;
}
static OnigCodePoint