mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2025-12-06 02:40:26 -08:00
stream: unread_error and unread_twice are now not continuable
At least in two from four cases continuing from the error lead to an error: - for concatenated stream we've tried to dispatch on CAR that was NIL (segfault) - for string stream we've decremented the position below 0 Also change these functions to defined macros ecl_unread_* that expand to FEerror (in internal.h). This is in anticipation of splitting file.d.
This commit is contained in:
parent
b8e8899280
commit
a5c922b849
2 changed files with 9 additions and 19 deletions
25
src/c/file.d
25
src/c/file.d
|
|
@ -83,8 +83,6 @@ static void not_an_output_stream(cl_object fn) ecl_attr_noreturn;
|
||||||
static void not_a_character_stream(cl_object s) ecl_attr_noreturn;
|
static void not_a_character_stream(cl_object s) ecl_attr_noreturn;
|
||||||
static void not_a_binary_stream(cl_object s) ecl_attr_noreturn;
|
static void not_a_binary_stream(cl_object s) ecl_attr_noreturn;
|
||||||
static int restartable_io_error(cl_object strm, const char *s);
|
static int restartable_io_error(cl_object strm, const char *s);
|
||||||
static void unread_error(cl_object strm);
|
|
||||||
static void unread_twice(cl_object strm);
|
|
||||||
static void io_error(cl_object strm) ecl_attr_noreturn;
|
static void io_error(cl_object strm) ecl_attr_noreturn;
|
||||||
#ifdef ECL_UNICODE
|
#ifdef ECL_UNICODE
|
||||||
static cl_index encoding_error(cl_object strm, unsigned char *buffer, ecl_character c);
|
static cl_index encoding_error(cl_object strm, unsigned char *buffer, ecl_character c);
|
||||||
|
|
@ -567,7 +565,7 @@ static void
|
||||||
eformat_unread_char(cl_object strm, ecl_character c)
|
eformat_unread_char(cl_object strm, ecl_character c)
|
||||||
{
|
{
|
||||||
unlikely_if (c != strm->stream.last_char) {
|
unlikely_if (c != strm->stream.last_char) {
|
||||||
unread_twice(strm);
|
ecl_unread_twice(strm);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
unsigned char buffer[2*ENCODING_BUFFER_MAX_SIZE];
|
unsigned char buffer[2*ENCODING_BUFFER_MAX_SIZE];
|
||||||
|
|
@ -1665,7 +1663,7 @@ str_in_unread_char(cl_object strm, ecl_character c)
|
||||||
{
|
{
|
||||||
cl_fixnum curr_pos = STRING_INPUT_POSITION(strm);
|
cl_fixnum curr_pos = STRING_INPUT_POSITION(strm);
|
||||||
unlikely_if (c <= 0) {
|
unlikely_if (c <= 0) {
|
||||||
unread_error(strm);
|
ecl_unread_error(strm);
|
||||||
}
|
}
|
||||||
STRING_INPUT_POSITION(strm) = curr_pos - 1;
|
STRING_INPUT_POSITION(strm) = curr_pos - 1;
|
||||||
}
|
}
|
||||||
|
|
@ -2242,7 +2240,7 @@ static void
|
||||||
echo_unread_char(cl_object strm, ecl_character c)
|
echo_unread_char(cl_object strm, ecl_character c)
|
||||||
{
|
{
|
||||||
unlikely_if (strm->stream.last_code[0] != EOF) {
|
unlikely_if (strm->stream.last_code[0] != EOF) {
|
||||||
unread_twice(strm);
|
ecl_unread_twice(strm);
|
||||||
}
|
}
|
||||||
strm->stream.last_code[0] = c;
|
strm->stream.last_code[0] = c;
|
||||||
ecl_unread_char(c, ECHO_STREAM_INPUT(strm));
|
ecl_unread_char(c, ECHO_STREAM_INPUT(strm));
|
||||||
|
|
@ -2431,8 +2429,9 @@ static void
|
||||||
concatenated_unread_char(cl_object strm, ecl_character c)
|
concatenated_unread_char(cl_object strm, ecl_character c)
|
||||||
{
|
{
|
||||||
cl_object l = CONCATENATED_STREAM_LIST(strm);
|
cl_object l = CONCATENATED_STREAM_LIST(strm);
|
||||||
unlikely_if (Null(l))
|
unlikely_if (Null(l)) {
|
||||||
unread_error(strm);
|
ecl_unread_error(strm);
|
||||||
|
}
|
||||||
ecl_unread_char(c, ECL_CONS_CAR(l));
|
ecl_unread_char(c, ECL_CONS_CAR(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6157,18 +6156,6 @@ file_libc_error(cl_object error_type, cl_object stream,
|
||||||
_ecl_unexpected_return();
|
_ecl_unexpected_return();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
unread_error(cl_object s)
|
|
||||||
{
|
|
||||||
CEerror(ECL_T, "Error when using UNREAD-CHAR on stream ~D", 1, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
unread_twice(cl_object s)
|
|
||||||
{
|
|
||||||
CEerror(ECL_T, "Used UNREAD-CHAR twice on stream ~D", 1, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
maybe_clearerr(cl_object strm)
|
maybe_clearerr(cl_object strm)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -390,6 +390,9 @@ extern enum ecl_ffi_tag ecl_foreign_type_code(cl_object type);
|
||||||
|
|
||||||
/* file.d */
|
/* file.d */
|
||||||
|
|
||||||
|
#define ecl_unread_error(s) FEerror("Error when using UNREAD-CHAR on stream ~D", 1, s)
|
||||||
|
#define ecl_unread_twice(s) FEerror("Used UNREAD-CHAR twice on stream ~D", 1, s);
|
||||||
|
|
||||||
/* Windows does not have this flag (POSIX thing) */
|
/* Windows does not have this flag (POSIX thing) */
|
||||||
#ifndef __COSMOPOLITAN__
|
#ifndef __COSMOPOLITAN__
|
||||||
# ifndef O_CLOEXEC
|
# ifndef O_CLOEXEC
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue