[vlc-devel] commit: IsUTF8: use clz ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sun Feb 7 10:41:55 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Feb 7 11:40:41 2010 +0200| [0b49b59c40489feae11430ccff125b4499159db5] | committer: Rémi Denis-Courmont
IsUTF8: use clz
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b49b59c40489feae11430ccff125b4499159db5
---
src/text/unicode.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/src/text/unicode.c b/src/text/unicode.c
index 5487e25..1c0501a 100644
--- a/src/text/unicode.c
+++ b/src/text/unicode.c
@@ -286,25 +286,20 @@ static char *CheckUTF8( char *str, char rep )
for (;;)
{
uint8_t c = ptr[0];
- int charlen = -1;
if (c == '\0')
break;
- for (int i = 0; i < 7; i++)
- if ((c >> (7 - i)) == ((0xff >> (7 - i)) ^ 1))
- {
- charlen = i;
- break;
- }
+ if (c > 0xF4)
+ goto error;
+ int charlen = clz8 (c ^ 0xFF);
switch (charlen)
{
case 0: // 7-bit ASCII character -> OK
ptr++;
continue;
- case -1: // 1111111x -> error
case 1: // continuation byte -> error
goto error;
}
More information about the vlc-devel
mailing list