History

error message fixes - CH_EOB is now '\'

bellard committed 23 years ago

Commit e926c351 parent 2f219d81 file · +12 −6Browse files

Unified · Split

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

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