Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.17
 
1.18
 
MAIN:ragge:20040622121245
 
cc.c
_>3535 
 3636 /*
 3737  * Front-end to the C compiler.
<> 38+ *
  39+ * Brief description of its syntax:
  40+ * - Files that end with .c are passed via cpp->ccom->as->ld
  41+ * - Files that end with .s are passed as->ld
  42+ * - Files that end with .o are passed directly to ld
  43+ * - Multiple files may be given on the command line.
  44+ * - Unrecognized options are all sent directly to ld.
  45+ * -c or -S cannot be combined with -o if multiple files are given.
  46+ *
  47+ * This file should be rewritten readable.
3848  */
 3949 #include <sys/types.h>
 4050 
     
 !
7484 int getsuf(char []);
 7585 int main(int, char *[]);
 7686 void error(char *, char *);
<> 87+void errorx(char *, char *, int);
7788 int nodup(char **, char *);
 7889 int callsys(char [], char *[]);
 7990 int cunlink(char *);
     
 !
116127         char *savetsp;
 117128         char *assource;
 118129         char **pv, *ptemp[MAXOPT], **pvt;
<>119 -        int nc, nl, i, j, c, f20, nxo, na, tt;
  130+        int nc, nl, i, j, c, f20, nxo, na;
120131         FILE *f;
 121132 
 122133         i = nc = nl = f20 = nxo = 0;
 123134         pv = ptemp;
 124135         while(++i < argc) {
<>125 -                if(*argv[i] == '-') switch (argv[i][1]) {
  136+                if (argv[i][0] == '-')
  137+                switch (argv[i][1]) {
126138                 default:
 127139                         goto passa;
 128140                 case 'X':
     
 !
165177                         cflag++;
 166178                         break;
 167179                 case 'o':
<>168 -                        if (++i < argc) {
 169 -                                outfile = argv[i];
 170 -                                if ((tt=getsuf(outfile))=='c'||
 171 -                                    (tt=='o' && !cflag)) {
 172 -                                        error("Would overwrite %s", outfile);
 173 -                                        exit(8);
 174 -                                }
 175 -                        }
  180+                        if (outfile)
  181+                                errorx("too many -o", "", 8);
  182+                        outfile = argv[++i];
176183                         break;
 177184                 case 'O':
 178185                         Oflag++;
     
 !
227234                         else
 228235                                 goto passa;
 229236                         break;
<>230 -
231237                 } else {
 232238                 passa:
 233239                         t = argv[i];
     
 !
254260                         }
 255261                 }
 256262         }
<> 263+        /* Sanity checking */
  264+        if (nc == 0 && nl == 0)
  265+                errorx("no input files", "", 8);
  266+        if (outfile && (cflag || sflag) && nc > 1)
  267+                errorx("-o given with -c || -S and more than one file", "", 8);
  268+        if (outfile && strcmp(outfile, clist[0]) == 0)
  269+                errorx("output file will be clobbered", "", 8);
  270+
257271         if (gflag) Oflag = 0;
 258272         if (noflflag)
 259273                 pref = proflag ? "/lib/fmcrt0.o" : "/lib/fcrt0.o";
     
 !
281295                 (tmp4 = copy(tmp0))[8] = '4';
 282296         pvt = pv;
 283297         for (i=0; i<nc; i++) {
<> 298+                /*
  299+                 * C preprocessor
  300+                 */
284301                 if (nc>1)
 285302                         printf("%s:\n", clist[i]);
 286303                 if (getsuf(clist[i])=='s') {
     
 !
311328                         dexit();
 312329                 if (xflag)
 313330                         goto assemble;
<> 331+
  332+                /*
  333+                 * C compiler
  334+                 */
314335                 av[0]= "ccom";
<>315 -                av[1] =tmp4;
  336+                av[1] = tmp4;
316337                 tsp = savetsp;
 317338                 if (pflag || exfail)
 318339                         {
     
 !
344365                 }
 345366                 if (sflag)
 346367                         continue;
<> 368+
  369+                /*
  370+                 * Assembler
  371+                 */
347372         assemble:
 348373                 av[0] = "as";
 349374                 av[1] = "-o";
<>350 -                av[2] = setsuf(clist[i], 'o');
  375+                if (outfile && cflag)
  376+                        av[2] = outfile;
  377+                else
  378+                        av[2] = setsuf(clist[i], 'o');
351379                 av[3] = xflag ? tmp4 : assource;
 352380                 if (dflag) {
 353381                         av[4] = alist;
     
 !
364392                 }
 365393                 cunlink(tmp4);
 366394         }
<> 395+
  396+        /*
  397+         * Linker
  398+         */
367399 nocom:
 368400         if (cflag==0 && nl!=0) {
 369401                 i = 0;
     
 !
443475         eflag++;
 444476 }
 445477 
<> 478+void
  479+errorx(char *s, char *x, int eval)
  480+{
  481+        error(s, x);
  482+        exit(eval);
  483+}
446484 
<>447 -
 448 -
<_449485 int
 450486 getsuf(as)
 451487 char as[];
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-08-31 08:15 +0200