summaryrefslogtreecommitdiff
path: root/libio/strops.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-04 17:14:36 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-04 17:14:36 +0000
commit2eb45444a74df5f8d47ba14e318aff2e78a915db (patch)
tree25bd570a73d217b7ed478e43398b341372e87dcd /libio/strops.c
parentea7eb7e3eb09a7f9444e0c599fdbafaadb3e391d (diff)
downloadglibc-2eb45444a74df5f8d47ba14e318aff2e78a915db.tar.gz
Update.
1998-03-04 16:12 H.J. Lu <hjl@gnu.org> * libio/strops.c (_IO_str_seekoff): Handle MODE == 0. 1998-03-04 16:19 Ulrich Drepper <drepper@cygnus.com> * nscd/nscd_getgr_r.c: Follow nscd_getpw_r.c change. 1998-03-04 Andreas Jaeger <aj@arthur.rhein-neckar.de> * 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 <aj@arthur.rhein-neckar.de> * 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 <drepper@cygnus.com> * manual/texinfo.tex: Updated. 1998-03-03 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * 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 <drepper@cygnus.com> * 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 <sopwith@cuc.edu>.
Diffstat (limited to 'libio/strops.c')
-rw-r--r--libio/strops.c84
1 files changed, 49 insertions, 35 deletions
diff --git a/libio/strops.c b/libio/strops.c
index 01f8d6eeb7..b079c9fc29 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;
}