Fix "PR c++/92804 ICE trying to use concept as a nested-name-specifier"
[official-gcc.git] / libgo / go / syscall / errstr.go
blob6c2441d364d720108d3ac2ea8b3125d2c041d7bc
1 // errstr.go -- Error strings.
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // +build !hurd
8 // +build !linux
10 package syscall
12 //sysnb strerror_r(errnum int, buf []byte) (err Errno)
13 //strerror_r(errnum _C_int, buf *byte, buflen Size_t) _C_int
15 func Errstr(errnum int) string {
16 for len := 128; ; len *= 2 {
17 b := make([]byte, len)
18 errno := strerror_r(errnum, b)
19 if errno == 0 {
20 i := 0
21 for b[i] != 0 {
22 i++
24 // Lowercase first letter: Bad -> bad, but
25 // STREAM -> STREAM.
26 if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
27 b[0] += 'a' - 'A'
29 return string(b[:i])
31 if errno != ERANGE {
32 return "errstr failure"