URI: 
       tInclude looks in #9/acid now. Acid works harder at not falling over. - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit a8c15b08ca39ae9fa8d50f9e338d341c09fa57dd
   DIR parent eaf56db5bc78cfec908db84dc792c53ac8ffb90e
  HTML Author: rsc <devnull@localhost>
       Date:   Wed, 21 Apr 2004 05:34:37 +0000
       
       Include looks in #9/acid now.
       Acid works harder at not falling over.
       
       Diffstat:
         M src/cmd/acid/builtin.c              |      16 +++++++++++++++-
         M src/cmd/acid/lex.c                  |      14 ++++++++++----
         M src/cmd/acid/util.c                 |       2 +-
       
       3 files changed, 26 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/src/cmd/acid/builtin.c b/src/cmd/acid/builtin.c
       t@@ -478,6 +478,8 @@ interpret(Node *r, Node *args)
        void
        include(Node *r, Node *args)
        {
       +        char *file, *libfile;
       +        static char buf[1024];
                Node res;
                int isave;
        
       t@@ -488,7 +490,19 @@ include(Node *r, Node *args)
                        error("include(string): arg type");
        
                Bflush(bout);
       -        pushfile(res.store.u.string->string);
       +
       +        libfile = nil;
       +        file = res.store.u.string->string;
       +        if(access(file, AREAD) < 0 && file[0] != '/'){
       +                snprint(buf, sizeof buf, "#9/acid/%s", file);
       +                libfile = unsharp(buf);
       +                if(access(libfile, AREAD) >= 0){
       +                        strecpy(buf, buf+sizeof buf, libfile);
       +                        file = buf;
       +                }
       +                free(libfile);
       +        }
       +        pushfile(file);
        
                isave = interactive;
                interactive = 0;
   DIR diff --git a/src/cmd/acid/lex.c b/src/cmd/acid/lex.c
       t@@ -76,6 +76,7 @@ struct IOstack
                IOstack        *prev;
        };
        IOstack *lexio;
       +uint nlexio;
        
        void
        setacidfile(void)
       t@@ -100,6 +101,9 @@ pushfile(char *file)
                Biobuf *b;
                IOstack *io;
        
       +        if(nlexio > 64)
       +                error("too many includes");
       +
                if(file)
                        b = Bopen(file, OREAD);
                else{
       t@@ -122,6 +126,7 @@ pushfile(char *file)
                io->fin = b;
                io->prev = lexio;
                lexio = io;
       +        nlexio++;
                setacidfile();
        }
        
       t@@ -156,6 +161,7 @@ pushstr(Node *s)
                io->ip = io->text;
                io->fin = 0;
                io->prev = lexio;
       +        nlexio++;
                lexio = io;
                setacidfile();
        }
       t@@ -190,6 +196,7 @@ popio(void)
                s = lexio;
                lexio = s->prev;
                free(s);
       +        nlexio--;
                setacidfile();
                return 1;
        }
       t@@ -197,18 +204,17 @@ popio(void)
        int
        Zfmt(Fmt *f)
        {
       -        int i;
       -        char buf[1024];
       +        char buf[1024], *p;
                IOstack *e;
        
                e = lexio;
                if(e) {
       -                i = sprint(buf, "%s:%d", e->name, line);
       +                p = seprint(buf, buf+sizeof buf, "%s:%d", e->name, line);
                        while(e->prev) {
                                e = e->prev;
                                if(initialising && e->prev == 0)
                                        break;
       -                        i += sprint(buf+i, " [%s:%d]", e->name, e->line);
       +                        p = seprint(p, buf+sizeof buf, " [%s:%d]", e->name, e->line);
                        }
                } else
                        sprint(buf, "no file:0");
   DIR diff --git a/src/cmd/acid/util.c b/src/cmd/acid/util.c
       t@@ -36,7 +36,7 @@ unique(char *buf, Symbol *s)
                        }
                }
                if(renamed && !quiet)
       -                print("\t%s=%s %c/%Z\n", s->name, buf, s->type, s->loc);
       +                print("\t%s=%s %c/%L\n", s->name, buf, s->type, s->loc);
                if(l == 0)
                        l = enter(buf, Tid);
                return l;