Index: cpp.c =================================================================== RCS file: /cvsroot/pcc/cc/cpp/cpp.c,v retrieving revision 1.201 diff -u -p -r1.201 cpp.c --- cpp.c 28 Nov 2014 19:31:57 -0000 1.201 +++ cpp.c 5 Dec 2014 10:39:09 -0000 @@ -1264,7 +1264,7 @@ delwarn(void) } else if (c == EBLOCK) { sss(); } else if (c == '\n') { - fputc(cinput(), stdout); + putch(cinput()); } else savstr(yytext); } @@ -1392,7 +1392,7 @@ upp: sbp = stringbuf; /* Found one, output \n to be in sync */ for (; *sbp; sbp++) { if (*sbp == '\n') - fputc('\n', stdout), ifiles->lineno++; + putch('\n'), ifiles->lineno++; } /* fetch arguments */ @@ -1545,7 +1545,7 @@ chkdir(void) while ((ch = cinput()) != '\n') ; ifiles->lineno++; - fputc('\n', stdout); + putch('\n'); } } @@ -1580,7 +1580,7 @@ readargs(struct symtab *sp, const usch * while ((c = sloscan()) == WSPACE || c == '\n') if (c == '\n') { ifiles->lineno++; - fputc(cinput(), stdout); + putch(cinput()); chkdir(); } for (;;) { @@ -1601,7 +1601,7 @@ readargs(struct symtab *sp, const usch * savstr(yytext); oho: while ((c = sloscan()) == '\n') { ifiles->lineno++; - fputc(cinput(), stdout); + putch(cinput()); chkdir(); savch(' '); } @@ -1978,6 +1978,24 @@ unpstr(const usch *c) } } +void +putch(int ch) +{ + if (Mflag == 0) + fputc(ch, stdout); +} + +void +putstr(const usch *s) +{ + for (; *s; s++) { + if (*s == PHOLD) + continue; + if (Mflag == 0) + fputc(*s, stdout); + } +} + /* * convert a number to an ascii string. Store it on the heap. */ Index: cpp.h =================================================================== RCS file: /cvsroot/pcc/cc/cpp/cpp.h,v retrieving revision 1.73 diff -u -p -r1.73 cpp.h --- cpp.h 28 Nov 2014 19:30:35 -0000 1.73 +++ cpp.h 5 Dec 2014 10:39:10 -0000 @@ -176,6 +176,8 @@ int yyparse(void); void unpstr(const usch *); usch *savstr(const usch *str); void savch(int c); +void putch(int); +void putstr(const usch *s); usch *sheap(const char *fmt, ...); void warning(const char *fmt, ...); void error(const char *fmt, ...); Index: token.c =================================================================== RCS file: /cvsroot/pcc/cc/cpp/token.c,v retrieving revision 1.120 diff -u -p -r1.120 token.c --- token.c 19 Oct 2014 17:40:36 -0000 1.120 +++ token.c 5 Dec 2014 10:39:14 -0000 @@ -65,7 +65,7 @@ static void undefstmt(void); static void pragmastmt(void); static void elifstmt(void); -#define PUTCH(ch) if (!flslvl) fputc(ch, stdout) +#define PUTCH(ch) if (!flslvl) putch(ch) /* protection against recursion in #include */ #define MAX_INCLEVEL 100 static int inclevel; @@ -312,7 +312,7 @@ eatcmnt(void) ch = inch(); if (ch == '\n') { ifiles->lineno++; - fputc('\n', stdout); + putch('\n'); continue; } if (ch == -1) @@ -374,10 +374,10 @@ xloop: if (ch == -1) case '/': /* Comments */ if ((ch = inch()) == '/') { if (!flslvl) { -cppcmt: fputc(Cflag ? ch : ' ', stdout); +cppcmt: putch(Cflag ? ch : ' '); } do { - if (Cflag && !flslvl) fputc(ch, stdout); + if (Cflag && !flslvl) putch(ch); ch = inch(); if (ch == -1) goto eof; @@ -387,7 +387,7 @@ cppcmt: fputc(Cflag ? ch : ' ', stdo if (eatcmnt() == -1) goto eof; } else { - if (!flslvl) fputc('/', stdout); + PUTCH('/'); goto xloop; } break; @@ -397,7 +397,7 @@ cppcmt: fputc(Cflag ? ch : ' ', stdo ifiles->lineno += i; ifiles->escln = 0; while (i-- > 0) - fputc('\n', stdout); + putch('\n'); run: for(;;) { ch = inch(); if (ch == '/') { @@ -414,7 +414,7 @@ run: for(;;) { } if (ch != ' ' && ch != '\t') break; - if (!flslvl) fputc(ch, stdout); + PUTCH(ch); } if (ch == '#') { ppdir(); @@ -539,9 +539,9 @@ con: PUTCH(ch); if (flslvl == 0) { cp = stringbuf; if ((nl = lookup(yytext, FIND)) && kfind(nl)) - printf("%s", stringbuf); + putstr(stringbuf); else - printf("%s", (char *)yytext); + putstr((usch *)yytext); stringbuf = cp; } if (ch == -1) @@ -561,7 +561,7 @@ con: PUTCH(ch); } eof: warning("unexpected EOF"); - fputc('\n', stdout); + putch('\n'); } int @@ -669,7 +669,7 @@ chlit: if (c == -1) return 0; if (c == '\n') - fputc(c, stdout), ifiles->lineno++; + putch(c), ifiles->lineno++; else if (c == EBLOCK) { (void)inch(); (void)inch(); @@ -1006,6 +1006,8 @@ pushfile(const usch *file, const usch *f void prtline(void) { + usch *sb = stringbuf; + if (Mflag) { if (dMflag) return; /* no output */ @@ -1017,11 +1019,13 @@ prtline(void) printf("%s:\n", ifiles->fname); } } else if (!Pflag) { - printf("\n# %d \"%s\"", ifiles->lineno, ifiles->fname); + sheap("\n# %d \"%s\"", ifiles->lineno, ifiles->fname); if (ifiles->idx == SYSINC) - printf(" 3"); - printf("\n"); + sheap(" 3"); + sheap("\n"); + putstr(sb); } + stringbuf = sb; } void @@ -1341,7 +1345,7 @@ pragmastmt(void) sb = stringbuf; savstr((const usch *)"\n#pragma "); savln(); - printf("%s", ((char *)sb)); + putstr(sb); prtline(); stringbuf = sb; } @@ -1413,7 +1417,7 @@ redo: while ((ch = inch()) == ' ' || ch goto redo; unch(ch); } else if (ch == '\n') { - fputc('\n', stdout); + putch('\n'); ifiles->lineno++; } } .