mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-15 01:10:53 -07:00
Implemented a function to change the encoding of a file stream
This commit is contained in:
parent
e581546e1c
commit
5af9a2e99b
4 changed files with 40 additions and 0 deletions
35
src/c/file.d
35
src/c/file.d
|
|
@ -3103,6 +3103,41 @@ set_stream_elt_type(cl_object stream, cl_fixnum byte_size, int flags,
|
|||
stream->stream.byte_size = byte_size;
|
||||
}
|
||||
|
||||
cl_object
|
||||
si_stream_external_format_set(cl_object stream, cl_object format)
|
||||
{
|
||||
#ifdef ECL_CLOS_STREAMS
|
||||
if (ECL_INSTANCEP(stream)) {
|
||||
FEerror("Cannot change external format of stream ~A", 1, stream);
|
||||
}
|
||||
#endif
|
||||
switch (stream->stream.mode) {
|
||||
case smm_input:
|
||||
case smm_input_file:
|
||||
case smm_output:
|
||||
case smm_output_file:
|
||||
case smm_io:
|
||||
case smm_io_file:
|
||||
#ifdef ECL_WSOCK
|
||||
case smm_input_wsock:
|
||||
case smm_output_wsock:
|
||||
case smm_io_wsock:
|
||||
#endif
|
||||
{
|
||||
cl_object elt_type = ecl_stream_element_type(stream);
|
||||
if (elt_type != @'character' && elt_type != @'base-char')
|
||||
FEerror("Cannot change external format"
|
||||
"of binary stream ~A", 1, stream);
|
||||
set_stream_elt_type(stream, stream->stream.byte_size,
|
||||
stream->stream.flags, format);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FEerror("Cannot change external format of stream ~A", 1, stream);
|
||||
}
|
||||
@(return)
|
||||
}
|
||||
|
||||
cl_object
|
||||
ecl_make_file_stream_from_fd(cl_object fname, int fd, enum ecl_smmode smm,
|
||||
cl_fixnum byte_size, int flags, cl_object external_format)
|
||||
|
|
|
|||
|
|
@ -1794,5 +1794,7 @@ cl_symbols[] = {
|
|||
{SYS_ "+ECL-SYNTAX-PROGV-LIST+", SI_ORDINARY, NULL, -1, OBJNULL},
|
||||
{SYS_ "WITH-ECL-IO-SYNTAX", SI_ORDINARY, NULL, -1, OBJNULL},
|
||||
|
||||
{SYS_ "STREAM-EXTERNAL-FORMAT-SET", CL_ORDINARY, si_stream_external_format_set, 2, OBJNULL},
|
||||
|
||||
/* Tag for end of list */
|
||||
{NULL, CL_ORDINARY, NULL, -1, OBJNULL}};
|
||||
|
|
|
|||
|
|
@ -1794,5 +1794,7 @@ cl_symbols[] = {
|
|||
{SYS_ "+ECL-SYNTAX-PROGV-LIST+",NULL},
|
||||
{SYS_ "WITH-ECL-IO-SYNTAX",NULL},
|
||||
|
||||
{SYS_ "STREAM-EXTERNAL-FORMAT-SET","si_stream_external_format_set"},
|
||||
|
||||
/* Tag for end of list */
|
||||
{NULL,NULL}};
|
||||
|
|
|
|||
|
|
@ -625,6 +625,7 @@ extern ECL_API cl_object si_do_read_sequence(cl_object string, cl_object stream,
|
|||
extern ECL_API cl_object si_file_column(cl_object strm);
|
||||
extern ECL_API cl_object cl_interactive_stream_p(cl_object strm);
|
||||
extern ECL_API cl_object si_set_buffering_mode(cl_object strm, cl_object mode);
|
||||
extern ECL_API cl_object si_stream_external_format_set(cl_object strm, cl_object format);
|
||||
|
||||
extern ECL_API bool ecl_input_stream_p(cl_object strm);
|
||||
extern ECL_API bool ecl_output_stream_p(cl_object strm);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue