Mercurial > hg > xemacs-beta
diff src/lstream.c @ 5795:d2c0ff38ad5c
Report lstream errors when encoding/decoding.
See <CAHCOHQ=FAieD-2nP303fMvwkii8HK2z+X7gRZ2+4PH1CA5_-NA@mail.gmail.com> in
xemacs-patches.
author | Jerry James <james@xemacs.org> |
---|---|
date | Wed, 14 May 2014 14:16:24 -0600 |
parents | 7343a186a475 |
children | a216b3c2b09e |
line wrap: on
line diff
--- a/src/lstream.c Wed May 07 13:33:50 2014 -0600 +++ b/src/lstream.c Wed May 14 14:16:24 2014 -0600 @@ -742,6 +742,12 @@ return Lstream_read_1 (lstr, data, size, 0); } +int +Lstream_errno (Lstream *lstr) +{ + return (lstr->imp->error) ? (lstr->imp->error) (lstr) : 0; +} + Charcount Lstream_character_tell (Lstream *lstr) { @@ -1118,6 +1124,7 @@ int current_pos; int end_pos; int chars_sans_newline; + int saved_errno; unsigned int closing :1; unsigned int allow_quit :1; unsigned int blocked_ok :1; @@ -1146,6 +1153,7 @@ fstr->pty_flushing = !!(flags & LSTR_PTY_FLUSHING); fstr->blocking_error_p = 0; fstr->chars_sans_newline = 0; + fstr->saved_errno = 0; fstr->starting_pos = lseek (filedesc, offset, SEEK_CUR); fstr->current_pos = max (fstr->starting_pos, 0); if (count < 0) @@ -1192,6 +1200,7 @@ { Bytecount nread; struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream); + str->saved_errno = 0; if (str->end_pos >= 0) size = min (size, (Bytecount) (str->end_pos - str->current_pos)); nread = str->allow_quit ? @@ -1202,7 +1211,10 @@ if (nread == 0) return 0; /* LSTREAM_EOF; */ if (nread < 0) - return LSTREAM_ERROR; + { + str->saved_errno = errno; + return LSTREAM_ERROR; + } return nread; } @@ -1228,6 +1240,8 @@ Bytecount retval; int need_newline = 0; + str->saved_errno = 0; + /* This function would be simple if it were not for the blasted PTY max-bytes stuff. Why the hell can't they just have written the PTY drivers right so this problem doesn't exist? @@ -1266,7 +1280,10 @@ } str->blocking_error_p = 0; if (retval < 0) - return LSTREAM_ERROR; + { + str->saved_errno = errno; + return LSTREAM_ERROR; + } /**** end non-PTY-crap ****/ if (str->pty_flushing) @@ -1298,7 +1315,10 @@ return 0; } else - return LSTREAM_ERROR; + { + str->saved_errno = errno; + return LSTREAM_ERROR; + } } else return retval; @@ -1334,7 +1354,10 @@ return 0; } else - return LSTREAM_ERROR; + { + str->saved_errno = errno; + return LSTREAM_ERROR; + } } else return retval; @@ -1345,6 +1368,13 @@ } static int +filedesc_error (Lstream *stream) +{ + struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream); + return str->saved_errno; +} + +static int filedesc_rewinder (Lstream *stream) { struct filedesc_stream *str = FILEDESC_STREAM_DATA (stream); @@ -1926,6 +1956,7 @@ LSTREAM_HAS_METHOD (filedesc, reader); LSTREAM_HAS_METHOD (filedesc, writer); + LSTREAM_HAS_METHOD (filedesc, error); LSTREAM_HAS_METHOD (filedesc, was_blocked_p); LSTREAM_HAS_METHOD (filedesc, rewinder); LSTREAM_HAS_METHOD (filedesc, seekable_p);