Stop reading at EOF, and signal an error when EOF occurs inside a string.
This commit is contained in:
parent
7e5014ab07
commit
6dd02a5d6e
8
reader.c
8
reader.c
|
|
@ -489,6 +489,8 @@ static value_t read_string(reader_state_t *state)
|
||||||
bool skip_ws = false;
|
bool skip_ws = false;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
|
release_assert(state->ch != EOF);
|
||||||
|
|
||||||
if ((buffer_size - length) < 1)
|
if ((buffer_size - length) < 1)
|
||||||
{
|
{
|
||||||
release_assert(buffer_size <= INT32_MAX / 3);
|
release_assert(buffer_size <= INT32_MAX / 3);
|
||||||
|
|
@ -551,7 +553,10 @@ static value_t read_string(reader_state_t *state)
|
||||||
/* Treats everything that follows on the same line as a comment,
|
/* Treats everything that follows on the same line as a comment,
|
||||||
* and additionally skips leading whitespace on the next line. */
|
* and additionally skips leading whitespace on the next line. */
|
||||||
while (state->ch != '\n')
|
while (state->ch != '\n')
|
||||||
|
{
|
||||||
|
release_assert(state->ch != EOF);
|
||||||
next_char(state);
|
next_char(state);
|
||||||
|
}
|
||||||
skip_ws = true;
|
skip_ws = true;
|
||||||
break;
|
break;
|
||||||
case '\\': ch = '\\'; next_char(state); break;
|
case '\\': ch = '\\'; next_char(state); break;
|
||||||
|
|
@ -869,6 +874,8 @@ static void tree_replace(value_t *in, value_t oldval, value_t newval)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void next_char(reader_state_t *state)
|
static void next_char(reader_state_t *state)
|
||||||
|
{
|
||||||
|
if (state->ch != EOF)
|
||||||
{
|
{
|
||||||
state->ch = fgetc(state->file);
|
state->ch = fgetc(state->file);
|
||||||
|
|
||||||
|
|
@ -882,6 +889,7 @@ static void next_char(reader_state_t *state)
|
||||||
++state->column;
|
++state->column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void skip_whitespace(reader_state_t *state)
|
static void skip_whitespace(reader_state_t *state)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue