summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-12-02 21:08:01 +0000
committerJim Meyering <jim@meyering.net>2000-12-02 21:08:01 +0000
commit8b4ac209082fc37f1d712228208689c21eb4b42d (patch)
treee7be2f590fea8ddfec4f96fd7193b5d60398de12 /src
parent1a0d9ea086566b43e856fdfd59af0b6916c511ce (diff)
downloadcoreutils-8b4ac209082fc37f1d712228208689c21eb4b42d.tar.xz
(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.
Diffstat (limited to 'src')
-rw-r--r--src/od.c18
1 files changed, 5 insertions, 13 deletions
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;