summaryrefslogtreecommitdiff
path: root/src/head.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-07-11 11:12:44 +0000
committerJim Meyering <jim@meyering.net>2003-07-11 11:12:44 +0000
commite1584f504fcae16933f3265368d5d3cc86c6f072 (patch)
tree936c74166c9e0fb60d4485624aeadfd4efc04d47 /src/head.c
parent1dae2a560aaca7f2f9f214a5e0bd607cc3e175aa (diff)
downloadcoreutils-e1584f504fcae16933f3265368d5d3cc86c6f072.tar.xz
(diagnose_copy_fd_failure): New function, renamed from
the macro, COPY_FD_DIAGNOSE. (diagnose_copy_fd_failure): Enclose diagnostic in _(...). (head_file): Likewise.
Diffstat (limited to 'src/head.c')
-rw-r--r--src/head.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/head.c b/src/head.c
index b685cd85b..4028d85da 100644
--- a/src/head.c
+++ b/src/head.c
@@ -85,27 +85,6 @@ enum Copy_fd_status
COPY_FD_UNEXPECTED_EOF
};
-#define COPY_FD_DIAGNOSE(Err, Filename) \
- do \
- { \
- switch (Err) \
- { \
- case COPY_FD_READ_ERROR: \
- error (0, errno, "error reading %s", quote (Filename)); \
- break; \
- case COPY_FD_WRITE_ERROR: \
- error (0, errno, "error writing %s", quote (Filename)); \
- break; \
- case COPY_FD_UNEXPECTED_EOF: \
- error (0, errno, "%s: file has shrunk too much", \
- quote (Filename)); \
- break; \
- default: \
- abort (); \
- } \
- } \
- while (0)
-
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
@@ -172,6 +151,25 @@ N may have a multiplier suffix: b 512, k 1024, m 1024*1024.\n\
}
static void
+diagnose_copy_fd_failure (enum Copy_fd_status err, char const *filename)
+{
+ switch (err)
+ {
+ case COPY_FD_READ_ERROR:
+ error (0, errno, _("error reading %s"), quote (filename));
+ break;
+ case COPY_FD_WRITE_ERROR:
+ error (0, errno, _("error writing %s"), quote (filename));
+ break;
+ case COPY_FD_UNEXPECTED_EOF:
+ error (0, errno, _("%s: file has shrunk too much"), quote (filename));
+ break;
+ default:
+ abort ();
+ }
+}
+
+static void
write_header (const char *filename)
{
static int first_file = 1;
@@ -464,7 +462,7 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide)
if (err == COPY_FD_OK)
return 0;
- COPY_FD_DIAGNOSE (err, filename);
+ diagnose_copy_fd_failure (err, filename);
return 1;
}
}
@@ -672,7 +670,7 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd,
err = copy_fd (fd, stdout, pos - start_pos);
if (err != COPY_FD_OK)
{
- COPY_FD_DIAGNOSE (err, pretty_filename);
+ diagnose_copy_fd_failure (err, pretty_filename);
return 1;
}
}
@@ -867,7 +865,7 @@ head_file (const char *filename, uintmax_t n_units, int count_lines,
fd = open (filename, O_RDONLY);
if (fd < 0)
{
- error (0, errno, "cannot open %s for reading", quote (filename));
+ error (0, errno, _("cannot open %s for reading"), quote (filename));
return 1;
}
}
@@ -875,7 +873,7 @@ head_file (const char *filename, uintmax_t n_units, int count_lines,
fail = head (filename, fd, n_units, count_lines, elide_from_end);
if (fd != STDIN_FILENO && close (fd) == -1)
{
- error (0, errno, "closing %s", quote (filename));
+ error (0, errno, _("closing %s"), quote (filename));
fail = 1;
}
return fail;