commit 7a10ad2b7f2b6345a42d0777be81c96ed60875c3
parent 2eb79037ab636f1babd53d73c289a61a2e01fc35
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;