Skip to content

Commit

Permalink
Don't discard locale info in starting P2008
Browse files Browse the repository at this point in the history
The program is started in the global locale, and then is converted to
the POSIX 2008 per-thread locale API.  Prior to this commit the startup
locale was discarded.  It really should be the foundation for the 2008
locales.  I don't know of any current paths through the code that this
makes a difference for, but it is a potential hole that is easy to plug.
  • Loading branch information
khwilliamson committed Apr 29, 2021
1 parent 555ddca commit 872653e
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions locale.c
Expand Up @@ -1053,11 +1053,29 @@ S_emulate_setlocale_i(pTHX_
}
else {
/* If we weren't in a thread safe locale, set so that newlocale() below
* which uses 'old_obj', uses an empty one. Same for our reserved C
* object. The latter is defensive coding, so that, even if there is
* some bug, we will never end up trying to modify either of these, as
* newlocale() just below would otherwise do. */
if (old_obj == LC_GLOBAL_LOCALE || old_obj == PL_C_locale_obj) {
* which uses 'old_obj', gets a legal copy. And, as a defensive coding
* measure, make sure we don't mistakenly modify our reserved C
* object, which the newlocale() just below would otherwise do. */
if (old_obj == LC_GLOBAL_LOCALE) {
old_obj = duplocale(old_obj);

# ifdef USE_PL_CURLOCALES

{ /* Fill in our records with the correct values, calculating
* LC_ALL's entry on the final iteration */
unsigned int i;
for (i = 0; i < NOMINAL_LC_ALL_INDEX; i++) {
update_PL_curlocales_i(i,
porcelain_setlocale(categories[i],
NULL),
LOOPING);
}
}

# endif

}
else if (old_obj == PL_C_locale_obj) {
old_obj = (locale_t) 0;
}

Expand Down

0 comments on commit 872653e

Please sign in to comment.