diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-01-19 00:59:30 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-01-19 00:59:30 -0800 |
commit | fccd5fda24a9689f5890abc8d824f7a8da139550 (patch) | |
tree | 47819eace65d3604fb26d953189fda0fc0cecc5f /stream.c | |
parent | 1043bad18b114590c78d1db804339a457fd37d96 (diff) | |
download | txr-fccd5fda24a9689f5890abc8d824f7a8da139550.tar.gz txr-fccd5fda24a9689f5890abc8d824f7a8da139550.tar.bz2 txr-fccd5fda24a9689f5890abc8d824f7a8da139550.zip |
Fix regression: get-char on string input stream.
This happened on 2015-07-29, before TXR 111,
"Deriving streams from the same base" commit.
* stream.c (string_in_get_char): Must retrieve the character
at the previous position, not the incremented one. Otherwise
we lose the first character, and of course we blow up with an
out of range access when we hit the end of the string.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1292,8 +1292,9 @@ static val string_in_get_char(val stream) struct string_in *s = coerce(struct string_in *, stream->co.handle); if (length_str_gt(s->string, s->pos)) { - set(mkloc(s->pos, stream), plus(s->pos, one)); - return chr_str(s->string, s->pos); + val pos = s->pos; + set(mkloc(s->pos, stream), plus(pos, one)); + return chr_str(s->string, pos); } return nil; |