1
0
mirror of https://github.com/golang/go synced 2024-11-24 21:20:05 -07:00

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: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2016-02-19 23:01:10 -08:00
parent 5fc43c94bf
commit 5621b09dad
2 changed files with 7 additions and 19 deletions

View File

@ -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
var myimportpath string var myimportpath string
var idirs *Idir
var localimport string var localimport string
var asmhdr string var asmhdr string

View File

@ -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) {
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
} }