Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt: ScanState.ReadRune returns wrong size if Reader is not a io.RuneReader #8512

Closed
gopherbot opened this issue Aug 11, 2014 · 3 comments
Closed
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 11, 2014

by kwalsh@holycross.edu:

What does 'go version' print? go version go1.3 linux/amd64

What steps reproduce the problem?

Example here: http://play.golang.org/p/H-KFkROfOJ
1. Call fmt.Sscanf("Hello", "%s", &x) where x implements Scanner.
2. Within x's Scan() function, call r, n, err := state.ReadRune().

What happened?
ReadRune() returns 'H', 0, nil

What should have happened instead?
ReadRune() should have returned 'H', 1, nil

Please provide any additional information below.
pkg/fmt/scan.go contains this code:
   356  func (r *readRune) ReadRune() (rr rune, size int, err error) {
   357      r.buf[0], err = r.readByte()
   358      if err != nil {
   359          return 0, 0, err
   360      }
   361      if r.buf[0] < utf8.RuneSelf { // fast check for common ASCII case
   362          rr = rune(r.buf[0])
   363          return
   364      }
The fast case needs to set the size, e.g.:
   size = utf8.RuneLen(rr)
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Aug 11, 2014

Comment 1:

Labels changed: added repo-main, release-go1.4.

Status changed to Accepted.

@gopherbot
Copy link
Author

@gopherbot gopherbot commented Aug 15, 2014

Comment 2:

CL https://golang.org/cl/130090043 mentions this issue.
@robpike
Copy link
Contributor

@robpike robpike commented Aug 15, 2014

Comment 3:

This issue was closed by revision 4edcbe0.

Status changed to Fixed.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman added a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Fixes golang#8512.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/130090043
wheatman added a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
Fixes golang#8512.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/130090043
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.