In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/f2819f4d11979695226b1e169dc3377ec58fcbc6?hp=69bc4c1f86bca21cf0baeb2b4812ea97d3bf438e>

- Log -----------------------------------------------------------------
commit f2819f4d11979695226b1e169dc3377ec58fcbc6
Author: Karl Williamson <[email protected]>
Date:   Thu Sep 1 12:07:33 2016 -0600

    Fix is_utf8_valid_partial_char()
    
    This should have been part of 4dab108fb5e7e21a547733bb00ddb5d8bffd936d,
    but when I was rebasing, these changes got moved to an unrelated commit
    that hasn't been pushed yet, and I didn't notice immediately.  I will
    add som API tests for this in the next few days.
-----------------------------------------------------------------------

Summary of changes:
 inline.h | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/inline.h b/inline.h
index 5cb9347..c3acf67 100644
--- a/inline.h
+++ b/inline.h
@@ -505,18 +505,22 @@ Perl_utf8_hop(const U8 *s, SSize_t off)
 
 =for apidoc is_utf8_valid_partial_char
 
-Returns 1 if the first few bytes of the string starting at C<s> and
-looking no further than S<C<e - 1>> are legal initial bytes of
-well-formed UTF-8; otherwise it returns 0.
+Returns 1 if there exists some sequence of bytes, call it C<s'>, that when
+appended to the sequence from C<s> through S<C<e - 1>> causes the entire
+sequence starting at C<s> (including C<s'>) to be the well-formed UTF-8 of
+some code point; otherwise returns 0.
+
+In other words this returns TRUE if C<s> points to the beginning, but partial,
+sequence of the UTF-8 for some code point.
 
 This is useful when some fixed-length buffer is being tested for being
-well-formed UTF-8, but the final few bytes in it are fewer than necessary to
-fully determine what code point they might mean.  (Presumably when the buffer
-is refreshed with the next chunk of data, the new first bytes will complete the
-partial code point.)   This function is used to verify that the final bytes in
-the current buffer are in fact the legal beginning of some code point, so that
-if they aren't, the failure can be signalled without having to wait for the
-next read.
+well-formed UTF-8, but the final few bytes in it don't comprise a full
+character: it is split somewhere in the middle of its UTF-8 representation.
+(Presumably when the buffer is refreshed with the next chunk of data, the new
+first bytes will complete the partial code point.)   This function is used to
+verify that the final bytes in the current buffer are in fact the legal
+beginning of some code point, so that if they aren't, the failure can be
+signalled without having to wait for the next read.
 
 If the bytes terminated at S<C<e - 1>> are a full character (or more), 0 is
 returned.
@@ -529,7 +533,7 @@ S_is_utf8_valid_partial_char(const U8 * const s, const U8 * 
const e)
 
     PERL_ARGS_ASSERT_IS_UTF8_VALID_PARTIAL_CHAR;
 
-    if (s >= e || s + UTF8SKIP(s) >= e) {
+    if (s >= e || s + UTF8SKIP(s) < e) {
         return FALSE;
     }
 

--
Perl5 Master Repository

Reply via email to