Skip to content

Commit

Permalink
locale.c: Don't add CP to Windows code page names
Browse files Browse the repository at this point in the history
The actual name appears to be just the number for purposes of
nl_langinfo()-ish things.
  • Loading branch information
khwilliamson committed May 9, 2021
1 parent 233a8b1 commit 3f34849
Showing 1 changed file with 6 additions and 28 deletions.
34 changes: 6 additions & 28 deletions locale.c
Expand Up @@ -3445,44 +3445,22 @@ S_my_langinfo(const nl_item item, bool toggle)

{ /* But on Windows, the name does seem to be consistent, so
use that. */
const char * p;
const char * first;
Size_t offset = 0;
const char * name = querylocale_c(LC_CTYPE);

if (isNAME_C_OR_POSIX(name)) {
return C_codeset;
}

/* Find the dot in the locale name */
first = (const char *) strchr(name, '.');
if (! first) {
first = name;
goto has_nondigit;
}

/* Look at everything past the dot */
first++;
p = first;

while (*p) {
if (! isDIGIT(*p)) {
goto has_nondigit;
retval = (const char *) strchr(name, '.');
if (! retval) {
return ""; /* Alas, no dot */
}

p++;
}
/* Use everything past the dot */
retval++;

/* Here everything past the dot is a digit. Treat it as a
* code page */
retval = save_to_buffer("CP", &PL_langinfo_buf,
retval = save_to_buffer(retval, &PL_langinfo_buf,
&PL_langinfo_bufsize, 0);
offset = STRLENs("CP");

has_nondigit:

retval = save_to_buffer(first, &PL_langinfo_buf,
&PL_langinfo_bufsize, offset);
}

break;
Expand Down

0 comments on commit 3f34849

Please sign in to comment.