summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-11-08 21:02:01 +0000
committerJim Meyering <jim@meyering.net>1997-11-08 21:02:01 +0000
commit979f238fb3fbf27417277b2a9d9014b3778e9e2f (patch)
tree27435668d82c8591859e245a30853d55649bfe0e /src
parent6af4f825de96e3aa0aa2beb2d50d9ec41b543681 (diff)
downloadcoreutils-979f238fb3fbf27417277b2a9d9014b3778e9e2f.tar.xz
(fseeko): Define a stub if ! HAVE_FSEEKO.
(skip): Use fseeko if available. Don't use lseek; it causes the stdio stream to become out of sync with respect to the underyling file descriptor. From Paul Eggert.
Diffstat (limited to 'src')
-rw-r--r--src/od.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/od.c b/src/od.c
index 9170107fb..72e33ca4d 100644
--- a/src/od.c
+++ b/src/od.c
@@ -109,6 +109,11 @@ typedef double LONG_DOUBLE;
# define LDBL_DIG DBL_DIG
#endif
+#if !HAVE_FSEEKO
+# undef fseeko
+# define fseeko(Stream, Offset, Whence) (-1)
+#endif
+
enum size_spec
{
NO_SIZE,
@@ -1039,13 +1044,10 @@ skip (off_t n_skip)
}
else
{
- /* fseek may work on some streams for which lseek doesn't.
- But fseek's offset argument is restricted to the range
- of type `long'. So if N_SKIP is too large or if fseek
- fails, try lseek. */
- if ((n_skip <= LONG_MAX
- && fseek (in_stream, (long) n_skip, SEEK_SET) == 0)
- || lseek (fileno (in_stream), n_skip, SEEK_SET) >= 0)
+ /* Try fseeko if available, fseek otherwise. */
+ if (fseeko (in_stream, n_skip, SEEK_SET) == 0
+ || (n_skip <= LONG_MAX
+ && fseek (in_stream, (long) n_skip, SEEK_SET) == 0))
{
n_skip = 0;
break;