error message fixes - CH_EOB is now '\'
This commit is contained in:
parent
2f219d8702
commit
e926c359bb
1 changed files with 12 additions and 6 deletions
16
tcc.c
16
tcc.c
|
@ -220,7 +220,7 @@ typedef struct BufferedFile {
|
||||||
unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */
|
unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */
|
||||||
} BufferedFile;
|
} BufferedFile;
|
||||||
|
|
||||||
#define CH_EOB 0 /* end of buffer or '\0' char in file */
|
#define CH_EOB '\\' /* end of buffer or '\0' char in file */
|
||||||
#define CH_EOF (-1) /* end of file */
|
#define CH_EOF (-1) /* end of file */
|
||||||
|
|
||||||
/* parsing state (used to save parser state to reparse part of the
|
/* parsing state (used to save parser state to reparse part of the
|
||||||
|
@ -1528,6 +1528,11 @@ int tcc_getc_slow(BufferedFile *bf)
|
||||||
void handle_eob(void)
|
void handle_eob(void)
|
||||||
{
|
{
|
||||||
TCCState *s1 = tcc_state;
|
TCCState *s1 = tcc_state;
|
||||||
|
|
||||||
|
/* no need to do anything if not at EOB */
|
||||||
|
if (file->buf_ptr <= file->buf_end)
|
||||||
|
return;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
ch1 = tcc_getc_slow(file);
|
ch1 = tcc_getc_slow(file);
|
||||||
if (ch1 != CH_EOF)
|
if (ch1 != CH_EOF)
|
||||||
|
@ -2501,7 +2506,7 @@ void parse_number(const char *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ch != 'p' && ch != 'P')
|
if (ch != 'p' && ch != 'P')
|
||||||
error("exponent expected");
|
expect("exponent");
|
||||||
ch = *p++;
|
ch = *p++;
|
||||||
s = 1;
|
s = 1;
|
||||||
exp_val = 0;
|
exp_val = 0;
|
||||||
|
@ -2512,7 +2517,7 @@ void parse_number(const char *p)
|
||||||
ch = *p++;
|
ch = *p++;
|
||||||
}
|
}
|
||||||
if (ch < '0' || ch > '9')
|
if (ch < '0' || ch > '9')
|
||||||
error("exponent digits expected");
|
expect("exponent digits");
|
||||||
while (ch >= '0' && ch <= '9') {
|
while (ch >= '0' && ch <= '9') {
|
||||||
exp_val = exp_val * 10 + ch - '0';
|
exp_val = exp_val * 10 + ch - '0';
|
||||||
ch = *p++;
|
ch = *p++;
|
||||||
|
@ -2565,7 +2570,7 @@ void parse_number(const char *p)
|
||||||
ch = *p++;
|
ch = *p++;
|
||||||
}
|
}
|
||||||
if (ch < '0' || ch > '9')
|
if (ch < '0' || ch > '9')
|
||||||
error("exponent digits expected");
|
expect("exponent digits");
|
||||||
while (ch >= '0' && ch <= '9') {
|
while (ch >= '0' && ch <= '9') {
|
||||||
if (q >= token_buf + STRING_MAX_SIZE)
|
if (q >= token_buf + STRING_MAX_SIZE)
|
||||||
goto num_too_long;
|
goto num_too_long;
|
||||||
|
@ -2812,7 +2817,7 @@ static inline void next_nomacro1(void)
|
||||||
b = (char)b;
|
b = (char)b;
|
||||||
tokc.i = b;
|
tokc.i = b;
|
||||||
if (ch != '\'')
|
if (ch != '\'')
|
||||||
expect("\'");
|
error("unterminated character constant");
|
||||||
minp();
|
minp();
|
||||||
break;
|
break;
|
||||||
case '\"':
|
case '\"':
|
||||||
|
@ -7604,6 +7609,7 @@ void tcc_define_symbol(TCCState *s1, const char *sym, const char *value)
|
||||||
bf->fd = -1;
|
bf->fd = -1;
|
||||||
bf->buf_ptr = bf->buffer;
|
bf->buf_ptr = bf->buffer;
|
||||||
bf->buf_end = bf->buffer + strlen(bf->buffer);
|
bf->buf_end = bf->buffer + strlen(bf->buffer);
|
||||||
|
*bf->buf_end = CH_EOB;
|
||||||
bf->filename[0] = '\0';
|
bf->filename[0] = '\0';
|
||||||
bf->line_num = 1;
|
bf->line_num = 1;
|
||||||
file = bf;
|
file = bf;
|
||||||
|
|
Loading…
Reference in a new issue