Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.224
 
1.225
 
MAIN:ragge:20120803143510
 
cc.c
_>156156 #endif
 157157 
 158158 
<>159 -#define MAXFIL 10000
 160 -#define MAXLIB 10000
161159 #define MAXAV  10000
 162160 char    *tmp3;
 163161 char    *tmp4;
     
 !
194192 char *win32commandline(char *, char *[]);
 195193 #endif
 196194 char    *av[MAXAV];
<>197 -char    *llist[MAXLIB];
 198 -char    *aslist[MAXAV];
199195 char    *xlist[100];
 200196 int     xnum;
 201197 char    *mlist[100];
     
 !
380376 struct strlist middle_linker_flags;
 381377 struct strlist late_linker_flags;
 382378 struct strlist inputs;
<> 379+struct strlist assembler_flags;
  380+struct strlist temp_outputs;
383381 
 384382 int
 385383 main(int argc, char *argv[])
     
 !
388386         struct Wflags *Wf;
 389387         char *t, *u, *argp;
 390388         char *assource;
<>391 -        int ninput, nl, nas, i, j, c, nxo, na;
  389+        int ninput, i, j, nxo, na;
392390 
 393391         lav = argv;
 394392         lac = argc;
     
 !
407405         strlist_init(&middle_linker_flags);
 408406         strlist_init(&late_linker_flags);
 409407         strlist_init(&inputs);
<> 408+        strlist_init(&assembler_flags);
  409+        strlist_init(&temp_outputs);
410410 
 411411         if ((t = strrchr(argv[0], '/')))
 412412                 t = copy(t+1, 0);
     
 !
454454 #endif
 455455 #endif
 456456 
<>457 -        nl = nas = nxo = 0;
  457+        nxo = 0;
458458         while (--lac) {
 459459                 ++lav;
 460460                 argp = *lav;
 461461 
<>462 -                if (*argp != '-' || match(argp, "-"))
 463 -                        goto passa;
  462+                if (*argp != '-' || match(argp, "-")) {
  463+                        /* Check for duplicate .o files. */
  464+                        if (getsuf(argp) == 'o') {
  465+                                j = 0;
  466+                                STRLIST_FOREACH(s, &inputs)
  467+                                        if (match(argp, s->value))
  468+                                                j++;
  469+                                if (j)
  470+                                        continue; /* skip it */
  471+                        }
  472+                        strlist_append(&inputs, argp);
  473+                        continue;
  474+                }
464475 
 465476                 switch (argp[1]) {
 466477                 default:
     
 !
477488                                 /* NOTHING YET */;
 478489                                 (void)nxtopt(0); /* ignore arg */
 479490                         } else
<>480 -                                goto passa;
  491+                                owarning(argp);
481492                         break;
 482493 
 483494                 case 'B': /* other search paths for binaries */
     
 !
499510                         Xflag++;
 500511                         break;
 501512                 case 'W': /* Ignore (most of) W-flags */
<>502 -                        if (strncmp(argp, "-Wl,", 4) == 0) {
 503 -                                /* options to the linker */
 504 -                                t = &argp[4];
 505 -                                while ((u = strchr(t, ','))) {
 506 -                                        *u++ = 0;
 507 -                                        llist[nl++] = t;
 508 -                                        t = u;
 509 -                                }
 510 -                                llist[nl++] = t;
 511 -                        } else if (strncmp(argp, "-Wa,", 4) == 0) {
 512 -                                /* options to the assembler */
 513 -                                t = &argp[4];
 514 -                                while ((u = strchr(t, ','))) {
 515 -                                        *u++ = 0;
 516 -                                        aslist[nas++] = t;
 517 -                                        t = u;
 518 -                                }
 519 -                                aslist[nas++] = t;
  513+                        if ((t = argnxt(argp, "-Wl,"))) {
  514+                                u = strtok(t, ",");
  515+                                do {
  516+                                        strlist_append(&middle_linker_flags, u);
  517+                                } while ((u = strtok(NULL, ",")) != NULL);
  518+                        } else if ((t = argnxt(argp, "-Wa,"))) {
  519+                                u = strtok(t, ",");
  520+                                do {
  521+                                        strlist_append(&assembler_flags, u);
  522+                                } while ((u = strtok(NULL, ",")) != NULL);
520523                         } else if (strncmp(argp, "-Wc,", 4) == 0) {
 521524                                 /* options to ccom */
 522525                                 t = &argp[4];
     
 !
609612                         } else if (strcmp(argp, "-idirafter") == 0) {
 610613                                 strlist_append(&dirafterdirs, nxtopt(0));
 611614 #ifdef os_darwin
<>612 -                        } else if (strcmp(argp, "-install_name") == 0) {
 613 -                                llist[nl++] = argp;
 614 -                                llist[nl++] = nxtopt("-install_name");
  615+                        } else if (match(argp, "-install_name")) {
  616+                                strlist_append(&middle_linker_flags, argp);
  617+                                strlist_append(&middle_linker_flags, nxtopt(0));
615618 #endif
 616619                         } else
<>617 -                                goto passa;
  620+                                owarning(argp);
618621                         break;
 619622 
 620623                 case 'k': /* generate PIC code */
     
 !
637640                         }
 638641 #endif
 639642                         mlist[nm++] = argp;
<> 643+                        strlist_append(&middle_linker_flags, argp);
640644                         if (argp[2] == 0) {
<>641 -                                /* separate second arg */
 642 -                                /* give also to linker */
 643 -                                llist[nl++] = argp;
 644 -                                lav++, lac--;
 645 -                                mlist[nm++] = lav[0];
 646 -                                llist[nl++] = lav[0];
  645+                                t = nxtopt(0);
  646+                                strlist_append(&middle_linker_flags, t);
  647+                                mlist[nm++] = t;
647648                         }
 648649                         break;
 649650 
     
 !
658659                         else if (strcmp(argp, "-nodefaultlibs") == 0)
 659660                                 nostdlib++;
 660661                         else
<>661 -                                goto passa;
  662+                                owarning(argp);
662663                         break;
 663664 
 664665                 case 'p':
     
 !
734735 
 735736                 case 'c':
 736737 #ifdef os_darwin
<>737 -                        if (strcmp(argp, "-compatibility_version") == 0) {
 738 -                                llist[nl++] = argp;
 739 -                                llist[nl++] = nxtopt(0);
 740 -                        } else if (strcmp(argp, "-current_version") == 0) {
 741 -                                llist[nl++] = argp;
 742 -                                llist[nl++] = nxtopt(0);
  738+                        if (match(argp, "-compatibility_version") ||
  739+                            match(argp, "-current_version")) {
  740+                                strlist_append(&middle_linker_flags, argp);
  741+                                strlist_append(&middle_linker_flags, nxtopt(0));
743742                         } else
 744743 #endif
 745744                                 cflag++;
     
 !
793792 #endif
 794793                         if (strcmp(argp, "-static") == 0) {
 795794                                 Bstatic = 1;
<>796 -                        } else if (strcmp(argp, "-symbolic") == 0) {
 797 -                                llist[nl++] = "-Bsymbolic";
  795+                        } else if (match(argp, "-symbolic")) {
  796+                                strlist_append(&middle_linker_flags,
  797+                                    "-Bsymbolic");
798798                         } else if (strncmp(argp, "-std", 4) == 0) {
 799799                                 if (strcmp(&argp[5], "gnu99") == 0 ||
 800800                                     strcmp(&argp[5], "gnu9x") == 0)
 801801                                         xgnu99 = 1;
 802802                                 if (strcmp(&argp[5], "gnu89") == 0)
 803803                                         xgnu89 = 1;
 804804                         } else
<>805 -                                goto passa;
  805+                                owarning(argp);
806806                         break;
 807807                 }
 808808                 continue;
 809809 
<>810 -        passa:
 811 -                t = argp;
 812 -                if ((cxxsuf(getsufp(t)) && cxxflag) ||
 813 -                    (c=getsuf(t))=='c' || c=='S' || c=='i' ||
 814 -                    c=='s'|| Eflag || xcflag || xasm) {
 815 -                        strlist_append(&inputs, t);
 816 -                }
 817 -
 818 -                /* Check for duplicate .o files. */
 819 -                for (j = getsuf(t) == 'o' ? 0 : nl; j < nl; j++) {
 820 -                        if (strcmp(llist[j], t) == 0)
 821 -                                break;
 822 -                }
 823 -                if ((c=getsuf(t))!='c' && c!='S' &&
 824 -                    c!='s' && c!='i' && j==nl &&
 825 -                    !(cxxsuf(getsufp(t)) && cxxflag) && !xasm) {
 826 -                        llist[nl++] = t;
 827 -                        if (nl >= MAXLIB) {
 828 -                                error("Too many object/library files");
 829 -                                exit(1);
 830 -                        }
 831 -                        if (getsuf(t)=='o')
 832 -                                nxo++;
 833 -                }
834810         }
 835811 
 836812         /* Sanity checking */
     
 !
848824 #endif
 849825                 }
 850826         }
<>851 -        if (ninput == 0 && nl == 0)
  827+        if (ninput == 0)
852828                 errorx(8, "no input files");
 853829         if (outfile && (cflag || sflag || Eflag) && ninput > 1)
 854830                 errorx(8, "-o given with -c || -E || -S and more than one file");
     
 !
883859                 /*
 884860                  * C preprocessor
 885861                  */
<> 862+                if (getsuf(ss->value) == 'o' || getsuf(ss->value) == 'a')
  863+                        continue;
  864+
886865                 if (ninput > 1 && !Eflag)
 887866                         printf("%s:\n", ss->value);
 888867                 onlyas = 0;
     
 !
10391018         assemble:
 10401019                 na = 0;
 10411020                 av[na++] = as;
<>1042 -                for (j = 0; j < nas; j++)
 1043 -                        av[na++] = aslist[j];
  1021+                STRLIST_FOREACH(s, &assembler_flags) {
  1022+                        av[na++] = s->value;
  1023+                }
10441024 #if defined(USE_YASM)
 10451025                 av[na++] = "-p";
 10461026                 av[na++] = "gnu";
     
 !
10841064                         ermfile = outfile;
 10851065                 else if (cflag)
 10861066                         ermfile = setsuf(ss->value, 'o');
<>1087 -                else
  1067+                else {
10881068                         ermfile = ss->value = gettmp();
<> 1069+                        strlist_append(&temp_outputs, ermfile);
  1070+                }
10891071 
 10901072                 av[na++] = ermfile;
 10911073                 av[na++] = assource;
     
 !
10941076                         cflag++;
 10951077                         eflag++;
 10961078                         cunlink(tmp4);
<>1097 -                        continue;
10981079                 }
 10991080                 cunlink(tmp4);
 11001081         }
     
 !
11061087          * Linker
 11071088          */
 11081089 nocom:
<>1109 -        if (cflag==0 && ninput+nl != 0) {
  1090+        if (cflag==0 && ninput != 0) {
11101091                 j = 0;
 11111092                 av[j++] = ld;
 11121093 #ifndef MSLINKER
     
 !
11971178                         }
 11981179                 }
 11991180                 i = 0;
<> 1181+                STRLIST_FOREACH(s, &middle_linker_flags)
  1182+                        av[j++] = s->value;
12001183                 STRLIST_FOREACH(s, &inputs)
 12011184                         av[j++] = s->value;
 12021185                 STRLIST_FOREACH(s, &late_linker_flags)
 12031186                         av[j++] = s->value;
 12041187 
 12051188                 i = 0;
<>1206 -                while(i<nl) {
 1207 -                        av[j++] = llist[i++];
 1208 -                        if (j >= MAXAV)
 1209 -                                error("Too many ld options");
 1210 -                }
12111189 #if !defined(os_darwin) && !defined(os_sunos)
 12121190                 /* darwin assembler doesn't want -g */
 12131191                 if (gflag)
     
 !
12651243                 }
 12661244                 av[j++] = 0;
 12671245                 eflag |= callsys(ld, av);
<>1268 -                if (ninput == 1 && nxo==1 && eflag==0)
 1269 -                        cunlink(STRLIST_FIRST(&inputs)->value);
 1270 -                else if (ninput > 0 && eflag == 0) {
 1271 -                        /* remove .o files XXX ugly */
 1272 -                        STRLIST_FOREACH(s, &inputs)
 1273 -                                cunlink(s->value);
 1274 -                }
  1246+                STRLIST_FOREACH(s, &temp_outputs)
  1247+                        cunlink(s->value);
12751248         }
 12761249 #ifdef notdef
 12771250         strlist_free(&crtdirs);
     
 !
12881261         strlist_free(&middle_linker_flags);
 12891262         strlist_free(&late_linker_flags);
 12901263         strlist_free(&inputs);
<> 1264+        strlist_free(&assembler_flags);
  1265+        strlist_free(&temp_outputs);
<_12911266 #endif
 12921267         dexit(eflag);
 12931268         return 0;
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-18 21:17 +0100