fseek.c (333fc21e3cd79bca0c94d7722c5a56cb5ad078d1) fseek.c (87275e436a0fb31fea2757532860a3ec993d2cd6)
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

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

254 if (target >= curoff && target < curoff + n) {
255 size_t o = target - curoff;
256
257 fp->_p = fp->_bf._base + o;
258 fp->_r = n - o;
259 if (HASUB(fp))
260 FREEUB(fp);
261 fp->_flags &= ~__SEOF;
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

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

254 if (target >= curoff && target < curoff + n) {
255 size_t o = target - curoff;
256
257 fp->_p = fp->_bf._base + o;
258 fp->_r = n - o;
259 if (HASUB(fp))
260 FREEUB(fp);
261 fp->_flags &= ~__SEOF;
262 memset(&fp->_extra->mbstate, 0, sizeof(mbstate_t));
262 return (0);
263 }
264
265abspos:
266 /*
267 * The place we want to get to is not within the current buffer,
268 * but we can still be kind to the kernel copyout mechanism.
269 * By aligning the file offset to a block boundary, we can let

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

298 return (-1);
299 /* success: clear EOF indicator and discard ungetc() data */
300 if (HASUB(fp))
301 FREEUB(fp);
302 fp->_p = fp->_bf._base;
303 fp->_r = 0;
304 /* fp->_w = 0; */ /* unnecessary (I think...) */
305 fp->_flags &= ~__SEOF;
263 return (0);
264 }
265
266abspos:
267 /*
268 * The place we want to get to is not within the current buffer,
269 * but we can still be kind to the kernel copyout mechanism.
270 * By aligning the file offset to a block boundary, we can let

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

299 return (-1);
300 /* success: clear EOF indicator and discard ungetc() data */
301 if (HASUB(fp))
302 FREEUB(fp);
303 fp->_p = fp->_bf._base;
304 fp->_r = 0;
305 /* fp->_w = 0; */ /* unnecessary (I think...) */
306 fp->_flags &= ~__SEOF;
307 memset(&fp->_extra->mbstate, 0, sizeof(mbstate_t));
306 if (ltest && ret > LONG_MAX) {
307 fp->_flags |= __SERR;
308 errno = EOVERFLOW;
309 return (-1);
310 }
311 return (0);
312}
308 if (ltest && ret > LONG_MAX) {
309 fp->_flags |= __SERR;
310 errno = EOVERFLOW;
311 return (-1);
312 }
313 return (0);
314}