Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.52
 
1.53
 
MAIN:ragge:20070909095854
 
cpp.c
_>108108 static int obufp, istty;
 109109 int Cflag, Mflag;
 110110 usch *Mfile;
<> 111+struct initar *initar;
111112 
 112113 /* avoid recursion */
 113114 struct recur {
     
 !
170171 int
 171172 main(int argc, char **argv)
 172173 {
<> 174+        struct initar *it;
173175         struct incs *w, *w2;
 174176         struct symtab *nl;
 175177         register int ch;
<>176 -        usch *osp;
  178+//      usch *osp;
177179 
<>178 -        while ((ch = getopt(argc, argv, "CD:I:MS:U:td")) != -1)
  180+        while ((ch = getopt(argc, argv, "CD:I:MS:U:di:t")) != -1)
179181                 switch (ch) {
 180182                 case 'C': /* Do not discard comments */
 181183                         Cflag++;
 182184                         break;
 183185 
<>184 -                case 'D': /* Define something */
  186+                case 'i': /* include */
  187+                case 'U': /* undef */
  188+                case 'D': /* define something */
  189+                        it = malloc(sizeof(struct initar));
  190+                        it->type = ch;
  191+                        it->str = optarg;
  192+                        it->next = initar;
  193+                        initar = it;
  194+#if 0
185195                         osp = (usch *)optarg;
 186196                         while (*osp && *osp != '=')
 187197                                 osp++;
     
 !
204214                                         error("%s redefined", optarg);
 205215                         }
 206216                         nl->value = osp;
<> 217+#endif
207218                         break;
 208219 
 209220                 case 'M': /* Generate dependencies for make */
     
 !
223234                                 incdir[ch == 'I' ? INCINC : SYSINC] = w;
 224235                         break;
 225236 
<> 237+#if 0
226238                 case 'U':
 227239                         if ((nl = lookup((usch *)optarg, FIND)))
 228240                                 nl->value = NULL;
 229241                         break;
<> 242+#endif
230243 #ifdef CPP_DEBUG
 231244                 case 'd':
 232245                         dflag++;
     
 !
236249                         tflag = 1;
 237250                         break;
 238251 
<> 252+#if 0
  253+                case 'i':
  254+                        if (ifile)
  255+                                error("max 1 -i entry");
  256+                        ifile = optarg;
  257+                        break;
  258+#endif
  259+
239260                 case '?':
 240261                         usage();
 241262                 default:
     
 !
494515                 yytext[strlen(yytext)-1] = 0;
 495516                 fn = (usch *)&yytext[1];
 496517                 /* first try to open file relative to previous file */
<>497 -                savstr(ifiles->orgfn);
 498 -                if ((stringbuf = (usch *)strrchr((char *)nm, '/')) == NULL)
 499 -                        stringbuf = nm;
 500 -                else
 501 -                        stringbuf++;
  518+                /* but only if it is not an absolute path */
  519+                if (*fn != '/') {
  520+                        savstr(ifiles->orgfn);
  521+                        if ((stringbuf =
  522+                            (usch *)strrchr((char *)nm, '/')) == NULL)
  523+                                stringbuf = nm;
  524+                        else
  525+                                stringbuf++;
  526+                }
502527                 savstr(fn); savch(0);
 503528                 while ((c = yylex()) == WSPACE)
 504529                         ;
     
 !
689714                 while (*o && *o == *n)
 690715                         o--, n--;
 691716                 if (*o || *o != *n)
<>692 -                        error("%s redefined", np->namep);
  717+                        error("%s redefined\nprevious define: %s:%d",
  718+                            np->namep, np->file, np->line);
693719                 stringbuf = sbeg/* forget this space */
 694720         } else
 695721                 np->value = stringbuf-1;
     
 !
10121038                 narg = vp[1];
 10131039         args = alloca(sizeof(usch *) * (narg+ellips));
 10141040 
<>1015 -
10161041         /*
 10171042          * read arguments and store them on heap.
 10181043          * will be removed just before return from this function.
     
 !
10391064                         stringbuf--;
 10401065                 savch('\0');
 10411066         }
<> 1067+        if (ellips)
  1068+                args[i] = (usch *)"";
10421069         if (ellips && c != ')') {
 10431070                 args[i] = stringbuf;
 10441071                 plev = 0;
     
 !
12091236 {
 12101237         static usch buf[12];
 12111238         usch *b = buf;
<>1212 -
 1213 -        if (num) {
 1214 -                while (num)
 1215 -                        *b++ = num % 10 + '0', num /= 10;
 1216 -        } else
 1217 -                *b++ = '0';
  1239+        int m = 0;
  1240+        
  1241+        if (num < 0)
  1242+                num = -num, m = 1;
  1243+        do {
  1244+                *b++ = num % 10 + '0', num /= 10;
  1245+        } while (num);
  1246+        if (m)
  1247+                *b++ = '-';
12181248         while (b > buf)
 12191249                 savch(*--b);
 12201250 }
     
 !
13031333 {
 13041334         struct symtab *sp = malloc(sizeof(struct symtab));
 13051335 
<>1306 -        sp->namep = savstr(str), savch('\0'), sp->value = NULL;
  1336+        sp->namep = savstr(str), savch('\0');
  1337+        sp->value = NULL;
  1338+        sp->file = ifiles ? ifiles->orgfn : (usch *)"<initial>";
  1339+        sp->line = ifiles ? ifiles->lineno : 0;
<_13071340         return sp;
 13081341 }
 13091342 
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-29 00:38 +0100