| @@ -1967,7 +1967,7 @@ static inline void inp(void) · 1966 unmodified lines |
| 1967 | } | 1967 | } |
| 1968 | | 1968 | |
| 1969 | /* handle '\[\r]\n' */ | 1969 | /* handle '\[\r]\n' */ |
| 1970 | static void handle_stray(void) | 1970 | static 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 | |
| | 1991 | static 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 if | 1997 | /* 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) |