mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-23 04:52:42 -08:00
printer: fix printing of string input streams
Currently ECL crashes because we did not set the array element
type for the stack allocated tag. Use the string pool instead.
This should be plenty fast enough, since the performance of
printing of string input streams is not important anyway.
This commit is contained in:
parent
4e02997d79
commit
4d3df3766b
1 changed files with 10 additions and 21 deletions
|
|
@ -178,12 +178,7 @@ write_stream(cl_object x, cl_object stream)
|
|||
{
|
||||
const char *prefix;
|
||||
cl_object tag;
|
||||
union cl_lispunion str;
|
||||
#ifdef ECL_UNICODE
|
||||
ecl_character buffer[10];
|
||||
#else
|
||||
ecl_base_char buffer[10];
|
||||
#endif
|
||||
cl_object buffer = OBJNULL;
|
||||
switch ((enum ecl_smmode)x->stream.mode) {
|
||||
case ecl_smm_input_file:
|
||||
prefix = "closed input file";
|
||||
|
|
@ -252,28 +247,20 @@ write_stream(cl_object x, cl_object stream)
|
|||
tag = ECL_NIL;
|
||||
break;
|
||||
case ecl_smm_string_input: {
|
||||
buffer = si_get_buffer_string();
|
||||
cl_object text = x->stream.object0;
|
||||
cl_index ndx, l = ecl_length(text);
|
||||
for (ndx = 0; (ndx < 8) && (ndx < l); ndx++) {
|
||||
buffer[ndx] = ecl_char(text, ndx);
|
||||
ecl_char_set(buffer, ndx, ecl_char(text, ndx));
|
||||
}
|
||||
if (l > ndx) {
|
||||
buffer[ndx-1] = '.';
|
||||
buffer[ndx-2] = '.';
|
||||
buffer[ndx-3] = '.';
|
||||
ecl_char_set(buffer, ndx-1, '.');
|
||||
ecl_char_set(buffer, ndx-2, '.');
|
||||
ecl_char_set(buffer, ndx-3, '.');
|
||||
}
|
||||
buffer[ndx++] = 0;
|
||||
si_fill_pointer_set(buffer, ecl_make_fixnum(ndx));
|
||||
prefix = "closed string-input stream from";
|
||||
tag = &str;
|
||||
#ifdef ECL_UNICODE
|
||||
tag->string.t = t_string;
|
||||
tag->string.self = buffer;
|
||||
#else
|
||||
tag->base_string.t = t_base_string;
|
||||
tag->base_string.self = buffer;
|
||||
#endif
|
||||
tag->base_string.dim = ndx;
|
||||
tag->base_string.fillp = ndx-1;
|
||||
tag = buffer;
|
||||
break;
|
||||
}
|
||||
case ecl_smm_string_output:
|
||||
|
|
@ -294,6 +281,8 @@ write_stream(cl_object x, cl_object stream)
|
|||
if (!x->stream.closed)
|
||||
prefix = prefix + 7;
|
||||
_ecl_write_unreadable(x, prefix, tag, stream);
|
||||
if (buffer != OBJNULL)
|
||||
si_put_buffer_string(buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue