]> Cypherpunks repositories - gostls13.git/commitdiff
autolib (#pragma lib)
authorKen Thompson <ken@golang.org>
Thu, 26 Jun 2008 03:22:10 +0000 (20:22 -0700)
committerKen Thompson <ken@golang.org>
Thu, 26 Jun 2008 03:22:10 +0000 (20:22 -0700)
added to 6g to autoload
the included import files.

SVN=124759

src/cmd/6g/gen.c
src/cmd/gc/lex.c
src/cmd/gc/subr.c

index 4faca96c584ef8d54c77aeb3289f7c482aff776c..9ec6fe0e148d0ba78e4242cec5bdae03dd6ff5fa 100644 (file)
@@ -28,7 +28,6 @@ compile(Node *fn)
                return;
        lno = dynlineno;
 
-
        curfn = fn;
        dynlineno = curfn->lineno;      // for diagnostics
        dowidth(curfn->type);
index ca7d3a09ef1eaa02c12a8d74faa228124d9f8728..74dbb1deb79b93bed6316e4dd32d7a0bbf159b4a 100644 (file)
@@ -118,7 +118,8 @@ importfile(Val *f)
                yyerror("import statement not a string");
                return;
        }
-       // BOTCH need to get .8 from backend
+
+       // BOTCH need to get .6 from backend
        snprint(namebuf, sizeof(namebuf), "%Z.6", f->sval);
        file = strdup(namebuf);
        linehist(file, 0);
@@ -126,6 +127,7 @@ importfile(Val *f)
        imp = Bopen(file, OREAD);
        if(imp == nil)
                fatal("cant open import: %s", namebuf);
+       linehist(file, -1);     // acts as #pragma lib
 
        /*
         * position the input right
index 5c8224bdc477132b4a1ec11a476b1fa37ffa895b..aed40b595629451fb162b7565158aedba6ba1a06 100644 (file)
@@ -64,13 +64,23 @@ void
 linehist(char *file, long off)
 {
        Hist *h;
+       char *cp;
 
        if(debug['i'])
-       if(file != nil)
-               print("%L: import %s\n", file);
-       else
+       if(file != nil) {
+               if(off < 0)
+                       print("%L: pragma %s\n", file);
+               else
+                       print("%L: import %s\n", file);
+       } else
                print("%L: <eof>\n");
 
+       if(off < 0 && file[0] != '/') {
+               cp = mal(strlen(file) + strlen(pathname) + 2);
+               sprint(cp, "%s/%s", pathname, file);
+               file = cp;
+       }
+
        h = alloc(sizeof(Hist));
        h->name = file;
        h->line = lineno;