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 {
field *Type
}
type Idir struct {
link *Idir
dir string
}
// argument passing to/from
// smagic and umagic
type Magic struct {
......@@ -519,8 +514,6 @@ var Tptr EType // either TPTR32 or TPTR64
var myimportpath string
var idirs *Idir
var localimport string
var asmhdr string
......
......@@ -561,17 +561,12 @@ func skiptopkgdef(b *obj.Biobuf) bool {
return true
}
func addidir(dir string) {
if dir == "" {
return
}
var idirs []string
var pp **Idir
for pp = &idirs; *pp != nil; pp = &(*pp).link {
func addidir(dir string) {
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 /
......@@ -610,12 +605,12 @@ func findpkg(name string) (file string, ok bool) {
return "", false
}
for p := idirs; p != nil; p = p.link {
file = fmt.Sprintf("%s/%s.a", p.dir, name)
for _, dir := range idirs {
file = fmt.Sprintf("%s/%s.a", dir, name)
if _, err := os.Stat(file); err == nil {
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 {
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