diff options
author | Karl Williamson <khw@cpan.org> | 2016-09-25 22:04:08 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2016-09-25 22:24:20 -0600 |
commit | 8bc127bf58304a1e46a3e33d30b0b8b6f21abb07 (patch) | |
tree | e19a856cb909b92fa7bd5a7c68dd1bc2fce270b0 /pp_sys.c | |
parent | 9f2abfdef8903cce0a7b12ce12788ce7e9f72ed1 (diff) | |
download | perl-8bc127bf58304a1e46a3e33d30b0b8b6f21abb07.tar.gz |
Add is_utf8_fixed_width_buf_flags() and use it
This encodes a simple pattern that may not be immediately obvious to
someone needing it. If you have a fixed-size buffer that is full of
purportedly UTF-8 bytes, is it valid or not? It's easy to do, as shown
in this commit. The file test operators -T and -B can be simpified by
using this function.
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -3556,14 +3556,10 @@ PP(pp_fttext) assert(len); if (! is_utf8_invariant_string((U8 *) s, len)) { - const U8 *ep; /* Here contains a variant under UTF-8 . See if the entire string is - * UTF-8. But the buffer may end in a partial character, so if it - * failed, see if the failure was due just to that */ - if ( is_utf8_string_loc((U8 *) s, len, &ep) - || is_utf8_valid_partial_char(ep, (U8 *) s + len)) - { + * UTF-8. */ + if (is_utf8_fixed_width_buf_flags((U8 *) s, len, 0)) { if (PL_op->op_type == OP_FTTEXT) { FT_RETURNYES; } |