Commit 63a84348 authored by Russ Cox's avatar Russ Cox

look for .6 before .a; accept archives with 0 length __.SYMDEF

TBR=r
OCL=19612
CL=19612
parent b548e734
......@@ -135,15 +135,16 @@ setfilename(char *file)
}
int
arsize(Biobuf *b, char *name){
arsize(Biobuf *b, char *name)
{
struct ar_hdr *a;
if((a = Brdline(b, '\n')) == nil)
return 0;
return -1;
if(Blinelen(b) != sizeof(struct ar_hdr))
return 0;
return -1;
if(strncmp(a->name, name, strlen(name)) != 0)
return 0;
return -1;
return atoi(a->size);
}
......@@ -162,7 +163,7 @@ skiptopkgdef(Biobuf *b)
return 0;
/* symbol table is first; skip it */
sz = arsize(b, "__.SYMDEF");
if(sz <= 0)
if(sz < 0)
return 0;
Bseek(b, sz, 1);
/* package export block is second */
......@@ -184,16 +185,20 @@ findpkg(String *name)
}
// BOTCH need to get .6 from backend
snprint(namebuf, sizeof(namebuf), "%Z.6", name);
if(access(namebuf, 0) >= 0)
return 1;
// try .a before .6. important for building libraries:
// if there is an array.6 in the array.a library,
// want to find all of array.a, not just array.6.
snprint(namebuf, sizeof(namebuf), "%Z.a", name);
if(access(namebuf, 0) >= 0)
return 1;
snprint(namebuf, sizeof(namebuf), "%s/pkg/%Z.6", goroot, name);
snprint(namebuf, sizeof(namebuf), "%Z.6", name);
if(access(namebuf, 0) >= 0)
return 1;
snprint(namebuf, sizeof(namebuf), "%s/pkg/%Z.a", goroot, name);
if(access(namebuf, 0) >= 0)
return 1;
snprint(namebuf, sizeof(namebuf), "%s/pkg/%Z.6", goroot, name);
if(access(namebuf, 0) >= 0)
return 1;
return 0;
......
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