Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: 96a4323e9d03702ad7250050abc6aeb19cb30266 https://github.com/Perl/perl5/commit/96a4323e9d03702ad7250050abc6aeb19cb30266 Author: Karl Williamson <k...@cpan.org> Date: 2024-01-21 (Sun, 21 Jan 2024)
Changed paths: M locale.c Log Message: ----------- locale.c: ALT_DIGITS should be empty not "0" when none This and the next commit fix the incorrect behavior that perl has always had for nl_langinfo(ALT_DIGITS). If there are no alternate digits, an empty string is returned by nl_langinfo when there are no such alternate digits. This should also be the case on platforms where we emulate nl_langinfo, but instead "0" was being returned. This commit makes things consistent. The next commit adds tests Commit: cc68a74a641e534b51b21dcc10b1c0b4d366da2b https://github.com/Perl/perl5/commit/cc68a74a641e534b51b21dcc10b1c0b4d366da2b Author: Karl Williamson <k...@cpan.org> Date: 2024-01-21 (Sun, 21 Jan 2024) Changed paths: M ext/I18N-Langinfo/Langinfo.pm M lib/locale.t M locale.c M pod/perldelta.pod Log Message: ----------- Fix langinfo(ALT_DIGITS) This has never worked properly before in Perl. The code is returning the result of the libc function nl_langinfo(). The documentation for it that I have found (and presumably my predecessors) is very unclear. But what actually happens (from using gdb) is that the return is very C unfriendly. Instead of returning a NUL-terminated string, it returns 100 (perhaps fewer) NUL-terminated strings in a row. When it is fewer (given the few examples I've seen), the final one ends with two NULs in a row. (I can't think of a way for it to work and be otherwise). The 100th one doesn't necessarily have two terminating NULs. Prior to this commit, only the string for the zeroth digit was returned; now the entire ALT_DIGIT string sequence is returned, forcing a double NUL at the end of the final one. This information is accessible in several ways. Via XS, one can use any of several functions, including the newly introduced sv_langinfo(), returning an SV, which allows for easier handling of embedded NULs. (Otherwise in XS, using the functions that return a char*, one has to look for the double-NUL.) >From Perl-space, the access is via I18N::Langinfo, which behind the scenes also uses an SV. The documentation added in this commit gives advice for how to turn the return into an @array for more convenient access. Compare: https://github.com/Perl/perl5/compare/d8b7e57ae089...cc68a74a641e