From 2eb45444a74df5f8d47ba14e318aff2e78a915db Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 4 Mar 1998 17:14:36 +0000 Subject: Update. 1998-03-04 16:12 H.J. Lu * libio/strops.c (_IO_str_seekoff): Handle MODE == 0. 1998-03-04 16:19 Ulrich Drepper * nscd/nscd_getgr_r.c: Follow nscd_getpw_r.c change. 1998-03-04 Andreas Jaeger * nscd/nscd_getpw_r.c (nscd_open_socket): Safe and reset errno so that a failure to connect to nscd doesn't change errno. 1998-03-04 Andreas Jaeger * manual/maint.texi (Reporting Bugs): Change bug-glibc@prep.ai.mit.edu to bug-glibc@gnu.org. * locale/iso-4217.def: Likewise 1998-03-04 12:43 Ulrich Drepper * manual/texinfo.tex: Updated. 1998-03-03 Andreas Schwab * sysdeps/posix/fpathconf.c: Don't modify errno for an undefined value. * sysdeps/posix/pathconf.c: Likewise. * posix/getconf.c: Print `undefined' if pathconf returns -1 without setting errno. 1998-03-04 Ulrich Drepper * sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c: Fix cut&paste problem. * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: New file. Patches by Elliot Lee . --- libio/strops.c | 84 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 35 deletions(-) (limited to 'libio/strops.c') diff --git a/libio/strops.c b/libio/strops.c index 01f8d6e..b079c9f 100644 --- a/libio/strops.c +++ b/libio/strops.c @@ -212,51 +212,65 @@ _IO_str_seekoff (fp, offset, dir, mode) int dir; int mode; { - _IO_ssize_t cur_size = _IO_str_count (fp); - _IO_fpos64_t new_pos = EOF; + _IO_fpos64_t new_pos; if (mode == 0 && (fp->_flags & _IO_TIED_PUT_GET)) mode = (fp->_flags & _IO_CURRENTLY_PUTTING ? _IOS_OUTPUT : _IOS_INPUT); - /* Move the get pointer, if requested. */ - if (mode & _IOS_INPUT) + if (mode == 0) { - switch (dir) + /* Don't move any pointers. But there is no clear indication what + mode FP is in. Let's guess. */ + if (fp->_IO_file_flags & _IO_NO_WRITES) + new_pos = fp->_IO_read_ptr - fp->_IO_read_base; + else + new_pos = fp->_IO_write_ptr - fp->_IO_write_base; + } + else + { + _IO_ssize_t cur_size = _IO_str_count(fp); + new_pos = EOF; + + /* Move the get pointer, if requested. */ + if (mode & _IOS_INPUT) { - case _IO_seek_end: - offset += cur_size; - break; - case _IO_seek_cur: - offset += fp->_IO_read_ptr - fp->_IO_read_base; - break; - default: /* case _IO_seek_set: */ - break; + switch (dir) + { + case _IO_seek_end: + offset += cur_size; + break; + case _IO_seek_cur: + offset += fp->_IO_read_ptr - fp->_IO_read_base; + break; + default: /* case _IO_seek_set: */ + break; + } + if (offset < 0 || (_IO_ssize_t) offset > cur_size) + return EOF; + fp->_IO_read_ptr = fp->_IO_read_base + offset; + fp->_IO_read_end = fp->_IO_read_base + cur_size; + new_pos = offset; } - if (offset < 0 || (_IO_ssize_t) offset > cur_size) - return EOF; - fp->_IO_read_ptr = fp->_IO_read_base + offset; - fp->_IO_read_end = fp->_IO_read_base + cur_size; - new_pos = offset; - } - /* Move the put pointer, if requested. */ - if (mode & _IOS_OUTPUT) - { - switch (dir) + /* Move the put pointer, if requested. */ + if (mode & _IOS_OUTPUT) { - case _IO_seek_end: - offset += cur_size; - break; - case _IO_seek_cur: - offset += fp->_IO_write_ptr - fp->_IO_write_base; - break; - default: /* case _IO_seek_set: */ - break; + switch (dir) + { + case _IO_seek_end: + offset += cur_size; + break; + case _IO_seek_cur: + offset += fp->_IO_write_ptr - fp->_IO_write_base; + break; + default: /* case _IO_seek_set: */ + break; + } + if (offset < 0 || (_IO_ssize_t) offset > cur_size) + return EOF; + fp->_IO_write_ptr = fp->_IO_write_base + offset; + new_pos = offset; } - if (offset < 0 || (_IO_ssize_t) offset > cur_size) - return EOF; - fp->_IO_write_ptr = fp->_IO_write_base + offset; - new_pos = offset; } return new_pos; } -- cgit v1.1