Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.102
 
1.103
 
MAIN:ragge:20100225154900
 
cpp.c
_>167167 #define FIND    0
 168168 #define ENTER   1
 169169 
<>170 -static void expdef(usch *proto, struct recur *, int gotwarn);
  170+static void expdef(const usch *proto, struct recur *, int gotwarn);
171171 void define(void);
 172172 static int canexpand(struct recur *, struct symtab *np);
 173173 void include(void);
 174174 void include_next(void);
 175175 void line(void);
 176176 void flbuf(void);
 177177 void usage(void);
<>178 -usch *xstrdup(char *str);
 179 -usch *prtprag(usch *opb);
  178+usch *xstrdup(const char *str);
  179+const usch *prtprag(const usch *opb);
180180 
 181181 
 182182 int
     
 !
186186         struct incs *w, *w2;
 187187         struct symtab *nl;
 188188         register int ch;
<>189 -        usch *fn1, *fn2;
  189+        const usch *fn1, *fn2;
190190 
 191191 #ifdef TIMING
 192192         struct timeval t1, t2;
     
 !
262262         argc -= optind;
 263263         argv += optind;
 264264 
<>265 -        filloc = lookup((usch *)"__FILE__", ENTER);
 266 -        linloc = lookup((usch *)"__LINE__", ENTER);
 267 -        pragloc = lookup((usch *)"_Pragma", ENTER);
 268 -        filloc->value = linloc->value = (usch *)""; /* Just something */
 269 -        pragloc->value = (usch *)"";
  265+        filloc = lookup((const usch *)"__FILE__", ENTER);
  266+        linloc = lookup((const usch *)"__LINE__", ENTER);
  267+        pragloc = lookup((const usch *)"_Pragma", ENTER);
  268+        filloc->value = linloc->value = (const usch *)""; /* Just something */
  269+        pragloc->value = (const usch *)"";
270270 
 271271         if (tflag == 0) {
 272272                 time_t t = time(NULL);
     
 !
275275                 /*
 276276                  * Manually move in the predefined macros.
 277277                  */
<>278 -                nl = lookup((usch *)"__TIME__", ENTER);
  278+                nl = lookup((const usch *)"__TIME__", ENTER);
279279                 savch(0); savch('"');  n[19] = 0; savstr(&n[11]); savch('"');
 280280                 savch(OBJCT);
 281281                 nl->value = stringbuf-1;
 282282 
<>283 -                nl = lookup((usch *)"__DATE__", ENTER);
  283+                nl = lookup((const usch *)"__DATE__", ENTER);
284284                 savch(0); savch('"'); n[24] = n[11] = 0; savstr(&n[4]);
 285285                 savstr(&n[20]); savch('"'); savch(OBJCT);
 286286                 nl->value = stringbuf-1;
 287287 
<>288 -                nl = lookup((usch *)"__STDC__", ENTER);
  288+                nl = lookup((const usch *)"__STDC__", ENTER);
289289                 savch(0); savch('1'); savch(OBJCT);
 290290                 nl->value = stringbuf-1;
 291291 
<>292 -                nl = lookup((usch *)"__STDC_VERSION__", ENTER);
 293 -                savch(0); savstr((usch *)"199901L"); savch(OBJCT);
  292+                nl = lookup((const usch *)"__STDC_VERSION__", ENTER);
  293+                savch(0); savstr((const usch *)"199901L"); savch(OBJCT);
294294                 nl->value = stringbuf-1;
 295295         }
 296296 
     
 !
322322                 fn1 = fn2 = (usch *)argv[0];
 323323         } else {
 324324                 fn1 = NULL;
<>325 -                fn2 = (usch *)"";
  325+                fn2 = (const usch *)"";
326326         }
 327327         if (pushfile(fn1, fn2, 0, NULL))
 328328                 error("cannot open %s", argv[0]);
     
 !
381381                                 c = sloscan();
 382382                         }
 383383                         if (c != EXPAND) {
<>384 -                                unpstr((usch *)yytext);
  384+                                unpstr((const usch *)yytext);
385385                                 if (ss2 != stringbuf)
 386386                                         unpstr(ss2);
 387387                                 unpstr(nl->namep);
     
 !
497497  * Return 1 on success.
 498498  */
 499499 static int
<>500 -fsrch(usch *fn, int idx, struct incs *w)
  500+fsrch(const usch *fn, int idx, struct incs *w)
501501 {
 502502         int i;
 503503 
     
 !
627627                 if (c == '*') {
 628628                         c = cinput();
 629629                         if (c == '/') {
<>630 -                                savstr((usch *)"*/");
  630+                                savstr((const usch *)"*/");
631631                                 return;
 632632                         }
 633633                         cunput(c);
     
 !
641641  * Compare two replacement lists, taking in account comments etc.
 642642  */
 643643 static int
<>644 -cmprepl(usch *o, usch *n)
  644+cmprepl(const usch *o, const usch *n)
645645 {
 646646         for (; *o; o--, n--) {
 647647                 /* comment skip */
     
 !
905905 
 906906 #ifdef CPP_DEBUG
 907907         if (dflag) {
<>908 -                usch *w = np->value;
  908+                const usch *w = np->value;
909909 
 910910                 printf("!define: ");
 911911                 if (*w == OBJCT)
     
 !
10381038 struct recur *rp;
 10391039 {
 10401040         struct recur rp2;
<>1041 -        register usch *vp, *cp, *obp;
  1041+        register const usch *vp, *cp;
  1042+        register usch *obp;
10421043         int c, nl;
 10431044 
 10441045         DPRINT(("subst: %s\n", sp->namep));
     
 !
12081209                                 stringbuf = och;
 12091210                                 continue; /* New longer identifier */
 12101211                         }
<>1211 -                        unpstr((usch *)yytext);
  1212+                        unpstr((const usch *)yytext);
12121213                         if (orgexp == -1)
 12131214                                 cunput(EXPAND);
 12141215                         else if (orgexp == -2)
     
 !
12551256                                 if (stksv)
 12561257                                         savstr(stksv);
 12571258                         } else {
<>1258 -                                unpstr((usch *)yytext);
  1259+                                unpstr((const usch *)yytext);
12591260                                 if (stksv)
 12601261                                         unpstr(stksv);
 12611262                                 savstr(nl->namep);
     
 !
13031304  * result is written on top of heap
 13041305  */
 13051306 void
<>1306 -expdef(usch *vp, struct recur *rp, int gotwarn)
  1307+expdef(const usch *vp, struct recur *rp, int gotwarn)
13071308 {
<>1308 -        usch **args, *sptr, *ap, *bp, *sp;
  1309+        const usch **args, *ap, *bp, *sp;
  1310+        usch *sptr;
13091311         int narg, c, i, plev, snuff, instr;
 13101312         int ellips = 0;
 13111313 
<>1312 -        DPRINT(("expdef rp %s\n", (rp ? (char *)rp->sp->namep : "")));
  1314+        DPRINT(("expdef rp %s\n", (rp ? (const char *)rp->sp->namep : "")));
13131315         if ((c = sloscan()) != '(')
 13141316                 error("got %c, expected (", c);
 13151317         if (vp[1] == VARG) {
     
 !
13661368                 savch('\0');
 13671369         }
 13681370         if (ellips)
<>1369 -                args[i] = (usch *)"";
  1371+                args[i] = (const usch *)"";
13701372         if (ellips && c != ')') {
 13711373                 args[i] = stringbuf;
 13721374                 plev = 0;
     
 !
14351437                         } else if (sp[-1] == GCCARG) {
 14361438                                 ap = args[narg];
 14371439                                 if (ap[0] == 0)
<>1438 -                                        ap = (usch *)"0";
  1440+                                        ap = (const usch *)"0";
14391441                                 bp = ap;
 14401442                                 sp--;
 14411443 #endif
     
 !
14881490 }
 14891491 
 14901492 usch *
<>1491 -savstr(usch *str)
  1493+savstr(const usch *str)
14921494 {
 14931495         usch *rv = stringbuf;
 14941496 
     
 !
15151517 }
 15161518 
 15171519 void
<>1518 -unpstr(usch *c)
  1520+unpstr(const usch *c)
15191521 {
<>1520 -        usch *d = c;
  1522+        const usch *d = c;
15211523 
 15221524         while (*d)
 15231525                 d++;
     
 !
15451547 }
 15461548 
 15471549 void
<>1548 -putstr(usch *s)
  1550+putstr(const usch *s)
15491551 {
 15501552         for (; *s; s++) {
 15511553                 if (*s == PRAGS) {
     
 !
15851587  * saves result on heap.
 15861588  */
 15871589 usch *
<>1588 -sheap(char *fmt, ...)
  1590+sheap(const char *fmt, ...)
15891591 {
 15901592         va_list ap;
 15911593         usch *op = stringbuf;
     
 !
16581660  * Allocate a symtab struct and store the string.
 16591661  */
 16601662 static struct symtab *
<>1661 -getsymtab(usch *str)
  1663+getsymtab(const usch *str)
16621664 {
 16631665         struct symtab *sp = malloc(sizeof(struct symtab));
 16641666 
     
 !
16671669         sp->namep = savstr(str);
 16681670         savch('\0');
 16691671         sp->value = NULL;
<>1670 -        sp->file = ifiles ? ifiles->orgfn : (usch *)"<initial>";
  1672+        sp->file = ifiles ? ifiles->orgfn : (const usch *)"<initial>";
16711673         sp->line = ifiles ? ifiles->lineno : 0;
 16721674         return sp;
 16731675 }
     
 !
16771679  * Only do full string matching, no pointer optimisations.
 16781680  */
 16791681 struct symtab *
<>1680 -lookup(usch *key, int enterf)
  1682+lookup(const usch *key, int enterf)
16811683 {
 16821684         struct symtab *sp;
 16831685         struct tree *w, *new, *last;
 16841686         int len, cix, bit, fbit, svbit, ix, bitno;
<>1685 -        usch *k, *m, *sm;
  1687+        const usch *k, *m, *sm;
16861688 
 16871689         /* Count full string length */
 16881690         for (k = key, len = 0; *k; k++, len++)
     
 !
17791781 }
 17801782 
 17811783 usch *
<>1782 -xstrdup(char *str)
  1784+xstrdup(const char *str)
17831785 {
 17841786         size_t len = strlen(str)+1;
 17851787         usch *rv;
     
 !
17901792         return rv;
 17911793 }
 17921794 
<>1793 -usch *
 1794 -prtprag(usch *s)
  1795+const usch *
  1796+prtprag(const usch *s)
17951797 {
 17961798         int ch;
 17971799 
 17981800         s++;
<>1799 -        putstr((usch *)"\n#pragma ");
  1801+        putstr((const usch *)"\n#pragma ");
18001802         while (*s != PRAGE) {
 18011803                 if (*s == 'L')
 18021804                         s++;
     
 !
18121814                         putch(*s);
 18131815                 }
 18141816         }
<>1815 -        putstr((usch *)"\n");
  1817+        putstr((const usch *)"\n");
<_18161818         prtline();
 18171819         return ++s;
 18181820 }
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 00:20 +0100