Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -3906,7 +3906,10 @@ Adp |bool |valid_identifier_pvn \
|U32 flags
Adp |bool |valid_identifier_sv \
|NULLOK SV *sv
CRTdip |UV |valid_utf8_to_uvchr \
CRTdip |UV |valid_utf8_to_uv \
|NN const U8 *s \
|NULLOK STRLEN *retlen
CRTdmp |UV |valid_utf8_to_uvchr \
|NN const U8 *s \
|NULLOK STRLEN *retlen
Adp |int |vcmp |NN SV *lhv \
Expand Down
3 changes: 2 additions & 1 deletion embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,8 @@
# define valid_identifier_pve(a,b,c) Perl_valid_identifier_pve(aTHX_ a,b,c)
# define valid_identifier_pvn(a,b,c) Perl_valid_identifier_pvn(aTHX_ a,b,c)
# define valid_identifier_sv(a) Perl_valid_identifier_sv(aTHX_ a)
# define valid_utf8_to_uvchr Perl_valid_utf8_to_uvchr
# define valid_utf8_to_uv Perl_valid_utf8_to_uv
# define Perl_valid_utf8_to_uvchr valid_utf8_to_uvchr
# define vcmp(a,b) Perl_vcmp(aTHX_ a,b)
# define vcroak(a,b) Perl_vcroak(aTHX_ a,b)
# define vdeb(a,b) Perl_vdeb(aTHX_ a,b)
Expand Down
21 changes: 16 additions & 5 deletions inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -1306,25 +1306,36 @@ Perl_utf8_to_bytes_overwrite(pTHX_ U8 **s_ptr, STRLEN *lenp)
}

/*
=for apidoc valid_utf8_to_uvchr
Like C<L<perlapi/utf8_to_uv>>, but should only be called when it is
=for apidoc valid_utf8_to_uv
=for apidoc_item valid_utf8_to_uvchr

These are synonymous.

These are like C<L<perlapi/utf8_to_uv>>, but should only be called when it is
known that the next character in the input UTF-8 string C<s> is well-formed
(I<e.g.>, it passes C<L<perlapi/isUTF8_CHAR>>. Surrogates, non-character code
points, and non-Unicode code points are allowed.

The only use for these is that they should run slightly faster than
C<utf8_to_uv> because no error checking is done.

The C<_uv> form is slightly preferred so as to have a consistent spelling with
the other C<_uv> forms that are definitely preferred over the older and
problematic C<_uvchr> forms.

=cut

*/

PERL_STATIC_INLINE UV
Perl_valid_utf8_to_uvchr(const U8 *s, STRLEN *retlen)
Perl_valid_utf8_to_uv(const U8 *s, STRLEN *retlen)
{
PERL_ARGS_ASSERT_VALID_UTF8_TO_UV;

const UV expectlen = UTF8SKIP(s);
const U8* send = s + expectlen;
UV uv = *s;

PERL_ARGS_ASSERT_VALID_UTF8_TO_UVCHR;

if (retlen) {
*retlen = expectlen;
}
Expand Down
7 changes: 7 additions & 0 deletions pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,13 @@ C<assert()> statements yourself to F<embed.fnc> that will be
incorporated into the generated macro, beyond the system-generated ones.
Comments and examples in F<embed.fnc> give details.

=item *

A new function C<valid_utf8_to_uv> has been added. This is synonymous
with C<valid_utf8_to_uvchr>; its reason for existence is to have
consistent spelling with the names of the other functions that translate
from UTF-8, so you don't have to remember a different spelling.

=back

=head1 Selected Bug Fixes
Expand Down
8 changes: 6 additions & 2 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ For details, see the description for L<perlapi/uv_to_utf8_flags>.
#define c9strict_utf8_to_uv(s, e, cp_p, advance_p) \
utf8_to_uv_flags( s, e, cp_p, advance_p, \
UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE)
#define valid_utf8_to_uvchr(s, advance_p) valid_utf8_to_uv(s, advance_p)

#define utf16_to_utf8(p, d, bytelen, newlen) \
utf16_to_utf8_base(p, d, bytelen, newlen, 0, 1)
Expand Down
Loading