Skip to content
Snippets Groups Projects
Commit 64e1c5fa authored by benjamin.franksen's avatar benjamin.franksen
Browse files

snc: fixed recognition of line markers for windows CPP output

This fixes error and warnign messages on windows so they refer
to the original source file. Also refactored line marker regexes
and allow whitespace before and after the '#'.
parent 7173a041
No related branches found
No related tags found
No related merge requests found
......@@ -153,6 +153,11 @@ static char *strdupft(uchar *start, uchar *stop) {
return result;
}
/*
* Note: Linemarkers differ between compilers. The MS C preprocessor outputs
* "#line <linenum> <filename>" directives, while gcc leaves off the "line".
*/
/*!re2c
NL = [\n];
ANY = [^];
......@@ -165,6 +170,7 @@ static char *strdupft(uchar *start, uchar *stop) {
FS = [fFlL];
IS = [uUlL]*;
ESC = [\\] ([abfnrtv?'"\\] | "x" HEX+ | OCT+);
LINE = SPC* "#" (SPC* "line")? SPC+;
*/
static int scan(Scanner *s, Token *t) {
......@@ -193,15 +199,15 @@ snl:
s->line++;
goto snl;
}
LINE {
line_marker_part = cursor - s->tok;
goto line_marker;
}
["] {
s->tok = s->end = cursor;
goto string_const;
}
"/*" { goto comment; }
"#" SPC* {
line_marker_part = cursor - s->tok;
goto line_marker;
}
"%{" {
s->tok = cursor;
in_c_code = 1;
......@@ -410,7 +416,7 @@ c_code:
LITERAL(CCODE, embedded_c_code, strdupft(s->tok, cursor - 2));
}
. { goto c_code; }
"#" SPC+ {
LINE {
line_marker_part = cursor - s->tok;
goto line_marker;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment