Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: 8d5b344cae7c43d8a1548db9fa7708a197de3d33 https://github.com/Perl/perl5/commit/8d5b344cae7c43d8a1548db9fa7708a197de3d33 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023)
Changed paths: M makedef.pl Log Message: ----------- makedef.pl: Remove redundant set This ||= is useless, as just above we've already set MULTIPLICITY if USE_ITHREADS is set. Commit: aa4cd703c149ad292d6d89efa0c102fee014840e https://github.com/Perl/perl5/commit/aa4cd703c149ad292d6d89efa0c102fee014840e Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M makedef.pl Log Message: ----------- makedef.pl: Don't use locale items unless using locale If we are configured to not look at locales at all, we shouldn't be looking at threaded locales nor POSIX 2008 ones. This commit fixes a situation that is not likely at all to show up in real life, but I stumbled across it in testing weird configurations. Commit: 2a1a6207f8ba69f6b00f64c93714466584c2108d https://github.com/Perl/perl5/commit/2a1a6207f8ba69f6b00f64c93714466584c2108d Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c M makedef.pl M perl.h Log Message: ----------- Remove PL_cur_LC_ALL for non-Windows This value is now held in a slot in PL_curlocales[] for non-Windows platforms. Commit: b60d50d3d0c9ba7ed9b7dbe2ee3054a7c2590e2f https://github.com/Perl/perl5/commit/b60d50d3d0c9ba7ed9b7dbe2ee3054a7c2590e2f Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M embed.fnc M embed.h M locale.c M proto.h Log Message: ----------- locale.c: Rename S_myquerylocale_i() This name doesn't effectively describe it. The new name is querylocale_2008_i, indicating it is for the POSIX 2008 API. Commit: 9106edf58567a1d5f69235f02341267df69d3da7 https://github.com/Perl/perl5/commit/9106edf58567a1d5f69235f02341267df69d3da7 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M embed.fnc M embed.h M locale.c M proto.h Log Message: ----------- locale.c: Separate setlocale into bool and query There are two ways that POSIX specifies to change the locale. The earlier interface is setlocale(), which either returns NULL on failure, or a pointer to global static memory containing the character string of the changed locale. That may very well be the input locale name, or the platform can return something that to it is equivalent. The second, from the 2008 standard, is newlocale() which returns either NULL on failure, or a pointer to an opaque object, and there is no official way to find out what the current locale is. (The next proposed version of the Standard will finally add this capability.) Some platforms have introduced a querylocale() to get this information. (glibc has a hidden function to do so.) Note that the return value of setlocale() is problematic, valid only until the next call to that function, which might be immediately from another thread. The value, if needed, has to be saved to a per-thread buffer in a critical section with the function call. That buffer presents opportunities for leaking, or being destroyed too early, resulting in heap use after being freed. And it turns out that the value is often not needed; often what is needed is only if the operation failed or succeeded. This commit starts the process of limiting the use of the changed value to just where its really needed. It does this by changing the newlocale() form to return success/failure, removing all the macros that think you can set and get the value in the same operation, and minor fixups. Commit: 250057152aa9a5d63f77e985873b25d11bad77e8 https://github.com/Perl/perl5/commit/250057152aa9a5d63f77e985873b25d11bad77e8 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M embed.fnc M embed.h M locale.c M proto.h Log Message: ----------- locale.c: Rmv less_dicey_void_setlocale_r() This function is simple, but almost entirely redundant with less_dicey_bool_setlocale_r(). A simple wrapper to the latter suffices. The commit also changes the macros for this to use void_setlocale_r() as the base which the other two are defined in terms of. This avoids a runtime calculation of the internal index corresponding to the input locale category except when we are about to panic. Commit: be682cacfd159685d6b059d24008f50d616b9dc5 https://github.com/Perl/perl5/commit/be682cacfd159685d6b059d24008f50d616b9dc5 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Avoid a runtime calculation As in the previous commit, this rewrites the void_setlocale_X macros so as to not need a runtime calculation except in the very rare event of executing a panic. Commit: 406f22d99e245d6f54c28f756e0cb7e83a5da0df https://github.com/Perl/perl5/commit/406f22d99e245d6f54c28f756e0cb7e83a5da0df Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Add missing panic In just the POSIX 2008 implementation of setting locales, the panic upon failure had been omitted. The whole point of a void call is so that the caller doesn't have to check the return code of something that should never fail, and can just assume that if it gets to the next statement everything worked as expected. Commit: 62c4bbf9d47864e2c90f13068b30edf0213c1d95 https://github.com/Perl/perl5/commit/62c4bbf9d47864e2c90f13068b30edf0213c1d95 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Reorder code, add extensive comments There are three separate implementations of an internal API for locale handling. This commit makes them stand out in the code, and makes the ordering within each implementation parallel to the other implementations. And adds explanatory comments. Commit: a0de14ae902f8da4eff40c41002d38c819d7a5dc https://github.com/Perl/perl5/commit/a0de14ae902f8da4eff40c41002d38c819d7a5dc Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Add a convenience macro query_nominal_locale_i This is used when the locale needs to be what an external caller would see. Adding this simplifies some code. Commit: a586eaeca51399dd0660c4f6811155a0edb29bdc https://github.com/Perl/perl5/commit/a586eaeca51399dd0660c4f6811155a0edb29bdc Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Remove one-off macro This was used to prevent an unnecessary copy. But the next commit will change the macro it was avoiding to not always do the copy. That will avoid more copies than this would. The copy that results will still be unnecessary in some cases, but there is a net gain. Commit: 2ede6361ad50f02a7b510b2a84667f9ebe8f85b5 https://github.com/Perl/perl5/commit/2ede6361ad50f02a7b510b2a84667f9ebe8f85b5 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Move copy from macro to called function Not all returns from the function need to be copied. Thus this eliminates some extraneous copies. Commit: 2906bfafe4e59d615532e9e26a3895a4f0630c2b https://github.com/Perl/perl5/commit/2906bfafe4e59d615532e9e26a3895a4f0630c2b Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- S_toggle_locale_i: Move some assert()s, initialization Commit: 038f51811029a8650725661dcaf507494427f4b5 https://github.com/Perl/perl5/commit/038f51811029a8650725661dcaf507494427f4b5 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M embed.fnc M embed.h M locale.c M perl.h M proto.h Log Message: ----------- locale.c: Add extra debug info to panics This commit adds some call stack information to the message that gets output when about to panic because of an unanticipated failure in the locale handling code. Commit: f9d2d5280f096a429453765d4c327a377f66a256 https://github.com/Perl/perl5/commit/f9d2d5280f096a429453765d4c327a377f66a256 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Add void_setlocale_with_caller macros These pass a file and line number from further up the calling stack to a panic so as to improve debugging information. Commit: bf38d1cf744fcc49b715b9d633761aa67436c002 https://github.com/Perl/perl5/commit/bf38d1cf744fcc49b715b9d633761aa67436c002 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Initialize PL_curlocales at startup Previously this was done later, which meant other code had to take them being uninitialized into consideration over and over at runtime. That code is hereby removed. This commit enables further simplifications to follow in later commits. Commit: 29a77eba93e22da7d0e2020ac9dc94559def586e https://github.com/Perl/perl5/commit/29a77eba93e22da7d0e2020ac9dc94559def586e Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Use void_ macro form when ignoring return The void_ form panics if unsuccessful; and here we are relying on it being successful. Commit: ec26684055ab257e10c2323b720a669a91df6640 https://github.com/Perl/perl5/commit/ec26684055ab257e10c2323b720a669a91df6640 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M locale.c Log Message: ----------- locale.c: Don't exclude LC_ALL in loop This function was setting each individual locale category to the same value. But if all the subcomponents are the same, so is LC_ALL. No need to special case it; just set the upper loop limit to include it. Commit: ce9a13f9c15f1b5b4dfb68cf849b19607e57da33 https://github.com/Perl/perl5/commit/ce9a13f9c15f1b5b4dfb68cf849b19607e57da33 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M embed.fnc M locale.c M proto.h Log Message: ----------- locale.c: Change function to return void It just returns the input value unchanged; this is a no-op. Commit: ab1f5e3581dff991b7695ffcbb96d29cf35b9d84 https://github.com/Perl/perl5/commit/ab1f5e3581dff991b7695ffcbb96d29cf35b9d84 Author: Karl Williamson <k...@cpan.org> Date: 2023-07-25 (Tue, 25 Jul 2023) Changed paths: M embed.fnc M embed.h M locale.c M perl.h M proto.h Log Message: ----------- locale.c: Remove no-longer needed parameter and computation When a locale category changes, LC_ALL necessarily also does. When we are looping changing a bunch of categories, LC_ALL's intermediate values are of no importance; only the final value matters. Prior to this commit, this was handled by setting a flag to not do the recalculation until the final loop iteration. But a more elegant solution is to not recalculate it at all, until the value is actually needed. So the code is changed to invalidate the stored value (by setting it to NULL) if an individual locale category changes, and then do the calculation only when needed and invalidated. Compare: https://github.com/Perl/perl5/compare/ec57fb93199c...ab1f5e3581df