diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-08-03 17:26:15 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-08-03 17:31:49 +0200 |
| commit | b757d264230d65f988e08158e096a09497d39eb4 (patch) | |
| tree | e20ec608a2ec8ebf603fa7aa060eb9723c4780b9 /src/pkg/fmt/scan.go | |
| parent | 5976088995f5c0d0bcada7d491fda4b6245e54e0 (diff) | |
| download | golang-b757d264230d65f988e08158e096a09497d39eb4.tar.gz | |
Imported Upstream version 2011.07.29
Diffstat (limited to 'src/pkg/fmt/scan.go')
| -rw-r--r-- | src/pkg/fmt/scan.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/pkg/fmt/scan.go b/src/pkg/fmt/scan.go index d93a8c1da..259451d02 100644 --- a/src/pkg/fmt/scan.go +++ b/src/pkg/fmt/scan.go @@ -271,14 +271,12 @@ func notSpace(r int) bool { return !unicode.IsSpace(r) } - // skipSpace provides Scan() methods the ability to skip space and newline characters // in keeping with the current scanning mode set by format strings and Scan()/Scanln(). func (s *ss) SkipSpace() { s.skipSpace(false) } - // readRune is a structure to enable reading UTF-8 encoded code points // from an io.Reader. It is used if the Reader given to the scanner does // not already implement io.RuneReader. @@ -337,7 +335,6 @@ func (r *readRune) ReadRune() (rune int, size int, err os.Error) { return } - var ssFree = newCache(func() interface{} { return new(ss) }) // Allocate a new ss struct or grab a cached one. @@ -411,7 +408,6 @@ func (s *ss) skipSpace(stopAtNewline bool) { } } - // token returns the next space-delimited string from the input. It // skips white space. For Scanln, it stops at newlines. For Scan, // newlines are treated as spaces. @@ -554,9 +550,11 @@ func (s *ss) getBase(verb int) (base int, digits string) { // scanNumber returns the numerical string with specified digits starting here. func (s *ss) scanNumber(digits string, haveDigits bool) string { - s.notEOF() - if !haveDigits && !s.accept(digits) { - s.errorString("expected integer") + if !haveDigits { + s.notEOF() + if !s.accept(digits) { + s.errorString("expected integer") + } } for s.accept(digits) { } |
