void (*oldquit)(int); /* old SIGQUIT handler */
void (*oldterm)(int); /* old SIGTERM handler */
char *tty; /* result of ttyname(1) */
-char *progname; /* program name */
unsigned ontty; /* whether running on tty device */
unsigned exitstatus; /* exit status */
int pagelen = 23; /* lines on a single screen page */
static void
needarg(char *s)
{
- fprintf(stderr, _("%s: option requires an argument -- %s\n"),
- progname, s);
+ warnx(_("option requires an argument -- %s"), s);
usage(stderr);
}
static void
invopt(char *s)
{
- fprintf(stderr, _("%s: illegal option -- %s\n"), progname, s);
+ warnx(_("illegal option -- %s"), s);
usage(stderr);
}
tmperr(FILE *f, char *ftype)
{
if (ferror(f))
- fprintf(stderr, _("%s: Read error from %s file\n"),
- progname, ftype);
+ warn(_("Read error from %s file"), ftype);
else if (feof(f))
/*
* Most likely '\0' in input.
*/
- fprintf(stderr, _("%s: Unexpected EOF in %s file\n"),
- progname, ftype);
+ warnx(_("Unexpected EOF in %s file"), ftype);
else
- fprintf(stderr, _("%s: Unknown error in %s file\n"),
- progname, ftype);
+ warn(_("Unknown error in %s file"), ftype);
quit(++exitstatus);
}
-/*
- * perror()-like, but showing the program's name.
- */
-static void
-pgerror(int eno, char *string)
-{
- fprintf(stderr, "%s: %s: %s\n", progname, string, strerror(eno));
-}
-
/*
* Read the file and respond to user input.
* Beware: long and ugly.
while ((sz = fread(b, sizeof *b, READBUF, f)) != 0)
write_all(1, b, sz);
if (ferror(f)) {
- pgerror(errno, name);
+ warn("%s", name);
exitstatus++;
}
return;
}
find = tmpfile();
if (fbuf == NULL || find == NULL) {
- fprintf(stderr, _("%s: Cannot create tempfile\n"), progname);
+ warn(_("Cannot create tempfile"));
quit(++exitstatus);
}
if (searchfor) {
p = fgets(b, READBUF, f);
if (nobuf)
if ((fpos = ftello(f)) == -1)
- pgerror(errno, name);
+ warn("%s", name);
canjump = 0;
}
if (p == NULL || *b == '\0') {
if (ferror(f))
- pgerror(errno, name);
+ warn("%s", name);
eofline = fline;
eof = 1;
break;
* Shell escape.
*/
if (rflag) {
- mesg(progname);
+ mesg(program_invocation_short_name);
mesg(_(": !command not allowed in "
"rflag mode.\n"));
} else {
my_sigset(SIGTERM, oldterm);
execl(p, p, "-c",
cmd.cmdline + 1, NULL);
- pgerror(errno, p);
+ warn("%s", p);
_exit(0177);
/*NOTREACHED*/
case -1:
else {
input = fopen(argv[arg], "r");
if (input == NULL) {
- pgerror(errno, argv[arg]);
+ warn("%s", argv[arg]);
exitstatus++;
continue;
}
int arg, i;
char *p;
- progname = basename(argv[0]);
xasprintf(©right,
_("%s %s Copyright (c) 2000-2001 Gunnar Ritter. All rights reserved.\n"),
program_invocation_short_name, PACKAGE_VERSION);