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 @@
1version 0.9.24:1version 0.9.24:
2 2
3- Handle backslashes within #include, #error, #warning
3- Import changesets (part 4) 428,457,460,467: defines for openbsd etc.4- Import changesets (part 4) 428,457,460,467: defines for openbsd etc.
4
5- Use _WIN32 for a windows hosted tcc and define it for the PE target,5- Use _WIN32 for a windows hosted tcc and define it for the PE target,
6 otherwise define __unix / __linux (Detlef Riekenberg)6 otherwise define __unix / __linux (Detlef Riekenberg)
7
8- Import changesets (part 3) 409,410: ARM EABI by Daniel Gl�ckner7- Import changesets (part 3) 409,410: ARM EABI by Daniel Gl�ckner
9
10- Some in-between fixes:8- Some in-between fixes:
11 TCC -E no longer hangs with macro calls involving newlines.9 TCC -E no longer hangs with macro calls involving newlines.
12 (next_nomacro1 now advances the read-pointer with TOK_LINEFEED)10 (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
1967}1967}
1968 1968
1969/* handle '\[\r]\n' */1969/* handle '\[\r]\n' */
1970static void handle_stray(void)1970static int handle_stray_noerror(void)
1971{1971{
1972 while (ch == '\\') {1972 while (ch == '\\') {
1973 inp();1973 inp();
@@ -1982,9 +1982,16 @@ static void handle_stray(void) · 8 unmodified lines
1982 inp();1982 inp();
1983 } else {1983 } else {
1984 fail:1984 fail:
1985 error("stray '\\' in program");1985 return 1;
1986 }1986 }
1987 }1987 }
1988 return 0;
1989}
1990
1991static void handle_stray(void)
1992{
1993 if (handle_stray_noerror())
1994 error("stray '\\' in program");
1988}1995}
1989 1996
1990/* skip the stray and handle the \\n case. Output an error if1997/* skip the stray and handle the \\n case. Output an error if
@@ -2264,9 +2271,8 @@ void preprocess_skip(void) · 273 unmodified lines
2264 if (c == CH_EOF) {2271 if (c == CH_EOF) {
2265 expect("#endif");2272 expect("#endif");
2266 } else if (c == '\\') {2273 } else if (c == '\\') {
2267 /* XXX: incorrect: should not give an error */
2268 ch = file->buf_ptr[0];2274 ch = file->buf_ptr[0];
2269 handle_stray();2275 handle_stray_noerror();
2270 }2276 }
2271 p = file->buf_ptr;2277 p = file->buf_ptr;
2272 goto redo_no_start;2278 goto redo_no_start;
@@ -2896,13 +2902,16 @@ static void preprocess(int is_bof) · 623 unmodified lines
2896 } else if (ch == '\"') {2902 } else if (ch == '\"') {
2897 c = ch;2903 c = ch;
2898 read_name:2904 read_name:
2899 /* XXX: better stray handling */2905 inp();
2900 minp();
2901 q = buf;2906 q = buf;
2902 while (ch != c && ch != '\n' && ch != CH_EOF) {2907 while (ch != c && ch != '\n' && ch != CH_EOF) {
2903 if ((q - buf) < sizeof(buf) - 1)2908 if ((q - buf) < sizeof(buf) - 1)
2904 *q++ = ch;2909 *q++ = ch;
2905 minp();2910 if (ch == '\\') {
2911 if (handle_stray_noerror() == 0)
2912 --q;
2913 } else
2914 inp();
2906 }2915 }
2907 *q = '\0';2916 *q = '\0';
2908 minp();2917 minp();
@@ -3104,7 +3113,11 @@ static void preprocess(int is_bof) · 195 unmodified lines
3104 while (ch != '\n' && ch != CH_EOF) {3113 while (ch != '\n' && ch != CH_EOF) {
3105 if ((q - buf) < sizeof(buf) - 1)3114 if ((q - buf) < sizeof(buf) - 1)
3106 *q++ = ch;3115 *q++ = ch;
3107 minp();3116 if (ch == '\\') {
3117 if (handle_stray_noerror() == 0)
3118 --q;
3119 } else
3120 inp();
3108 }3121 }
3109 *q = '\0';3122 *q = '\0';
3110 if (c == TOK_ERROR)3123 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