diff options
author | Karl Williamson <khw@cpan.org> | 2020-01-03 22:16:42 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-02-19 22:09:48 -0700 |
commit | d2c9cb5392e8c58c3bb1935fc3c098737224567c (patch) | |
tree | 647a4398f465b3b0751440c59747aea104c989ac /pod/perldelta.pod | |
parent | 4829f32decd128e6a122bd8ce35fe944bd87f104 (diff) | |
download | perl-d2c9cb5392e8c58c3bb1935fc3c098737224567c.tar.gz |
POSIX::mblen() Make thread-safe; allow shift state control
This commit changes the behavior so that it takes a scalar parameter
instead of a char *, and thus might not be forceable into a valid PV.
When not a PV, the shift state is reinitialized, like calling mblen with
a NULL first parameter. Previously the shift state was always
reinitialized with every call, which meant this could not work on
locales with shift states.
This commit also changes to use mbrlen() on threaded perls transparently
(mostly), when available, to achieve thread-safe operation. It is not
completely transparent because mbrlen (under the very rare stateful
locales) returns a different value when it's resetting the shift state.
It also may set errno differently upon errors, and no effort is made to
hide that difference. Also mbrlen on some platforms can handle partial
characters.
[perl #133928] showed that someone was having trouble with shift states.
Diffstat (limited to 'pod/perldelta.pod')
-rw-r--r-- | pod/perldelta.pod | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/pod/perldelta.pod b/pod/perldelta.pod index f76af50567..c6cad67e71 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -54,6 +54,23 @@ patterns using the above syntaxes, as an alternative to C<\N{...}>. A comparison of the two methods is given in L<perlunicode/Comparison of \N{...} and \p{name=...}>. +=head2 The C<POSIX::mblen()> function now works on shift state locales +and is thread-safe on C99 and above compilers +when executed on a platform that has locale thread-safety. + +This function is always executed under the current C language locale. +(See L<perllocale>.) Most locales are stateless, but a few, notably the +very rarely encountered ISO 2022, maintain a state between calls to this +function. Previously the state was cleared on every call to this +function, but now the state is not reset unless the first parameter is +C<undef>. + +On threaded perls, the C99 function L<mbrlen(3)>, +when available, is substituted for plain +C<mblen>. +This makes this function thread-safe when executing on a locale +thread-safe platform. + =head1 Security XXX Any security-related notices go here. In particular, any security |