Skip to content

Commit

Permalink
locale.c: Move fcn within file
Browse files Browse the repository at this point in the history
This is for later commits which will change it to rely on new defines
that won't occur until later in the file than its current position
  • Loading branch information
khwilliamson committed May 6, 2021
1 parent 33d6a1c commit a37d187
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions locale.c
Expand Up @@ -174,48 +174,6 @@ STATIC_ASSERT_DECL(STRLENs(UTF8NESS_PREFIX) == 1);
locale, result)
# endif

STATIC char *
S_stdize_locale(pTHX_ char *locs)
{
/* Standardize the locale name from a string returned by 'setlocale',
* possibly modifying that string.
*
* The typical return value of setlocale() is either
* (1) "xx_YY" if the first argument of setlocale() is not LC_ALL
* (2) "xa_YY xb_YY ..." if the first argument of setlocale() is LC_ALL
* (the space-separated values represent the various sublocales,
* in some unspecified order). This is not handled by this function.
*
* In some platforms it has a form like "LC_SOMETHING=Lang_Country.866\n",
* which is harmful for further use of the string in setlocale(). This
* function removes the trailing new line and everything up through the '='
* */

const char * const s = strchr(locs, '=');
bool okay = TRUE;

PERL_ARGS_ASSERT_STDIZE_LOCALE;

if (s) {
const char * const t = strchr(s, '.');
okay = FALSE;
if (t) {
const char * const u = strchr(t, '\n');
if (u && (u[1] == 0)) {
const STRLEN len = u - s;
Move(s + 1, locs, len, char);
locs[len] = 0;
okay = TRUE;
}
}
}

if (!okay)
Perl_croak(aTHX_ "Can't fix broken locale name \"%s\"", locs);

return locs;
}

/* Two parallel arrays indexed by our mapping of category numbers into small
* non-negative indexes; first the locale categories Perl uses on this system,
* used to do the inverse mapping. The second array is their names. These
Expand Down Expand Up @@ -1110,6 +1068,48 @@ S_emulate_setlocale_i(pTHX_ const unsigned int index, const char * locale)

#ifdef USE_LOCALE

STATIC char *
S_stdize_locale(pTHX_ char *locs)
{
/* Standardize the locale name from a string returned by 'setlocale',
* possibly modifying that string.
*
* The typical return value of setlocale() is either
* (1) "xx_YY" if the first argument of setlocale() is not LC_ALL
* (2) "xa_YY xb_YY ..." if the first argument of setlocale() is LC_ALL
* (the space-separated values represent the various sublocales,
* in some unspecified order). This is not handled by this function.
*
* In some platforms it has a form like "LC_SOMETHING=Lang_Country.866\n",
* which is harmful for further use of the string in setlocale(). This
* function removes the trailing new line and everything up through the '='
* */

const char * const s = strchr(locs, '=');
bool okay = TRUE;

PERL_ARGS_ASSERT_STDIZE_LOCALE;

if (s) {
const char * const t = strchr(s, '.');
okay = FALSE;
if (t) {
const char * const u = strchr(t, '\n');
if (u && (u[1] == 0)) {
const STRLEN len = u - s;
Move(s + 1, locs, len, char);
locs[len] = 0;
okay = TRUE;
}
}
}

if (!okay)
Perl_croak(aTHX_ "Can't fix broken locale name \"%s\"", locs);

return locs;
}

STATIC void
S_set_numeric_radix(pTHX_ const bool use_locale)
{
Expand Down

0 comments on commit a37d187

Please sign in to comment.