diff options
| author | Alex Brainman <alex.brainman@gmail.com> | 2015-12-21 16:16:06 +1100 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2016-01-08 16:15:59 +0000 |
| commit | d75acd67eccbfe6f03b6474baea3b569cd0135d6 (patch) | |
| tree | 5a0770b3174ea63ecef80d2b2a8adb84fd559588 /src/internal/syscall/windows | |
| parent | 5755c011de9c75a05825b0c08ce61c77c5207f1d (diff) | |
| download | go-d75acd67eccbfe6f03b6474baea3b569cd0135d6.tar.xz | |
internal/syscall/windows: correct GetACP and MultiByteToWideChar
CL 4310 introduced these functions, but their
implementation does not match with their published
documentation. Correct the implementation.
Change-Id: I285e41f9c7c5fc4e550ff59b0adb8b2bcbf6737a
Reviewed-on: https://go-review.googlesource.com/17997
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/internal/syscall/windows')
| -rw-r--r-- | src/internal/syscall/windows/syscall_windows.go | 4 | ||||
| -rw-r--r-- | src/internal/syscall/windows/zsyscall_windows.go | 21 |
2 files changed, 9 insertions, 16 deletions
diff --git a/src/internal/syscall/windows/syscall_windows.go b/src/internal/syscall/windows/syscall_windows.go index e5c1cd600c..165e8945ec 100644 --- a/src/internal/syscall/windows/syscall_windows.go +++ b/src/internal/syscall/windows/syscall_windows.go @@ -139,5 +139,5 @@ func Rename(oldpath, newpath string) error { return MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING) } -//sys GetACP() (acp uint, err error) = kernel32.GetACP -//sys MultiByteToWideChar(codePage uint, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int, err error) = kernel32.MultiByteToWideChar +//sys GetACP() (acp uint32) = kernel32.GetACP +//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar diff --git a/src/internal/syscall/windows/zsyscall_windows.go b/src/internal/syscall/windows/zsyscall_windows.go index fd614f8897..de41786c76 100644 --- a/src/internal/syscall/windows/zsyscall_windows.go +++ b/src/internal/syscall/windows/zsyscall_windows.go @@ -50,23 +50,16 @@ func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { return } -func MultiByteToWideChar(codePage uint, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int, err error) { - r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) - nwrite = int(r0) - if nwrite == 0 { - if e1 != 0 { - err = error(e1) - } else { - err = syscall.EINVAL - } - } +func GetACP() (acp uint32) { + r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) + acp = uint32(r0) return } -func GetACP() (acp uint, err error) { - r0, _, e1 := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) - acp = uint(r0) - if acp == 0 { +func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) { + r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) + nwrite = int32(r0) + if nwrite == 0 { if e1 != 0 { err = error(e1) } else { |
