[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] nfkc.c: do not use UTF-8 codes longer then 4 bytes, do not use U
From: |
Karlson2k |
Subject: |
[PATCH] nfkc.c: do not use UTF-8 codes longer then 4 bytes, do not use UCS-4 codes > 0x10FFFF (non-UTF-32) |
Date: |
Mon, 4 Apr 2016 15:55:29 +0300 |
---
lib/nfkc.c | 28 +++-------------------------
1 file changed, 3 insertions(+), 25 deletions(-)
diff --git a/lib/nfkc.c b/lib/nfkc.c
index edc62c4..a843a2b 100644
--- a/lib/nfkc.c
+++ b/lib/nfkc.c
@@ -171,25 +171,13 @@ GNormalizeMode;
Len = 4; \
Mask = 0x07; \
} \
- else if ((Char & 0xfc) == 0xf8) \
- { \
- Len = 5; \
- Mask = 0x03; \
- } \
- else if ((Char & 0xfe) == 0xfc) \
- { \
- Len = 6; \
- Mask = 0x01; \
- } \
else \
Len = -1;
#define UTF8_LENGTH(Char) \
((Char) < 0x80 ? 1 : \
((Char) < 0x800 ? 2 : \
- ((Char) < 0x10000 ? 3 : \
- ((Char) < 0x200000 ? 4 : \
- ((Char) < 0x4000000 ? 5 : 6)))))
+ ((Char) < 0x10000 ? 3 : 4)))
#define UTF8_GET(Result, Chars, Count, Mask, Len) \
(Result) = (Chars)[0] & (Mask); \
@@ -337,21 +325,11 @@ g_unichar_to_utf8 (gunichar c, gchar * outbuf)
first = 0xe0;
len = 3;
}
- else if (c < 0x200000)
+ else
{
first = 0xf0;
len = 4;
}
- else if (c < 0x4000000)
- {
- first = 0xf8;
- len = 5;
- }
- else
- {
- first = 0xfc;
- len = 6;
- }
if (outbuf)
{
@@ -498,7 +476,7 @@ g_ucs4_to_utf8 (const gunichar * str,
if (!str[i])
break;
- if (str[i] >= 0x80000000)
+ if (str[i] > 0x10FFFF)
goto err_out;
result_length += UTF8_LENGTH (str[i]);
--
2.8.0.windows.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] nfkc.c: do not use UTF-8 codes longer then 4 bytes, do not use UCS-4 codes > 0x10FFFF (non-UTF-32),
Karlson2k <=