tthe lastbug fix? - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 92a0a8b69faf7882459c1ac6c9186e1c47ef0a91
 (DIR) parent 8f8b0e542a8284671f9a3ae0678bb20f6962a420
 (HTM) Author: rsc <devnull@localhost>
       Date:   Wed, 21 Apr 2004 07:38:03 +0000
       
       tthe lastbug fix?
       
       Diffstat:
         M src/cmd/mk/archive.c                |       4 ++--
         M src/cmd/mk/graph.c                  |       2 +-
         M src/cmd/mk/mk.c                     |       4 ++--
         M src/cmd/mk/unix.c                   |      11 +++++++----
       
       4 files changed, 12 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/mk/archive.c b/src/cmd/mk/archive.c
       t@@ -17,7 +17,7 @@ struct        ar_hdr
        };
        #define        SAR_HDR        (SARNAME+44)
        
       -static int dolong;
       +static int dolong = 1;
        
        static void atimes(char *);
        static char *split(char*, char**);
       t@@ -154,7 +154,7 @@ atimes(char *ar)
                                goto skip;
                        }else if(strings && h.name[0]=='/' && isdigit(h.name[1])){
                                i = strtol(h.name+1, &p, 10);
       -                        if(*p != ' ' || strlen(strings) < i)
       +                        if(*p != ' ' || i >= strlen(strings))
                                        goto skip;
                                p = strings+i;
                                for(; *p && *p != '/'; p++)
 (DIR) diff --git a/src/cmd/mk/graph.c b/src/cmd/mk/graph.c
       t@@ -180,7 +180,7 @@ dumpn(char *s, Node *n)
                char buf[1024];
                Arc *a;
        
       -        sprint(buf, "%s   ", (*s == ' ')? s:"");
       +        snprint(buf, sizeof buf, "%s   ", (*s == ' ')? s:"");
                Bprint(&bout, "%s%s@%ld: time=%ld flags=0x%x next=%ld\n",
                        s, n->name, n, n->time, n->flags, n->next);
                for(a = n->prereqs; a; a = a->next)
 (DIR) diff --git a/src/cmd/mk/mk.c b/src/cmd/mk/mk.c
       t@@ -198,7 +198,7 @@ pcmp(char *prog, char *p, char *q)
                int pid;
        
                Bflush(&bout);
       -        sprint(buf, "%s '%s' '%s'\n", prog, p, q);
       +        snprint(buf, sizeof buf, "%s '%s' '%s'\n", prog, p, q);
                pid = pipecmd(buf, 0, 0);
                while(waitup(-3, &pid) >= 0)
                        ;
       t@@ -214,7 +214,7 @@ outofdate(Node *node, Arc *arc, int eval)
        
                str = 0;
                if(arc->prog){
       -                sprint(buf, "%s%c%s", node->name, 0377, arc->n->name);
       +                snprint(buf, sizeof buf, "%s%c%s", node->name, 0377, arc->n->name);
                        sym = symlook(buf, S_OUTOFDATE, 0);
                        if(sym == 0 || eval){
                                if(sym == 0)
 (DIR) diff --git a/src/cmd/mk/unix.c b/src/cmd/mk/unix.c
       t@@ -47,15 +47,15 @@ exportenv(Envy *e)
        {
                int i;
                char **p;
       -        char buf[4096];
       +        static char buf[16384];
        
                p = 0;
                for(i = 0; e->name; e++, i++) {
                        p = (char**) Realloc(p, (i+2)*sizeof(char*));
                        if(e->values)
       -                        sprint(buf, "%s=%s", e->name,  wtos(e->values, IWS));
       +                        snprint(buf, sizeof buf, "%s=%s", e->name,  wtos(e->values, IWS));
                        else
       -                        sprint(buf, "%s=", e->name);
       +                        snprint(buf, sizeof buf, "%s=", e->name);
                        p[i] = strdup(buf);
                }
                p[i] = 0;
       t@@ -91,6 +91,8 @@ expunge(int pid, char *msg)
                        kill(pid, SIGHUP);
        }
        
       +int mypid;
       +
        int
        execsh(char *args, char *cmd, Bufblock *buf, Envy *e)
        {
       t@@ -102,6 +104,7 @@ execsh(char *args, char *cmd, Bufblock *buf, Envy *e)
                        Exit();
                }
                pid = fork();
       +        mypid = getpid();
                if(pid < 0){
                        mkperror("mk fork");
                        Exit();
       t@@ -225,7 +228,7 @@ static        struct
                SIGFPE,                "sys: fp: fptrap",
                SIGPIPE,        "sys: write on closed pipe",
                SIGILL,                "sys: trap: illegal instruction",
       -        SIGSEGV,        "sys: segmentation violation",
       +//        SIGSEGV,        "sys: segmentation violation",
                0,                0
        };