1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:14:41 -07:00

fmt: scan FALSE correctly

Fixes bug 2922.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5642072
This commit is contained in:
Rob Pike 2012-02-09 14:12:55 +11:00
parent 00d0f8e320
commit c0e74b63cf
2 changed files with 5 additions and 1 deletions

View File

@ -512,7 +512,7 @@ func (s *ss) scanBool(verb rune) bool {
}
return true
case 'f', 'F':
if s.accept("aL") && (!s.accept("lL") || !s.accept("sS") || !s.accept("eE")) {
if s.accept("aA") && (!s.accept("lL") || !s.accept("sS") || !s.accept("eE")) {
s.error(boolError)
}
return false

View File

@ -317,6 +317,7 @@ var overflowTests = []ScanTest{
{"(1-1e500i)", &complex128Val, 0},
}
var truth bool
var i, j, k int
var f float64
var s, t string
@ -350,6 +351,9 @@ var multiTests = []ScanfMultiTest{
// Bad UTF-8: should see every byte.
{"%c%c%c", "\xc2X\xc2", args(&r1, &r2, &r3), args(utf8.RuneError, 'X', utf8.RuneError), ""},
// Fixed bugs
{"%v%v", "FALSE23", args(&truth, &i), args(false, 23), ""},
}
func testScan(name string, t *testing.T, scan func(r io.Reader, a ...interface{}) (int, error)) {