Branch: refs/heads/locale
  Home:   https://github.com/Perl/perl5
  Commit: 6546288f8943d6cd83c2db6c694422ad47148872
      
https://github.com/Perl/perl5/commit/6546288f8943d6cd83c2db6c694422ad47148872
  Author: Karl Williamson <[email protected]>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

  Changed paths:
    M embedvar.h
    M ext/POSIX/POSIX.xs
    M ext/POSIX/lib/POSIX.pod
    M ext/POSIX/t/mb.t
    M intrpvar.h
    M locale.c
    M perl.h
    M pod/perldelta.pod
    M t/porting/known_pod_issues.dat

  Log Message:
  -----------
  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.


  Commit: 9d41ab746799a4b87f2cef1be1fdbf30d4a87def
      
https://github.com/Perl/perl5/commit/9d41ab746799a4b87f2cef1be1fdbf30d4a87def
  Author: Karl Williamson <[email protected]>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

  Changed paths:
    M ext/POSIX/POSIX.xs
    M ext/POSIX/lib/POSIX.pod
    M ext/POSIX/t/mb.t
    M pod/perldelta.pod

  Log Message:
  -----------
  POSIX::mblen: Make length parameter optional

Now that the typemap is an SV, we can access the length from that.


  Commit: fb0082f5827091c887763a5d562e5b50526e4c48
      
https://github.com/Perl/perl5/commit/fb0082f5827091c887763a5d562e5b50526e4c48
  Author: Karl Williamson <[email protected]>
  Date:   2020-01-04 (Sat, 04 Jan 2020)

  Changed paths:
    M embedvar.h
    M ext/POSIX/POSIX.xs
    M ext/POSIX/lib/POSIX.pod
    M ext/POSIX/t/mb.t
    M intrpvar.h
    M locale.c
    M pod/perldelta.pod
    M t/porting/known_pod_issues.dat

  Log Message:
  -----------
  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.


Compare: https://github.com/Perl/perl5/compare/fc9527e64174...fb0082f58270

Reply via email to