Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.219
 
1.220
 
MAIN:ragge:20120802132736
 
cc.c
_>132132 char    *tmp3;
 133133 char    *tmp4;
 134134 char    *outfile, *ermfile;
<> 135+static char **lav;
  136+static int lac;
135137 static void add_prefix(const char *);
 136138 static char *find_file(const char *, int);
 137139 char *copy(const char *, int);
     
 !
152154 void aerror(char *);
 153155 void oerror(char *);
 154156 char *argnxt(char *, char *);
<> 157+char *nxtopt(char *o);
155158 #ifdef os_win32
 156159 char *win32pathsubst(char *);
 157160 char *win32commandline(char *, char *[]);
     
 !
366369 #ifdef MULTITARGET
 367370         int k;
 368371 #endif
<> 372+        lav = argv;
  373+        lac = argc;
369374 
 370375         strlist_init(&preprocessor_flags);
 371376         strlist_init(&incdirs);
     
 !
416421 #endif
 417422 #endif
 418423 
<>419 -        i = nc = nl = nas = ncpp = nxo = 0;
  424+        nc = nl = nas = ncpp = nxo = 0;
420425         pv = ptemp;
<>421 -        while(++i < argc) {
 422 -                if (argv[i][0] == '-') {
  426+        while (--lac) {
  427+                ++lav;
  428+                argp = *lav;
423429 
<>424 -                        argp = argv[i];
 425 -                        switch (argv[i][1]) {
 426 -                        default:
 427 -                                goto passa;
  430+                if (*argp != '-' || match(argp, "-"))
  431+                        goto passa;
  432+
  433+                switch (argp[1]) {
  434+                default:
  435+                        goto passa;
428436 #ifdef notyet
 429437         /* must add library options first (-L/-l/...) */
<>430 -                                error("unrecognized option `-%c'", argv[i][1]);
 431 -                                break;
  438+                        oerror(argp);
  439+                        break;
432440 #endif
 433441 
<>434 -                        case '-': /* double -'s */
 435 -                                if (strcmp(argv[i], "--version") == 0) {
 436 -                                        printf("%s\n", VERSSTR);
 437 -                                        return 0;
 438 -                                } else if (strncmp(argv[i], "--sysroot=", 10) == 0) {
 439 -                                        sysroot = argv[i] + 10;
 440 -                                } else if (strcmp(argv[i], "--param") == 0) {
 441 -                                        /* NOTHING YET */;
 442 -                                        i++; /* ignore arg */
 443 -                                } else
 444 -                                        goto passa;
 445 -                                break;
  442+                case '-': /* double -'s */
  443+                        if (match(argp, "--version")) {
  444+                                printf("%s\n", VERSSTR);
  445+                                return 0;
  446+                        } else if (strncmp(argp, "--sysroot=", 10) == 0) {
  447+                                sysroot = argp + 10;
  448+                        } else if (strcmp(argp, "--param") == 0) {
  449+                                /* NOTHING YET */;
  450+                                (void)nxtopt(0); /* ignore arg */
  451+                        } else
  452+                                goto passa;
  453+                        break;
446454 
<>447 -                        case 'B': /* other search paths for binaries */
 448 -                                add_prefix(argv[i] + 2);
 449 -                                break;
  455+                case 'B': /* other search paths for binaries */
  456+                        add_prefix(argp + 2);
  457+                        break;
450458 
 451459 #ifdef MULTITARGET
<>452 -                        case 'b':
 453 -                                t = &argv[i][2];
 454 -                                if (*t == '\0' && i + 1 < argc) {
 455 -                                        t = argv[i+1];
 456 -                                        i++;
 457 -                                }
 458 -                                if (strncmp(t, "?", 1) == 0) {
 459 -                                        /* show machine targets */
 460 -                                        printf("Available machine targets:");
 461 -                                        for (j=0; cppmds[j].mach; j++)
 462 -                                                printf(" %s",cppmds[j].mach);
 463 -                                        printf("\n");
 464 -                                        exit(0);
 465 -                                }
  460+                case 'b':
  461+                        t = &argp[2];
  462+                        if (*t == '\0' && i + 1 < argc) {
  463+                                t = nxtopt(0);
  464+                        }
  465+                        if (strncmp(t, "?", 1) == 0) {
  466+                                /* show machine targets */
  467+                                printf("Available machine targets:");
466468                                 for (j=0; cppmds[j].mach; j++)
<>467 -                                        if (strcmp(t, cppmds[j].mach) == 0) {
 468 -                                                mach = cppmds[j].mach;
 469 -                                                break;
 470 -                                        }
 471 -                                if (cppmds[j].mach == NULL)
 472 -                                        errorx(1, "unknown target arch %s", t);
 473 -                                break;
  469+                                        printf(" %s",cppmds[j].mach);
  470+                                printf("\n");
  471+                                exit(0);
  472+                        }
  473+                        for (j=0; cppmds[j].mach; j++)
  474+                                if (strcmp(t, cppmds[j].mach) == 0) {
  475+                                        mach = cppmds[j].mach;
  476+                                        break;
  477+                                }
  478+                        if (cppmds[j].mach == NULL)
  479+                                errorx(1, "unknown target arch %s", t);
  480+                        break;
474481 #endif
 475482 
<>476 -                        case 'C':
 477 -                                if (match(argp, "-C") || match(argp, "-CC"))
 478 -                                        strlist_append(&preprocessor_flags, argp);
 479 -                                else
 480 -                                        oerror(argp);
 481 -                                break;
  483+                case 'C':
  484+                        if (match(argp, "-C") || match(argp, "-CC"))
  485+                                strlist_append(&preprocessor_flags, argp);
  486+                        else
  487+                                oerror(argp);
  488+                        break;
482489 
<>483 -                        case 'X':
 484 -                                Xflag++;
 485 -                                break;
 486 -                        case 'W': /* Ignore (most of) W-flags */
 487 -                                if (strncmp(argv[i], "-Wl,", 4) == 0) {
 488 -                                        /* options to the linker */
 489 -                                        t = &argv[i][4];
 490 -                                        while ((u = strchr(t, ','))) {
 491 -                                                *u++ = 0;
 492 -                                                llist[nl++] = t;
 493 -                                                t = u;
 494 -                                        }
  490+                case 'X':
  491+                        Xflag++;
  492+                        break;
  493+                case 'W': /* Ignore (most of) W-flags */
  494+                        if (strncmp(argp, "-Wl,", 4) == 0) {
  495+                                /* options to the linker */
  496+                                t = &argp[4];
  497+                                while ((u = strchr(t, ','))) {
  498+                                        *u++ = 0;
495499                                         llist[nl++] = t;
<>496 -                                } else if (strncmp(argv[i], "-Wa,", 4) == 0) {
 497 -                                        /* options to the assembler */
 498 -                                        t = &argv[i][4];
 499 -                                        while ((u = strchr(t, ','))) {
 500 -                                                *u++ = 0;
 501 -                                                aslist[nas++] = t;
 502 -                                                t = u;
 503 -                                        }
  500+                                        t = u;
  501+                                }
  502+                                llist[nl++] = t;
  503+                        } else if (strncmp(argp, "-Wa,", 4) == 0) {
  504+                                /* options to the assembler */
  505+                                t = &argp[4];
  506+                                while ((u = strchr(t, ','))) {
  507+                                        *u++ = 0;
504508                                         aslist[nas++] = t;
<>505 -                                } else if (strncmp(argv[i], "-Wc,", 4) == 0) {
 506 -                                        /* options to ccom */
 507 -                                        t = &argv[i][4];
 508 -                                        while ((u = strchr(t, ','))) {
 509 -                                                *u++ = 0;
 510 -                                                wlist[nw++] = t;
 511 -                                                t = u;
 512 -                                        }
  509+                                        t = u;
  510+                                }
  511+                                aslist[nas++] = t;
  512+                        } else if (strncmp(argp, "-Wc,", 4) == 0) {
  513+                                /* options to ccom */
  514+                                t = &argp[4];
  515+                                while ((u = strchr(t, ','))) {
  516+                                        *u++ = 0;
513517                                         wlist[nw++] = t;
<>514 -                                } else if ((t = argnxt(argp, "-Wp,"))) {
 515 -                                        u = strtok(t, ",");
 516 -                                        do {
 517 -                                                strlist_append(&preprocessor_flags, u);
 518 -                                        } while ((u = strtok(NULL, ",")) != NULL);
 519 -                                } else if (strcmp(argv[i], "-Werror") == 0) {
 520 -                                        wlist[nw++] = argv[i];
 521 -                                } else if (strcmp(argv[i], "-Wall") == 0) {
 522 -                                        Wallflag = 1;
 523 -                                } else if (strcmp(argv[i], "-WW") == 0) {
 524 -                                        Wflag = 1;
 525 -                                } else {
 526 -                                        /* pass through, if supported */
 527 -                                        t = &argv[i][2];
 528 -                                        if (strncmp(t, "no-", 3) == 0)
 529 -                                                t += 3;
 530 -                                        if (strncmp(t, "error=", 6) == 0)
 531 -                                                t += 6;
 532 -                                        for (Wf = Wflags; Wf->name; Wf++) {
 533 -                                                if (strcmp(t, Wf->name) == 0)
 534 -                                                        wlist[nw++] = argv[i];
 535 -                                        }
  518+                                        t = u;
536519                                 }
<>537 -                                break;
 538 -
 539 -                        case 'f': /* GCC compatibility flags */
 540 -                                if (strcmp(argv[i], "-fPIC") == 0)
 541 -                                        kflag = F_PIC;
 542 -                                else if (strcmp(argv[i], "-fpic") == 0)
 543 -                                        kflag = F_pic;
 544 -                                else if (strcmp(argv[i], "-ffreestanding") == 0)
 545 -                                        freestanding = 1;
 546 -                                else if (strcmp(argv[i],
 547 -                                    "-fsigned-char") == 0)
 548 -                                        xuchar = 0;
 549 -                                else if (strcmp(argv[i],
 550 -                                    "-fno-signed-char") == 0)
 551 -                                        xuchar = 1;
 552 -                                else if (strcmp(argv[i],
 553 -                                    "-funsigned-char") == 0)
 554 -                                        xuchar = 1;
 555 -                                else if (strcmp(argv[i],
 556 -                                    "-fno-unsigned-char") == 0)
 557 -                                        xuchar = 0;
 558 -                                else if (strcmp(argv[i],
 559 -                                    "-fstack-protector") == 0) {
 560 -                                        flist[nf++] = argv[i];
 561 -                                        sspflag++;
 562 -                                } else if (strcmp(argv[i],
 563 -                                    "-fstack-protector-all") == 0) {
 564 -                                        flist[nf++] = argv[i];
 565 -                                        sspflag++;
 566 -                                } else if (strcmp(argv[i],
 567 -                                    "-fno-stack-protector") == 0) {
 568 -                                        flist[nf++] = argv[i];
 569 -                                        sspflag = 0;
 570 -                                } else if (strcmp(argv[i],
 571 -                                    "-fno-stack-protector-all") == 0) {
 572 -                                        flist[nf++] = argv[i];
 573 -                                        sspflag = 0;
  520+                                wlist[nw++] = t;
  521+                        } else if ((t = argnxt(argp, "-Wp,"))) {
  522+                                u = strtok(t, ",");
  523+                                do {
  524+                                        strlist_append(&preprocessor_flags, u);
  525+                                } while ((u = strtok(NULL, ",")) != NULL);
  526+                        } else if (strcmp(argp, "-Werror") == 0) {
  527+                                wlist[nw++] = argp;
  528+                        } else if (strcmp(argp, "-Wall") == 0) {
  529+                                Wallflag = 1;
  530+                        } else if (strcmp(argp, "-WW") == 0) {
  531+                                Wflag = 1;
  532+                        } else {
  533+                                /* pass through, if supported */
  534+                                t = &argp[2];
  535+                                if (strncmp(t, "no-", 3) == 0)
  536+                                        t += 3;
  537+                                if (strncmp(t, "error=", 6) == 0)
  538+                                        t += 6;
  539+                                for (Wf = Wflags; Wf->name; Wf++) {
  540+                                        if (strcmp(t, Wf->name) == 0)
  541+                                                wlist[nw++] = argp;
574542                                 }
<>575 -                                /* silently ignore the rest */
 576 -                                break;
  543+                        }
  544+                        break;
577545 
<>578 -                        case 'g': /* create debug output */
 579 -                                if (argv[i][2] == '0')
 580 -                                        gflag = 0;
 581 -                                else
 582 -                                        gflag++;
 583 -                                break;
  546+                case 'f': /* GCC compatibility flags */
  547+                        if (strcmp(argp, "-fPIC") == 0)
  548+                                kflag = F_PIC;
  549+                        else if (strcmp(argp, "-fpic") == 0)
  550+                                kflag = F_pic;
  551+                        else if (strcmp(argp, "-ffreestanding") == 0)
  552+                                freestanding = 1;
  553+                        else if (strcmp(argp,
  554+                            "-fsigned-char") == 0)
  555+                                xuchar = 0;
  556+                        else if (strcmp(argp,
  557+                            "-fno-signed-char") == 0)
  558+                                xuchar = 1;
  559+                        else if (strcmp(argp,
  560+                            "-funsigned-char") == 0)
  561+                                xuchar = 1;
  562+                        else if (strcmp(argp,
  563+                            "-fno-unsigned-char") == 0)
  564+                                xuchar = 0;
  565+                        else if (strcmp(argp,
  566+                            "-fstack-protector") == 0) {
  567+                                flist[nf++] = argp;
  568+                                sspflag++;
  569+                        } else if (strcmp(argp,
  570+                            "-fstack-protector-all") == 0) {
  571+                                flist[nf++] = argp;
  572+                                sspflag++;
  573+                        } else if (strcmp(argp,
  574+                            "-fno-stack-protector") == 0) {
  575+                                flist[nf++] = argp;
  576+                                sspflag = 0;
  577+                        } else if (strcmp(argp,
  578+                            "-fno-stack-protector-all") == 0) {
  579+                                flist[nf++] = argp;
  580+                                sspflag = 0;
  581+                        }
  582+                        /* silently ignore the rest */
  583+                        break;
584584 
<>585 -                        case 'D':
 586 -                        case 'U':
 587 -                        case 'I': /* Add include dirs */
 588 -                                sl = argp[1] == 'I' ? &incdirs : &preprocessor_flags;
 589 -                                strlist_append(sl, argp);
 590 -                                if (argp[2] != 0)
 591 -                                        break;
 592 -                                if (argc == i+1)
 593 -                                        aerror(argp);
 594 -                                strlist_append(sl, argv[++i]);
  585+                case 'g': /* create debug output */
  586+                        if (argp[2] == '0')
  587+                                gflag = 0;
  588+                        else
  589+                                gflag++;
  590+                        break;
  591+
  592+                case 'D':
  593+                case 'U':
  594+                case 'I': /* Add include dirs */
  595+                        sl = argp[1] == 'I' ? &incdirs : &preprocessor_flags;
  596+                        strlist_append(sl, argp);
  597+                        if (argp[2] != 0)
595598                                 break;
<> 599+                        strlist_append(sl, nxtopt(argp));
  600+                        break;
596601 
<>597 -                        case 'i':
 598 -                                if (strcmp(argv[i], "-isystem") == 0) {
 599 -                                        *pv++ = "-S";
 600 -                                        *pv++ = argv[++i];
 601 -                                } else if (strcmp(argv[i], "-include") == 0) {
 602 -                                        *pv++ = "-i";
 603 -                                        *pv++ = argv[++i];
 604 -                                } else if (strcmp(argv[i], "-idirafter") == 0) {
 605 -                                        idirafter = argv[++i];
  602+                case 'i':
  603+                        if (strcmp(argp, "-isystem") == 0) {
  604+                                *pv++ = "-S";
  605+                                *pv++ = nxtopt("-isystem");
  606+                        } else if (strcmp(argp, "-include") == 0) {
  607+                                *pv++ = "-i";
  608+                                *pv++ = nxtopt("-include");
  609+                        } else if (strcmp(argp, "-idirafter") == 0) {
  610+                                idirafter = nxtopt("-idirafter");
606611 #ifdef os_darwin
<>607 -                                } else if (strcmp(argv[i], "-install_name") == 0) {
 608 -                                        llist[nl++] = argv[i];
 609 -                                        llist[nl++] = argv[++i];
  612+                        } else if (strcmp(argp, "-install_name") == 0) {
  613+                                llist[nl++] = argp;
  614+                                llist[nl++] = nxtopt("-install_name");
610615 #endif
<>611 -                                } else
 612 -                                        goto passa;
 613 -                                break;
  616+                        } else
  617+                                goto passa;
  618+                        break;
614619 
<>615 -                        case 'k': /* generate PIC code */
 616 -                                kflag = F_pic;
 617 -                                break;
  620+                case 'k': /* generate PIC code */
  621+                        kflag = F_pic;
  622+                        break;
618623 
<>619 -                        case 'm': /* target-dependent options */
  624+                case 'm': /* target-dependent options */
620625 #ifdef mach_amd64
<>621 -                                /* need to call i386 ccom for this */
 622 -                                if (strcmp(argv[i], "-m32") == 0) {
 623 -                                        pass0 = LIBEXECDIR "/ccom_i386";
 624 -                                        amd64_i386 = 1;
 625 -                                        break;
 626 -                                }
 627 -#endif
 628 -                                mlist[nm++] = argv[i];
 629 -                                if (argv[i][2] == 0) {
 630 -                                        /* separate second arg */
 631 -                                        /* give also to linker */
 632 -                                        llist[nl++] = argv[i++];
 633 -                                        mlist[nm++] = argv[i];
 634 -                                        llist[nl++] = argv[i];
 635 -                                }
  626+                        /* need to call i386 ccom for this */
  627+                        if (strcmp(argp, "-m32") == 0) {
  628+                                pass0 = LIBEXECDIR "/ccom_i386";
  629+                                amd64_i386 = 1;
636630                                 break;
<> 631+                        }
  632+#endif
  633+                        mlist[nm++] = argp;
  634+                        if (argp[2] == 0) {
  635+                                /* separate second arg */
  636+                                /* give also to linker */
  637+                                llist[nl++] = argp;
  638+                                lav++, lac--;
  639+                                mlist[nm++] = lav[0];
  640+                                llist[nl++] = lav[0];
  641+                        }
  642+                        break;
637643 
<>638 -                        case 'n': /* handle -n flags */
 639 -                                if (strcmp(argv[i], "-nostdinc") == 0)
 640 -                                        nostdinc++;
 641 -                                else if (strcmp(argv[i], "-nostdlib") == 0) {
 642 -                                        nostdlib++;
 643 -                                        nostartfiles++;
 644 -                                } else if (strcmp(argv[i], "-nostartfiles") == 0)
 645 -                                        nostartfiles = 1;
 646 -                                else if (strcmp(argv[i], "-nodefaultlibs") == 0)
 647 -                                        nostdlib++;
 648 -                                else
 649 -                                        goto passa;
 650 -                                break;
  644+                case 'n': /* handle -n flags */
  645+                        if (strcmp(argp, "-nostdinc") == 0)
  646+                                nostdinc++;
  647+                        else if (strcmp(argp, "-nostdlib") == 0) {
  648+                                nostdlib++;
  649+                                nostartfiles++;
  650+                        } else if (strcmp(argp, "-nostartfiles") == 0)
  651+                                nostartfiles = 1;
  652+                        else if (strcmp(argp, "-nodefaultlibs") == 0)
  653+                                nostdlib++;
  654+                        else
  655+                                goto passa;
  656+                        break;
651657 
<>652 -                        case 'p':
 653 -                                if (strcmp(argv[i], "-pg") == 0 ||
 654 -                                    strcmp(argv[i], "-p") == 0)
 655 -                                        pgflag++;
 656 -                                else if (strcmp(argv[i], "-pthread") == 0)
 657 -                                        pthreads++;
 658 -                                else if (strcmp(argv[i], "-pipe") == 0)
 659 -                                        /* NOTHING YET */;
 660 -                                else if (strcmp(argv[i], "-pedantic") == 0)
 661 -                                        /* NOTHING YET */;
 662 -                                else if (strcmp(argv[i],
 663 -                                    "-print-prog-name=ld") == 0) {
 664 -                                        printf("%s\n", LINKER);
 665 -                                        return 0;
 666 -                                } else if (strcmp(argv[i],
 667 -                                    "-print-multi-os-directory") == 0) {
 668 -                                        printf("%s\n", MULTIOSDIR);
 669 -                                        return 0;
 670 -                                } else
 671 -                                        errorx(1, "unknown option %s", argv[i]);
 672 -                                break;
  658+                case 'p':
  659+                        if (strcmp(argp, "-pg") == 0 ||
  660+                            strcmp(argp, "-p") == 0)
  661+                                pgflag++;
  662+                        else if (strcmp(argp, "-pthread") == 0)
  663+                                pthreads++;
  664+                        else if (strcmp(argp, "-pipe") == 0)
  665+                                /* NOTHING YET */;
  666+                        else if (strcmp(argp, "-pedantic") == 0)
  667+                                /* NOTHING YET */;
  668+                        else if (strcmp(argp,
  669+                            "-print-prog-name=ld") == 0) {
  670+                                printf("%s\n", LINKER);
  671+                                return 0;
  672+                        } else if (strcmp(argp,
  673+                            "-print-multi-os-directory") == 0) {
  674+                                printf("%s\n", MULTIOSDIR);
  675+                                return 0;
  676+                        } else
  677+                                oerror(argp);
  678+                        break;
673679 
<>674 -                        case 'r':
 675 -                                rflag = 1;
 676 -                                break;
  680+                case 'r':
  681+                        rflag = 1;
  682+                        break;
677683 
<>678 -                        case 'x':
 679 -                                t = &argv[i][2];
 680 -                                if (*t == 0)
 681 -                                        t = argv[++i];
 682 -                                if (strcmp(t, "c") == 0)
 683 -                                        xcflag = 1; /* default */
 684 -                                else if (strcmp(t, "assembler") == 0)
 685 -                                        xasm = 1;
 686 -                                else if (strcmp(t, "assembler-with-cpp") == 0)
 687 -                                        ascpp = 1;
 688 -                                else if (strcmp(t, "c++") == 0)
 689 -                                        cxxflag++;
 690 -                                else
 691 -                                        xlist[xnum++] = argv[i];
 692 -                                break;
 693 -                        case 't':
 694 -                                tflag++;
 695 -                                break;
 696 -                        case 'S':
 697 -                                sflag++;
 698 -                                cflag++;
 699 -                                break;
 700 -                        case 'o':
 701 -                                if (outfile)
 702 -                                        errorx(8, "too many -o");
 703 -                                outfile = argv[++i];
 704 -                                break;
 705 -                        case 'O':
 706 -                                if (argv[i][2] == '\0')
 707 -                                        Oflag++;
 708 -                                else if (argv[i][3] == '\0' && isdigit((unsigned char)argv[i][2]))
 709 -                                        Oflag = argv[i][2] - '0';
 710 -                                else if (argv[i][3] == '\0' && argv[i][2] == 's')
 711 -                                        Oflag = 1;      /* optimize for space only */
 712 -                                else
 713 -                                        error("unknown option %s", argv[i]);
 714 -                                break;
 715 -                        case 'E':
 716 -                                Eflag++;
 717 -                                break;
 718 -                        case 'P':
 719 -                                pflag++;
 720 -                                *pv++ = argv[i];
 721 -                        case 'c':
  684+                case 'x':
  685+                        t = nxtopt("-x");
  686+                        if (match(t, "c"))
  687+                                xcflag = 1; /* default */
  688+                        else if (match(t, "assembler"))
  689+                                xasm = 1;
  690+                        else if (match(t, "assembler-with-cpp"))
  691+                                ascpp = 1;
  692+                        else if (match(t, "c++"))
  693+                                cxxflag++;
  694+                        else if (argp[2])
  695+                                xlist[xnum++] = argp;
  696+                        else
  697+                                xlist[xnum++] = "-x", xlist[xnum++] = t;
  698+                        break;
  699+                case 't':
  700+                        tflag++;
  701+                        break;
  702+                case 'S':
  703+                        sflag++;
  704+                        cflag++;
  705+                        break;
  706+                case 'o':
  707+                        if (outfile)
  708+                                errorx(8, "too many -o");
  709+                        outfile = nxtopt("-o");
  710+                        break;
  711+                case 'O':
  712+                        if (argp[2] == '\0')
  713+                                Oflag++;
  714+                        else if (argp[3] == '\0' && isdigit((unsigned char)argp[2]))
  715+                                Oflag = argp[2] - '0';
  716+                        else if (argp[3] == '\0' && argp[2] == 's')
  717+                                Oflag = 1;      /* optimize for space only */
  718+                        else
  719+                                oerror(argp);
  720+                        break;
  721+                case 'E':
  722+                        Eflag++;
  723+                        break;
  724+                case 'P':
  725+                        pflag++;
  726+                        *pv++ = argp;
  727+                case 'c':
722728 #ifdef os_darwin
<>723 -                                if (strcmp(argv[i], "-compatibility_version") == 0) {
 724 -                                        llist[nl++] = argv[i];
 725 -                                        llist[nl++] = argv[++i];
 726 -                                } else if (strcmp(argv[i], "-current_version") == 0) {
 727 -                                        llist[nl++] = argv[i];
 728 -                                        llist[nl++] = argv[++i];
 729 -                                } else
  729+                        if (strcmp(argp, "-compatibility_version") == 0) {
  730+                                llist[nl++] = argp;
  731+                                llist[nl++] = nxtopt(0);
  732+                        } else if (strcmp(argp, "-current_version") == 0) {
  733+                                llist[nl++] = argp;
  734+                                llist[nl++] = nxtopt(0);
  735+                        } else
730736 #endif
<>731 -                                        cflag++;
 732 -                                break;
  737+                                cflag++;
  738+                        break;
733739 #if 0
<>734 -                        case '2':
 735 -                                if(argv[i][2] == '\0')
 736 -                                        pref = "/lib/crt2.o";
 737 -                                else {
 738 -                                        pref = "/lib/crt20.o";
 739 -                                }
 740 -                                break;
  740+                case '2':
  741+                        if(argp[2] == '\0')
  742+                                pref = "/lib/crt2.o";
  743+                        else {
  744+                                pref = "/lib/crt20.o";
  745+                        }
  746+                        break;
741747 #endif
<>742 -                        case 'M':
 743 -                                switch (argv[i][2]) {
 744 -                                case '\0': Mflag++; break;
 745 -                                case 'P': MPflag++; break;
 746 -                                case 'F': outfile = argv[++i]; break;
 747 -                                case 'T':
 748 -                                case 'Q':
 749 -                                        j = strlen(argv[++i]);
 750 -                                        t = copy("-xM.,", j);
 751 -                                        strlcat(t, argv[i], j+6);
 752 -                                        t[3] = argv[i-1][2];
 753 -                                        Mfiles[nMfiles++] = t;
 754 -                                        break;
 755 -                                default:
 756 -                                        error("unknown option '%s'", argv[i]);
 757 -                                }
  748+                case 'M':
  749+                        switch (argp[2]) {
  750+                        case '\0': Mflag++; break;
  751+                        case 'P': MPflag++; break;
  752+                        case 'F': outfile = nxtopt(0); break;
  753+                        case 'T':
  754+                        case 'Q':
  755+                                j = strlen(u = nxtopt(0));
  756+                                t = copy("-xM.,", j);
  757+                                strlcat(t, u, j+6);
  758+                                t[3] = argp[2];
  759+                                Mfiles[nMfiles++] = t;
758760                                 break;
<> 761+                        default:
  762+                                oerror(argp);
  763+                        }
  764+                        break;
759765 
<>760 -                        case 'd':
  766+                case 'd':
761767 #ifdef os_darwin
<>762 -                                if (strcmp(argv[i], "-dynamiclib") == 0) {
 763 -                                        shared = 1;
 764 -                                } else
  768+                        if (strcmp(argp, "-dynamiclib") == 0) {
  769+                                shared = 1;
  770+                        } else
765771 #endif
<>766 -                                break;
 767 -                        case 'v':
 768 -                                printf("%s\n", VERSSTR);
 769 -                                vflag++;
 770 -                                break;
  772+                        break;
  773+                case 'v':
  774+                        printf("%s\n", VERSSTR);
  775+                        vflag++;
  776+                        break;
771777 
<>772 -                        case 's':
  778+                case 's':
773779 #ifndef os_darwin
<>774 -                                if (strcmp(argv[i], "-shared") == 0) {
 775 -                                        shared = 1;
 776 -                                } else
  780+                        if (strcmp(argp, "-shared") == 0) {
  781+                                shared = 1;
  782+                        } else
777783 #endif
<>778 -                                if (strcmp(argv[i], "-static") == 0) {
 779 -                                        Bstatic = 1;
 780 -                                } else if (strcmp(argv[i], "-symbolic") == 0) {
 781 -                                        llist[nl++] = "-Bsymbolic";
 782 -                                } else if (strncmp(argv[i], "-std", 4) == 0) {
 783 -                                        if (strcmp(&argv[i][5], "gnu99") == 0 ||
 784 -                                            strcmp(&argv[i][5], "gnu9x") == 0)
 785 -                                                xgnu99 = 1;
 786 -                                        if (strcmp(&argv[i][5], "gnu89") == 0)
 787 -                                                xgnu89 = 1;
 788 -                                } else
 789 -                                        goto passa;
 790 -                                break;
  784+                        if (strcmp(argp, "-static") == 0) {
  785+                                Bstatic = 1;
  786+                        } else if (strcmp(argp, "-symbolic") == 0) {
  787+                                llist[nl++] = "-Bsymbolic";
  788+                        } else if (strncmp(argp, "-std", 4) == 0) {
  789+                                if (strcmp(&argp[5], "gnu99") == 0 ||
  790+                                    strcmp(&argp[5], "gnu9x") == 0)
  791+                                        xgnu99 = 1;
  792+                                if (strcmp(&argp[5], "gnu89") == 0)
  793+                                        xgnu89 = 1;
  794+                        } else
  795+                                goto passa;
  796+                        break;
  797+                }
  798+                continue;
  799+
  800+        passa:
  801+                t = argp;
  802+                if (*argp == '-' && argp[1] == 'L')
  803+                        ;
  804+                else if ((cxxsuf(getsufp(t)) && cxxflag) ||
  805+                    (c=getsuf(t))=='c' || c=='S' || c=='i' ||
  806+                    c=='s'|| Eflag || xcflag || xasm) {
  807+                        clist[nc++] = t;
  808+                        if (nc>=MAXFIL) {
  809+                                error("Too many source files");
  810+                                exit(1);
791811                         }
<>792 -                } else {
 793 -                passa:
 794 -                        t = argv[i];
 795 -                        if (*argv[i] == '-' && argv[i][1] == 'L')
 796 -                                ;
 797 -                        else if ((cxxsuf(getsufp(t)) && cxxflag) ||
 798 -                            (c=getsuf(t))=='c' || c=='S' || c=='i' ||
 799 -                            c=='s'|| Eflag || xcflag || xasm) {
 800 -                                clist[nc++] = t;
 801 -                                if (nc>=MAXFIL) {
 802 -                                        error("Too many source files");
 803 -                                        exit(1);
 804 -                                }
 805 -                        }
  812+                }
806813 
<>807 -                        /* Check for duplicate .o files. */
 808 -                        for (j = getsuf(t) == 'o' ? 0 : nl; j < nl; j++) {
 809 -                                if (strcmp(llist[j], t) == 0)
 810 -                                        break;
  814+                /* Check for duplicate .o files. */
  815+                for (j = getsuf(t) == 'o' ? 0 : nl; j < nl; j++) {
  816+                        if (strcmp(llist[j], t) == 0)
  817+                                break;
  818+                }
  819+                if ((c=getsuf(t))!='c' && c!='S' &&
  820+                    c!='s' && c!='i' && j==nl &&
  821+                    !(cxxsuf(getsufp(t)) && cxxflag) && !xasm) {
  822+                        llist[nl++] = t;
  823+                        if (nl >= MAXLIB) {
  824+                                error("Too many object/library files");
  825+                                exit(1);
811826                         }
<>812 -                        if ((c=getsuf(t))!='c' && c!='S' &&
 813 -                            c!='s' && c!='i' && j==nl &&
 814 -                            !(cxxsuf(getsufp(t)) && cxxflag) && !xasm) {
 815 -                                llist[nl++] = t;
 816 -                                if (nl >= MAXLIB) {
 817 -                                        error("Too many object/library files");
 818 -                                        exit(1);
 819 -                                }
 820 -                                if (getsuf(t)=='o')
 821 -                                        nxo++;
 822 -                        }
  827+                        if (getsuf(t)=='o')
  828+                                nxo++;
823829                 }
 824830         }
 825831         /* Sanity checking */
     
 !
17171723         return str + strlen(m);
 17181724 }
 17191725 
<> 1726+/*
  1727+ * Return next argument to option, or complain.
  1728+ */
  1729+char *
  1730+nxtopt(char *o)
  1731+{
  1732+        int l;
  1733+
  1734+        if (o != NULL) {
  1735+                l = strlen(o);
  1736+                if (lav[0][l] != 0)
  1737+                        return &lav[0][l];
  1738+        }
  1739+        if (lac == 0)
  1740+                aerror(o);
  1741+        lav++;
  1742+        lac--;
  1743+        return lav[0];
  1744+}
  1745+
<_17201746 #ifdef os_win32
 17211747 char *
 17221748 win32pathsubst(char *s)
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-09-01 23:05 +0200