Unified · Split
| @@ -220,7 +220,7 @@ typedef struct BufferedFile { · 219 unmodified lines | ||
| 220 | 220 | unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */ |
| 221 | 221 | } BufferedFile; |
| 222 | 222 | |
| 223 | −#define CH_EOB 0 /* end of buffer or '\0' char in file */ | |
| 223 | +#define CH_EOB '\\' /* end of buffer or '\0' char in file */ | |
| 224 | 224 | #define CH_EOF (-1) /* end of file */ |
| 225 | 225 | |
| 226 | 226 | /* parsing state (used to save parser state to reparse part of the |
| @@ -1528,6 +1528,11 @@ int tcc_getc_slow(BufferedFile *bf) · 1301 unmodified lines | ||
| 1528 | 1528 | void handle_eob(void) |
| 1529 | 1529 | { |
| 1530 | 1530 | TCCState *s1 = tcc_state; |
| 1531 | + | |
| 1532 | + /* no need to do anything if not at EOB */ | |
| 1533 | + if (file->buf_ptr <= file->buf_end) | |
| 1534 | + return; | |
| 1535 | + | |
| 1531 | 1536 | for(;;) { |
| 1532 | 1537 | ch1 = tcc_getc_slow(file); |
| 1533 | 1538 | if (ch1 != CH_EOF) |
| @@ -2501,7 +2506,7 @@ void parse_number(const char *p) · 967 unmodified lines | ||
| 2501 | 2506 | } |
| 2502 | 2507 | } |
| 2503 | 2508 | if (ch != 'p' && ch != 'P') |
| 2504 | − error("exponent expected"); | |
| 2509 | + expect("exponent"); | |
| 2505 | 2510 | ch = *p++; |
| 2506 | 2511 | s = 1; |
| 2507 | 2512 | exp_val = 0; |
| @@ -2512,7 +2517,7 @@ void parse_number(const char *p) · 4 unmodified lines | ||
| 2512 | 2517 | ch = *p++; |
| 2513 | 2518 | } |
| 2514 | 2519 | if (ch < '0' || ch > '9') |
| 2515 | − error("exponent digits expected"); | |
| 2520 | + expect("exponent digits"); | |
| 2516 | 2521 | while (ch >= '0' && ch <= '9') { |
| 2517 | 2522 | exp_val = exp_val * 10 + ch - '0'; |
| 2518 | 2523 | ch = *p++; |
| @@ -2565,7 +2570,7 @@ void parse_number(const char *p) · 46 unmodified lines | ||
| 2565 | 2570 | ch = *p++; |
| 2566 | 2571 | } |
| 2567 | 2572 | if (ch < '0' || ch > '9') |
| 2568 | − error("exponent digits expected"); | |
| 2573 | + expect("exponent digits"); | |
| 2569 | 2574 | while (ch >= '0' && ch <= '9') { |
| 2570 | 2575 | if (q >= token_buf + STRING_MAX_SIZE) |
| 2571 | 2576 | goto num_too_long; |
| @@ -2812,7 +2817,7 @@ static inline void next_nomacro1(void) · 240 unmodified lines | ||
| 2812 | 2817 | b = (char)b; |
| 2813 | 2818 | tokc.i = b; |
| 2814 | 2819 | if (ch != '\'') |
| 2815 | − expect("\'"); | |
| 2820 | + error("unterminated character constant"); | |
| 2816 | 2821 | minp(); |
| 2817 | 2822 | break; |
| 2818 | 2823 | case '\"': |
| @@ -7599,11 +7604,12 @@ void tcc_define_symbol(TCCState *s1, const char *sym, const char *value) · 4780 unmodified lines | ||
| 7599 | 7604 | if (!value) |
| 7600 | 7605 | value = "1"; |
| 7601 | 7606 | pstrcat(bf->buffer, IO_BUF_SIZE, value); |
| 7602 | − | |
| 7607 | + | |
| 7603 | 7608 | /* init file structure */ |
| 7604 | 7609 | bf->fd = -1; |
| 7605 | 7610 | bf->buf_ptr = bf->buffer; |
| 7606 | 7611 | bf->buf_end = bf->buffer + strlen(bf->buffer); |
| 7612 | + *bf->buf_end = CH_EOB; | |
| 7607 | 7613 | bf->filename[0] = '\0'; |
| 7608 | 7614 | bf->line_num = 1; |
| 7609 | 7615 | file = bf; |