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

go/scanner: rewrite \r\n to \n in comments #3961

Closed
gopherbot opened this issue Aug 16, 2012 · 7 comments
Closed

go/scanner: rewrite \r\n to \n in comments #3961

gopherbot opened this issue Aug 16, 2012 · 7 comments
Milestone

Comments

@gopherbot
Copy link

by accipiter:

What steps will reproduce the problem?
1. Copy the code from http://play.golang.org/p/3nLyaBE-Os (or any commented code) into
your favourite text editor
2. Make sure all EOL is incorrectly set/converted to CR/LF
3. Save file as eg. crlf.go
3. Run go fmt crlf.go

What is the expected output?
A crlf.go file where all the EOL are LF

What do you see instead?
Commented lines is still using CR/LF as EOL while all other lines is converted to LF.
While it doesn't effect compiling, I can see nothing good coming from mixed usage.

Which operating system are you using?
Windows

Which version are you using?
go1.0.2
@robpike
Copy link
Contributor

robpike commented Aug 17, 2012

Comment 1:

Labels changed: added priority-later, removed priority-triage.

Owner changed to @griesemer.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Aug 31, 2012

Comment 2:

The previous issue about this was issue #680. We decided that \r is ignored so that \r\n
becomes \n in multiline `` literals. So this seems like just an update to go/scanner to
do the same in comments.

@griesemer
Copy link
Contributor

Comment 3:

Note: go/scanner is doing the right thing and stripping the CRs in comments,
scanner_test.go tests for it. The CR must be sneaking in elsewhere, possibly via
go/printer.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 4:

Labels changed: added go1.1.

@griesemer
Copy link
Contributor

Comment 5:

I cannot reproduce this: Try e.g.: http://play.golang.org/p/qNfUiJ5lGf which takes your
example, introduces the \r\n's and then invokes gofmt on it. The \r\n's are gone
afterwards.
(You need to copy playground source into a local file, say test.go, and run it with: "go
run test.go" because the gofmt executable is not available in the playground. Make sure
gofmt is in your $PATH).
Similarly, when storing the source as a file with \r\n line endings (crlf.go) and
applying both gofmt or go fmt, the \r\n's are gone and replaced by \n's everywhere.
Finally, go/scanner is testing explicitly that the \r's are gone.
Perhaps your favorite editor is doing something funny? I am going to close this. If you
have a concrete test case that misbehaves (executable source - no manual steps that rely
on some 3rd party editor), than you can reopen this. Thanks.

Status changed to WorkingAsIntended.

@rsc
Copy link
Contributor

rsc commented Sep 19, 2012

Comment 6:

I can reproduce this. Will show gri offline.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 19, 2012

Comment 7:

This is broken in go1.0.x but fixed at tip. It will be fixed in the
go1.1 release.

Status changed to Fixed.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants