Commit 86f2731e by Ian Lance Taylor

syscall: Force first letter of error message to lower case.

From-SVN: r193449
parent 36a41ef1
...@@ -6,22 +6,27 @@ ...@@ -6,22 +6,27 @@
package syscall 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 //strerror_r(errnum _C_int, buf *byte, buflen Size_t) _C_int
func Errstr(errnum int) string { func Errstr(errnum int) string {
for len := 128; ; len *= 2 { for len := 128; ; len *= 2 {
b := make([]byte, len) b := make([]byte, len)
err := strerror_r(errnum, b) errno := strerror_r(errnum, b)
if err == nil { if errno == 0 {
i := 0 i := 0
for b[i] != 0 { for b[i] != 0 {
i++ 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]) return string(b[:i])
} }
if err != ERANGE { if errno != ERANGE {
return "Errstr failure" return "errstr failure"
} }
} }
} }
...@@ -19,5 +19,10 @@ func Errstr(errnum int) string { ...@@ -19,5 +19,10 @@ func Errstr(errnum int) string {
for b[i] != 0 { for b[i] != 0 {
i++ 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]) return string(b[:i])
} }
...@@ -25,7 +25,15 @@ func Errstr(errno int) string { ...@@ -25,7 +25,15 @@ func Errstr(errno int) string {
for b[i] != 0 { for b[i] != 0 {
i++ 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() errstr_lock.Unlock()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment