Commit aae64f8c authored by Robert Griesemer's avatar Robert Griesemer

- exit godoc w/o crashing if negative tabwidth is provided

- minor related cleanups

R=rsc
http://go/go-review/1025026
parent 8b04ceff
...@@ -143,16 +143,13 @@ func main() { ...@@ -143,16 +143,13 @@ func main() {
flag.Usage = usage; flag.Usage = usage;
flag.Parse(); flag.Parse();
// Check usage first; get usage message out early. // Check usage: either server and no args, or command line and args
switch { if (*httpaddr != "") != (flag.NArg() == 0) {
case *httpaddr != "": usage();
if flag.NArg() != 0 { }
usage();
} if *tabwidth < 0 {
default: log.Exitf("negative tabwidth %d", *tabwidth);
if flag.NArg() == 0 {
usage();
}
} }
if err := os.Chdir(goroot); err != nil { if err := os.Chdir(goroot); err != nil {
...@@ -168,8 +165,10 @@ func main() { ...@@ -168,8 +165,10 @@ func main() {
log.Stderrf("Go Documentation Server\n"); log.Stderrf("Go Documentation Server\n");
log.Stderrf("address = %s\n", *httpaddr); log.Stderrf("address = %s\n", *httpaddr);
log.Stderrf("goroot = %s\n", goroot); log.Stderrf("goroot = %s\n", goroot);
log.Stderrf("cmdroot = %s\n", *cmdroot);
log.Stderrf("pkgroot = %s\n", *pkgroot); log.Stderrf("pkgroot = %s\n", *pkgroot);
log.Stderrf("tmplroot = %s\n", *tmplroot); log.Stderrf("tmplroot = %s\n", *tmplroot);
log.Stderrf("tabwidth = %d\n", *tabwidth);
handler = loggingHandler(handler); handler = loggingHandler(handler);
} }
......
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