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

Split Close
Expand all
Collapse all
          --- old/cpp/cpp.c
          +++ new/cpp/cpp.c
↓ open down ↓ 1018 lines elided ↑ open up ↑
1019 1019                  if (flslvl==0 && yyparse()) ++trulvl; else ++flslvl;
1020 1020                  p=newp;
1021 1021  #endif
1022 1022          } else if (np == idtloc) {              /* ident */
1023 1023                  if (pflag == 0)
1024 1024                          while (*inp != '\n')    /* pass text */
1025 1025                                  p = cotoken(p);
1026 1026          } else if (np == pragmaloc) {           /* pragma */
1027 1027                  while (*inp != '\n')            /* pass text */
1028 1028                          p = cotoken(p);
     1029 +#ifdef EXIT_ON_ERROR
1029 1030          } else if (np == errorloc) {            /* error */
1030      -#ifdef  EXIT_ON_ERROR
1031 1031                  if (trulvl > 0) {
1032 1032                          char ebuf[BUFFERSIZ];
1033 1033  
1034 1034                          p = ebuf;
1035 1035                          while (*inp != '\n') {
1036 1036                                  if (*inp == '\0')
1037 1037                                          if (eob(--inp)) {
1038 1038                                                  inp = refill(inp);
1039 1039                                                  continue;
1040 1040                                          }
1041 1041                                  *p++ = *inp++;
1042 1042                                  if (p >= &ebuf[BUFFERSIZ-1])
1043 1043                                          break;
1044 1044                          }
1045 1045                          *p = '\0';
1046 1046                          pperror(ebuf);
1047 1047                          exit(exfail);
1048 1048                  }
1049      -#else
1050      -                while (*inp != '\n')            /* pass text */
1051      -                        p = cotoken(p);
1052 1049  #endif
1053 1050          } else if (np==lneloc) {/* line */
1054 1051                  if (flslvl==0 && pflag==0) {
1055 1052                          outp=inp=p;
1056 1053                          *--outp='#';
1057 1054                          while (*inp!='\n')
1058 1055                                  p=cotoken(p);
1059 1056                          continue;
1060 1057                  }
1061 1058          } else if (*++inp=='\n') {
↓ open down ↓ 495 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX