]> Cypherpunks.ru repositories - gostls13.git/commitdiff
time: unconditionally use RegLoadMUIString on Windows
authorqmuntal <quimmuntal@gmail.com>
Tue, 12 Sep 2023 13:32:22 +0000 (15:32 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Thu, 14 Sep 2023 07:20:34 +0000 (07:20 +0000)
RegLoadMUIString is supported on Windows Vista and later, so this
should be safe to do unconditionally.

While here, also unconditionally use GetDynamicTimeZoneInformation
in syscall/windows/registry tests, since it's also supported on Windows
Vista and later.

Change-Id: Ifa32a81f4727d4810f2b9ccc814aa77a43513e59
Reviewed-on: https://go-review.googlesource.com/c/go/+/527595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

src/internal/syscall/windows/registry/registry_test.go
src/internal/syscall/windows/registry/syscall.go
src/internal/syscall/windows/registry/value.go
src/time/zoneinfo_windows.go
src/time/zoneinfo_windows_test.go

index 278b0b491178d59d9d178bb988017243077ea004..afe7a5d1c3ffa44591dd9c722389153c835ec4c3 100644 (file)
@@ -599,12 +599,6 @@ func TestInvalidValues(t *testing.T) {
 }
 
 func TestGetMUIStringValue(t *testing.T) {
-       if err := registry.LoadRegLoadMUIString(); err != nil {
-               t.Skip("regLoadMUIString not supported; skipping")
-       }
-       if err := procGetDynamicTimeZoneInformation.Find(); err != nil {
-               t.Skipf("%s not supported; skipping", procGetDynamicTimeZoneInformation.Name)
-       }
        var dtzi DynamicTimezoneinformation
        if _, err := GetDynamicTimeZoneInformation(&dtzi); err != nil {
                t.Fatal(err)
index cb315adadedf728a3f356bbc09d6f31c0e242908..8e730916a969734d80f26868eb018ec87aa21276 100644 (file)
@@ -17,10 +17,6 @@ const (
        _ERROR_NO_MORE_ITEMS syscall.Errno = 259
 )
 
-func LoadRegLoadMUIString() error {
-       return procRegLoadMUIStringW.Find()
-}
-
 //sys  regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) = advapi32.RegCreateKeyExW
 //sys  regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) = advapi32.RegDeleteKeyW
 //sys  regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) = advapi32.RegSetValueExW
index 7dfee0330fe3515784780269f87710adba7000cc..bda16fda5d265abfbf280cd5bc0d5e6dd2ef6018 100644 (file)
@@ -115,9 +115,6 @@ func (k Key) GetStringValue(name string) (val string, valtype uint32, err error)
 // the specified value name associated with an open key k.
 // If the value name doesn't exist or the localized string value
 // can't be resolved, GetMUIStringValue returns ErrNotExist.
-// GetMUIStringValue panics if the system doesn't support
-// regLoadMUIString; use LoadRegLoadMUIString to check if
-// regLoadMUIString is supported before calling this function.
 func (k Key) GetMUIStringValue(name string) (string, error) {
        pname, err := syscall.UTF16PtrFromString(name)
        if err != nil {
index 76d79759f7de9cde67bfc22beea3954046882a50..c9f38ea3e058d874f4dac9f1a8c6ab1765da8ac3 100644 (file)
@@ -20,8 +20,8 @@ var platformZoneSources []string // none: Windows uses system calls instead
 // time apply to all previous and future years as well.
 
 // matchZoneKey checks if stdname and dstname match the corresponding key
-// values "MUI_Std" and MUI_Dlt" or "Std" and "Dlt" (the latter down-level
-// from Vista) in the kname key stored under the open registry key zones.
+// values "MUI_Std" and MUI_Dlt" or "Std" and "Dlt" in the kname key stored
+// under the open registry key zones.
 func matchZoneKey(zones registry.Key, kname string, stdname, dstname string) (matched bool, err2 error) {
        k, err := registry.OpenKey(zones, kname, registry.READ)
        if err != nil {
@@ -30,12 +30,10 @@ func matchZoneKey(zones registry.Key, kname string, stdname, dstname string) (ma
        defer k.Close()
 
        var std, dlt string
-       if err = registry.LoadRegLoadMUIString(); err == nil {
-               // Try MUI_Std and MUI_Dlt first, fallback to Std and Dlt if *any* error occurs
-               std, err = k.GetMUIStringValue("MUI_Std")
-               if err == nil {
-                       dlt, err = k.GetMUIStringValue("MUI_Dlt")
-               }
+       // Try MUI_Std and MUI_Dlt first, fallback to Std and Dlt if *any* error occurs
+       std, err = k.GetMUIStringValue("MUI_Std")
+       if err == nil {
+               dlt, err = k.GetMUIStringValue("MUI_Dlt")
        }
        if err != nil { // Fallback to Std and Dlt
                if std, _, err = k.GetStringValue("Std"); err != nil {
index f23d9dcecb83ad2d6dd1209f9f9ef3912753c7a4..5196b8e1de027a354e54051bb167711fa80acd87 100644 (file)
@@ -45,12 +45,10 @@ func TestToEnglishName(t *testing.T) {
        defer k.Close()
 
        var std, dlt string
-       if err = registry.LoadRegLoadMUIString(); err == nil {
-               // Try MUI_Std and MUI_Dlt first, fallback to Std and Dlt if *any* error occurs
-               std, err = k.GetMUIStringValue("MUI_Std")
-               if err == nil {
-                       dlt, err = k.GetMUIStringValue("MUI_Dlt")
-               }
+       // Try MUI_Std and MUI_Dlt first, fallback to Std and Dlt if *any* error occurs
+       std, err = k.GetMUIStringValue("MUI_Std")
+       if err == nil {
+               dlt, err = k.GetMUIStringValue("MUI_Dlt")
        }
        if err != nil { // Fallback to Std and Dlt
                if std, _, err = k.GetStringValue("Std"); err != nil {