forked from Mirrors/tinycc
Handle backslashes within #include, #error, #warning
parent
6c96c41ee4
commit
adb1456472
|
@ -1,12 +1,10 @@
|
||||||
version 0.9.24:
|
version 0.9.24:
|
||||||
|
|
||||||
|
- Handle backslashes within #include, #error, #warning
|
||||||
- Import changesets (part 4) 428,457,460,467: defines for openbsd etc.
|
- Import changesets (part 4) 428,457,460,467: defines for openbsd etc.
|
||||||
|
|
||||||
- Use _WIN32 for a windows hosted tcc and define it for the PE target,
|
- Use _WIN32 for a windows hosted tcc and define it for the PE target,
|
||||||
otherwise define __unix / __linux (Detlef Riekenberg)
|
otherwise define __unix / __linux (Detlef Riekenberg)
|
||||||
|
|
||||||
- Import changesets (part 3) 409,410: ARM EABI by Daniel Glöckner
|
- Import changesets (part 3) 409,410: ARM EABI by Daniel Glöckner
|
||||||
|
|
||||||
- Some in-between fixes:
|
- Some in-between fixes:
|
||||||
TCC -E no longer hangs with macro calls involving newlines.
|
TCC -E no longer hangs with macro calls involving newlines.
|
||||||
(next_nomacro1 now advances the read-pointer with TOK_LINEFEED)
|
(next_nomacro1 now advances the read-pointer with TOK_LINEFEED)
|
||||||
|
|
29
tcc.c
29
tcc.c
|
@ -1967,7 +1967,7 @@ static inline void inp(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle '\[\r]\n' */
|
/* handle '\[\r]\n' */
|
||||||
static void handle_stray(void)
|
static int handle_stray_noerror(void)
|
||||||
{
|
{
|
||||||
while (ch == '\\') {
|
while (ch == '\\') {
|
||||||
inp();
|
inp();
|
||||||
|
@ -1982,9 +1982,16 @@ static void handle_stray(void)
|
||||||
inp();
|
inp();
|
||||||
} else {
|
} else {
|
||||||
fail:
|
fail:
|
||||||
error("stray '\\' in program");
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_stray(void)
|
||||||
|
{
|
||||||
|
if (handle_stray_noerror())
|
||||||
|
error("stray '\\' in program");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip the stray and handle the \\n case. Output an error if
|
/* skip the stray and handle the \\n case. Output an error if
|
||||||
|
@ -2264,9 +2271,8 @@ void preprocess_skip(void)
|
||||||
if (c == CH_EOF) {
|
if (c == CH_EOF) {
|
||||||
expect("#endif");
|
expect("#endif");
|
||||||
} else if (c == '\\') {
|
} else if (c == '\\') {
|
||||||
/* XXX: incorrect: should not give an error */
|
|
||||||
ch = file->buf_ptr[0];
|
ch = file->buf_ptr[0];
|
||||||
handle_stray();
|
handle_stray_noerror();
|
||||||
}
|
}
|
||||||
p = file->buf_ptr;
|
p = file->buf_ptr;
|
||||||
goto redo_no_start;
|
goto redo_no_start;
|
||||||
|
@ -2896,13 +2902,16 @@ static void preprocess(int is_bof)
|
||||||
} else if (ch == '\"') {
|
} else if (ch == '\"') {
|
||||||
c = ch;
|
c = ch;
|
||||||
read_name:
|
read_name:
|
||||||
/* XXX: better stray handling */
|
inp();
|
||||||
minp();
|
|
||||||
q = buf;
|
q = buf;
|
||||||
while (ch != c && ch != '\n' && ch != CH_EOF) {
|
while (ch != c && ch != '\n' && ch != CH_EOF) {
|
||||||
if ((q - buf) < sizeof(buf) - 1)
|
if ((q - buf) < sizeof(buf) - 1)
|
||||||
*q++ = ch;
|
*q++ = ch;
|
||||||
minp();
|
if (ch == '\\') {
|
||||||
|
if (handle_stray_noerror() == 0)
|
||||||
|
--q;
|
||||||
|
} else
|
||||||
|
inp();
|
||||||
}
|
}
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
minp();
|
minp();
|
||||||
|
@ -3104,7 +3113,11 @@ static void preprocess(int is_bof)
|
||||||
while (ch != '\n' && ch != CH_EOF) {
|
while (ch != '\n' && ch != CH_EOF) {
|
||||||
if ((q - buf) < sizeof(buf) - 1)
|
if ((q - buf) < sizeof(buf) - 1)
|
||||||
*q++ = ch;
|
*q++ = ch;
|
||||||
minp();
|
if (ch == '\\') {
|
||||||
|
if (handle_stray_noerror() == 0)
|
||||||
|
--q;
|
||||||
|
} else
|
||||||
|
inp();
|
||||||
}
|
}
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
if (c == TOK_ERROR)
|
if (c == TOK_ERROR)
|
||||||
|
|
Loading…
Reference in New Issue