-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/scanner: don't eat \r in comments if that shortens the comment
For consistent formatting across platforms we strip \r's from comments. This happens in the go/scanner which already does this for raw string literals where it is mandated by the spec. But if a (sequence of) \r appears in a regular (/*-style) comment between a * and a /, removing that (sequence of) \r shortens that text segment to */ which terminates the comment prematurely. Don't do it. As an aside, a better approach would be to not touch comments, (and raw string literals for that matter) in the scanner and leave the extra processing to clients. That is the approach taken by the cmd/compile/internal/syntax package. However, we probably can't change the semantics here too much, so just do the minimal change that doesn't produce invalid comments. It's an esoteric case after all. Fixes #11151. Change-Id: Ib4dcb52094f13c235e840c9672e439ea65fef961 Reviewed-on: https://go-review.googlesource.com/87498 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
- Loading branch information
Showing
3 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters