diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2017-09-27 00:43:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 00:43:30 -0700 |
commit | 2567868bdf5664e95f998e76512c84d2c63f09a2 (patch) | |
tree | 2ddbfc324bf04fed2d45aaaecf9aae10510ae063 /src/parser | |
parent | f82e4308d1f1b8cc033ca6bfd70e707e4695a47d (diff) |
Fix seeking for buffered input (#1145)
CVC4's implementation of seek was calculating the pointer difference
between the current position in the input and the seek point to
determine how many characters to consume. This was causing problems when
ANTLR was seeking to a pointer on a line after the current line because
it would result in a big number of characters to consume because each
line is allocated separately. This resulted in issue #1113, where CVC4
was computing a large number of characters to consume and would block
until it received all of them. This commit fixes and simplifies the
code by simply consuming characters until the seek point is reached
without computing a count beforehand.
Diffstat (limited to 'src/parser')
-rw-r--r-- | src/parser/antlr_line_buffered_input.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/parser/antlr_line_buffered_input.cpp b/src/parser/antlr_line_buffered_input.cpp index 8a4bcdebb..e9e861e17 100644 --- a/src/parser/antlr_line_buffered_input.cpp +++ b/src/parser/antlr_line_buffered_input.cpp @@ -294,10 +294,8 @@ static void bufferedInputSeek(pANTLR3_INT_STREAM is, ANTLR3_MARKER seekPoint) { assert(!line_buffered_input->line_buffer->isPtrBefore( (uint8_t*)seekPoint, input->line, input->charPositionInLine)); - ssize_t count = (ssize_t)(seekPoint - (ANTLR3_MARKER)(input->nextChar)); - while (count > 0) { + while ((ANTLR3_MARKER)(input->nextChar) != seekPoint) { is->consume(is); - count--; } } |