comparison lib/fseeko.c @ 8717:3afefd650c3a

On BSD implementations, when we call lseek(), we must also update or disable the stream's file descriptor position cache.
author Bruno Haible <bruno@clisp.org>
date Thu, 26 Apr 2007 09:25:05 +0000
parents aad7ea346fbf
children 95c5da6920cb
comparison
equal deleted inserted replaced
8716:43a9fb438a48 8717:3afefd650c3a
64 && (fp->_ptr == NULL || fp->_cnt == 0)) 64 && (fp->_ptr == NULL || fp->_cnt == 0))
65 # endif 65 # endif
66 #else 66 #else
67 #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib." 67 #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib."
68 #endif 68 #endif
69 return (lseek (fileno (fp), offset, whence) == (off_t)(-1) ? -1 : 0); 69 {
70 off_t pos = lseek (fileno (fp), offset, whence);
71 if (pos == -1)
72 {
73 #if defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
74 fp->_flags &= ~__SOFF;
75 #endif
76 return -1;
77 }
78 else
79 {
80 #if defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
81 fp->_offset = pos;
82 fp->_flags |= __SOFF;
83 #endif
84 return 0;
85 }
86 }
70 else 87 else
71 return fseeko (fp, offset, whence); 88 return fseeko (fp, offset, whence);
72 } 89 }