]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: remove terminating \r and \n from windows error messages
authorAlex Brainman <alex.brainman@gmail.com>
Mon, 13 Dec 2010 06:02:01 +0000 (17:02 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Mon, 13 Dec 2010 06:02:01 +0000 (17:02 +1100)
R=rsc, peterGo
CC=golang-dev
https://golang.org/cl/3095042

src/pkg/syscall/syscall_windows.go

index 5d045862cae9537b1dc37f07de375e086330c672..38bd063b0ad46c99346fb9531f3ee39a9bd01a95 100644 (file)
@@ -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)) }