diff options
author | Karl Williamson <khw@cpan.org> | 2020-01-03 22:18:02 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-02-19 22:09:48 -0700 |
commit | 5a6637f01ac3edd837722b6d156ddb2250ea049f (patch) | |
tree | f6138a6fbd869dcd0a560fffcd31a0aca1321556 /embedvar.h | |
parent | 63bebc1439c3a3eefd310e674f2593ff60cceca4 (diff) | |
download | perl-5a6637f01ac3edd837722b6d156ddb2250ea049f.tar.gz |
Fixup POSIX::mbtowc, wctomb
This commit enhances these functions so that on threaded perls, they use
mbrtowc and wcrtomb when available, making them thread safe. The
substitution isn't completely transparent, as no effort is made to hide
any differences in errno setting upon error. And there may be slight
differences in edge case behavior on some platforms.
This commit also changes the behaviors so that they take a scalar
parameter instead of a char *, and this might be 'undef' or not be
forceable into a valid PV. If not a PV, the functions initialize the
shift state. Previously the shift state was always reinitialized with
every call, which meant these could not work on locales with shift
states.
In addition, there were several issues in mbtowc and wctomb that this
commit fixes.
mbtowc and wctomb, when used, are now run with a semaphore. This avoids
races if called at the same time in another thread.
The returned wide character from mbtowc() could well have been garbage.
The final parameter to mbtowc is now optional, as passing an SV allows
us to determine the length without the need for an extra parameter. It
is now used only to restrict the parsing of the string to shorter than
the actual length.
wctomb would segfault if the string parameter was shared or hadn't
been pre-allocated with a string of sufficient length to hold the
result.
Diffstat (limited to 'embedvar.h')
-rw-r--r-- | embedvar.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/embedvar.h b/embedvar.h index 3970f5a42b..ce6ec27cba 100644 --- a/embedvar.h +++ b/embedvar.h @@ -204,6 +204,7 @@ #define PL_max_intro_pending (vTHX->Imax_intro_pending) #define PL_maxsysfd (vTHX->Imaxsysfd) #define PL_mbrlen_ps (vTHX->Imbrlen_ps) +#define PL_mbrtowc_ps (vTHX->Imbrtowc_ps) #define PL_memory_debug_header (vTHX->Imemory_debug_header) #define PL_mess_sv (vTHX->Imess_sv) #define PL_min_intro_pending (vTHX->Imin_intro_pending) @@ -370,6 +371,7 @@ #define PL_warnhook (vTHX->Iwarnhook) #define PL_watchaddr (vTHX->Iwatchaddr) #define PL_watchok (vTHX->Iwatchok) +#define PL_wcrtomb_ps (vTHX->Iwcrtomb_ps) #define PL_xsubfilename (vTHX->Ixsubfilename) #endif /* MULTIPLICITY */ |