From b66d66b5979a5c86359a083d836998d2e622a3c6 Mon Sep 17 00:00:00 2001 From: dtrg Date: Sat, 21 Apr 2007 23:10:13 +0000 Subject: [PATCH] Fixed a bug where the preprocessor would occasionally lose whitespace at the beginning of lines immediately after a #endif, which was confusing the assembler. --- lang/cem/cpp.ansi/preprocess.c | 89 ++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/lang/cem/cpp.ansi/preprocess.c b/lang/cem/cpp.ansi/preprocess.c index f1ddfbbd5..72fa647e9 100644 --- a/lang/cem/cpp.ansi/preprocess.c +++ b/lang/cem/cpp.ansi/preprocess.c @@ -5,6 +5,8 @@ /* $Id$ */ /* PREPROCESSOR DRIVER */ +#include +#include #include #include #include "input.h" @@ -160,57 +162,58 @@ preprocess(fn) while (startline) { /* first flush the saved pragma's */ if (pragma_nr) { - register int i = 0; - int LiNo = LineNumber; - char *FiNam = FileName; - - while (i < pragma_nr) { - register char *c_ptr = "#pragma"; - - LineNumber = pragma_tab[i].pr_linnr; - FileName = pragma_tab[i].pr_fil; - do_line_dir(lineno, fn); - while (*c_ptr) { echo(*c_ptr++); } - c_ptr = pragma_tab[i].pr_text; - while (*c_ptr) { echo(*c_ptr++); } - newline(); lineno++; - free(pragma_tab[i].pr_text); - i++; - } - free((char *) pragma_tab); - pragma_tab = (struct prag_info *)0; - pragma_nr = 0; - LineNumber = LiNo; - FileName = FiNam; - do_line_dir(lineno, fn); + register int i = 0; + int LiNo = LineNumber; + char *FiNam = FileName; + + while (i < pragma_nr) { + register char *c_ptr = "#pragma"; + + LineNumber = pragma_tab[i].pr_linnr; + FileName = pragma_tab[i].pr_fil; + do_line_dir(lineno, fn); + while (*c_ptr) { echo(*c_ptr++); } + c_ptr = pragma_tab[i].pr_text; + while (*c_ptr) { echo(*c_ptr++); } + newline(); lineno++; + free(pragma_tab[i].pr_text); + i++; + } + free((char *) pragma_tab); + pragma_tab = (struct prag_info *)0; + pragma_nr = 0; + LineNumber = LiNo; + FileName = FiNam; + do_line_dir(lineno, fn); } while (class(c) == STSKIP || c == '/') { - if (c == '/') { - if (!InputLevel) { - c = GetChar(); - if (c == '*') { - op = SkipComment(op, &lineno); - if (!op) return; - if (!options['C']) { echo(' '); } - c = GetChar(); - continue; + if (c == '/') { + if (!InputLevel) { + c = GetChar(); + if (c == '*') { + op = SkipComment(op, &lineno); + if (!op) return; + if (!options['C']) { echo(' '); } + c = GetChar(); + continue; + } + UnGetChar(); + c = '/'; + } + break; } - UnGetChar(); - c = '/'; - } - break; - } - echo(c); - c = GetChar(); + echo(c); + c = GetChar(); } if (c == '#') { - domacro(); - lineno++; - newline(); - c = GetChar(); + domacro(); + lineno++; + newline(); + do_line_dir(lineno, fn); + c = GetChar(); } else startline = 0; } do_line_dir(lineno, fn);