1
0
mirror of https://github.com/golang/go synced 2024-10-05 09:11:21 -06:00
go/src/fmt
Rob Pike 57f4b43078 fmt: require newlines to match when scanning with a format
The documentation says that newlines behave like this:

Scan etc.: newlines are spaces.
Scanln etc.: newlines terminate the scan.
Scanf etc.: newlines must match in input and format.

The code did not implement this behavior in all cases,
especially for Scanf. Make it behave:

- Fix the handling of spaces and newlines in ss.Advance.
The code is longer but now behaves as it should.

- Delete the reuse of the current ss in newScanState.
There is really no need, since it's only used in recursive
calls to Scan etc., and the flags are likely wrong. Simpler
just to allocate a new one every time, and likelier to
be correct.

Fixes #10862.

Change-Id: If060ac021017346723b0d62de4e5a305da898f68
Reviewed-on: https://go-review.googlesource.com/10991
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-12 20:14:14 +00:00
..
doc.go fmt: require newlines to match when scanning with a format 2015-06-12 20:14:14 +00:00
export_test.go
fmt_test.go fmt: fix buffer underflow for negative integers 2015-06-02 13:55:40 +00:00
format.go fmt: fix buffer underflow for negative integers 2015-06-02 13:55:40 +00:00
norace_test.go fmt: skip malloc test under race detector 2015-05-11 17:45:26 +00:00
print.go fmt: prevent panic from %.[] 2015-05-05 21:07:38 +00:00
race_test.go fmt: skip malloc test under race detector 2015-05-11 17:45:26 +00:00
scan_test.go fmt: require newlines to match when scanning with a format 2015-06-12 20:14:14 +00:00
scan.go fmt: require newlines to match when scanning with a format 2015-06-12 20:14:14 +00:00
stringer_test.go