From: Rob Pike Date: Wed, 3 Apr 2013 17:40:04 +0000 (-0700) Subject: bufio: make it a little clearer how the default Scanner splits lines. X-Git-Tag: go1.1rc2~205 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=995eb2cf5166908d2eddde6829c79aa5908ef11b;p=gostls13.git bufio: make it a little clearer how the default Scanner splits lines. Just commentary, no semantic change. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/8329043 --- diff --git a/src/pkg/bufio/scan.go b/src/pkg/bufio/scan.go index d94f7f9adc..486853e6bc 100644 --- a/src/pkg/bufio/scan.go +++ b/src/pkg/bufio/scan.go @@ -16,7 +16,7 @@ import ( // the Scan method will step through the 'tokens' of a file, skipping // the bytes between the tokens. The specification of a token is // defined by a split function of type SplitFunc; the default split -// function breaks the input into lines with newlines stripped. Split +// function breaks the input into lines with line termination stripped. Split // functions are defined in this package for scanning a file into // lines, bytes, UTF-8-encoded runes, and space-delimited words. The // client may instead provide a custom split function. @@ -70,6 +70,7 @@ const ( ) // NewScanner returns a new Scanner to read from r. +// The split function defaults to ScanLines. func NewScanner(r io.Reader) *Scanner { return &Scanner{ r: r, @@ -257,7 +258,7 @@ func dropCR(data []byte) []byte { // ScanLines is a split function for a Scanner that returns each line of // text, stripped of any trailing end-of-line marker. The returned line may // be empty. The end-of-line marker is one optional carriage return followed -// by one mandatory newline. In regular expression notation, it is `\r?\n'. +// by one mandatory newline. In regular expression notation, it is `\r?\n`. // The last non-empty line of input will be returned even if it has no // newline. func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {