Commit 8401b19e authored by Rob Pike's avatar Rob Pike

cmd/doc: fix handling of paths like ./fmt

An error in string slice offsets caused the loop to run forever if the
first character in the argument was a period.

Fixes #10833.

Change-Id: Iefb6aac5cff8864fe93d08e2600cb07d82c6f6df
Reviewed-on: https://go-review.googlesource.com/10285Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 197aa9e6
......@@ -132,11 +132,12 @@ func parseArgs() (*build.Package, string, string) {
// slash+1: if there's no slash, the value is -1 and start is 0; otherwise
// start is the byte after the slash.
for start := slash + 1; start < len(arg); start = period + 1 {
period = start + strings.Index(arg[start:], ".")
period = strings.Index(arg[start:], ".")
symbol := ""
if period < 0 {
period = len(arg)
} else {
period += start
symbol = arg[period+1:]
}
// Have we identified a package already?
......
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