summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-01-03 22:16:42 -0700
committerKarl Williamson <khw@cpan.org>2020-02-19 22:09:48 -0700
commitd2c9cb5392e8c58c3bb1935fc3c098737224567c (patch)
tree647a4398f465b3b0751440c59747aea104c989ac /sv.c
parent4829f32decd128e6a122bd8ce35fe944bd87f104 (diff)
downloadperl-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 'sv.c')
-rw-r--r--sv.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index f464065e90..3c533b08d2 100644
--- a/sv.c
+++ b/sv.c
@@ -15688,6 +15688,10 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
# endif
#endif /* !USE_LOCALE_NUMERIC */
+#ifdef HAS_MBRLEN
+ PL_mbrlen_ps = proto_perl->Imbrlen_ps;
+#endif
+
PL_langinfo_buf = NULL;
PL_langinfo_bufsize = 0;