Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.217
 
1.218
 
MAIN:ragge:20120802100909
 
cc.c
_>8484 
 8585 #include "ccconfig.h"
 8686 #include "macdefs.h"
<> 87+
  88+#include "xalloc.h"
  89+#include "strlist.h"
8790 /* C command */
 8891 
 8992 #define MKS(x) _MKS(x)
     
 !
146149 void idexit(int);
 147150 char *gettmp(void);
 148151 void *ccmalloc(int size);
<> 152+void aerror(char *);
  153+char *argnxt(char *, char *);
149154 #ifdef os_win32
 150155 char *win32pathsubst(char *);
 151156 char *win32commandline(char *, char *[]);
     
 !
155160 char    *olist[MAXFIL];
 156161 char    *llist[MAXLIB];
 157162 char    *aslist[MAXAV];
<>158 -char    *cpplist[MAXAV];
159163 char    *xlist[100];
 160164 int     xnum;
 161165 char    *mlist[100];
     
 !
267271 int amd64_i386;
 268272 #endif
 269273 
<> 274+#define match(a,b)      (strcmp(a,b) == 0)
  275+
270276 /* handle gcc warning emulations */
 271277 struct Wflags {
 272278         char *name;
     
 !
343349 #define CPPROGNAME      "cpp"
 344350 #endif
 345351 
<> 352+struct strlist preprocessor_flags;
  353+
346354 int
 347355 main(int argc, char *argv[])
 348356 {
<> 357+        struct string *s;
349358         struct Wflags *Wf;
<>350 -        char *t, *u;
  359+        char *t, *u, *argp;
351360         char *assource;
 352361         char **pv, *ptemp[MAXOPT], **pvt;
 353362         int nc, nl, nas, ncpp, i, j, c, nxo, na;
 354363 #ifdef MULTITARGET
 355364         int k;
 356365 #endif
 357366 
<> 367+        strlist_init(&preprocessor_flags);
  368+
358369         if ((t = strrchr(argv[0], '/')))
 359370                 t = copy(t+1, 0);
 360371         else
     
 !
405416         pv = ptemp;
 406417         while(++i < argc) {
 407418                 if (argv[i][0] == '-') {
<> 419+
  420+                        argp = argv[i];
408421                         switch (argv[i][1]) {
 409422                         default:
 410423                                 goto passa;
     
 !
456469                                 break;
 457470 #endif
 458471 
<> 472+                        case 'C':
  473+                                if (match(argp, "-C") || match(argp, "-CC"))
  474+                                        strlist_append(&preprocessor_flags, argp);
  475+                                else
  476+                                        aerror(argp);
  477+                                break;
  478+
459479                         case 'X':
 460480                                 Xflag++;
 461481                                 break;
     
 !
487507                                                 t = u;
 488508                                         }
 489509                                         wlist[nw++] = t;
<>490 -                                } else if (strncmp(argv[i], "-Wp,", 4) == 0) {
 491 -                                        /* preprocessor */
 492 -                                        t = &argv[i][4];
 493 -                                        while ((u = strchr(t, ','))) {
 494 -                                                *u++ = 0;
 495 -                                                cpplist[ncpp++] = t;
 496 -                                                t = u;
 497 -                                        }
 498 -                                        cpplist[ncpp++] = t;
  510+                                } else if ((t = argnxt(argp, "-Wp,"))) {
  511+                                        u = strtok(t, ",");
  512+                                        do {
  513+                                                strlist_append(&preprocessor_flags, u);
  514+                                        } while ((u = strtok(NULL, ",")) != NULL);
499515                                 } else if (strcmp(argv[i], "-Werror") == 0) {
 500516                                         wlist[nw++] = argv[i];
 501517                                 } else if (strcmp(argv[i], "-Wall") == 0) {
     
 !
707723                                 }
 708724                                 break;
 709725 #endif
<>710 -                        case 'C':
 711 -                                cpplist[ncpp++] = argv[i];
 712 -                                break;
713726                         case 'D':
 714727                         case 'I':
 715728                         case 'U':
     
 !
909922 #endif
 910923                 for (j = 0; cppadd[j]; j++)
 911924                         av[na++] = cppadd[j];
<>912 -                for (j = 0; j < ncpp; j++)
 913 -                        av[na++] = cpplist[j];
  925+                STRLIST_FOREACH(s, &preprocessor_flags) {
  926+                        av[na++] = s->value;
  927+                }
914928                 av[na++] = "-D__STDC_ISO_10646__=200009L";
 915929                 av[na++] = "-D__WCHAR_TYPE__=" WCT;
 916930                 av[na++] = "-D__SIZEOF_WCHAR_T__=" MKS(WCHAR_SIZE);
     
 !
16661680         return rv;
 16671681 }
 16681682 
<> 1683+void
  1684+aerror(char *s)
  1685+{
  1686+        fprintf(stderr, "error: unknown option '%s'\n", s);
  1687+        exit(1);
  1688+}
  1689+
  1690+/*
  1691+ * See if m matches the beginning of string str, if it does return the
  1692+ * remaining of str, otherwise NULL.
  1693+ */
  1694+char *
  1695+argnxt(char *str, char *m)
  1696+{
  1697+        if (strncmp(str, m, strlen(m)))
  1698+                return NULL; /* No match */
  1699+        return str + strlen(m);
  1700+}
  1701+
<_16691702 #ifdef os_win32
 16701703 char *
 16711704 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-10-02 14:34 +0200