From: Alex Brainman Date: Mon, 13 Dec 2010 06:02:01 +0000 (+1100) Subject: syscall: remove terminating \r and \n from windows error messages X-Git-Tag: weekly.2010-12-15~50 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=84713d46f6acc2f64b544e7ede1326a2d3a46d09;p=gostls13.git syscall: remove terminating \r and \n from windows error messages R=rsc, peterGo CC=golang-dev https://golang.org/cl/3095042 --- diff --git a/src/pkg/syscall/syscall_windows.go b/src/pkg/syscall/syscall_windows.go index 5d045862ca..38bd063b0a 100644 --- a/src/pkg/syscall/syscall_windows.go +++ b/src/pkg/syscall/syscall_windows.go @@ -161,7 +161,10 @@ func Errstr(errno int) string { if err != 0 { return "error " + str(errno) + " (FormatMessage failed with err=" + str(err) + ")" } - return string(utf16.Decode(b[0 : n-1])) + // trim terminating \r and \n + for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- { + } + return string(utf16.Decode(b[:n])) } func Exit(code int) { ExitProcess(uint32(code)) }