This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX::mblen() Make thread-safe; allow shift state control
authorKarl Williamson <khw@cpan.org>
Sat, 4 Jan 2020 05:16:42 +0000 (22:16 -0700)
committerKarl Williamson <khw@cpan.org>
Thu, 20 Feb 2020 05:09:48 +0000 (22:09 -0700)
commitd2c9cb5392e8c58c3bb1935fc3c098737224567c
tree647a4398f465b3b0751440c59747aea104c989ac
parent4829f32decd128e6a122bd8ce35fe944bd87f104
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.
embedvar.h
ext/POSIX/POSIX.xs
ext/POSIX/lib/POSIX.pod
ext/POSIX/t/mb.t
intrpvar.h
locale.c
perl.h
pod/perldelta.pod
sv.c
t/porting/known_pod_issues.dat