Commit 50ec8317 authored by Ryoichi KATO's avatar Ryoichi KATO Committed by Brad Fitzpatrick

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/46915Reviewed-by: default avatarRob Pike <r@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent cea92e8d
...@@ -123,8 +123,9 @@ var ErrFinalToken = errors.New("final token") ...@@ -123,8 +123,9 @@ var ErrFinalToken = errors.New("final token")
// After Scan returns false, the Err method will return any error that // After Scan returns false, the Err method will return any error that
// occurred during scanning, except that if it was io.EOF, Err // occurred during scanning, except that if it was io.EOF, Err
// will return nil. // will return nil.
// Scan panics if the split function returns 100 empty tokens without // Scan panics if the split function returns too many empty
// advancing the input. This is a common error mode for scanners. // tokens without advancing the input. This is a common error mode for
// scanners.
func (s *Scanner) Scan() bool { func (s *Scanner) Scan() bool {
if s.done { if s.done {
return false return false
...@@ -156,8 +157,8 @@ func (s *Scanner) Scan() bool { ...@@ -156,8 +157,8 @@ func (s *Scanner) Scan() bool {
} else { } else {
// Returning tokens not advancing input at EOF. // Returning tokens not advancing input at EOF.
s.empties++ s.empties++
if s.empties > 100 { if s.empties > maxConsecutiveEmptyReads {
panic("bufio.Scan: 100 empty tokens without progressing") panic("bufio.Scan: too many empty tokens without progressing")
} }
} }
return true return true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment