Issue #252 - Fix off-by-one error

When decrementing the length to account for newlines, also decrement the code point count.
This commit is contained in:
Justin Ethier 2018-04-02 13:47:01 -04:00
parent b7e465af17
commit 9090952300
2 changed files with 2 additions and 0 deletions

View file

@ -4,6 +4,7 @@
Bug Fixes
- Fixed an off-by-one error in `read-line` where the function erroneously reported an extra character was read from `stdin`. Thanks to wasamasa for the bug report.
- Fixed a CPS optimization issue where multiple copies of the same lambda are introduced during beta expansion, which causes the optimizer to potentially pick up the wrong value when optimizing-out function calls later on. Thanks to @Chant on Github for providing the report and a test program demonstrating the issue.
## 0.7.2 - February 15, 2018

View file

@ -6629,6 +6629,7 @@ object Cyc_io_read_line(void *data, object cont, object port)
while (len > 0 && (buf[len - 1] == '\n' ||
buf[len - 1] == '\r')) {
len--;
num_cp--;
}
buf[len] = '\0';
make_string_noalloc(s, buf, len);