Deleted Added
sdiff udiff text old ( 72529 ) new ( 81666 )
full compact
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 25 unchanged lines hidden (view full) ---

34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38#if 0
39static char sccsid[] = "@(#)fseek.c 8.3 (Berkeley) 1/2/94";
40#endif
41static const char rcsid[] =
42 "$FreeBSD: head/lib/libc/stdio/fseek.c 72529 2001-02-16 06:11:22Z imp $";
43#endif /* LIBC_SCCS and not lint */
44
45#include "namespace.h"
46#include <sys/types.h>
47#include <sys/stat.h>
48#include <fcntl.h>
49#include <stdio.h>
50#include <stdlib.h>

--- 76 unchanged lines hidden (view full) ---

127 }
128 if (fp->_flags & __SRD) {
129 curoff -= fp->_r;
130 if (HASUB(fp))
131 curoff -= fp->_ur;
132 } else if (fp->_flags & __SWR && fp->_p != NULL)
133 curoff += fp->_p - fp->_bf._base;
134
135 offset += curoff;
136 whence = SEEK_SET;
137 havepos = 1;
138 break;
139
140 case SEEK_SET:
141 case SEEK_END:
142 curoff = 0; /* XXX just to keep gcc quiet */
143 havepos = 0;
144 break;
145
146 default:
147 errno = EINVAL;
148 return (EOF);

--- 26 unchanged lines hidden (view full) ---

175 * We are reading; we can try to optimise.
176 * Figure out where we are going and where we are now.
177 */
178 if (whence == SEEK_SET)
179 target = offset;
180 else {
181 if (_fstat(fp->_file, &st))
182 goto dumb;
183 target = st.st_size + offset;
184 }
185
186 if (!havepos) {
187 if (fp->_flags & __SOFF)
188 curoff = fp->_offset;
189 else {
190 curoff = (*seekfn)(fp->_cookie, (fpos_t)0, SEEK_CUR);
191 if (curoff == POS_ERR)

--- 84 unchanged lines hidden ---