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
220220 unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */
221221 } BufferedFile;
222222
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 */
224224 #define CH_EOF (-1) /* end of file */
225225
226226 /* 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
15281528 void handle_eob(void)
15291529 {
15301530 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+
15311536 for(;;) {
15321537 ch1 = tcc_getc_slow(file);
15331538 if (ch1 != CH_EOF)
@@ -2501,7 +2506,7 @@ void parse_number(const char *p) · 967 unmodified lines
25012506 }
25022507 }
25032508 if (ch != 'p' && ch != 'P')
2504− error("exponent expected");
2509+ expect("exponent");
25052510 ch = *p++;
25062511 s = 1;
25072512 exp_val = 0;
@@ -2512,7 +2517,7 @@ void parse_number(const char *p) · 4 unmodified lines
25122517 ch = *p++;
25132518 }
25142519 if (ch < '0' || ch > '9')
2515− error("exponent digits expected");
2520+ expect("exponent digits");
25162521 while (ch >= '0' && ch <= '9') {
25172522 exp_val = exp_val * 10 + ch - '0';
25182523 ch = *p++;
@@ -2565,7 +2570,7 @@ void parse_number(const char *p) · 46 unmodified lines
25652570 ch = *p++;
25662571 }
25672572 if (ch < '0' || ch > '9')
2568− error("exponent digits expected");
2573+ expect("exponent digits");
25692574 while (ch >= '0' && ch <= '9') {
25702575 if (q >= token_buf + STRING_MAX_SIZE)
25712576 goto num_too_long;
@@ -2812,7 +2817,7 @@ static inline void next_nomacro1(void) · 240 unmodified lines
28122817 b = (char)b;
28132818 tokc.i = b;
28142819 if (ch != '\'')
2815− expect("\'");
2820+ error("unterminated character constant");
28162821 minp();
28172822 break;
28182823 case '\"':
@@ -7599,11 +7604,12 @@ void tcc_define_symbol(TCCState *s1, const char *sym, const char *value) · 4780 unmodified lines
75997604 if (!value)
76007605 value = "1";
76017606 pstrcat(bf->buffer, IO_BUF_SIZE, value);
7602−
7607+
76037608 /* init file structure */
76047609 bf->fd = -1;
76057610 bf->buf_ptr = bf->buffer;
76067611 bf->buf_end = bf->buffer + strlen(bf->buffer);
7612+ *bf->buf_end = CH_EOB;
76077613 bf->filename[0] = '\0';
76087614 bf->line_num = 1;
76097615 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