unix: fix infinite recursion in itoa

Bring in http://golang.org/cl/138650044 from syscall package.

Change-Id: I554b0b31b981c682b6826644564971321a55c9e4
Reviewed-on: https://go-review.googlesource.com/10030
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Ian Lance Taylor
2015-05-13 20:12:53 +00:00
parent 3dec8fc77c
commit 082a6a3a8b
3 changed files with 29 additions and 1 deletions
+5 -1
View File
@@ -8,8 +8,12 @@ package unix
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
if val < 0 {
return "-" + itoa(-val)
return "-" + uitoa(uint(-val))
}
return uitoa(uint(val))
}
func uitoa(val uint) string {
var buf [32]byte // big enough for int64
i := len(buf) - 1
for val >= 10 {