bc: Fix comment parsing

The function comment was misparsing comments, because it ate always
the character after a *, invalidating sequences like **/. Also, as it
didn't count new line characters error messages were misleading.
This commit is contained in:
Roberto E. Vargas Caballero 2025-11-23 12:31:30 +01:00
parent 4e3d54e231
commit bda3c88559

15
bc.y
View File

@ -587,10 +587,17 @@ operand(int ch)
static void
comment(void)
{
do {
while (getchar() != '*')
;
} while (getchar() != '/');
int c;
for (;;) {
while ((c = getchar()) != '*') {
if (c == '\n')
lineno++;
}
if ((c = getchar()) == '/')
break;
ungetc(c, stdin);
}
}
static int