sync with OpenBSD -current

This commit is contained in:
purplerain 2024-08-30 18:07:36 +00:00
parent c0feaae94d
commit 7aba15d530
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
44 changed files with 470 additions and 445 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: fseek.c,v 1.15 2024/08/12 20:53:09 guenther Exp $ */
/* $OpenBSD: fseek.c,v 1.16 2024/08/30 03:44:48 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@ -116,8 +116,7 @@ fseeko(FILE *fp, off_t offset, int whence)
/*
* Can only optimise if:
* reading (and not reading-and-writing);
* not unbuffered;
* not immediately after an fflush(); and
* not unbuffered; and
* this is a `regular' Unix file (and hence seekfn==__sseek).
* We must check __NBF first, because it is possible to have __NBF
* and __SOPT both set.
@ -126,8 +125,6 @@ fseeko(FILE *fp, off_t offset, int whence)
__smakebuf(fp);
if (fp->_flags & (__SWR | __SRW | __SNBF | __SNPT))
goto dumb;
if (fp->_r == 0 && (fp->_p == NULL || fp->_p == fp->_bf._base))
goto dumb;
if ((fp->_flags & __SOPT) == 0) {
if (seekfn != __sseek ||
fp->_file < 0 || fstat(fp->_file, &st) == -1 ||
@ -231,7 +228,7 @@ fseeko(FILE *fp, off_t offset, int whence)
* do it. Allow the seek function to change fp->_bf._base.
*/
dumb:
if (((fp->_flags & __SWR) && __sflush(fp)) ||
if (__sflush(fp) ||
(*seekfn)(fp->_cookie, (fpos_t)offset, whence) == POS_ERR) {
FUNLOCKFILE(fp);
return (EOF);