Fixed a bug where the preprocessor would occasionally lose whitespace at the beginning of lines immediately after a #endif, which was confusing the assembler.

This commit is contained in:
dtrg 2007-04-21 23:10:13 +00:00
parent 2a367fa192
commit b66d66b597

View file

@ -5,6 +5,8 @@
/* $Id$ */ /* $Id$ */
/* PREPROCESSOR DRIVER */ /* PREPROCESSOR DRIVER */
#include <stdlib.h>
#include <stdio.h>
#include <system.h> #include <system.h>
#include <alloc.h> #include <alloc.h>
#include "input.h" #include "input.h"
@ -160,57 +162,58 @@ preprocess(fn)
while (startline) { while (startline) {
/* first flush the saved pragma's */ /* first flush the saved pragma's */
if (pragma_nr) { if (pragma_nr) {
register int i = 0; register int i = 0;
int LiNo = LineNumber; int LiNo = LineNumber;
char *FiNam = FileName; char *FiNam = FileName;
while (i < pragma_nr) { while (i < pragma_nr) {
register char *c_ptr = "#pragma"; register char *c_ptr = "#pragma";
LineNumber = pragma_tab[i].pr_linnr; LineNumber = pragma_tab[i].pr_linnr;
FileName = pragma_tab[i].pr_fil; FileName = pragma_tab[i].pr_fil;
do_line_dir(lineno, fn); do_line_dir(lineno, fn);
while (*c_ptr) { echo(*c_ptr++); } while (*c_ptr) { echo(*c_ptr++); }
c_ptr = pragma_tab[i].pr_text; c_ptr = pragma_tab[i].pr_text;
while (*c_ptr) { echo(*c_ptr++); } while (*c_ptr) { echo(*c_ptr++); }
newline(); lineno++; newline(); lineno++;
free(pragma_tab[i].pr_text); free(pragma_tab[i].pr_text);
i++; i++;
} }
free((char *) pragma_tab); free((char *) pragma_tab);
pragma_tab = (struct prag_info *)0; pragma_tab = (struct prag_info *)0;
pragma_nr = 0; pragma_nr = 0;
LineNumber = LiNo; LineNumber = LiNo;
FileName = FiNam; FileName = FiNam;
do_line_dir(lineno, fn); do_line_dir(lineno, fn);
} }
while (class(c) == STSKIP || c == '/') { while (class(c) == STSKIP || c == '/') {
if (c == '/') { if (c == '/') {
if (!InputLevel) { if (!InputLevel) {
c = GetChar(); c = GetChar();
if (c == '*') { if (c == '*') {
op = SkipComment(op, &lineno); op = SkipComment(op, &lineno);
if (!op) return; if (!op) return;
if (!options['C']) { echo(' '); } if (!options['C']) { echo(' '); }
c = GetChar(); c = GetChar();
continue; continue;
}
UnGetChar();
c = '/';
}
break;
} }
UnGetChar(); echo(c);
c = '/'; c = GetChar();
}
break;
}
echo(c);
c = GetChar();
} }
if (c == '#') { if (c == '#') {
domacro(); domacro();
lineno++; lineno++;
newline(); newline();
c = GetChar(); do_line_dir(lineno, fn);
c = GetChar();
} else startline = 0; } else startline = 0;
} }
do_line_dir(lineno, fn); do_line_dir(lineno, fn);