History

Handle backslashes within #include, #error, #warning

grischka committed 18 years ago

Commit adb14561 parent 6c96c412 files · +22 −11Browse files

Unified · Split

2 files
  1. Changelog +1 −3
  2. tcc.c +21 −8
Changelog+1−3
@@ -1,12 +1,10 @@
11 version 0.9.24:
22
3+- Handle backslashes within #include, #error, #warning
34 - Import changesets (part 4) 428,457,460,467: defines for openbsd etc.
4−
55 - Use _WIN32 for a windows hosted tcc and define it for the PE target,
66 otherwise define __unix / __linux (Detlef Riekenberg)
7−
87 - Import changesets (part 3) 409,410: ARM EABI by Daniel Gl�ckner
9−
108 - Some in-between fixes:
119 TCC -E no longer hangs with macro calls involving newlines.
1210 (next_nomacro1 now advances the read-pointer with TOK_LINEFEED)
tcc.c+21−8
@@ -1967,7 +1967,7 @@ static inline void inp(void) · 1966 unmodified lines
19671967 }
19681968
19691969 /* handle '\[\r]\n' */
1970−static void handle_stray(void)
1970+static int handle_stray_noerror(void)
19711971 {
19721972 while (ch == '\\') {
19731973 inp();
@@ -1982,9 +1982,16 @@ static void handle_stray(void) · 8 unmodified lines
19821982 inp();
19831983 } else {
19841984 fail:
1985− error("stray '\\' in program");
1985+ return 1;
19861986 }
19871987 }
1988+ return 0;
1989+}
1990+
1991+static void handle_stray(void)
1992+{
1993+ if (handle_stray_noerror())
1994+ error("stray '\\' in program");
19881995 }
19891996
19901997 /* skip the stray and handle the \\n case. Output an error if
@@ -2264,9 +2271,8 @@ void preprocess_skip(void) · 273 unmodified lines
22642271 if (c == CH_EOF) {
22652272 expect("#endif");
22662273 } else if (c == '\\') {
2267− /* XXX: incorrect: should not give an error */
22682274 ch = file->buf_ptr[0];
2269− handle_stray();
2275+ handle_stray_noerror();
22702276 }
22712277 p = file->buf_ptr;
22722278 goto redo_no_start;
@@ -2896,13 +2902,16 @@ static void preprocess(int is_bof) · 623 unmodified lines
28962902 } else if (ch == '\"') {
28972903 c = ch;
28982904 read_name:
2899− /* XXX: better stray handling */
2900− minp();
2905+ inp();
29012906 q = buf;
29022907 while (ch != c && ch != '\n' && ch != CH_EOF) {
29032908 if ((q - buf) < sizeof(buf) - 1)
29042909 *q++ = ch;
2905− minp();
2910+ if (ch == '\\') {
2911+ if (handle_stray_noerror() == 0)
2912+ --q;
2913+ } else
2914+ inp();
29062915 }
29072916 *q = '\0';
29082917 minp();
@@ -3104,7 +3113,11 @@ static void preprocess(int is_bof) · 195 unmodified lines
31043113 while (ch != '\n' && ch != CH_EOF) {
31053114 if ((q - buf) < sizeof(buf) - 1)
31063115 *q++ = ch;
3107− minp();
3116+ if (ch == '\\') {
3117+ if (handle_stray_noerror() == 0)
3118+ --q;
3119+ } else
3120+ inp();
31083121 }
31093122 *q = '\0';
31103123 if (c == TOK_ERROR)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t