summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-02-13 13:13:02 -0700
committerKarl Williamson <public@khwilliamson.com>2012-02-13 13:42:54 -0700
commitf7d739d1511e40955f3a5ee22efc6a6e64af9bce (patch)
tree8329ce25277ed461ec8926ab1dd9903aef11f56d
parentd6495f5d84361750b54f6ff0916cc93c2a501a2d (diff)
downloadperl-f7d739d1511e40955f3a5ee22efc6a6e64af9bce.tar.gz
is_utf8_char_slow(): Make constistent, correct docs.
This function is only used by the Perl core for very large code points, though it is designed to be able to be used for all code points. For any variant code points, it doesn't succeed unless the passed in length is exactly the same as the number of bytes the code point occupies. The documentation says it succeeds if the length is at least that number. This commit updates the documentation to match the behavior. Also, for an invariant code point, it succeeds no matter what the passed-in length says. This commit changes this to be consistent with the behavior for all other code points.
-rw-r--r--utf8.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/utf8.c b/utf8.c
index 5c1f7c0338..2a5d93e193 100644
--- a/utf8.c
+++ b/utf8.c
@@ -257,9 +257,9 @@ Perl_uvuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
/*
-Tests if some arbitrary number of bytes begins in a valid UTF-8
+Tests if the first C<len> bytes of string C<s> form a valid UTF-8
character. Note that an INVARIANT (i.e. ASCII) character is a valid
-UTF-8 character. The actual number of bytes in the UTF-8 character
+UTF-8 character. The number of bytes in the UTF-8 character
will be returned if it is valid, otherwise 0.
This is the "slow" version as opposed to the "fast" version which is
@@ -283,7 +283,7 @@ S_is_utf8_char_slow(const U8 *s, const STRLEN len)
PERL_ARGS_ASSERT_IS_UTF8_CHAR_SLOW;
if (UTF8_IS_INVARIANT(u))
- return 1;
+ return len == 1;
if (!UTF8_IS_START(u))
return 0;