mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-05 03:50:41 -08:00
Patch to improve CLHS compliance of file-position
CLHS mandates that failure to determine or set the file position on a stream should be signalled by returning NIL rather than raising an error. Also, POSIX does not mandate that lseek fail on terminals, but these devices obviously are not seekable. Hence, CLHS compliance is improved by explicitly returning NIL when the requested stream is a tty.
This commit is contained in:
parent
e8dd76ffee
commit
8a2d0c96e8
1 changed files with 7 additions and 1 deletions
|
|
@ -2774,6 +2774,8 @@ static cl_object
|
|||
io_file_get_position(cl_object strm)
|
||||
{
|
||||
int f = IO_FILE_DESCRIPTOR(strm);
|
||||
if (isatty(f)) return(ECL_NIL);
|
||||
|
||||
cl_object output;
|
||||
ecl_off_t offset;
|
||||
|
||||
|
|
@ -2781,7 +2783,10 @@ io_file_get_position(cl_object strm)
|
|||
offset = lseek(f, 0, SEEK_CUR);
|
||||
ecl_enable_interrupts();
|
||||
unlikely_if (offset < 0)
|
||||
io_error(strm);
|
||||
if (errno == ESPIPE)
|
||||
return(ECL_NIL);
|
||||
else
|
||||
io_error(strm);
|
||||
if (sizeof(ecl_off_t) == sizeof(long)) {
|
||||
output = ecl_make_integer(offset);
|
||||
} else {
|
||||
|
|
@ -2806,6 +2811,7 @@ static cl_object
|
|||
io_file_set_position(cl_object strm, cl_object large_disp)
|
||||
{
|
||||
int f = IO_FILE_DESCRIPTOR(strm);
|
||||
if (isatty(f)) return(ECL_NIL);
|
||||
ecl_off_t disp;
|
||||
int mode;
|
||||
if (Null(large_disp)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue