aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyoichi KATO <ryo1kato@gmail.com>2017-06-24 23:39:29 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2017-11-14 05:21:00 +0000
commit50ec831749fc40b30fd43cf0594d388500ea2887 (patch)
tree74c1f560372facda57700b0a6f85cdec209ddacd
parentcea92e8d130540969056be58be188a8487d90a88 (diff)
downloadgo-50ec831749fc40b30fd43cf0594d388500ea2887.tar.xz
bufio: Use maxConsecutiveEmptyReads instead of 100
Use maxConsecutiveEmptyReads const instead of hardcoded 100 in scan.go too. Change-Id: I993f353a3748f0d6bdefab38bf5cb224eea8a969 Reviewed-on: https://go-review.googlesource.com/46915 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/bufio/scan.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/bufio/scan.go b/src/bufio/scan.go
index 9f741c9830..40aaa4ab81 100644
--- a/src/bufio/scan.go
+++ b/src/bufio/scan.go
@@ -123,8 +123,9 @@ var ErrFinalToken = errors.New("final token")
// After Scan returns false, the Err method will return any error that
// occurred during scanning, except that if it was io.EOF, Err
// will return nil.
-// Scan panics if the split function returns 100 empty tokens without
-// advancing the input. This is a common error mode for scanners.
+// Scan panics if the split function returns too many empty
+// tokens without advancing the input. This is a common error mode for
+// scanners.
func (s *Scanner) Scan() bool {
if s.done {
return false
@@ -156,8 +157,8 @@ func (s *Scanner) Scan() bool {
} else {
// Returning tokens not advancing input at EOF.
s.empties++
- if s.empties > 100 {
- panic("bufio.Scan: 100 empty tokens without progressing")
+ if s.empties > maxConsecutiveEmptyReads {
+ panic("bufio.Scan: too many empty tokens without progressing")
}
}
return true