/* od -- dump files in octal and other formats
- Copyright (C) 92, 1995-2002 Free Software Foundation, Inc.
+ Copyright (C) 92, 1995-2003 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
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
-#include "closeout.h"
#include "error.h"
#include "posixver.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "od"
-#define AUTHORS "Jim Meyering"
+#define WRITTEN_BY _("Written by Jim Meyering.")
#if defined(__GNUC__) || defined(STDC_HEADERS)
# include <float.h>
{
enum output_format fmt;
enum size_spec size;
- void (*print_function) PARAMS ((size_t, const char *, const char *));
+ void (*print_function) (size_t, const char *, const char *);
char *fmt_string;
int hexl_mode_trailer;
int field_width;
/* Function that accepts an address and an optional following char,
and prints the address and char to stdout. */
-static void (*format_address) PARAMS ((uintmax_t, char));
+static void (*format_address) (uintmax_t, char);
/* The number of input bytes to skip before formatting and writing. */
static uintmax_t n_bytes_to_skip = 0;
enum output_format fmt;
const char *pre_fmt_string;
char *fmt_string;
- void (*print_function) PARAMS ((size_t, const char *, const char *));
+ void (*print_function) (size_t, const char *, const char *);
const char *p;
unsigned int c;
unsigned int field_width = 0;
it is not standard input. Return nonzero if there has been an error
on in_stream or stdout; return zero otherwise. This function will
report more than one error only if both a read and a write error
- have occurred. */
+ have occurred. IN_ERRNO, if nonzero, is the error number
+ corresponding to the most recent action for IN_STREAM. */
static int
-check_and_close (void)
+check_and_close (int in_errno)
{
int err = 0;
{
if (ferror (in_stream))
{
- error (0, errno, "%s", input_filename);
+ error (0, in_errno, _("%s: read error"), input_filename);
if (in_stream != stdin)
fclose (in_stream);
err = 1;
if (ferror (stdout))
{
- error (0, errno, _("standard output"));
+ error (0, 0, _("write error"));
err = 1;
}
if (n_specs >= n_specs_allocated)
{
n_specs_allocated = 1 + (3 * n_specs_allocated) / 2;
- spec = (struct tspec *) xrealloc ((char *) spec,
- (n_specs_allocated
- * sizeof (struct tspec)));
+ spec = xrealloc (spec, (n_specs_allocated * sizeof (struct tspec)));
}
memcpy ((char *) &spec[n_specs], (char *) &tspec,
skip (uintmax_t n_skip)
{
int err = 0;
+ int in_errno = 0;
if (n_skip == 0)
return 0;
{
if (fseeko (in_stream, n_skip, SEEK_CUR) != 0)
{
- error (0, errno, "%s", input_filename);
+ in_errno = errno;
err = 1;
}
n_skip = 0;
n_bytes_read = fread (buf, 1, n_bytes_to_read, in_stream);
n_skip -= n_bytes_read;
if (n_bytes_read != n_bytes_to_read)
- break;
+ {
+ in_errno = errno;
+ err = 1;
+ n_skip = 0;
+ break;
+ }
}
}
err = 1;
}
- err |= check_and_close ();
+ err |= check_and_close (in_errno);
err |= open_next_file ();
}
if (*c != EOF)
break;
- err |= check_and_close ();
+ err |= check_and_close (errno);
err |= open_next_file ();
}
if (n_read == n_needed)
break;
- err |= check_and_close ();
+ err |= check_and_close (errno);
err |= open_next_file ();
}
int err;
size_t n_bytes_read;
- block[0] = (char *) alloca (bytes_per_block);
- block[1] = (char *) alloca (bytes_per_block);
+ block[0] = alloca (bytes_per_block);
+ block[1] = alloca (bytes_per_block);
current_offset = n_bytes_to_skip;
format_address (current_offset, '\n');
if (limit_bytes_to_format && current_offset >= end_offset)
- err |= check_and_close ();
+ err |= check_and_close (0);
return err;
}
free (buf);
- err |= check_and_close ();
+ err |= check_and_close (0);
return err;
}
after any true address. */
uintmax_t pseudo_start IF_LINT (= 0);
+ initialize_main (&argc, &argv);
program_name = argv[0];
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
n_specs = 0;
n_specs_allocated = 5;
- spec = (struct tspec *) xmalloc (n_specs_allocated * sizeof (struct tspec));
+ spec = xmalloc (n_specs_allocated * sizeof (struct tspec));
format_address = format_address_std;
address_base = 8;
case_GETOPT_HELP_CHAR;
- case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, WRITTEN_BY);
default:
usage (EXIT_FAILURE);
{
end_offset = n_bytes_to_skip + max_bytes_to_format;
if (end_offset < n_bytes_to_skip)
- error (EXIT_FAILURE, 0, "skip-bytes + read-bytes is too large");
+ error (EXIT_FAILURE, 0, _("skip-bytes + read-bytes is too large"));
}
if (n_specs == 0)