void
addlib(char *src, char *obj)
{
- char name[1024], comp[256], *p, *q;
- int i;
+ char name[1024], pname[1024], comp[256], *p, *q;
+ int i, search;
if(histfrogp <= 0)
return;
+ search = 0;
if(histfrog[0]->name[1] == '/') {
sprint(name, "");
i = 1;
sprint(name, ".");
i = 0;
} else {
- if(debug['9'])
- sprint(name, "/%s/lib", thestring);
- else
- sprint(name, "/usr/%clib", thechar);
+ sprint(name, "");
i = 0;
+ search = 1;
}
for(; i<histfrogp; i++) {
strcat(name, "/");
strcat(name, comp);
}
+
+ if(search) {
+ // try dot and then try goroot.
+ // going to have to do better (probably a command line flag) later.
+ snprint(pname, sizeof pname, ".%s", name);
+ if(access(pname, AEXIST) < 0)
+ snprint(pname, sizeof pname, "%s/pkg/%s", goroot, name);
+ strcpy(name, pname);
+ }
if(debug['v'])
Bprint(&bso, "%5.2f addlib: %s %s pulls in %s\n", cputime(), obj, src, name);
void yyerror(char*, ...);
void warn(char*, ...);
void fatal(char*, ...);
-void linehist(char*, int32);
+void linehist(char*, int32, int);
int32 setlineno(Node*);
Node* nod(int, Node*, Node*);
Node* nodlit(Val);
setfilename(argv[0]);
infile = argv[0];
- linehist(infile, 0);
+ linehist(infile, 0, 0);
curio.infile = infile;
curio.bin = Bopen(infile, OREAD);
yyparse();
runifacechecks();
- linehist(nil, 0);
+ linehist(nil, 0, 0);
if(curio.bin != nil)
Bterm(curio.bin);
if(p != nil && strcmp(p, ".go") == 0)
*p = 0;
filename = strdup(namebuf);
-
+
// turn invalid identifier chars into _
for(p=filename; *p; p++) {
c = *p & 0xFF;
importfile(Val *f)
{
Biobuf *imp;
- char *file;
+ char *file, *p;
int32 c;
int len;
file = strdup(namebuf);
len = strlen(namebuf);
- if(len > 2)
- if(namebuf[len-2] == '.')
- if(namebuf[len-1] == 'a')
- if(!skiptopkgdef(imp))
- fatal("import not package file: %s", namebuf);
-
- linehist(file, 0);
- linehist(file, -1); // acts as #pragma lib
+ if(len > 2 && namebuf[len-2] == '.' && namebuf[len-1] == 'a') {
+ if(!skiptopkgdef(imp))
+ fatal("import not package file: %s", namebuf);
+
+ // assume .a files move (get installed)
+ // so don't record the full path.
+ p = file + len - f->u.sval->len - 2;
+ linehist(p, 0, 0);
+ linehist(p, -1, 1); // acts as #pragma lib
+ } else {
+ // assume .6 files don't move around
+ // so do record the full path
+ linehist(file, 0, 0);
+ linehist(file, -1, 0);
+ }
/*
* position the input right
void
unimportfile(void)
{
- linehist(nil, 0);
+ linehist(nil, 0, 0);
if(curio.bin != nil) {
Bterm(curio.bin);
cannedimports(char *file, char *cp)
{
lineno++; // if sys.6 is included on line 1,
- linehist(file, 0); // the debugger gets confused
+ linehist(file, 0, 0); // the debugger gets confused
pushedio = curio;
curio.bin = nil;
}
void
-linehist(char *file, int32 off)
+linehist(char *file, int32 off, int relative)
{
Hist *h;
char *cp;
print("end of import at line %L\n", lineno);
}
- if(off < 0 && file[0] != '/') {
+ if(off < 0 && file[0] != '/' && !relative) {
cp = mal(strlen(file) + strlen(pathname) + 2);
sprint(cp, "%s/%s", pathname, file);
file = cp;
convlit(nr->left, types[TFUNC]);
t = nr->left->type;
if(t == T)
- return; // error already printed
+ return nl; // error already printed
if(t->etype == tptr)
t = t->type;
if(t == T || t->etype != TFUNC) {
yyerror("cannot call %T", t);
- return;
+ return nl;
}
if(t->outtuple != cl) {
cr = t->outtuple;
rm -f $*.6
%.install: %.6
- mv $*.6 $(GOROOT)/pkg/$*.6
+ 6ar grc $*.a $*.6
+ mv $*.a $(GOROOT)/pkg/$*.a
+ rm -f $*.6
%.dirclean:
+cd $* && make clean
bignum.6: fmt.dirinstall
bufio.6: io.dirinstall os.dirinstall
-exec.6: os.dirinstall
+exec.6: os.dirinstall strings.install
flag.6: fmt.dirinstall os.dirinstall strconv.dirinstall
log.6: fmt.dirinstall io.dirinstall os.dirinstall time.dirinstall
path.6: io.dirinstall