error message fixes - CH_EOB is now '\'

This commit is contained in:
bellard 2002-11-22 14:43:38 +00:00
parent 2f219d8702
commit e926c359bb

18
tcc.c
View File

@ -220,7 +220,7 @@ typedef struct BufferedFile {
unsigned char buffer[IO_BUF_SIZE + 1]; /* extra size for CH_EOB char */
} 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 */
/* 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)
{
TCCState *s1 = tcc_state;
/* no need to do anything if not at EOB */
if (file->buf_ptr <= file->buf_end)
return;
for(;;) {
ch1 = tcc_getc_slow(file);
if (ch1 != CH_EOF)
@ -2501,7 +2506,7 @@ void parse_number(const char *p)
}
}
if (ch != 'p' && ch != 'P')
error("exponent expected");
expect("exponent");
ch = *p++;
s = 1;
exp_val = 0;
@ -2512,7 +2517,7 @@ void parse_number(const char *p)
ch = *p++;
}
if (ch < '0' || ch > '9')
error("exponent digits expected");
expect("exponent digits");
while (ch >= '0' && ch <= '9') {
exp_val = exp_val * 10 + ch - '0';
ch = *p++;
@ -2565,7 +2570,7 @@ void parse_number(const char *p)
ch = *p++;
}
if (ch < '0' || ch > '9')
error("exponent digits expected");
expect("exponent digits");
while (ch >= '0' && ch <= '9') {
if (q >= token_buf + STRING_MAX_SIZE)
goto num_too_long;
@ -2812,7 +2817,7 @@ static inline void next_nomacro1(void)
b = (char)b;
tokc.i = b;
if (ch != '\'')
expect("\'");
error("unterminated character constant");
minp();
break;
case '\"':
@ -7599,11 +7604,12 @@ void tcc_define_symbol(TCCState *s1, const char *sym, const char *value)
if (!value)
value = "1";
pstrcat(bf->buffer, IO_BUF_SIZE, value);
/* init file structure */
bf->fd = -1;
bf->buf_ptr = bf->buffer;
bf->buf_end = bf->buffer + strlen(bf->buffer);
*bf->buf_end = CH_EOB;
bf->filename[0] = '\0';
bf->line_num = 1;
file = bf;