]> Cypherpunks repositories - gostls13.git/commit
fmt: document and adjust Scanf space handling to eliminate a few paradoxes
authorRuss Cox <rsc@golang.org>
Thu, 6 Oct 2016 21:08:44 +0000 (17:08 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 7 Oct 2016 03:46:50 +0000 (03:46 +0000)
commit0db9518ab30f35c7c185aed337037e8305a98b34
tree6a0a61f102ee67cd0d3a684c4de4151c3d6d176c
parent23606c6fc4ed21d563f8e9a49b2ed6e18489e222
fmt: document and adjust Scanf space handling to eliminate a few paradoxes

This CL makes minor adjustment to the handling of spaces and newlines
and then documents the result.

The semantic adjustment mainly concerns the handling of a run of
spaces following a newline in the format, like in "\n ".
Previously, that run of spaces was ignored entirely, leading to paradoxes
like the format "1 \n 2" not matching itself as input.
Now, spaces following a newline in the format match zero or more
spaces following the corresponding newline in the input.

The changes to the test suite show how minor the semantic adjustments are
and how they make the behavior more regular than previously.

This CL also updates the documentation to explain the handling of
spaces more precisely, incorporating the draft from CL 17723 but
describing the newly introduced behavior.

Fixes #13565.

Change-Id: I129666e9ba42de3c28b67f75cb47488e9a4c1867
Reviewed-on: https://go-review.googlesource.com/30611
Reviewed-by: Rob Pike <r@golang.org>
src/fmt/doc.go
src/fmt/scan.go
src/fmt/scan_test.go