Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.113
 
1.114
 
MAIN:ragge:20110111095948
 
cpp.c
_>133133 void flbuf(void);
 134134 void usage(void);
 135135 usch *xstrdup(const char *str);
<>136 -const usch *prtprag(const usch *opb);
137136 static void addidir(char *idir, struct incs **ww);
 138137 void imp(const char *);
 139138 #define IMP(x) if (dflag>1) imp(x)
     
 !
213212 
 214213         filloc = lookup((const usch *)"__FILE__", ENTER);
 215214         linloc = lookup((const usch *)"__LINE__", ENTER);
<>216 -        pragloc = lookup((const usch *)"_Pragma", ENTER);
 217 -        pragloc->value = filloc->value = linloc->value = stringbuf;
  215+        filloc->value = linloc->value = stringbuf;
218216         savch(OBJCT);
 219217 
<> 218+        /* create a complete macro for pragma */
  219+        pragloc = lookup((const usch *)"_Pragma", ENTER);
  220+        savch(0);
  221+        savstr("_Pragma(");
  222+        savch(0);
  223+        savch(WARN);
  224+        savch(')');
  225+        pragloc->value = stringbuf;
  226+        savch(1);
  227+
220228         if (tflag == 0) {
 221229                 time_t t = time(NULL);
 222230                 usch *n = (usch *)ctime(&t);
     
 !
949957 
 950958 /*
 951959  * convert _Pragma to #pragma for output.
<> 960+ * Syntax is already correct.
952961  */
 953962 static void
 954963 pragoper(void)
 955964 {
<>956 -        usch *opb;
 957 -        int t, plev;
  965+        usch *s;
  966+        int t;
958967 
<>959 -        if ((t = sloscan()) == WSPACE)
 960 -                t = sloscan();
 961 -        if (t != '(')
 962 -                goto bad;
 963 -        if ((t = sloscan()) == WSPACE)
 964 -                t = sloscan();
 965 -        opb = stringbuf;
 966 -        for (plev = 0; ; t = sloscan()) {
 967 -                if (t == '(')
 968 -                        plev++;
 969 -                if (t == ')')
 970 -                        plev--;
 971 -                if (plev < 0)
 972 -                        break;
 973 -                savstr((usch *)yytext);
  968+        while ((t = sloscan()) != '(') {
  969+                if (t == EXP)
  970+                        doexp();
  971+                else if (t == NEX)
  972+                        donex();
974973         }
 975974 
<>976 -        savch(0);
 977 -        cunput(WARN);
 978 -        unpstr(opb);
 979 -        stringbuf = opb;
 980 -        error("pragoper expmac");
 981 -#if 0
 982 -        expmac(NULL);
 983 -#endif
 984 -        cunput('\n');
 985 -        while (stringbuf > opb)
 986 -                cunput(*--stringbuf);
 987 -        savch(PRAGS);
 988 -        while ((t = sloscan()) != '\n') {
 989 -                if (t == WSPACE)
  975+        while ((t = sloscan()) == WSPACE)
  976+                ;
  977+        if (t != STRING)
  978+                error("pragma must have string argument");
  979+        savstr((const usch *)"\n#pragma ");
  980+        s = (usch *)yytext;
  981+        if (*s == 'L')
  982+                s++;
  983+        for (; *s; s++) {
  984+                if (*s == '\"')
990985                         continue;
<>991 -                if (t != STRING)
 992 -                        goto bad;
 993 -                savstr((usch *)yytext);
  986+                if (*s == '\\' && (s[1] == '\"' || s[1] == '\\'))
  987+                        s++;
  988+                savch(*s);
994989         }
<>995 -
 996 -        savch(PRAGE);
 997 -        while (stringbuf > opb)
 998 -                cunput(*--stringbuf);
 999 -        return;
 1000 -bad:    error("bad pragma operator");
  990+        sheap("\n# %d \"%s\"\n", ifiles->lineno, ifiles->fname);
  991+        while ((t = sloscan()) == WSPACE)
  992+                ;
  993+        if (t != ')')
  994+                error("pragma syntax error");
1001995 }
 1002996 
 1003997 /*
     
 !
10651059                                  * should not me done.
 10661060                                  */
 10671061                                 nl = lookup((usch *)yytext, FIND);
<> 1062+                                /* Deal with pragmas here */
  1063+                                if (nl == pragloc) {
  1064+                                        pragoper();
  1065+                                        break;
  1066+                                }
10681067                                 if (nl == NULL || !okexp(nl) ||
 10691068                                     *nl->value == OBJCT) {
 10701069                                         /* Not fun-like macro */
     
 !
11751174                 } else if (sp == linloc) {
 11761175                         unpstr(sheap("%d", ifiles->lineno));
 11771176                         return 1;
<>1178 -                } else if (sp == pragloc) {
 1179 -                        pragoper();
 1180 -                        return 1;
11811177                 }
<>1182 -                /* XXX insert special check here */
11831178 
 11841179                 DPRINT(("submac: exp object macro '%s'\n",sp->namep));
 11851180                 /* expand object-type macros */
     
 !
17561751 putstr(const usch *s)
 17571752 {
 17581753         for (; *s; s++) {
<>1759 -                if (*s == PRAGS) {
 1760 -                        s = prtprag(s);
 1761 -                        continue;
 1762 -                }
17631754                 outbuf[obufp++] = *s;
 17641755                 if (obufp == CPPBUF || (istty && *s == '\n'))
 17651756                         flbuf();
     
 !
19971988         strlcpy((char *)rv, str, len);
 19981989         return rv;
 19991990 }
<_2000 -
 2001 -const usch *
 2002 -prtprag(const usch *s)
 2003 -{
 2004 -        int ch;
 2005 -
 2006 -        s++;
 2007 -        putstr((const usch *)"\n#pragma ");
 2008 -        while (*s != PRAGE) {
 2009 -                if (*s == 'L')
 2010 -                        s++;
 2011 -                if (*s == '\"') {
 2012 -                        s++;
 2013 -                        while ((ch = *s++) != '\"') {
 2014 -                                if (ch == '\\' && (*s == '\"' || *s == '\\'))
 2015 -                                        ch = *s++;
 2016 -                                putch(ch);
 2017 -                        }
 2018 -                } else {
 2019 -                        s++;
 2020 -                        putch(*s);
 2021 -                }
 2022 -        }
 2023 -        putstr((const usch *)"\n");
 2024 -        prtline();
 2025 -        return ++s;
 2026 -}
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-23 09:29 +0200