mirror of
https://github.com/janet-lang/janet
synced 2024-06-16 02:09:56 +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
|
# Changelog
|
||||||
All notable changes to this project will be documented in this file.
|
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
|
## 1.5.0 - 2019-11-10
|
||||||
- `os/date` now defaults to UTC.
|
- `os/date` now defaults to UTC.
|
||||||
- Add `--test` flag to jpm to test libraries on installation.
|
- Add `--test` flag to jpm to test libraries on installation.
|
||||||
|
|
|
@ -253,11 +253,13 @@ void janet_to_string_b(JanetBuffer *buffer, Janet x) {
|
||||||
default:
|
default:
|
||||||
janet_description_b(buffer, x);
|
janet_description_b(buffer, x);
|
||||||
break;
|
break;
|
||||||
case JANET_BUFFER:
|
case JANET_BUFFER: {
|
||||||
janet_buffer_push_bytes(buffer,
|
JanetBuffer *to = janet_unwrap_buffer(x);
|
||||||
janet_unwrap_buffer(x)->data,
|
/* Prevent resizing buffer while appending */
|
||||||
janet_unwrap_buffer(x)->count);
|
if (buffer == to) janet_buffer_extra(buffer, to->count);
|
||||||
|
janet_buffer_push_bytes(buffer, to->data, to->count);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case JANET_STRING:
|
case JANET_STRING:
|
||||||
case JANET_SYMBOL:
|
case JANET_SYMBOL:
|
||||||
case JANET_KEYWORD:
|
case JANET_KEYWORD:
|
||||||
|
|
|
@ -221,4 +221,11 @@
|
||||||
:week-day 3}
|
:week-day 3}
|
||||||
(os/date 1388608200)) "os/date")
|
(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)
|
(end-suite)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user