Signed-off-by: Francois Gouget fgouget@codeweavers.com --- It's more practical than running WineTest just for that and there are quite a few cases where the desired changes don't in fact happen.
testbot/bin/SetWinLocale | 107 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+)
diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale index 4f50ed555c..135c7b9b48 100755 --- a/testbot/bin/SetWinLocale +++ b/testbot/bin/SetWinLocale @@ -608,6 +608,62 @@ if ($OptShow) }
+# +# Helper to get the LCIDs +# + +my (%WinLCIDs, %WinKeyboardIds); + +sub GetWinKeyboardIds($) +{ + my ($Locale) = @_; + + # Look for that locale's keyboard id. + # Its first component is the locale's LCID. + my $Values = RegGetValues("$HKCU_USER_PROFILE\$Locale", "*:*"); + foreach my $VName (keys %$Values) + { + next if ($VName !~ /^[0-9A-F]{4}:/); + $WinKeyboardIds{$Locale} = [$VName]; + last; + } + $WinKeyboardIds{$Locale} ||= $Keyboards{$Locale}; + if (!$WinKeyboardIds{$Locale}) + { + FatalError("could not find the $Locale LCID and keyboard ids\n"); + } + + my $WinLCID = uc($WinKeyboardIds{$Locale}->[0]); + $WinLCID =~ s/:.*$//; + $WinLCIDs{$Locale} = $WinLCID; + + # Check our builtin information + if ($Keyboards{$Locale}) + { + my $LCID = uc($Keyboards{$Locale}->[0]); + $LCID =~ s/:.*$//; + if ($LCID ne $WinLCID) + { + FatalError("inconsistent $Locale LCID: expected $LCID, got $WinLCID\n"); + } + } + + return $WinKeyboardIds{$Locale}; +} + +sub GetLCID($) +{ + my ($Locale) = @_; + return undef if (!$Locale); + + GetWinKeyboardIds($Locale) if (!$WinLCIDs{$Locale}); + return $WinLCIDs{$Locale}; +} + +my $LCIDLocale = GetLCID($OptLocale); +my $LCIDSystem = GetLCID($OptSystem); + + # # Generate the intl.cpl configuration # @@ -738,5 +794,56 @@ if ($OptReboot) } }
+ +# +# Check that all the changes succeeded +# + +my $Success = 1; +sub CheckSetting($$$$;$) +{ + my ($Settings, $VName, $Expected, $For, $IgnoreCase) = @_; + + my $Value = $Settings->{$VName}; + if (defined $Value) + { + if ((!$IgnoreCase and $Value ne $Expected) or + ($IgnoreCase and uc($Value) ne uc($Expected))) + { + Error("expected $VName = $Expected but got $Value $For\n"); + $Success = 0; + } + } +} + +Debug(Elapsed($Start), " Checking the new locale settings\n"); +my $Settings = GetWinSettings($Debug); +ShowWinSettings($Settings) if ($Debug); +if ($OptLocale) +{ + CheckSetting($Settings, "Locale", "0000$LCIDLocale", "for --locale $OptLocale", 1); + CheckSetting($Settings, "LocaleName", $OptLocale, "for --locale $OptLocale"); +} +if ($OptKeyboard) +{ + CheckSetting($Settings, "InputMethod", $Keyboards{$OptKeyboard}->[0], "for --keyboard $OptKeyboard", 1); +} +if ($OptMUI) +{ + CheckSetting($Settings, "PreferredUILanguages", $OptMUI, "for --mui $OptMUI"); +} +if ($OptCountry) +{ + CheckSetting($Settings, "Country", $CountryId, "for --country $OptCountry"); + CheckSetting($Settings, "CountryName", $OptCountry, "for --country $OptCountry"); +} +if ($OptSystem) +{ + CheckSetting($Settings, "SysLanguage", $LCIDSystem, "for --system $OptSystem", 1); + CheckSetting($Settings, "SysLocale", "0000$LCIDSystem", "for --system $OptSystem", 1); +} +exit(1) if (!$Success); + + Debug(Elapsed($Start), " All done!\n"); exit(0);
The information is available on Windows 10.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/SetWinLocale | 43 +++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale index 135c7b9b48..e7ae3c0ced 100755 --- a/testbot/bin/SetWinLocale +++ b/testbot/bin/SetWinLocale @@ -376,7 +376,7 @@ while (@ARGV) }
# Check and untaint parameters -my ($KeyboardIds, $CountryId); +my $CountryId; if (!defined $Usage) { if (!defined $OptHostName) @@ -397,18 +397,6 @@ if (!defined $Usage) $OptLocale ||= $OptDefault; $OptSystem ||= $OptDefault; $OptMUI ||= $OptDefault; - $OptKeyboard ||= $OptDefault; - if (defined $OptKeyboard) - { - if (!exists $Keyboards{$OptKeyboard}) - { - # intl.cpl automatically pick the appropriate keyboard but, unlike - # for Windows' initial installation, it does not make it the - # default since the system has a keyboard already. - Warning("unknown keyboard '$OptKeyboard'. Letting intl.cpl use its default.\n"); - } - $KeyboardIds = $Keyboards{$OptKeyboard}; - } if (!defined $OptCountry and defined $OptDefault and $OptDefault =~ /-([A-Z]{2})$/) { @@ -561,7 +549,7 @@ sub GetWinSettings($) $Settings->{Country} = $Values->{Nation}; $Settings->{CountryName} = $Values->{Name}; } - if ($OptKeyboard or $All) + if (($OptKeyboard || $OptDefault) or $All) { $Settings->{InputMethod} = RegGetValue($HKCU_USER_PROFILE, "InputMethodOverride"); } @@ -660,9 +648,32 @@ sub GetLCID($) return $WinLCIDs{$Locale}; }
+sub GetKeyboardIds($) +{ + my ($Locale) = @_; + return undef if (!$Locale); + + GetWinKeyboardIds($Locale) if (!$WinKeyboardIds{$Locale}); + return $WinKeyboardIds{$Locale}; +} + my $LCIDLocale = GetLCID($OptLocale); my $LCIDSystem = GetLCID($OptSystem);
+my $KeyboardIds = GetKeyboardIds($OptKeyboard || $OptDefault); +if (!$KeyboardIds and ($OptKeyboard or $OptDefault)) +{ + if ($OptKeyboard) + { + FatalError("no known keyboard for the $OptKeyboard locale\n"); + } + # intl.cpl automatically pick the appropriate keyboard but, unlike + # for Windows' initial installation, it does not make it the + # default since the system has a keyboard already. + Warning("no known keyboard for the $OptDefault locale. Letting intl.cpl use its default.\n"); +} +$OptKeyboard ||= $OptDefault; +
# # Generate the intl.cpl configuration @@ -824,9 +835,9 @@ if ($OptLocale) CheckSetting($Settings, "Locale", "0000$LCIDLocale", "for --locale $OptLocale", 1); CheckSetting($Settings, "LocaleName", $OptLocale, "for --locale $OptLocale"); } -if ($OptKeyboard) +if ($KeyboardIds) { - CheckSetting($Settings, "InputMethod", $Keyboards{$OptKeyboard}->[0], "for --keyboard $OptKeyboard", 1); + CheckSetting($Settings, "InputMethod", $KeyboardIds->[0], "for --keyboard $OptKeyboard", 1); } if ($OptMUI) {