diff options
| author | grischka <grischka> | 2007-12-17 19:35:15 +0000 |
|---|---|---|
| committer | grischka <grischka> | 2007-12-17 19:35:15 +0000 |
| commit | adb14564724f9afdae98678a2b237413d0e42bcf (patch) | |
| tree | 53d007c8f772333850145bf66d7a287e0937c70f | |
| parent | 6c96c41ee49c11dda436eecc23beea002eace19e (diff) | |
| download | tinycc-adb14564724f9afdae98678a2b237413d0e42bcf.tar.gz tinycc-adb14564724f9afdae98678a2b237413d0e42bcf.tar.bz2 | |
Handle backslashes within #include, #error, #warning
| -rw-r--r-- | Changelog | 4 | ||||
| -rw-r--r-- | tcc.c | 29 |
2 files changed, 22 insertions, 11 deletions
@@ -1,12 +1,10 @@ version 0.9.24: +- Handle backslashes within #include, #error, #warning - 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, otherwise define __unix / __linux (Detlef Riekenberg) - - Import changesets (part 3) 409,410: ARM EABI by Daniel Glöckner - - Some in-between fixes: TCC -E no longer hangs with macro calls involving newlines. (next_nomacro1 now advances the read-pointer with TOK_LINEFEED) @@ -1967,7 +1967,7 @@ static inline void inp(void) } /* handle '\[\r]\n' */ -static void handle_stray(void) +static int handle_stray_noerror(void) { while (ch == '\\') { inp(); @@ -1982,9 +1982,16 @@ static void handle_stray(void) inp(); } else { 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 @@ -2264,9 +2271,8 @@ void preprocess_skip(void) if (c == CH_EOF) { expect("#endif"); } else if (c == '\\') { - /* XXX: incorrect: should not give an error */ ch = file->buf_ptr[0]; - handle_stray(); + handle_stray_noerror(); } p = file->buf_ptr; goto redo_no_start; @@ -2896,13 +2902,16 @@ static void preprocess(int is_bof) } else if (ch == '\"') { c = ch; read_name: - /* XXX: better stray handling */ - minp(); + inp(); q = buf; while (ch != c && ch != '\n' && ch != CH_EOF) { if ((q - buf) < sizeof(buf) - 1) *q++ = ch; - minp(); + if (ch == '\\') { + if (handle_stray_noerror() == 0) + --q; + } else + inp(); } *q = '\0'; minp(); @@ -3104,7 +3113,11 @@ static void preprocess(int is_bof) while (ch != '\n' && ch != CH_EOF) { if ((q - buf) < sizeof(buf) - 1) *q++ = ch; - minp(); + if (ch == '\\') { + if (handle_stray_noerror() == 0) + --q; + } else + inp(); } *q = '\0'; if (c == TOK_ERROR) |
