]> Cypherpunks repositories - gostls13.git/commit
fmt: require newlines to match when scanning with a format
authorRob Pike <r@golang.org>
Fri, 5 Jun 2015 21:23:54 +0000 (14:23 -0700)
committerRob Pike <r@golang.org>
Fri, 12 Jun 2015 20:14:14 +0000 (20:14 +0000)
commit57f4b43078e5f24a08088fb5ef91bc9f0e432015
tree590a340a955bacd999e4c76b162b78db9040b603
parentab89378cb73003058d1f9707535610af468752fc
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>
src/fmt/doc.go
src/fmt/scan.go
src/fmt/scan_test.go