Commit 5621b09d authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: simplify import path handling

Change-Id: I64c9b4c4978520a9bc989b7fd7d5708d364dc88a
Reviewed-on: https://go-review.googlesource.com/19755
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent 5fc43c94
...@@ -397,11 +397,6 @@ type Dlist struct { ...@@ -397,11 +397,6 @@ type Dlist struct {
field *Type field *Type
} }
type Idir struct {
link *Idir
dir string
}
// argument passing to/from // argument passing to/from
// smagic and umagic // smagic and umagic
type Magic struct { type Magic struct {
...@@ -519,8 +514,6 @@ var Tptr EType // either TPTR32 or TPTR64 ...@@ -519,8 +514,6 @@ var Tptr EType // either TPTR32 or TPTR64
var myimportpath string var myimportpath string
var idirs *Idir
var localimport string var localimport string
var asmhdr string var asmhdr string
......
...@@ -561,17 +561,12 @@ func skiptopkgdef(b *obj.Biobuf) bool { ...@@ -561,17 +561,12 @@ func skiptopkgdef(b *obj.Biobuf) bool {
return true return true
} }
func addidir(dir string) { var idirs []string
if dir == "" {
return
}
var pp **Idir func addidir(dir string) {
for pp = &idirs; *pp != nil; pp = &(*pp).link { if dir != "" {
idirs = append(idirs, dir)
} }
*pp = new(Idir)
(*pp).link = nil
(*pp).dir = dir
} }
// is this path a local name? begins with ./ or ../ or / // is this path a local name? begins with ./ or ../ or /
...@@ -610,12 +605,12 @@ func findpkg(name string) (file string, ok bool) { ...@@ -610,12 +605,12 @@ func findpkg(name string) (file string, ok bool) {
return "", false return "", false
} }
for p := idirs; p != nil; p = p.link { for _, dir := range idirs {
file = fmt.Sprintf("%s/%s.a", p.dir, name) file = fmt.Sprintf("%s/%s.a", dir, name)
if _, err := os.Stat(file); err == nil { if _, err := os.Stat(file); err == nil {
return file, true return file, true
} }
file = fmt.Sprintf("%s/%s.o", p.dir, name) file = fmt.Sprintf("%s/%s.o", dir, name)
if _, err := os.Stat(file); err == nil { if _, err := os.Stat(file); err == nil {
return file, true return file, true
} }
......
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