Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.2
 
1.3
 
MAIN:ragge:20030807115449
 
cc.c
_>11 /*      $Id$    */
<> 2+/*
  3+ * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
  4+ *
  5+ * Redistribution and use in source and binary forms, with or without
  6+ * modification, are permitted provided that the following conditions
  7+ * are met:
  8+ *
  9+ * Redistributions of source code and documentation must retain the above
  10+ * copyright notice, this list of conditions and the following disclaimer.
  11+ * Redistributions in binary form must reproduce the above copyright
  12+ * notice, this list of conditionsand the following disclaimer in the
  13+ * documentation and/or other materials provided with the distribution.
  14+ * All advertising materials mentioning features or use of this software
  15+ * must display the following acknowledgement:
  16+ *      This product includes software developed or owned by Caldera
  17+ *      International, Inc.
  18+ * Neither the name of Caldera International, Inc. nor the names of other
  19+ * contributors may be used to endorse or promote products derived from
  20+ * this software without specific prior written permission.
  21+ *
  22+ * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
  23+ * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
  24+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26+ * DISCLAIMED.  IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
  27+ * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30+ * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
  31+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  32+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33+ * POSSIBILITY OF SUCH DAMAGE.
  34+ */
235 
<>3 -#if 0
 4 -static  char sccsid[] = "@(#)cc.c 4.21 6/30/90";
 5 -#endif
636 /*
<>7 - * cc - front end for C compiler
  37+ * Front-end to the C compiler.
838  */
<>9 -#include <sys/param.h>
 10 -#include <sys/dir.h>
 11 -#include <sys/wait.h>
1239 
 1340 #include <stdio.h>
 1441 #include <ctype.h>
 1542 #include <signal.h>
<>16 -#include <stdlib.h>
 17 -#include <unistd.h>
 18 -#include <string.h>
  43+/* C command */
1944 
<>20 -#include "pathnames.h"
 21 -
 22 -char    *cpp = _PATH_CPP;
 23 -char    *ccom = _PATH_CCOM;
 24 -char    *c2 = _PATH_C2;
 25 -char    *as = _PATH_AS;
 26 -char    *ld = _PATH_LD;
 27 -char    *crt0 = _PATH_CRT0;
 28 -
 29 -char    tmp0[MAXPATHLEN];
 30 -char    *tmp1, *tmp2, *tmp3, *tmp4, *tmp5;
  45+#define SBSIZE 10000
  46+#define MAXINC 10
  47+#define MAXFIL 100
  48+#define MAXLIB 100
  49+#define MAXOPT 100
  50+char    *tmp0;
  51+char    *tmp1;
  52+char    *tmp2;
  53+char    *tmp3;
  54+char    *tmp4;
  55+char    *tmp5;
3156 char    *outfile;
<>32 -char    *savestr(char *cp), *strspl(char *left, char *right);
 33 -char    *setsuf(char *as, int ch);
 34 -int     getsuf(char as[]), nodup(char **l, char *os);
 35 -int     callsys(char *f, char **v);
 36 -void    idexit(int a), error(char *s, char *x), dexit(void);
 37 -char    **av, **clist, **llist, **plist;
 38 -int     cflag, eflag, oflag, pflag, sflag, wflag, Rflag, exflag, proflag;
 39 -int     gflag, Gflag, Mflag, debug;
 40 -char    *dflag;
  57+char *copy(),*setsuf();
  58+# define CHSPACE 1000
  59+char    ts[CHSPACE+50];
  60+char    *tsa = ts;
  61+char    *tsp = ts;
  62+char    *av[50];
  63+char    *clist[MAXFIL];
  64+char    *llist[MAXLIB];
  65+char    *alist[20];
  66+int dflag;
  67+int     pflag;
  68+int     sflag;
  69+int     cflag;
  70+int     eflag;
  71+int     gflag;
  72+int     exflag;
  73+int     oflag;
  74+int     proflag;
  75+int     noflflag;
4176 int     exfail;
<>42 -char    *chpass;
 43 -char    *npassname;
  77+char    *chpass ;
  78+char    *npassname ;
  79+char    pass0[40] = "/lib/ccom";
  80+char    pass2[20] = "/lib/c2";
  81+char    passp[20] = "/lib/cpp";
  82+char    *pref = "/lib/crt0.o";
4483 
<>45 -int     nc, nl, np, nxo, na;
 46 -
 47 -#define cunlink(s)      if (s) unlink(s)
 48 -
 49 -int
 50 -main(int argc, char **argv)
 51 -{
  84+main(argc, argv)
  85+char *argv[]; {
5286         char *t;
<> 87+        char *savetsp;
5388         char *assource;
<>54 -        int i, j, c;
  89+        char **pv, *ptemp[MAXOPT], **pvt;
  90+        int nc, nl, i, j, c, f20, nxo, na;
  91+        int idexit();
5592 
<>56 -        /* ld currently adds upto 5 args; 10 is room to spare */
 57 -        av = (char **)calloc(argc+10, sizeof (char **));
 58 -        clist = (char **)calloc(argc, sizeof (char **));
 59 -        llist = (char **)calloc(argc, sizeof (char **));
 60 -        plist = (char **)calloc(argc, sizeof (char **));
 61 -        for (i = 1; i < argc; i++) {
 62 -                if (*argv[i] == '-') switch (argv[i][1]) {
 63 -
  93+        i = nc = nl = f20 = nxo = 0;
  94+        pv = ptemp;
  95+        while(++i < argc) {
  96+                if(*argv[i] == '-') switch (argv[i][1]) {
  97+                default:
  98+                        goto passa;
6499                 case 'S':
 65100                         sflag++;
 66101                         cflag++;
<>67 -                        continue;
  102+                        break;
68103                 case 'o':
 69104                         if (++i < argc) {
 70105                                 outfile = argv[i];
<>71 -                                switch (getsuf(outfile)) {
 72 -
 73 -                                case 'c':
 74 -                                        error("-o would overwrite %s",
 75 -                                            outfile);
  106+                                if ((t=getsuf(outfile))=='c'||t=='o') {
  107+                                        error("Would overwrite %s", outfile);
76108                                         exit(8);
 77109                                 }
 78110                         }
<>79 -                        continue;
 80 -                case 'R':
 81 -                        Rflag++;
 82 -                        continue;
  111+                        break;
83112                 case 'O':
 84113                         oflag++;
<>85 -                        continue;
  114+                        break;
86115                 case 'p':
 87116                         proflag++;
<>88 -                        crt0 = _PATH_MCRT0;
 89 -                        if (argv[i][2] == 'g')
 90 -                                crt0 = _PATH_GCRT0;
 91 -                        continue;
  117+                        break;
92118                 case 'g':
<>93 -                        if (argv[i][2] == 'o') {
 94 -                            Gflag++;    /* old format for -go */
 95 -                        } else {
 96 -                            gflag++;    /* new format for -g */
 97 -                        }
 98 -                        continue;
 99 -                case 'w':
 100 -                        wflag++;
 101 -                        continue;
  119+                        gflag++;
  120+                        break;
102121                 case 'E':
 103122                         exflag++;
 104123                 case 'P':
 105124                         pflag++;
 106125                         if (argv[i][1]=='P')
<>107 -                                fprintf(stderr,
 108 -        "cc: warning: -P option obsolete; you should use -E instead\n");
 109 -                        plist[np++] = argv[i];
  126+                        fprintf(stderr, "(Warning): -P option obsolete\n");
  127+                        *pv++ = argv[i];
110128                 case 'c':
 111129                         cflag++;
<>112 -                        continue;
 113 -                case 'M':
 114 -                        exflag++;
 115 -                        pflag++;
 116 -                        Mflag++;
 117 -                        /* and fall through */
  130+                        break;
  131+
  132+                case 'f':
  133+                        noflflag++;
  134+                        if (npassname || chpass)
  135+                                error("-f overwrites earlier option",0);
  136+                        npassname = "/lib/f";
  137+                        chpass = "12";
  138+                        break;
  139+
  140+                case '2':
  141+                        if(argv[i][2] == '\0')
  142+                                pref = "/lib/crt2.o";
  143+                        else {
  144+                                pref = "/lib/crt20.o";
  145+                                f20 = 1;
  146+                        }
  147+                        break;
118148                 case 'D':
 119149                 case 'I':
 120150                 case 'U':
 121151                 case 'C':
<>122 -                        plist[np++] = argv[i];
 123 -                        continue;
 124 -                case 'L':
 125 -                        llist[nl++] = argv[i];
 126 -                        continue;
  152+                        *pv++ = argv[i];
  153+                        if (pv >= ptemp+MAXOPT)
  154+                                {
  155+                                error("Too many DIUC options", 0);
  156+                                --pv;
  157+                                }
  158+                        break;
127159                 case 't':
 128160                         if (chpass)
<>129 -                                error("-t overwrites earlier option", 0);
  161+                                error("-t overwrites earlier option",0);
130162                         chpass = argv[i]+2;
 131163                         if (chpass[0]==0)
 132164                                 chpass = "012p";
<>133 -                        continue;
  165+                        break;
  166+
134167                 case 'B':
 135168                         if (npassname)
 136169                                 error("-B overwrites earlier option", 0);
 137170                         npassname = argv[i]+2;
 138171                         if (npassname[0]==0)
<>139 -                                error("-B requires an argument", 0);
 140 -                        continue;
  172+                                npassname = "/usr/c/o";
  173+                        break;
  174+
141175                 case 'd':
<>142 -                        if (argv[i][2] == '\0') {
 143 -                                debug++;
 144 -                                continue;
  176+                        dflag++;
  177+                        strcpyn(alist, argv[i], 19);
  178+                        break;
  179+                } else {
  180+                passa:
  181+                        t = argv[i];
  182+                        if((c=getsuf(t))=='c' || c=='s'|| exflag) {
  183+                                clist[nc++] = t;
  184+                                if (nc>=MAXFIL)
  185+                                        {
  186+                                        error("Too many source files",0);
  187+                                        exit(1);
  188+                                        }
  189+                                t = setsuf(t, 'o');
145190                         }
<>146 -                        dflag = argv[i];
 147 -                        continue;
  191+                        if (nodup(llist, t)) {
  192+                                llist[nl++] = t;
  193+                                if (nl >= MAXLIB)
  194+                                        {
  195+                                        error("Too many object/library files",0);
  196+                                        exit(1);
  197+                                        }
  198+                                if (getsuf(t)=='o')
  199+                                        nxo++;
  200+                        }
148201                 }
<>149 -                t = argv[i];
 150 -                c = getsuf(t);
 151 -                if (c=='c' || c=='s' || exflag) {
 152 -                        clist[nc++] = t;
 153 -                        t = setsuf(t, 'o');
 154 -                }
 155 -                if (nodup(llist, t)) {
 156 -                        llist[nl++] = t;
 157 -                        if (getsuf(t)=='o')
 158 -                                nxo++;
 159 -                }
160202         }
<>161 -        if (gflag || Gflag) {
 162 -                if (oflag)
 163 -                        fprintf(stderr, "cc: warning: -g disables -O\n");
 164 -                oflag = 0;
 165 -        }
  203+        if (gflag) oflag = 0;
166204         if (npassname && chpass ==0)
 167205                 chpass = "012p";
 168206         if (chpass && npassname==0)
<>169 -                npassname = _PATH_USRNEW;
  207+                npassname = "/usr/c/";
170208         if (chpass)
<>171 -        for (t=chpass; *t; t++) {
 172 -                switch (*t) {
 173 -
 174 -                case '0':
 175 -                        ccom = strspl(npassname, "ccom");
 176 -                        continue;
 177 -                case '2':
 178 -                        c2 = strspl(npassname, "c2");
 179 -                        continue;
 180 -                case 'p':
 181 -                        cpp = strspl(npassname, "cpp");
 182 -                        continue;
  209+        for (t=chpass; *t; t++)
  210+                {
  211+                switch (*t)
  212+                        {
  213+                        case '0':
  214+                                strcpy (pass0, npassname);
  215+                                strcat (pass0, "ccom");
  216+                                continue;
  217+                        case '2':
  218+                                strcpy (pass2, npassname);
  219+                                strcat (pass2, "c2");
  220+                                continue;
  221+                        case 'p':
  222+                                strcpy (passp, npassname);
  223+                                strcat (passp, "cpp");
  224+                                continue;
  225+                        }
183226                 }
<>184 -        }
 185 -        if (nc==0)
  227+        if (noflflag)
  228+                pref = proflag ? "/lib/fmcrt0.o" : "/lib/fcrt0.o";
  229+        else if (proflag)
  230+                pref = "/lib/mcrt0.o";
  231+        if(nc==0)
186232                 goto nocom;
<>187 -        if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  233+        if (pflag==0) {
  234+                tmp0 = copy("/tmp/ctm0a");
  235+                while((c=fopen(tmp0, "r")) != NULL) {
  236+                        fclose(c);
  237+                        tmp0[9]++;
  238+                }
  239+                while((creat(tmp0, 0400))<0)
  240+                        tmp0[9]++;
  241+        }
  242+        if (signal(SIGINT, SIG_IGN) != SIG_IGN/* interrupt */
188243                 signal(SIGINT, idexit);
<>189 -        if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
  244+        if (signal(SIGTERM, SIG_IGN) != SIG_IGN)        /* terminate */
190245                 signal(SIGTERM, idexit);
<>191 -        if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
 192 -                signal(SIGHUP, idexit);
 193 -        if (pflag==0)
 194 -                (void)sprintf(tmp0, "%s/ctm%5.5d", _PATH_TMP, getpid());
 195 -        tmp1 = strspl(tmp0, "1");
 196 -        tmp2 = strspl(tmp0, "2");
 197 -        tmp3 = strspl(tmp0, "3");
 198 -        if (pflag==0)
 199 -                tmp4 = strspl(tmp0, "4");
  246+        (tmp1 = copy(tmp0))[8] = '1';
  247+        (tmp2 = copy(tmp0))[8] = '2';
  248+        (tmp3 = copy(tmp0))[8] = '3';
200249         if (oflag)
<>201 -                tmp5 = strspl(tmp0, "5");
  250+                (tmp5 = copy(tmp0))[8] = '5';
  251+        if (pflag==0)
  252+                (tmp4 = copy(tmp0))[8] = '4';
  253+        pvt = pv;
202254         for (i=0; i<nc; i++) {
<>203 -                if (nc > 1 && !Mflag) {
  255+                if (nc>1)
204256                         printf("%s:\n", clist[i]);
<>205 -                        fflush(stdout);
 206 -                }
 207 -                if (!Mflag && getsuf(clist[i]) == 's') {
  257+                if (getsuf(clist[i])=='s') {
208258                         assource = clist[i];
 209259                         goto assemble;
 210260                 } else
 211261                         assource = tmp3;
 212262                 if (pflag)
 213263                         tmp4 = setsuf(clist[i], 'i');
<>214 -                av[0] = "cpp"; av[1] = clist[i];
 215 -                na = 2;
 216 -                if (!exflag)
 217 -                        av[na++] = tmp4;
 218 -                for (j = 0; j < np; j++)
 219 -                        av[na++] = plist[j];
 220 -                av[na++] = 0;
 221 -                if (callsys(cpp, av)) {
 222 -                        exfail++;
 223 -                        eflag++;
  264+                savetsp = tsp;
  265+                av[0] = "cpp";
  266+                av[1] = clist[i];
  267+                av[2] = exflag ? "-" : tmp4;
  268+                na = 3;
  269+                for(pv=ptemp; pv <pvt; pv++)
  270+                        av[na++] = *pv;
  271+                av[na++]=0;
  272+                if (callsys(passp, av))
  273+                        {exfail++; eflag++;}
  274+                av[1] =tmp4;
  275+                tsp = savetsp;
  276+                av[0]= "ccom";
  277+                if (pflag || exfail)
  278+                        {
224279                         cflag++;
 225280                         continue;
<>226 -                }
 227 -                if (pflag) {
 228 -                        cflag++;
 229 -                        continue;
 230 -                }
 231 -                if (sflag) {
 232 -                        if (nc==1 && outfile)
 233 -                                tmp3 = outfile;
 234 -                        else
 235 -                                tmp3 = setsuf(clist[i], 's');
 236 -                        assource = tmp3;
 237 -                }
 238 -                av[0] = "ccom";
 239 -                av[1] = tmp4; av[2] = oflag?tmp5:tmp3; na = 3;
 240 -                if (proflag)
 241 -                        av[na++] = "-XP";
  281+                        }
  282+                if(sflag)
  283+                        assource = tmp3 = setsuf(clist[i], 's');
  284+                av[2] = tmp3;
  285+                if(oflag)
  286+                        av[2] = tmp5;
  287+                if (proflag) {
  288+                        av[3] = "-XP";
  289+                        av[4] = 0;
  290+                } else
  291+                        av[3] = 0;
242292                 if (gflag) {
<>243 -                        av[na++] = "-Xg";
 244 -                } else if (Gflag) {
 245 -                        av[na++] = "-XG";
  293+                        int i;
  294+                        i = av[3] ? 4 : 3;
  295+                        av[i++] = "-Xg";
  296+                        av[i] = 0;
246297                 }
<>247 -                if (wflag)
 248 -                        av[na++] = "-w";
 249 -                av[na] = 0;
 250 -                if (callsys(ccom, av)) {
  298+                if (callsys(pass0, av)) {
251299                         cflag++;
 252300                         eflag++;
 253301                         continue;
 254302                 }
 255303                 if (oflag) {
<>256 -                        av[0] = "c2"; av[1] = tmp5; av[2] = tmp3; av[3] = 0;
 257 -                        if (callsys(c2, av)) {
  304+                        av[0] = "c2";
  305+                        av[1] = tmp5;
  306+                        av[2] = tmp3;
  307+                        av[3] = 0;
  308+                        if (callsys(pass2, av)) {
258309                                 unlink(tmp3);
 259310                                 tmp3 = assource = tmp5;
 260311                         } else
     
 !
263314                 if (sflag)
 264315                         continue;
 265316         assemble:
<>266 -                cunlink(tmp1); cunlink(tmp2); cunlink(tmp4);
 267 -                av[0] = "as"; av[1] = "-o";
 268 -                if (cflag && nc==1 && outfile)
 269 -                        av[2] = outfile;
 270 -                else
 271 -                        av[2] = setsuf(clist[i], 'o');
 272 -                na = 3;
 273 -                if (Rflag)
 274 -                        av[na++] = "-R";
 275 -                if (dflag)
 276 -                        av[na++] = dflag;
 277 -                av[na++] = assource;
 278 -                av[na] = 0;
 279 -                if (callsys(as, av) > 1) {
  317+                av[0] = "as";
  318+                av[1] = "-o";
  319+                av[2] = setsuf(clist[i], 'o');
  320+                av[3] = assource;
  321+                if (dflag) {
  322+                        av[4] = alist;
  323+                        av[5] = 0;
  324+                } else
  325+                        av[4] = 0;
  326+                cunlink(tmp1);
  327+                cunlink(tmp2);
  328+                cunlink(tmp4);
  329+                if (callsys("/bin/as", av) > 1) {
280330                         cflag++;
 281331                         eflag++;
 282332                         continue;
     
 !
285335 nocom:
 286336         if (cflag==0 && nl!=0) {
 287337                 i = 0;
<>288 -                av[0] = "ld"; av[1] = "-X"; av[2] = crt0; na = 3;
  338+                av[0] = "ld";
  339+                av[1] = "-X";
  340+                av[2] = pref;
  341+                j = 3;
289342                 if (outfile) {
<>290 -                        av[na++] = "-o";
 291 -                        av[na++] = outfile;
  343+                        av[j++] = "-o";
  344+                        av[j++] = outfile;
292345                 }
<>293 -                while (i < nl)
 294 -                        av[na++] = llist[i++];
 295 -                if (proflag)
 296 -                        av[na++] = "-lc_p";
 297 -                else
 298 -                        av[na++] = "-lc";
 299 -                av[na++] = 0;
 300 -                eflag |= callsys(ld, av);
  346+                while(i<nl)
  347+                        av[j++] = llist[i++];
  348+                if (gflag)
  349+                        av[j++] = "-lg";
  350+                if(f20)
  351+                        av[j++] = "-l2";
  352+                else {
  353+                        av[j++] = "/lib/libc.a";
  354+                        av[j++] = "-l";
  355+                }
  356+                av[j++] = 0;
  357+                eflag |= callsys("/bin/ld", av);
301358                 if (nc==1 && nxo==1 && eflag==0)
<>302 -                        unlink(setsuf(clist[0], 'o'));
  359+                        cunlink(setsuf(clist[0], 'o'));
303360         }
 304361         dexit();
<>305 -        return 0; /* not reached */
306362 }
 307363 
<>308 -void
 309 -idexit(int a)
  364+idexit()
310365 {
<>311 -
312366         eflag = 100;
 313367         dexit();
 314368 }
 315369 
<>316 -void
 317 -dexit(void)
  370+dexit()
318371 {
<>319 -
320372         if (!pflag) {
 321373                 cunlink(tmp1);
 322374                 cunlink(tmp2);
 323375                 if (sflag==0)
 324376                         cunlink(tmp3);
 325377                 cunlink(tmp4);
 326378                 cunlink(tmp5);
<> 379+                cunlink(tmp0);
327380         }
 328381         exit(eflag);
 329382 }
 330383 
<>331 -void
 332 -error(char *s, char *x)
  384+error(s, x)
333385 {
<>334 -        FILE *diag = exflag ? stderr : stdout;
 335 -
 336 -        fprintf(diag, "cc: ");
 337 -        fprintf(diag, s, x);
 338 -        putc('\n', diag);
  386+        fprintf(exflag?stderr:stdout , s, x);
  387+        putc('\n', exflag? stderr : stdout);
339388         exfail++;
 340389         cflag++;
 341390         eflag++;
 342391 }
 343392 
<>344 -int
 345 -getsuf(char as[])
  393+
  394+
  395+
  396+getsuf(as)
  397+char as[];
346398 {
 347399         register int c;
 348400         register char *s;
 349401         register int t;
 350402 
 351403         s = as;
 352404         c = 0;
<>353 -        while ((t = *s++))
  405+        while(t = *s++)
354406                 if (t=='/')
 355407                         c = 0;
 356408                 else
 357409                         c++;
 358410         s -= 3;
<>359 -        if (c <= MAXNAMLEN && c > 2 && *s++ == '.')
 360 -                return (*s);
 361 -        return (0);
  411+        if (c<=14 && c>2 && *s++=='.')
  412+                return(*s);
  413+        return(0);
362414 }
 363415 
 364416 char *
<>365 -setsuf(char *as, int ch)
  417+setsuf(as, ch)
  418+char as[];
366419 {
 367420         register char *s, *s1;
 368421 
<>369 -        s = s1 = savestr(as);
 370 -        while (*s)
  422+        s = s1 = copy(as);
  423+        while(*s)
371424                 if (*s++ == '/')
 372425                         s1 = s;
 373426         s[-1] = ch;
<>374 -        return (s1);
  427+        return(s1);
375428 }
 376429 
<>377 -int
 378 -callsys(char *f, char **v)
 379 -{
  430+callsys(f, v)
  431+char f[], *v[]; {
380432         int t, status;
<>381 -        char **cpp;
382433 
<>383 -        if (debug) {
 384 -                fprintf(stderr, "%s:", f);
 385 -                for (cpp = v; *cpp != 0; cpp++)
 386 -                        fprintf(stderr, " %s", *cpp);
 387 -                fprintf(stderr, "\n");
 388 -        }
 389 -        t = vfork();
 390 -        if (t == -1) {
 391 -                printf("No more processes\n");
 392 -                return (100);
 393 -        }
 394 -        if (t == 0) {
  434+        if ((t=fork())==0) {
395435                 execv(f, v);
 396436                 printf("Can't find %s\n", f);
<>397 -                fflush(stdout);
 398 -                _exit(100);
 399 -        }
 400 -        while (t != wait(&status))
 401 -                ;
  437+                exit(100);
  438+        } else
  439+                if (t == -1) {
  440+                        printf("Try again\n");
  441+                        return(100);
  442+                }
  443+        while(t!=wait(&status));
402444         if ((t=(status&0377)) != 0 && t!=14) {
<>403 -                if (t!=2) {
  445+                if (t!=2)               /* interrupt */
  446+                        {
404447                         printf("Fatal error in %s\n", f);
 405448                         eflag = 8;
<>406 -                }
  449+                        }
407450                 dexit();
 408451         }
<>409 -        return ((status>>8) & 0377);
  452+        return((status>>8) & 0377);
410453 }
 411454 
<>412 -int
 413 -nodup(char **l, char *os)
  455+char *
  456+copy(as)
  457+char as[];
414458 {
<> 459+        register char *otsp, *s;
  460+        int i;
  461+
  462+        otsp = tsp;
  463+        s = as;
  464+        while(*tsp++ = *s++);
  465+        if (tsp >tsa+CHSPACE)
  466+                {
  467+                tsp = tsa = i = calloc(CHSPACE+50,1);
  468+                if (i== -1){
  469+                        error("no space for file names");
  470+                        dexit(8);
  471+                        }
  472+                }
  473+        return(otsp);
  474+}
  475+
  476+nodup(l, os)
  477+char **l, *os;
  478+{
415479         register char *t, *s;
 416480         register int c;
 417481 
 418482         s = os;
 419483         if (getsuf(s) != 'o')
<>420 -                return (1);
 421 -        while ((t = *l++)) {
 422 -                while ((c = *s++))
  484+                return(1);
  485+        while(t = *l++) {
  486+                while(c = *s++)
423487                         if (c != *t++)
 424488                                 break;
<>425 -                if (*t==0 && c==0)
 426 -                        return (0);
  489+                if (*t=='\0' && c=='\0')
  490+                        return(0);
427491                 s = os;
 428492         }
<>429 -        return (1);
  493+        return(1);
430494 }
 431495 
<>432 -#define NSAVETAB        1024
 433 -char    *savetab;
 434 -int     saveleft;
 435 -
 436 -char *
 437 -savestr(char *cp)
  496+cunlink(f)
  497+char *f;
438498 {
<>439 -        register int len;
 440 -
 441 -        len = strlen(cp) + 1;
 442 -        if (len > saveleft) {
 443 -                saveleft = NSAVETAB;
 444 -                if (len > saveleft)
 445 -                        saveleft = len;
 446 -                savetab = (char *)malloc(saveleft);
 447 -                if (savetab == 0) {
 448 -                        fprintf(stderr, "ran out of memory (savestr)\n");
 449 -                        exit(1);
 450 -                }
 451 -        }
 452 -        strncpy(savetab, cp, len);
 453 -        cp = savetab;
 454 -        savetab += len;
 455 -        saveleft -= len;
 456 -        return (cp);
  499+        if (f==0)
  500+                return(0);
  501+        return(unlink(f));
457502 }
<_458 -
 459 -char *
 460 -strspl(char *left, char *right)
 461 -{
 462 -        char buf[BUFSIZ];
 463 -
 464 -        strcpy(buf, left);
 465 -        strcat(buf, right);
 466 -        return (savestr(buf));
 467 -}
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-21 17:32 +0100