mirror of
https://github.com/golang/go
synced 2024-11-24 19:10:15 -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:
parent
5fc43c94bf
commit
5621b09dad
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user