Print this page
cpp: enable as many warnings as practical


 232 static  int     nopredef;       /* -undef all */
 233 static  int     ifno;
 234 # define NPREDEF 64
 235 static  char *prespc[NPREDEF];
 236 static  char **predef = prespc;
 237 static  char *punspc[NPREDEF];
 238 static  char **prund = punspc;
 239 static  int     exfail;
 240 static  struct symtab *lastsym;
 241 
 242 
 243 static  void            sayline(char *);
 244 static  void            dump(void);
 245 static  char            *refill(char *);
 246 static  char            *cotoken(char *);
 247 char            *skipbl(char *);
 248 static  char            *unfill(char *);
 249 static  char            *doincl(char *);
 250 static  int             equfrm(char *, char *, char *);
 251 static  char            *dodef(char *);
 252 static  char            *control(char *);
 253 static  struct symtab   *stsym(char *);
 254 static  struct symtab   *ppsym(char *);
 255 void            pperror(char *fmt, ...);
 256 void            yyerror(char *fmt, ...);
 257 static  void            ppwarn(char *fmt, ...);
 258 struct symtab   *lookup(char *, int);
 259 static  struct symtab   *slookup(char *, char *, int);
 260 static  char            *subst(char *, struct symtab *);
 261 static  char            *trmdir(char *);
 262 static  char            *copy(char *);
 263 static  char            *strdex(char *, int);
 264 int             yywrap(void);
 265 int             main(int argc, char **argav);
 266 
 267 
 268 #define symsiz 16000
 269 static  struct symtab stab[symsiz];
 270 
 271 static  struct symtab *defloc;
 272 static  struct symtab *udfloc;


 891                 --cf;   /* skip no. of params, which may be zero */
 892                 while (*--cf);  /* go back to the beginning */
 893                 if (0!=strcmp(++cf,oldsavch)) {
 894                         /* redefinition different from old */
 895                         --lineno[ifno];
 896                         ppwarn("%s redefined",np->name);
 897                         ++lineno[ifno];
 898                         np->value=psav-1;
 899                 } else {
 900                         psav=oldsavch; /* identical redef.; reclaim space */
 901                 }
 902         } else {
 903                 np->value=psav-1;
 904         }
 905         --flslvl; inp=pin; savch=psav; return(p);
 906 }
 907 
 908 #define fasscan() ptrtab=fastab+COFF
 909 #define sloscan() ptrtab=slotab+COFF
 910 
 911 static char *
 912 control(p) register char *p; {/* find and handle preprocessor control lines */
 913         register struct symtab *np;
 914 for (;;) {
 915         fasscan(); p=cotoken(p); if (*inp=='\n') ++inp; dump();
 916         sloscan(); p=skipbl(p);
 917         *--inp=SALT; outp=inp; ++flslvl; np=slookup(inp,p,0); --flslvl;
 918         if (np==defloc) {/* define */
 919                 if (flslvl==0) {p=dodef(p); continue;}
 920         } else if (np==incloc) {/* include */
 921                 if (flslvl==0) {p=doincl(p); continue;}
 922         } else if (np==ifnloc) {/* ifndef */
 923                 ++flslvl; p=skipbl(p); np=slookup(inp,p,0); --flslvl;
 924                 if (flslvl==0 && np->value==0) ++trulvl;
 925                 else ++flslvl;
 926         } else if (np==ifdloc) {/* ifdef */
 927                 ++flslvl; p=skipbl(p); np=slookup(inp,p,0); --flslvl;
 928                 if (flslvl==0 && np->value!=0) ++trulvl;
 929                 else ++flslvl;
 930         } else if (np==eifloc) {/* endif */
 931                 if (flslvl) {if (--flslvl==0) sayline(NOINCLUDE);}




 232 static  int     nopredef;       /* -undef all */
 233 static  int     ifno;
 234 # define NPREDEF 64
 235 static  char *prespc[NPREDEF];
 236 static  char **predef = prespc;
 237 static  char *punspc[NPREDEF];
 238 static  char **prund = punspc;
 239 static  int     exfail;
 240 static  struct symtab *lastsym;
 241 
 242 
 243 static  void            sayline(char *);
 244 static  void            dump(void);
 245 static  char            *refill(char *);
 246 static  char            *cotoken(char *);
 247 char            *skipbl(char *);
 248 static  char            *unfill(char *);
 249 static  char            *doincl(char *);
 250 static  int             equfrm(char *, char *, char *);
 251 static  char            *dodef(char *);
 252 void                    control(char *);
 253 static  struct symtab   *stsym(char *);
 254 static  struct symtab   *ppsym(char *);
 255 void            pperror(char *fmt, ...);
 256 void            yyerror(char *fmt, ...);
 257 static  void            ppwarn(char *fmt, ...);
 258 struct symtab   *lookup(char *, int);
 259 static  struct symtab   *slookup(char *, char *, int);
 260 static  char            *subst(char *, struct symtab *);
 261 static  char            *trmdir(char *);
 262 static  char            *copy(char *);
 263 static  char            *strdex(char *, int);
 264 int             yywrap(void);
 265 int             main(int argc, char **argav);
 266 
 267 
 268 #define symsiz 16000
 269 static  struct symtab stab[symsiz];
 270 
 271 static  struct symtab *defloc;
 272 static  struct symtab *udfloc;


 891                 --cf;   /* skip no. of params, which may be zero */
 892                 while (*--cf);  /* go back to the beginning */
 893                 if (0!=strcmp(++cf,oldsavch)) {
 894                         /* redefinition different from old */
 895                         --lineno[ifno];
 896                         ppwarn("%s redefined",np->name);
 897                         ++lineno[ifno];
 898                         np->value=psav-1;
 899                 } else {
 900                         psav=oldsavch; /* identical redef.; reclaim space */
 901                 }
 902         } else {
 903                 np->value=psav-1;
 904         }
 905         --flslvl; inp=pin; savch=psav; return(p);
 906 }
 907 
 908 #define fasscan() ptrtab=fastab+COFF
 909 #define sloscan() ptrtab=slotab+COFF
 910 
 911 void
 912 control(p) register char *p; {/* find and handle preprocessor control lines */
 913         register struct symtab *np;
 914 for (;;) {
 915         fasscan(); p=cotoken(p); if (*inp=='\n') ++inp; dump();
 916         sloscan(); p=skipbl(p);
 917         *--inp=SALT; outp=inp; ++flslvl; np=slookup(inp,p,0); --flslvl;
 918         if (np==defloc) {/* define */
 919                 if (flslvl==0) {p=dodef(p); continue;}
 920         } else if (np==incloc) {/* include */
 921                 if (flslvl==0) {p=doincl(p); continue;}
 922         } else if (np==ifnloc) {/* ifndef */
 923                 ++flslvl; p=skipbl(p); np=slookup(inp,p,0); --flslvl;
 924                 if (flslvl==0 && np->value==0) ++trulvl;
 925                 else ++flslvl;
 926         } else if (np==ifdloc) {/* ifdef */
 927                 ++flslvl; p=skipbl(p); np=slookup(inp,p,0); --flslvl;
 928                 if (flslvl==0 && np->value!=0) ++trulvl;
 929                 else ++flslvl;
 930         } else if (np==eifloc) {/* endif */
 931                 if (flslvl) {if (--flslvl==0) sayline(NOINCLUDE);}