Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.3
 
1.4
 
MAIN:ragge:20030807150307
 
cc.c
_>4040 #include <stdio.h>
 4141 #include <ctype.h>
 4242 #include <signal.h>
<> 43+#include <string.h>
  44+#include <fcntl.h>
  45+#include <unistd.h>
  46+#include <stdlib.h>
  47+#include <sys/wait.h>
4348 /* C command */
 4449 
 4550 #define SBSIZE 10000
     
 !
5459 char    *tmp4;
 5560 char    *tmp5;
 5661 char    *outfile;
<>57 -char *copy(),*setsuf();
  62+char *copy(char []),*setsuf(char [], int);
  63+int getsuf(char []);
  64+int main(int, char *[]);
  65+void error(char *, char *);
  66+int nodup(char **, char *);
  67+int callsys(char [], char *[]);
  68+int cunlink(char *);
  69+void dexit(void);
  70+void idexit(int);
5871 # define CHSPACE 1000
 5972 char    ts[CHSPACE+50];
 6073 char    *tsa = ts;
 6174 char    *tsp = ts;
 6275 char    *av[50];
 6376 char    *clist[MAXFIL];
 6477 char    *llist[MAXLIB];
<>65 -char    *alist[20];
  78+char    alist[20];
6679 int dflag;
 6780 int     pflag;
 6881 int     sflag;
 6982 int     cflag;
 7083 int     eflag;
 7184 int     gflag;
 7285 int     exflag;
<>73 -int     oflag;
  86+int     Oflag;
7487 int     proflag;
 7588 int     noflflag;
 7689 int     exfail;
<>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";
  90+char    *pass0 = "/lib/ccom";
  91+char    *passp = "/usr/libexec/cpp";
  92+char    *pref = "/usr/lib/crt0.o";
8393 
<> 94+int
8495 main(argc, argv)
 8596 char *argv[]; {
 8697         char *t;
 8798         char *savetsp;
 8899         char *assource;
 89100         char **pv, *ptemp[MAXOPT], **pvt;
<>90 -        int nc, nl, i, j, c, f20, nxo, na;
 91 -        int idexit();
  101+        int nc, nl, i, j, c, f20, nxo, na, tt;
  102+        FILE *f;
92103 
 93104         i = nc = nl = f20 = nxo = 0;
 94105         pv = ptemp;
     
 !
103114                 case 'o':
 104115                         if (++i < argc) {
 105116                                 outfile = argv[i];
<>106 -                                if ((t=getsuf(outfile))=='c'||t=='o') {
  117+                                if ((tt=getsuf(outfile))=='c'||tt=='o') {
107118                                         error("Would overwrite %s", outfile);
 108119                                         exit(8);
 109120                                 }
 110121                         }
 111122                         break;
 112123                 case 'O':
<>113 -                        oflag++;
  124+                        Oflag++;
114125                         break;
 115126                 case 'p':
 116127                         proflag++;
     
 !
122133                         exflag++;
 123134                 case 'P':
 124135                         pflag++;
<>125 -                        if (argv[i][1]=='P')
 126 -                        fprintf(stderr, "(Warning): -P option obsolete\n");
127136                         *pv++ = argv[i];
 128137                 case 'c':
 129138                         cflag++;
 130139                         break;
 131140 
<>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 -
140141                 case '2':
 141142                         if(argv[i][2] == '\0')
 142143                                 pref = "/lib/crt2.o";
     
 !
156157                                 --pv;
 157158                                 }
 158159                         break;
<>159 -                case 't':
 160 -                        if (chpass)
 161 -                                error("-t overwrites earlier option",0);
 162 -                        chpass = argv[i]+2;
 163 -                        if (chpass[0]==0)
 164 -                                chpass = "012p";
 165 -                        break;
166160 
<>167 -                case 'B':
 168 -                        if (npassname)
 169 -                                error("-B overwrites earlier option", 0);
 170 -                        npassname = argv[i]+2;
 171 -                        if (npassname[0]==0)
 172 -                                npassname = "/usr/c/o";
 173 -                        break;
 174 -
175161                 case 'd':
 176162                         dflag++;
<>177 -                        strcpyn(alist, argv[i], 19);
  163+                        strncpy(alist, argv[i], 19);
178164                         break;
 179165                 } else {
 180166                 passa:
     
 !
200186                         }
 201187                 }
 202188         }
<>203 -        if (gflag) oflag = 0;
 204 -        if (npassname && chpass ==0)
 205 -                chpass = "012p";
 206 -        if (chpass && npassname==0)
 207 -                npassname = "/usr/c/";
 208 -        if (chpass)
 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 -                        }
 226 -                }
  189+        if (gflag) Oflag = 0;
227190         if (noflflag)
 228191                 pref = proflag ? "/lib/fmcrt0.o" : "/lib/fcrt0.o";
 229192         else if (proflag)
     
 !
232195                 goto nocom;
 233196         if (pflag==0) {
 234197                 tmp0 = copy("/tmp/ctm0a");
<>235 -                while((c=fopen(tmp0, "r")) != NULL) {
 236 -                        fclose(c);
  198+                while((f=fopen(tmp0, "r")) != NULL) {
  199+                        fclose(f);
237200                         tmp0[9]++;
 238201                 }
 239202                 while((creat(tmp0, 0400))<0)
     
 !
246209         (tmp1 = copy(tmp0))[8] = '1';
 247210         (tmp2 = copy(tmp0))[8] = '2';
 248211         (tmp3 = copy(tmp0))[8] = '3';
<>249 -        if (oflag)
 250 -                (tmp5 = copy(tmp0))[8] = '5';
251212         if (pflag==0)
 252213                 (tmp4 = copy(tmp0))[8] = '4';
 253214         pvt = pv;
     
 !
282243                 if(sflag)
 283244                         assource = tmp3 = setsuf(clist[i], 's');
 284245                 av[2] = tmp3;
<>285 -                if(oflag)
 286 -                        av[2] = tmp5;
287246                 if (proflag) {
 288247                         av[3] = "-XP";
 289248                         av[4] = 0;
     
 !
300259                         eflag++;
 301260                         continue;
 302261                 }
<>303 -                if (oflag) {
 304 -                        av[0] = "c2";
 305 -                        av[1] = tmp5;
 306 -                        av[2] = tmp3;
 307 -                        av[3] = 0;
 308 -                        if (callsys(pass2, av)) {
 309 -                                unlink(tmp3);
 310 -                                tmp3 = assource = tmp5;
 311 -                        } else
 312 -                                unlink(tmp5);
 313 -                }
314262                 if (sflag)
 315263                         continue;
 316264         assemble:
     
 !
359307                         cunlink(setsuf(clist[0], 'o'));
 360308         }
 361309         dexit();
<> 310+        return 0;
362311 }
 363312 
<>364 -idexit()
  313+void
  314+idexit(int arg)
365315 {
 366316         eflag = 100;
 367317         dexit();
 368318 }
 369319 
<> 320+void
370321 dexit()
 371322 {
 372323         if (!pflag) {
     
 !
381332         exit(eflag);
 382333 }
 383334 
<>384 -error(s, x)
  335+void
  336+error(char *s, char *x)
385337 {
 386338         fprintf(exflag?stderr:stdout , s, x);
 387339         putc('\n', exflag? stderr : stdout);
     
 !
393345 
 394346 
 395347 
<> 348+int
396349 getsuf(as)
 397350 char as[];
 398351 {
<>399 -        register int c;
400352         register char *s;
<>401 -        register int t;
402353 
<>403 -        s = as;
 404 -        c = 0;
 405 -        while(t = *s++)
 406 -                if (t=='/')
 407 -                        c = 0;
 408 -                else
 409 -                        c++;
 410 -        s -= 3;
 411 -        if (c<=14 && c>2 && *s++=='.')
 412 -                return(*s);
  354+        if ((s = strrchr(as, '.')) && s[1] != '\0' && s[2] == '\0')
  355+                return s[1];
413356         return(0);
 414357 }
 415358 
     
 !
427370         return(s1);
 428371 }
 429372 
<> 373+int
430374 callsys(f, v)
 431375 char f[], *v[]; {
 432376         int t, status;
<> 377+        char *s;
433378 
 434379         if ((t=fork())==0) {
 435380                 execv(f, v);
<> 381+                if ((s = strrchr(f, '/')))
  382+                        execvp(s+1, v);
436383                 printf("Can't find %s\n", f);
 437384                 exit(100);
 438385         } else
     
 !
457404 char as[];
 458405 {
 459406         register char *otsp, *s;
<>460 -        int i;
461407 
 462408         otsp = tsp;
 463409         s = as;
<>464 -        while(*tsp++ = *s++);
  410+        while((*tsp++ = *s++));
465411         if (tsp >tsa+CHSPACE)
 466412                 {
<>467 -                tsp = tsa = i = calloc(CHSPACE+50,1);
 468 -                if (i== -1){
 469 -                        error("no space for file names");
 470 -                        dexit(8);
  413+                tsp = tsa = calloc(CHSPACE+50,1);
  414+                if (tsa== 0){
  415+                        error("no space for file names", 0);
  416+                        eflag = 8;
  417+                        dexit();
471418                         }
 472419                 }
 473420         return(otsp);
 474421 }
 475422 
<> 423+int
476424 nodup(l, os)
 477425 char **l, *os;
 478426 {
     
 !
482430         s = os;
 483431         if (getsuf(s) != 'o')
 484432                 return(1);
<>485 -        while(t = *l++) {
 486 -                while(c = *s++)
  433+        while((t = *l++)) {
  434+                while((c = *s++))
487435                         if (c != *t++)
 488436                                 break;
 489437                 if (*t=='\0' && c=='\0')
     
 !
493441         return(1);
 494442 }
 495443 
<> 444+int
<_496445 cunlink(f)
 497446 char *f;
 498447 {
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-22 09:30 +0100