setlocale(LC_ALL, "LC_foo=bar; LC_baz=gah") is legal. Any categories
omitted in the string are set to "C". Prior to this commit the omitted
categories were unchanged
* other platforms do it differently, so we have to handle all cases
* ourselves */
* other platforms do it differently, so we have to handle all cases
* ourselves */
const char * s = locale;
const char * e = locale + strlen(locale);
const char * p = s;
const char * s = locale;
const char * e = locale + strlen(locale);
const char * p = s;
const char * name_start;
const char * name_end;
const char * name_start;
const char * name_end;
+ /* If the string that gives what to set doesn't include all categories,
+ * the omitted ones get set to "C". To get this behavior, first set
+ * all the individual categories to "C", and override the furnished
+ * ones below */
+ for (i = 0; i < LC_ALL_INDEX; i++) {
+ if (! emulate_setlocale(categories[i], "C", i, TRUE)) {
+ return NULL;
+ }
+ }
+
/* Parse through the category */
while (isWORDCHAR(*p)) {
/* Parse through the category */
while (isWORDCHAR(*p)) {
my $valid_string = "";
my $invalid_string = "";
my $valid_string = "";
my $invalid_string = "";
- foreach my $category (@valid_categories) {
+ # Deliberately don't include all categories, so as to test this situation
+ for my $i (0 .. @valid_categories - 2) {
+ my $category = $valid_categories[$i];
if ($category ne "LC_ALL") {
$invalid_string .= ";" if $invalid_string ne "";
$invalid_string .= "$category=foo_BAR";
if ($category ne "LC_ALL") {
$invalid_string .= ";" if $invalid_string ne "";
$invalid_string .= "$category=foo_BAR";