commit 539338d3e3f1ac406cd5bf8863d217bcb648e7c2
parent e7546f194ee39c7e10e95479d594fd450ea8dff2
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 17 Nov 2021 19:29:01 +0100
cc1: Substitute // comments by \n
The code was substituing all the comments by a space, but it only
works with /* */ comments. // comments should be substitued by
newlines, otherwise they cannot be used in preprocessor directives
that need to be in only one line.
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/cmd/cc/cc1/lex.c b/src/cmd/cc/cc1/lex.c
@@ -219,9 +219,15 @@ readline(void)
peekc = readchar();
if (peekc != '*' && peekc != '/')
continue;
- comment((peekc == '/') ? '\n' : '*');
+
+ if (peekc == '/') {
+ comment('\n');
+ break;
+ } else {
+ comment('*');
+ c = ' ';
+ }
peekc = 0;
- c = ' ';
}
input->begin = input->p = input->line;