mirror of
https://github.com/golang/go
synced 2024-11-24 23:07:56 -07:00
cmd/yacc/units.y: update comment, give better error messages when $GOROOT not set
R=r, golang-dev CC=golang-dev https://golang.org/cl/5698062
This commit is contained in:
parent
4af3dda41b
commit
bdca78e1a7
@ -5,3 +5,6 @@
|
||||
units: yacc.go units.y
|
||||
go run yacc.go -p units_ units.y
|
||||
go build -o units y.go
|
||||
|
||||
clean:
|
||||
rm -f y.go y.output units
|
||||
|
@ -15,9 +15,8 @@
|
||||
// example of a Go yacc program
|
||||
// usage is
|
||||
// go tool yacc -p "units_" units.y (produces y.go)
|
||||
// 6g y.go
|
||||
// 6l y.6
|
||||
// ./6.out $GOROOT/src/cmd/yacc/units
|
||||
// go build -o units y.go
|
||||
// ./units $GOROOT/src/cmd/yacc/units.txt
|
||||
// you have: c
|
||||
// you want: furlongs/fortnight
|
||||
// * 1.8026178e+12
|
||||
@ -288,9 +287,14 @@ func main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
file = os.Getenv("GOROOT") + "/src/cmd/yacc/units.txt"
|
||||
if dir := os.Getenv("GOROOT"); dir != "" {
|
||||
file = dir + "/src/cmd/yacc/units.txt"
|
||||
}
|
||||
if flag.NArg() > 0 {
|
||||
file = flag.Arg(0)
|
||||
} else if file == "" {
|
||||
fmt.Fprintf(os.Stderr, "can not find data file units.txt; provide it as argument or set $GOROOT\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
f, err := os.Open(file)
|
||||
|
Loading…
Reference in New Issue
Block a user