Print this page
cpp: do not pass #error into output stream, warn about it and exit non-0


1009         } else if (np==udfloc) {/* undefine */
1010                 if (flslvl==0) {
1011                         ++flslvl; p=skipbl(p); slookup(inp,p,DROP); --flslvl;
1012                 }
1013         } else if (np==ifloc) {/* if */
1014 #if tgp
1015                 pperror(" IF not implemented, true assumed", 0);
1016                 if (flslvl==0) ++trulvl; else ++flslvl;
1017 #else
1018                 newp=p;
1019                 if (flslvl==0 && yyparse()) ++trulvl; else ++flslvl;
1020                 p=newp;
1021 #endif
1022         } else if (np == idtloc) {              /* ident */
1023                 if (pflag == 0)
1024                         while (*inp != '\n')    /* pass text */
1025                                 p = cotoken(p);
1026         } else if (np == pragmaloc) {           /* pragma */
1027                 while (*inp != '\n')            /* pass text */
1028                         p = cotoken(p);
1029         } else if (np == errorloc) {            /* error */
1030 #ifdef  EXIT_ON_ERROR

1031                 if (trulvl > 0) {
1032                         char ebuf[BUFFERSIZ];
1033 
1034                         p = ebuf;
1035                         while (*inp != '\n') {
1036                                 if (*inp == '\0')
1037                                         if (eob(--inp)) {
1038                                                 inp = refill(inp);
1039                                                 continue;
1040                                         }
1041                                 *p++ = *inp++;
1042                                 if (p >= &ebuf[BUFFERSIZ-1])
1043                                         break;
1044                         }
1045                         *p = '\0';
1046                         pperror(ebuf);
1047                         exit(exfail);
1048                 }
1049 #else
1050                 while (*inp != '\n')            /* pass text */
1051                         p = cotoken(p);
1052 #endif
1053         } else if (np==lneloc) {/* line */
1054                 if (flslvl==0 && pflag==0) {
1055                         outp=inp=p;
1056                         *--outp='#';
1057                         while (*inp!='\n')
1058                                 p=cotoken(p);
1059                         continue;
1060                 }
1061         } else if (*++inp=='\n') {
1062                 outp=inp;       /* allows blank line after # */
1063         } else {
1064                 pperror("undefined control",0);
1065         }
1066         /* flush to lf */
1067         ++flslvl;
1068         while (*inp!='\n') {
1069                 outp=inp=p;
1070                 p=cotoken(p);
1071         }




1009         } else if (np==udfloc) {/* undefine */
1010                 if (flslvl==0) {
1011                         ++flslvl; p=skipbl(p); slookup(inp,p,DROP); --flslvl;
1012                 }
1013         } else if (np==ifloc) {/* if */
1014 #if tgp
1015                 pperror(" IF not implemented, true assumed", 0);
1016                 if (flslvl==0) ++trulvl; else ++flslvl;
1017 #else
1018                 newp=p;
1019                 if (flslvl==0 && yyparse()) ++trulvl; else ++flslvl;
1020                 p=newp;
1021 #endif
1022         } else if (np == idtloc) {              /* ident */
1023                 if (pflag == 0)
1024                         while (*inp != '\n')    /* pass text */
1025                                 p = cotoken(p);
1026         } else if (np == pragmaloc) {           /* pragma */
1027                 while (*inp != '\n')            /* pass text */
1028                         p = cotoken(p);

1029 #ifdef EXIT_ON_ERROR
1030         } else if (np == errorloc) {            /* error */
1031                 if (trulvl > 0) {
1032                         char ebuf[BUFFERSIZ];
1033 
1034                         p = ebuf;
1035                         while (*inp != '\n') {
1036                                 if (*inp == '\0')
1037                                         if (eob(--inp)) {
1038                                                 inp = refill(inp);
1039                                                 continue;
1040                                         }
1041                                 *p++ = *inp++;
1042                                 if (p >= &ebuf[BUFFERSIZ-1])
1043                                         break;
1044                         }
1045                         *p = '\0';
1046                         pperror(ebuf);
1047                         exit(exfail);
1048                 }



1049 #endif
1050         } else if (np==lneloc) {/* line */
1051                 if (flslvl==0 && pflag==0) {
1052                         outp=inp=p;
1053                         *--outp='#';
1054                         while (*inp!='\n')
1055                                 p=cotoken(p);
1056                         continue;
1057                 }
1058         } else if (*++inp=='\n') {
1059                 outp=inp;       /* allows blank line after # */
1060         } else {
1061                 pperror("undefined control",0);
1062         }
1063         /* flush to lf */
1064         ++flslvl;
1065         while (*inp!='\n') {
1066                 outp=inp=p;
1067                 p=cotoken(p);
1068         }