-
Notifications
You must be signed in to change notification settings - Fork 575
Perl 5.40 on Solaris can not parse setlocale(3C) output #23195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I seem to have problems uploading a patch which fixes the issue, I'll just paste it here. --- perl-5.40.1/locale.c
+++ perl-5.40.1/locale.c
@@ -1303,6 +1303,17 @@ S_parse_LC_ALL_string(pTHX_ const char *
Size_t index; /* Our internal index for the current category */
const char * s = string;
+
+#if defined(__sun__)
+ /* Solaris setlocale(3C) returns composite locale prefixed by slash. For example
+ * "/en_US.UTF-8/C/C/C/C/C". See man page. We must remove it or this
+ * function will think that there is additional empty locale at the
+ * beginning of the string and the number of detected locales will not
+ * match expected LC_ALL_INDEX_. */
+ if (s == instr(s, separator)) {
+ s += separator_len;
+ }
+#endif
const char * e = s + strlen(string);
const char * category_end = NULL;
const char * saved_first = NULL; I can create pull request if you are inclined to accept it. Thank you |
Thank you for your comprehensive analysis. Yes, I'd be inclined to accept the patch. The one thing I might want to change is to not do this just for Solaris. Locale names are documented as being opaque. It would be legal if libc used control characters entirely to spell them. That said, it is a basic human desire to name things. Posix tried to not have a way of finding the current locale, but was forced eventually to add that capability. (Although the positional notation used by Solaris and others is close to not being human readable, since you have to have memorized or look up which position means which category.) So parsing a locale is fraught with the possibility of getting it wrong. Yet all systems known to me are of the name=value form or the positional form. This leading slash is an additional wrinkle. My guess is that a leading separator string in any system is more likely to mean what it does in Solaris than that there is an empty category (which would be illegal, since there always has to be a locale.) Therefore, I'd be inclined to pull out the |
This was fixed by #23199 |
Description
Perl 5.40 built on recent Solaris 11 reports an error:
This happens only when composite locales are reported by
setlocale(3C)
. In my case:The problem is that
setlocale(3C)
reports a slash at the beginning. Here is except from man page:The function
S_parse_LC_ALL_string
does not expect that slash and thinks that there is additinal (empty) locale definition. And exits with an error as there is now unexpected number of locales detected from the string.Steps to Reproduce
Compile on Solaris, use force the
setlocale(3C)
to use composite locales. For example viaRun
perl -e 0
.Expected behavior
See perl exit cleanly without any error.
Perl configuration
The text was updated successfully, but these errors were encountered: