summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-12 19:34:52 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-12 19:34:52 +0000
commitd945c17c5bf5dd51b5bbc5066fe0d5c0e574d943 (patch)
tree3ffc2f248e7a0d59729ef6a812638e41e11d1564 /libgo
parentf59282967bf79149ebd41aa475ca5dd9e496865f (diff)
downloadgcc-d945c17c5bf5dd51b5bbc5066fe0d5c0e574d943.tar.gz
syscall: Force first letter of error message to lower case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193449 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/syscall/errstr.go15
-rw-r--r--libgo/go/syscall/errstr_linux.go5
-rw-r--r--libgo/go/syscall/errstr_nor.go10
3 files changed, 24 insertions, 6 deletions
diff --git a/libgo/go/syscall/errstr.go b/libgo/go/syscall/errstr.go
index d003441ae9e..aa656ca7cbe 100644
--- a/libgo/go/syscall/errstr.go
+++ b/libgo/go/syscall/errstr.go
@@ -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 --git a/libgo/go/syscall/errstr_linux.go b/libgo/go/syscall/errstr_linux.go
index 3dbd20b07a4..d10476d3cb1 100644
--- a/libgo/go/syscall/errstr_linux.go
+++ b/libgo/go/syscall/errstr_linux.go
@@ -19,5 +19,10 @@ func Errstr(errnum int) string {
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 --git a/libgo/go/syscall/errstr_nor.go b/libgo/go/syscall/errstr_nor.go
index 963c7846026..796561adda0 100644
--- a/libgo/go/syscall/errstr_nor.go
+++ b/libgo/go/syscall/errstr_nor.go
@@ -25,7 +25,15 @@ func Errstr(errno int) string {
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()