summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-01-02 23:40:02 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-02 23:40:02 +0000
commit60006e79a806469b722900503d1a06b25590578c (patch)
treecd4d53fcea4606ecf80a763ba39c9209e429694f /utf8.c
parentdd30be90cd62b995d60efee76ad35ee657dbb913 (diff)
downloadperl-60006e79a806469b722900503d1a06b25590578c.tar.gz
Use the UTF8_XXX macros in is_utf8_char(), a performance nit
in is_utf8_string(). p4raw-id: //depot/perl@8300
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/utf8.c b/utf8.c
index be542814cd..d1f1d6631f 100644
--- a/utf8.c
+++ b/utf8.c
@@ -119,15 +119,15 @@ Perl_is_utf8_char(pTHX_ U8 *s)
STRLEN slen, len;
UV uv, ouv;
- if (u <= 0x7f)
+ if (UTF8_IS_ASCII(u))
return 1;
- if (u >= 0x80 && u <= 0xbf)
+ if (!UTF8_IS_START(u))
return 0;
len = UTF8SKIP(s);
- if (len < 2 || (u >= 0xc0 && u <= 0xfd && s[1] < 0x80))
+ if (len < 2 || !UTF8_IS_CONTINUATION(s[1]))
return 0;
slen = len - 1;
@@ -135,7 +135,7 @@ Perl_is_utf8_char(pTHX_ U8 *s)
uv = u;
ouv = uv;
while (slen--) {
- if ((*s & 0xc0) != 0x80)
+ if (!UTF8_IS_CONTINUATION(*s))
return 0;
uv = UTF8_ACCUMULATE(uv, *s);
if (uv < ouv)
@@ -175,9 +175,9 @@ Perl_is_utf8_string(pTHX_ U8 *s, STRLEN len)
if (!c)
return FALSE;
x += c;
- if (x > send)
- return FALSE;
}
+ if (x != send)
+ return FALSE;
return TRUE;
}