mirror of
https://github.com/janet-lang/janet
synced 2024-12-29 09:50:27 +00:00
Fix bug when appending buffer to self.
janet_to_string_b had a bug when printing buffers.
This commit is contained in:
parent
5681e02e0f
commit
6b76ac3d18
@ -1,6 +1,9 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
### Unreleased
|
||||
- Fix bug when printing buffer to self in some cases.
|
||||
|
||||
## 1.5.0 - 2019-11-10
|
||||
- `os/date` now defaults to UTC.
|
||||
- Add `--test` flag to jpm to test libraries on installation.
|
||||
|
@ -253,11 +253,13 @@ void janet_to_string_b(JanetBuffer *buffer, Janet x) {
|
||||
default:
|
||||
janet_description_b(buffer, x);
|
||||
break;
|
||||
case JANET_BUFFER:
|
||||
janet_buffer_push_bytes(buffer,
|
||||
janet_unwrap_buffer(x)->data,
|
||||
janet_unwrap_buffer(x)->count);
|
||||
case JANET_BUFFER: {
|
||||
JanetBuffer *to = janet_unwrap_buffer(x);
|
||||
/* Prevent resizing buffer while appending */
|
||||
if (buffer == to) janet_buffer_extra(buffer, to->count);
|
||||
janet_buffer_push_bytes(buffer, to->data, to->count);
|
||||
break;
|
||||
}
|
||||
case JANET_STRING:
|
||||
case JANET_SYMBOL:
|
||||
case JANET_KEYWORD:
|
||||
|
@ -221,4 +221,11 @@
|
||||
:week-day 3}
|
||||
(os/date 1388608200)) "os/date")
|
||||
|
||||
# Appending buffer to self
|
||||
|
||||
(with-dyns [:out @""]
|
||||
(prin "abcd")
|
||||
(prin (dyn :out))
|
||||
(assert (deep= (dyn :out) @"abcdabcd") "print buffer to self"))
|
||||
|
||||
(end-suite)
|
||||
|
Loading…
Reference in New Issue
Block a user