From 8b4ac209082fc37f1d712228208689c21eb4b42d Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 2 Dec 2000 21:08:01 +0000 Subject: (skip): Use lseek instead of worrying about fseeko or fseek. This should be portable, as we seek before doing any I/O. (fseeko): Remove; no longer used. --- src/od.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/od.c b/src/od.c index 381ba6e6f..2b8ba2f42 100644 --- a/src/od.c +++ b/src/od.c @@ -65,11 +65,6 @@ 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, @@ -986,15 +981,15 @@ skip (off_t n_skip) if (n_skip == 0) break; - /* First try using fseek. For large offsets, this extra work is + /* First try seeking. For large offsets, this extra work is worthwhile. If the offset is below some threshold it may be more efficient to move the pointer by reading. There are two - issues when trying to use fseek: + issues when trying to seek: - the file must be seekable. - before seeking to the specified position, make sure that the new position is in the current file. - Try to do that by getting file's size using fstat(). - But that will work only for regular files and dirs. */ + Try to do that by getting file's size using fstat. + But that will work only for regular files. */ if (fstat (fileno (in_stream), &file_stats)) { @@ -1022,10 +1017,7 @@ skip (off_t n_skip) } else { - /* 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)) + if (0 <= lseek (fileno (in_stream), n_skip, SEEK_CUR)) { n_skip = 0; break; -- cgit v1.2.3-54-g00ecf