[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lseek on BeOS (1)
From: |
Bruno Haible |
Subject: |
lseek on BeOS (1) |
Date: |
Sun, 19 Aug 2007 00:59:16 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Eric,
The lseek configure-time test fails not only on mingw, but also on BeOS.
Here is a proposed fix.
2007-08-18 Bruno Haible <address@hidden>
* lib/lseek.c: Include <sys/stat.h>.
(rpl_lseek): Add workaround code also for Unix platforms.
Needed for BeOS.
* doc/functions/lseek.texi: Document BeOS definiency.
*** lib/lseek.c 28 May 2007 12:43:30 -0000 1.2
--- lib/lseek.c 18 Aug 2007 22:56:22 -0000
***************
*** 20,28 ****
/* Specification. */
#include <unistd.h>
! /* Get GetFileType. The replacement lseek is only used on mingw, so
! this include can be unconditional. */
! #include <windows.h>
#include <errno.h>
#undef lseek
--- 20,32 ----
/* Specification. */
#include <unistd.h>
! #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
! /* Windows platforms. */
! /* Get GetFileType. */
! # include <windows.h>
! #else
! # include <sys/stat.h>
! #endif
#include <errno.h>
#undef lseek
***************
*** 30,35 ****
--- 34,40 ----
off_t
rpl_lseek (int fd, off_t offset, int whence)
{
+ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
HANDLE h = (HANDLE) _get_osfhandle (fd);
if (h == INVALID_HANDLE_VALUE)
***************
*** 42,46 ****
--- 47,62 ----
errno = ESPIPE;
return -1;
}
+ #else
+ /* BeOS lseek mistakenly succeeds on pipes... */
+ struct stat statbuf;
+ if (fstat (fd, &statbuf) < 0)
+ return -1;
+ if (!S_ISREG (statbuf.st_mode))
+ {
+ errno = ESPIPE;
+ return -1;
+ }
+ #endif
return lseek (fd, offset, whence);
}
*** doc/functions/lseek.texi 2 Jun 2007 00:42:13 -0000 1.4
--- doc/functions/lseek.texi 18 Aug 2007 22:56:22 -0000
***************
*** 9,15 ****
Portability problems fixed by Gnulib:
@itemize
@item
! This function mistakenly succeeds on pipes on some platforms: mingw.
@end itemize
Portability problems not fixed by Gnulib:
--- 9,15 ----
Portability problems fixed by Gnulib:
@itemize
@item
! This function mistakenly succeeds on pipes on some platforms: mingw, BeOS.
@end itemize
Portability problems not fixed by Gnulib:
- lseek on BeOS (1),
Bruno Haible <=