One minor difference between the gc and gccgo libraries is that the error messages returned by the gc library force the first letter of the error message to be lower case. This normally doesn't matter, but of course it does matter for code that compares error strings directly. Such code is of course non-portable, but people do write it, and gccgo should behave the same as gc on the same system. This patch does the lower case forcing in the gccgo library, the same way as it is done in the gc library. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 767d1b1ee0cf libgo/go/syscall/errstr.go --- a/libgo/go/syscall/errstr.go Sat Nov 10 12:21:49 2012 -0800 +++ b/libgo/go/syscall/errstr.go Mon Nov 12 11:31:07 2012 -0800 @@ -6,22 +6,27 @@ package syscall -//sysnb strerror_r(errnum int, buf []byte) (err error) +//sysnb strerror_r(errnum int, buf []byte) (err Errno) //strerror_r(errnum _C_int, buf *byte, buflen Size_t) _C_int func Errstr(errnum int) string { for len := 128; ; len *= 2 { b := make([]byte, len) - err := strerror_r(errnum, b) - if err == nil { + errno := strerror_r(errnum, b) + if errno == 0 { i := 0 for b[i] != 0 { i++ } + // Lowercase first letter: Bad -> bad, but + // STREAM -> STREAM. + if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' { + b[0] += 'a' - 'A' + } return string(b[:i]) } - if err != ERANGE { - return "Errstr failure" + if errno != ERANGE { + return "errstr failure" } } } diff -r 767d1b1ee0cf libgo/go/syscall/errstr_linux.go --- a/libgo/go/syscall/errstr_linux.go Sat Nov 10 12:21:49 2012 -0800 +++ b/libgo/go/syscall/errstr_linux.go Mon Nov 12 11:31:07 2012 -0800 @@ -19,5 +19,10 @@ for b[i] != 0 { i++ } + // Lowercase first letter: Bad -> bad, but STREAM -> STREAM. + if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' { + c := b[0] + 'a' - 'A' + return string(c) + string(b[1:i]) + } return string(b[:i]) } diff -r 767d1b1ee0cf libgo/go/syscall/errstr_nor.go --- a/libgo/go/syscall/errstr_nor.go Sat Nov 10 12:21:49 2012 -0800 +++ b/libgo/go/syscall/errstr_nor.go Mon Nov 12 11:31:07 2012 -0800 @@ -25,7 +25,15 @@ for b[i] != 0 { i++ } - s := string(b[:i]) + + // Lowercase first letter: Bad -> bad, but STREAM -> STREAM. + var s string + if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' { + c := b[0] + 'a' - 'A' + s = string(c) + string(b[1:i]) + } else { + s = string(b[:i]) + } errstr_lock.Unlock()