summaryrefslogtreecommitdiff
path: root/lib/unistr/u8-check.c
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:15 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:15 +0200
commit3e0814cd9862b89c7a39672672937477bd87ddfb (patch)
tree159134a624e51509f40ed8823249f09a70d1dda3 /lib/unistr/u8-check.c
parent3bebb94360f1c2333feb8d504a9fa4f96984d8b7 (diff)
Imported Upstream version 0.9.3upstream/0.9.3
Diffstat (limited to 'lib/unistr/u8-check.c')
-rw-r--r--lib/unistr/u8-check.c126
1 files changed, 63 insertions, 63 deletions
diff --git a/lib/unistr/u8-check.c b/lib/unistr/u8-check.c
index 53897fc5..368042b0 100644
--- a/lib/unistr/u8-check.c
+++ b/lib/unistr/u8-check.c
@@ -1,5 +1,5 @@
/* Check UTF-8 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -31,73 +31,73 @@ u8_check (const uint8_t *s, size_t n)
uint8_t c = *s;
if (c < 0x80)
- {
- s++;
- continue;
- }
+ {
+ s++;
+ continue;
+ }
if (c >= 0xc2)
- {
- if (c < 0xe0)
- {
- if (s + 2 <= s_end
- && (s[1] ^ 0x80) < 0x40)
- {
- s += 2;
- continue;
- }
- }
- else if (c < 0xf0)
- {
- if (s + 3 <= s_end
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (c >= 0xe1 || s[1] >= 0xa0)
- && (c != 0xed || s[1] < 0xa0))
- {
- s += 3;
- continue;
- }
- }
- else if (c < 0xf8)
- {
- if (s + 4 <= s_end
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40
- && (c >= 0xf1 || s[1] >= 0x90)
+ {
+ if (c < 0xe0)
+ {
+ if (s + 2 <= s_end
+ && (s[1] ^ 0x80) < 0x40)
+ {
+ s += 2;
+ continue;
+ }
+ }
+ else if (c < 0xf0)
+ {
+ if (s + 3 <= s_end
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (c >= 0xe1 || s[1] >= 0xa0)
+ && (c != 0xed || s[1] < 0xa0))
+ {
+ s += 3;
+ continue;
+ }
+ }
+ else if (c < 0xf8)
+ {
+ if (s + 4 <= s_end
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40
+ && (c >= 0xf1 || s[1] >= 0x90)
#if 1
- && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
+ && (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
#endif
- )
- {
- s += 4;
- continue;
- }
- }
+ )
+ {
+ s += 4;
+ continue;
+ }
+ }
#if 0
- else if (c < 0xfc)
- {
- if (s + 5 <= s_end
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (c >= 0xf9 || s[1] >= 0x88))
- {
- s += 5;
- continue;
- }
- }
- else if (c < 0xfe)
- {
- if (s + 6 <= s_end
- && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
- && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
- && (s[5] ^ 0x80) < 0x40
- && (c >= 0xfd || s[1] >= 0x84))
- {
- s += 6;
- continue;
- }
- }
+ else if (c < 0xfc)
+ {
+ if (s + 5 <= s_end
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (c >= 0xf9 || s[1] >= 0x88))
+ {
+ s += 5;
+ continue;
+ }
+ }
+ else if (c < 0xfe)
+ {
+ if (s + 6 <= s_end
+ && (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
+ && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
+ && (s[5] ^ 0x80) < 0x40
+ && (c >= 0xfd || s[1] >= 0x84))
+ {
+ s += 6;
+ continue;
+ }
+ }
#endif
- }
+ }
/* invalid or incomplete multibyte character */
return s;
}