- struct stat stats;
-
- /* FIXME: resolve this like in dd.c. */
- /* Use fstat instead of checking for errno == ESPIPE because
- lseek doesn't work on some special files but doesn't return an
- error, either. */
- if (fstat (fd, &stats))
- {
- detailed_error (0, errno, "%s", filename);
- return 1;
- }
-
- if (from_start)
- {
- if (S_ISREG (stats.st_mode))
- lseek (fd, n_bytes, SEEK_CUR);
- else if (start_bytes (filename, fd, n_bytes))
- return 1;
- dump_remainder (filename, fd);
- }
- else
- {
- if (S_ISREG (stats.st_mode))
- {
- off_t current_pos, end_pos;
- size_t bytes_remaining;
-
- if ((current_pos = lseek (fd, (off_t) 0, SEEK_CUR)) != -1
- && (end_pos = lseek (fd, (off_t) 0, SEEK_END)) != -1)
- {
- off_t diff;
- /* Be careful here. The current position may actually be
- beyond the end of the file. */
- bytes_remaining = (diff = end_pos - current_pos) < 0 ? 0 : diff;
- }
- else
- {
- detailed_error (0, errno, "%s", filename);
- return 1;
- }
-
- if (bytes_remaining <= n_bytes)
- {
- /* From the current position to end of file, there are no
- more bytes than have been requested. So reposition the
- file pointer to the incoming current position and print
- everything after that. */
- lseek (fd, current_pos, SEEK_SET);
- }
- else
- {
- /* There are more bytes remaining than were requested.
- Back up. */
- lseek (fd, -n_bytes, SEEK_END);
- }
- dump_remainder (filename, fd);
+ struct stat stats;
+
+ /* FIXME: resolve this like in dd.c. */
+ /* Use fstat instead of checking for errno == ESPIPE because
+ lseek doesn't work on some special files but doesn't return an
+ error, either. */
+ if (fstat(fd, &stats)) {
+ detailed_error(0, errno, "%s", filename);
+ return 1;
+ }
+
+ if (from_start) {
+ if (S_ISREG(stats.st_mode))
+ lseek(fd, n_bytes, SEEK_CUR);
+ else if (start_bytes(filename, fd, n_bytes))
+ return 1;
+ dump_remainder(filename, fd);
+ } else {
+ if (S_ISREG(stats.st_mode)) {
+ off_t current_pos, end_pos;
+ size_t bytes_remaining;
+
+ if ((current_pos = lseek(fd, (off_t) 0, SEEK_CUR)) != -1
+ && (end_pos = lseek(fd, (off_t) 0, SEEK_END)) != -1) {
+ off_t diff;
+
+ /* Be careful here. The current position may actually be
+ beyond the end of the file. */
+ bytes_remaining = (diff =
+ end_pos - current_pos) < 0 ? 0 : diff;
+ } else {
+ detailed_error(0, errno, "%s", filename);
+ return 1;
+ }
+
+ if (bytes_remaining <= n_bytes) {
+ /* From the current position to end of file, there are no
+ more bytes than have been requested. So reposition the
+ file pointer to the incoming current position and print
+ everything after that. */
+ lseek(fd, current_pos, SEEK_SET);
+ } else {
+ /* There are more bytes remaining than were requested.
+ Back up. */
+ lseek(fd, -n_bytes, SEEK_END);
+ }
+ dump_remainder(filename, fd);
+ } else
+ return pipe_bytes(filename, fd, n_bytes);