summaryrefslogtreecommitdiff
path: root/src/head.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-02-16 14:42:43 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-02-16 14:42:43 +0000
commit7548e75065063dae256d94e6c7f4f9f43bd7f210 (patch)
treef23b000f8822f6eb70249c1106a3275deaa03bac /src/head.c
parentddefcddae2e97579f82320f4fd70d0ba14a52392 (diff)
parent974ab3dd887985e3aa347f3c6521f819296396a0 (diff)
downloadcoreutils-7548e75065063dae256d94e6c7f4f9f43bd7f210.tar.gz
Merge tag 'upstream/8.21'
Upstream version 8.21
Diffstat (limited to 'src/head.c')
-rw-r--r--src/head.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/head.c b/src/head.c
index d7e83b71..d79d5f7d 100644
--- a/src/head.c
+++ b/src/head.c
@@ -1,5 +1,5 @@
/* head -- output first part of file(s)
- Copyright (C) 1989-2012 Free Software Foundation, Inc.
+ Copyright (C) 1989-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -110,11 +110,10 @@ Usage: %s [OPTION]... [FILE]...\n\
Print the first 10 lines of each FILE to standard output.\n\
With more than one FILE, precede each with a header giving the file name.\n\
With no FILE, or when FILE is -, read standard input.\n\
-\n\
-"), stdout);
- fputs (_("\
-Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
+
+ emit_mandatory_arg_note ();
+
fputs (_("\
-c, --bytes=[-]K print the first K bytes of each file;\n\
with the leading '-', print all but the last\n\
@@ -667,6 +666,14 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd,
Don't bother testing for failure for such a small amount.
Any failure will be detected upon close. */
fwrite (buffer, 1, n + 1, stdout);
+
+ /* Set file pointer to the byte after what we've output. */
+ if (lseek (fd, pos + n + 1, SEEK_SET) < 0)
+ {
+ error (0, errno, _("%s: failed to reset file pointer"),
+ quote (pretty_filename));
+ return false;
+ }
return true;
}
}
@@ -852,7 +859,7 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines,
ok = head (filename, fd, n_units, count_lines, elide_from_end);
if (!is_stdin && close (fd) != 0)
{
- error (0, errno, _("closing %s"), quote (filename));
+ error (0, errno, _("failed to close %s"), quote (filename));
return false;
}
return ok;