Changed the err and warns to macros

err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
This commit is contained in:
Craig Small 2012-01-03 18:48:43 +11:00
parent 76b3e91e6a
commit fb11e1fe0a
15 changed files with 100 additions and 147 deletions

7
free.c
View File

@ -206,6 +206,7 @@ int main(int argc, char **argv)
args.repeat_interval = 1000000;
args.repeat_counter = 0;
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@ -246,9 +247,9 @@ int main(int argc, char **argv)
flags |= FREE_REPEAT;
args.repeat_interval = (1000000 * strtof(optarg, &endptr));
if (errno || optarg == endptr || (endptr && *endptr))
errx(EXIT_FAILURE, _("seconds argument `%s' failed"), optarg);
xerrx(EXIT_FAILURE, _("seconds argument `%s' failed"), optarg);
if (args.repeat_interval < 1)
errx(EXIT_FAILURE,
xerrx(EXIT_FAILURE,
_("seconds argument `%s' is not positive number"), optarg);
break;
case 'c':
@ -256,7 +257,7 @@ int main(int argc, char **argv)
flags |= FREE_REPEATCOUNT;
args.repeat_counter = strtoul(optarg, &endptr, 10);
if (errno || optarg == endptr || (endptr && *endptr))
errx(EXIT_FAILURE, _("count argument `%s' failed"), optarg);
xerrx(EXIT_FAILURE, _("count argument `%s' failed"), optarg);
break;
case HELP_OPTION:

View File

@ -17,10 +17,6 @@
#include <string.h>
#include <errno.h>
#ifdef HAVE_ERR_H
# include <err.h>
#endif
/*
* Compiler specific stuff
*/
@ -106,43 +102,10 @@ static inline char *prog_inv_sh_nm_from_file(char *f, char stripext)
/*
* Error printing.
*/
#ifndef HAVE_ERR_H
static inline void
errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
{
fprintf(stderr, "%s: ", program_invocation_short_name);
if (fmt != NULL) {
va_list argp;
va_start(argp, fmt);
vfprintf(stderr, fmt, argp);
va_end(argp);
if (adderr)
fprintf(stderr, ": ");
}
if (adderr)
fprintf(stderr, "%m");
fprintf(stderr, "\n");
if (doexit)
exit(excode);
}
# ifndef HAVE_ERR
# define err(E, FMT...) errmsg(1, E, 1, FMT)
# endif
# ifndef HAVE_ERRX
# define errx(E, FMT...) errmsg(1, E, 0, FMT)
# endif
# ifndef HAVE_WARN
# define warn(FMT...) errmsg(0, 0, 1, FMT)
# endif
# ifndef HAVE_WARNX
# define warnx(FMT...) errmsg(0, 0, 0, FMT)
# endif
#endif /* !HAVE_ERR_H */
#define xwarn(FMT...) error(0, errno, FMT)
#define xwarnx(FMT...) error(0, 0, FMT)
#define xerr(STATUS, FMT...) error(STATUS, errno, FMT)
#define xerrx(STATUS, FMT...) error(STATUS, 0, FMT)
/*
* Constant strings for usage() functions.

View File

@ -15,19 +15,14 @@ long strtol_or_err(const char *str, const char *errmesg)
long num;
char *end = NULL;
if (str == NULL || *str == '\0')
goto err;
errno = 0;
num = strtol(str, &end, 10);
if (errno || str == end || (end && *end))
goto err;
return num;
err:
if (errno)
err(EXIT_FAILURE, "%s: '%s'", errmesg, str);
else
errx(EXIT_FAILURE, "%s: '%s'", errmesg, str);
if (str != NULL && *str != '\0') {
errno = 0;
num = strtol(str, &end, 10);
if (errno == 0 && str != end && end != NULL && *end == '\0')
return num;
}
error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str);
return 0;
}
/*
* same as strtod(3) but exit on failure instead of returning crap
@ -37,20 +32,13 @@ double strtod_or_err(const char *str, const char *errmesg)
double num;
char *end = NULL;
if (str == NULL || *str == '\0')
goto err;
errno = 0;
num = strtod(str, &end);
if (errno || str == end || (end && *end))
goto err;
return num;
err:
if (errno)
err(EXIT_FAILURE, "%s: '%s'", errmesg, str);
else
errx(EXIT_FAILURE, "%s: '%s'", errmesg, str);
if (str != NULL && *str != '\0') {
errno = 0;
num = strtod(str, &end);
if (errno == 0 && str != end && end != NULL && *end == '\0')
return num;
}
error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str);
return 0;
}

21
pgrep.c
View File

@ -255,7 +255,7 @@ static int conv_uid (const char *restrict name, union el *restrict e)
pwd = getpwnam (name);
if (pwd == NULL) {
warnx(_("invalid user name: %s"), name);
xwarnx(_("invalid user name: %s"), name);
return 0;
}
e->num = pwd->pw_uid;
@ -272,7 +272,7 @@ static int conv_gid (const char *restrict name, union el *restrict e)
grp = getgrnam (name);
if (grp == NULL) {
warnx(_("invalid group name: %s"), name);
xwarnx(_("invalid group name: %s"), name);
return 0;
}
e->num = grp->gr_gid;
@ -283,7 +283,7 @@ static int conv_gid (const char *restrict name, union el *restrict e)
static int conv_pgrp (const char *restrict name, union el *restrict e)
{
if (! strict_atol (name, &e->num)) {
warnx(_("invalid process group: %s"), name);
xwarnx(_("invalid process group: %s"), name);
return 0;
}
if (e->num == 0)
@ -295,7 +295,7 @@ static int conv_pgrp (const char *restrict name, union el *restrict e)
static int conv_sid (const char *restrict name, union el *restrict e)
{
if (! strict_atol (name, &e->num)) {
warnx(_("invalid session id: %s"), name);
xwarnx(_("invalid session id: %s"), name);
return 0;
}
if (e->num == 0)
@ -307,7 +307,7 @@ static int conv_sid (const char *restrict name, union el *restrict e)
static int conv_num (const char *restrict name, union el *restrict e)
{
if (! strict_atol (name, &e->num)) {
warnx(_("not a number: %s"), name);
xwarnx(_("not a number: %s"), name);
return 0;
}
return 1;
@ -733,14 +733,14 @@ static void parse_opts (int argc, char **argv)
}
if(opt_lock && !opt_pidfile)
errx(EXIT_FAILURE, _("-L without -F makes no sense\n"
xerrx(EXIT_FAILURE, _("-L without -F makes no sense\n"
"Try `%s --help' for more information."),
program_invocation_short_name);
if(opt_pidfile){
opt_pid = read_pidfile();
if(!opt_pid)
errx(EXIT_FAILURE, _("pidfile not valid\n"
xerrx(EXIT_FAILURE, _("pidfile not valid\n"
"Try `%s --help' for more information."),
program_invocation_short_name);
}
@ -748,11 +748,11 @@ static void parse_opts (int argc, char **argv)
if (argc - optind == 1)
opt_pattern = argv[optind];
else if (argc - optind > 1)
errx(EXIT_FAILURE, _("only one pattern can be provided\n"
xerrx(EXIT_FAILURE, _("only one pattern can be provided\n"
"Try `%s --help' for more information."),
program_invocation_short_name);
else if (criteria_count == 0)
errx(EXIT_FAILURE, _("no matching criteria specified\n"
xerrx(EXIT_FAILURE, _("no matching criteria specified\n"
"Try `%s --help' for more information."),
program_invocation_short_name);
}
@ -763,6 +763,7 @@ int main (int argc, char **argv)
union el *procs;
int num;
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@ -778,7 +779,7 @@ int main (int argc, char **argv)
if (errno==ESRCH)
// gone now, which is OK
continue;
warn(_("killing pid %ld failed"));
xwarn(_("killing pid %ld failed"));
}
} else {
if (opt_count) {

8
pmap.c
View File

@ -10,7 +10,6 @@
*/
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@ -393,6 +392,7 @@ int main(int argc, char **argv)
{NULL, 0, NULL, 0}
};
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@ -405,7 +405,7 @@ int main(int argc, char **argv)
x_option = 1;
break;
case 'r':
warnx(_("option -r is ignored as SunOS compatibility"));
xwarnx(_("option -r is ignored as SunOS compatibility"));
break;
case 'd':
d_option = 1;
@ -460,9 +460,9 @@ int main(int argc, char **argv)
argv += optind;
if (argc < 1)
errx(EXIT_FAILURE, _("argument missing"));
xerrx(EXIT_FAILURE, _("argument missing"));
if (d_option && x_option)
errx(EXIT_FAILURE, _("options -d and -x cannot coexist"));
xerrx(EXIT_FAILURE, _("options -d and -x cannot coexist"));
pidlist = xmalloc(sizeof(unsigned) * argc);

View File

@ -45,15 +45,6 @@
#define NORETURN __attribute__((__noreturn__))
#define FUNCTION __attribute__((__const__)) // no access to global mem, even via ptr, and no side effect
#if !defined(restrict) && __STDC_VERSION__ < 199901
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 92
#define restrict __restrict__
#else
#warning No restrict keyword?
#define restrict
#endif
#endif
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
// won't alias anything, and aligned enough for anything
#define MALLOC __attribute__ ((__malloc__))

1
pwdx.c
View File

@ -48,6 +48,7 @@ int main(int argc, char *argv[])
{NULL, 0, 0, 0}
};
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

15
skill.c
View File

@ -245,7 +245,7 @@ static void iterate(struct run_time_conf_t *run_time)
#endif
d = opendir("/proc");
if (!d)
err(EXIT_FAILURE, "/proc");
xerr(EXIT_FAILURE, "/proc");
while ((de = readdir(d))) {
if (de->d_name[0] > '9')
continue;
@ -387,7 +387,7 @@ static void __attribute__ ((__noreturn__))
if (s)
printf("%s\n", s);
else
warnx(_("unknown signal name %s"),
xwarnx(_("unknown signal name %s"),
optarg);
free(s);
} else {
@ -448,7 +448,7 @@ int snice_prio_option(int *argc, char **argv)
prio = strtol_or_err(argv[i],
_("failed to parse argument"));
if (prio < INT_MIN || INT_MAX < prio)
errx(EXIT_FAILURE,
xerrx(EXIT_FAILURE,
_("priority %lu out of range"), prio);
nargs--;
if (nargs - i)
@ -604,15 +604,15 @@ static void skillsnice_parse(int argc,
/* No more arguments to process. Must sanity check. */
if (!tty_count && !uid_count && !cmd_count && !pid_count)
errx(EXIT_FAILURE, _("no process selection criteria"));
xerrx(EXIT_FAILURE, _("no process selection criteria"));
if ((run_time->fast | run_time->interactive | run_time->
verbose | run_time->warnings | run_time->noaction) & ~1)
errx(EXIT_FAILURE, _("general flags may not be repeated"));
xerrx(EXIT_FAILURE, _("general flags may not be repeated"));
if (run_time->interactive
&& (run_time->verbose | run_time->fast | run_time->noaction))
errx(EXIT_FAILURE, _("-i makes no sense with -v, -f, and -n"));
xerrx(EXIT_FAILURE, _("-i makes no sense with -v, -f, and -n"));
if (run_time->verbose && (run_time->interactive | run_time->fast))
errx(EXIT_FAILURE, _("-v makes no sense with -i and -f"));
xerrx(EXIT_FAILURE, _("-v makes no sense with -i and -f"));
if (run_time->noaction) {
program = PROG_SKILL;
/* harmless */
@ -627,6 +627,7 @@ static void skillsnice_parse(int argc,
/* main body */
int main(int argc, char ** argv)
{
program_invocation_name = program_invocation_short_name;
struct run_time_conf_t run_time;
memset(&run_time, 0, sizeof(struct run_time_conf_t));
my_pid = getpid();

View File

@ -276,7 +276,7 @@ int main(int argc, char *argv[])
int o;
unsigned short old_rows;
struct slab_info *slab_list = NULL;
int run_once=0;
int run_once=0;
static const struct option longopts[] = {
{ "delay", required_argument, NULL, 'd' },
@ -287,6 +287,7 @@ int main(int argc, char *argv[])
{ NULL, 0, NULL, 0 }
};
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@ -300,7 +301,7 @@ int main(int argc, char *argv[])
errno = 0;
delay = strtol_or_err(optarg, _("illegal delay"));
if (delay < 1)
errx(EXIT_FAILURE,
xerrx(EXIT_FAILURE,
_("delay must be positive integer"));
break;
case 's':
@ -322,7 +323,7 @@ int main(int argc, char *argv[])
}
if (tcgetattr(STDIN_FILENO, &saved_tty) == -1)
warn(_("terminal setting retrieval"));
xwarn(_("terminal setting retrieval"));
old_rows = rows;
term_size(0);

View File

@ -70,7 +70,7 @@ static void slashdot(char *restrict p, char old, char new){
while(p){
char c = *p;
if((*(p+1) == '/' || *(p+1) == '.') && warned) {
warnx(_("separators should not be repeated: %s"), p);
xwarnx(_("separators should not be repeated: %s"), p);
warned = 0;
}
if(c==old) *p=new;
@ -156,7 +156,7 @@ static int ReadSetting(const char *restrict const name) {
struct stat ts;
if (!name || !*name) {
warnx(_("\"%s\" is an unknown key"), name);
xwarnx(_("\"%s\" is an unknown key"), name);
return -1;
}
@ -176,7 +176,7 @@ static int ReadSetting(const char *restrict const name) {
if (stat(tmpname, &ts) < 0) {
if (!IgnoreError) {
warn(_("cannot stat %s"), tmpname);
xwarn(_("cannot stat %s"), tmpname);
rc = -1;
}
goto out;
@ -204,16 +204,16 @@ static int ReadSetting(const char *restrict const name) {
switch(errno) {
case ENOENT:
if (!IgnoreError) {
warnx(_("\"%s\" is an unknown key"), outname);
xwarnx(_("\"%s\" is an unknown key"), outname);
rc = -1;
}
break;
case EACCES:
warnx(_("permission denied on key '%s'"), outname);
xwarnx(_("permission denied on key '%s'"), outname);
rc = -1;
break;
default:
warn(_("reading key \"%s\""), outname);
xwarn(_("reading key \"%s\""), outname);
rc = -1;
break;
}
@ -241,7 +241,7 @@ static int ReadSetting(const char *restrict const name) {
} else {
switch(errno) {
case EACCES:
warnx(_("permission denied on key '%s'"), outname);
xwarnx(_("permission denied on key '%s'"), outname);
rc = -1;
break;
case EISDIR:{
@ -254,7 +254,7 @@ static int ReadSetting(const char *restrict const name) {
goto out;
}
default:
warnx(_("reading key \"%s\""), outname);
xwarnx(_("reading key \"%s\""), outname);
rc = -1;
case 0:
break;
@ -284,7 +284,7 @@ static int DisplayAll(const char *restrict const path) {
dp = opendir(path);
if (!dp) {
warnx(_("unable to open directory \"%s\""), path);
xwarnx(_("unable to open directory \"%s\""), path);
rc = -1;
} else {
readdir(dp); // skip .
@ -295,7 +295,7 @@ static int DisplayAll(const char *restrict const path) {
sprintf(tmpdir, "%s%s", path, de->d_name);
rc2 = stat(tmpdir, &ts);
if (rc2 != 0) {
warn(_("cannot stat %s"), tmpdir);
xwarn(_("cannot stat %s"), tmpdir);
} else {
if (S_ISDIR(ts.st_mode)) {
strcat(tmpdir, "/");
@ -333,14 +333,14 @@ static int WriteSetting(const char *setting) {
equals = strchr(setting, '=');
if (!equals) {
warnx(_("\"%s\" must be of the form name=value"), setting);
xwarnx(_("\"%s\" must be of the form name=value"), setting);
return -1;
}
value = equals + 1; /* point to the value in name=value */
if (!*name || !*value || name == equals) {
warnx(_("Malformed setting \"%s\""), setting);
xwarnx(_("Malformed setting \"%s\""), setting);
return -2;
}
@ -359,19 +359,19 @@ static int WriteSetting(const char *setting) {
if (stat(tmpname, &ts) < 0) {
if (!IgnoreError) {
warn(_("cannot stat %s"), tmpname);
xwarn(_("cannot stat %s"), tmpname);
rc = -1;
}
goto out;
}
if ((ts.st_mode & S_IWUSR) == 0) {
warn(_("setting key \"%s\""), outname);
xwarn(_("setting key \"%s\""), outname);
goto out;
}
if (S_ISDIR(ts.st_mode)) {
warn(_("setting key \"%s\""), outname);
xwarn(_("setting key \"%s\""), outname);
goto out;
}
@ -381,28 +381,28 @@ static int WriteSetting(const char *setting) {
switch(errno) {
case ENOENT:
if (!IgnoreError) {
warnx(_("\"%s\" is an unknown key"), outname);
xwarnx(_("\"%s\" is an unknown key"), outname);
rc = -1;
}
break;
case EACCES:
warnx(_("permission denied on key '%s'"), outname);
xwarnx(_("permission denied on key '%s'"), outname);
rc = -1;
break;
default:
warn(_("setting key \"%s\""), outname);
xwarn(_("setting key \"%s\""), outname);
rc = -1;
break;
}
} else {
rc = fprintf(fp, "%s\n", value);
if (rc < 0) {
warn(_("setting key \"%s\""), outname);
xwarn(_("setting key \"%s\""), outname);
fclose(fp);
} else {
rc=fclose(fp);
if (rc != 0)
warn(_("setting key \"%s\""), outname);
xwarn(_("setting key \"%s\""), outname);
}
if (rc==0 && !Quiet) {
if (NameOnly) {
@ -461,7 +461,7 @@ static int Preload(const char *restrict const filename) {
;
if (!fp) {
warn(_("cannot open \"%s\""), filename);
xwarn(_("cannot open \"%s\""), filename);
return -1;
}
@ -477,7 +477,7 @@ static int Preload(const char *restrict const filename) {
name = strtok(t, "=");
if (!name || !*name) {
warnx(_("%s(%d): invalid syntax, continuing..."), filename, n);
xwarnx(_("%s(%d): invalid syntax, continuing..."), filename, n);
continue;
}
@ -489,7 +489,7 @@ static int Preload(const char *restrict const filename) {
value = strtok(NULL, "\n\r");
if (!value || !*value) {
warnx(_("%s(%d): invalid syntax, continuing..."), filename, n);
xwarnx(_("%s(%d): invalid syntax, continuing..."), filename, n);
continue;
}
@ -610,9 +610,10 @@ int main(int argc, char *argv[])
{NULL, 0, NULL, 0}
};
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
PrintName = true;
PrintNewline = true;
@ -691,11 +692,11 @@ int main(int argc, char *argv[])
argv += optind;
if (argc < 1)
errx(EXIT_FAILURE, _("no variables specified\n"
xerrx(EXIT_FAILURE, _("no variables specified\n"
"Try `%s --help' for more information."),
program_invocation_short_name);
if (NameOnly && Quiet)
errx(EXIT_FAILURE, _("options -N and -q cannot coexist\n"
xerrx(EXIT_FAILURE, _("options -N and -q cannot coexist\n"
"Try `%s --help' for more information."),
program_invocation_short_name);

11
tload.c
View File

@ -97,7 +97,8 @@ int main(int argc, char **argv)
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@ -108,14 +109,14 @@ int main(int argc, char **argv)
case 's':
max_scale = strtod_or_err(optarg, _("failed to parse argument"));
if (max_scale < 0)
errx(EXIT_FAILURE, _("scale cannot be negative"));
xerrx(EXIT_FAILURE, _("scale cannot be negative"));
break;
case 'd':
tmpdly = strtol_or_err(optarg, _("failed to parse argument"));
if (tmpdly < 1)
errx(EXIT_FAILURE, _("delay must be positive integer"));
xerrx(EXIT_FAILURE, _("delay must be positive integer"));
else if (UINT_MAX < tmpdly)
errx(EXIT_FAILURE, _("too large delay value"));
xerrx(EXIT_FAILURE, _("too large delay value"));
dly = tmpdly;
break;
case 'V':
@ -130,7 +131,7 @@ int main(int argc, char **argv)
if (argc > optind)
if ((fd = open(argv[optind], 1)) == -1)
err(EXIT_FAILURE, _("can not open tty"));
xerr(EXIT_FAILURE, _("can not open tty"));
setsize(0);

View File

@ -30,6 +30,7 @@ int main(int argc, char **argv)
{NULL, 0, NULL, 0}
};
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

View File

@ -360,7 +360,7 @@ static int diskpartition_format(const char *partition_name)
fDiskstat = fopen("/proc/diskstats", "rb");
if (!fDiskstat)
errx(EXIT_FAILURE,
xerrx(EXIT_FAILURE,
_("Your kernel doesn't support diskstat. (2.5.70 or above required)"));
fclose(fDiskstat);
@ -501,7 +501,7 @@ static void diskformat(void)
free(partitions);
}
} else
errx(EXIT_FAILURE,
xerrx(EXIT_FAILURE,
_("Your kernel doesn't support diskstat (2.5.70 or above required)"));
}
@ -532,7 +532,7 @@ static void slabformat(void)
fSlab = fopen("/proc/slabinfo", "rb");
if (!fSlab) {
warnx(_("Your kernel doesn't support slabinfo or your permissions are insufficient."));
xwarnx(_("Your kernel doesn't support slabinfo or your permissions are insufficient."));
return;
}
@ -706,6 +706,7 @@ int main(int argc, char *argv[])
{NULL, 0, NULL, 0}
};
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@ -765,7 +766,7 @@ int main(int argc, char *argv[])
dataUnit = UNIT_M;
break;
default:
errx(EXIT_FAILURE,
xerrx(EXIT_FAILURE,
/* Translation Hint: do not change argument characters */
_("-S requires k, K, m or M (default is kb)"));
}
@ -782,9 +783,9 @@ int main(int argc, char *argv[])
if (optind < argc) {
tmp = strtol_or_err(argv[optind++], _("failed to parse argument"));
if (tmp < 1)
errx(EXIT_FAILURE, _("delay must be positive integer"));
xerrx(EXIT_FAILURE, _("delay must be positive integer"));
else if (UINT_MAX < tmp)
errx(EXIT_FAILURE, _("too large delay value"));
xerrx(EXIT_FAILURE, _("too large delay value"));
sleep_time = tmp;
infinite_updates = 1;
}

9
w.c
View File

@ -343,6 +343,7 @@ int main(int argc, char **argv)
{NULL, 0, NULL, 0}
};
program_invocation_name = program_invocation_short_name;
setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
@ -388,7 +389,7 @@ int main(int argc, char **argv)
if ((env_var = getenv("PROCPS_USERLEN")) != NULL) {
userlen = atoi(env_var);
if (userlen < 8 || userlen > USERSZ) {
warnx
xwarnx
(_("User length environment PROCPS_USERLEN must be between 8 and %d, ignoring.\n"),
USERSZ);
userlen = 8;
@ -398,7 +399,7 @@ int main(int argc, char **argv)
if ((env_var = getenv("PROCPS_FROMLEN")) != NULL) {
fromlen = atoi(env_var);
if (fromlen < 8 || fromlen > HOSTSZ) {
warnx
xwarnx
(_("From length environment PROCPS_FROMLEN must be between 8 and %d, ignoring.\n"),
HOSTSZ);
fromlen = 16;
@ -411,11 +412,11 @@ int main(int argc, char **argv)
else
maxcmd = 80;
if (maxcmd < 71)
errx(EXIT_FAILURE, _("%d column window is too narrow"), maxcmd);
xerrx(EXIT_FAILURE, _("%d column window is too narrow"), maxcmd);
maxcmd -= 21 + userlen + (from ? fromlen : 0) + (longform ? 20 : 0);
if (maxcmd < 3)
warnx(_("warning: screen width %d suboptimal"), win.ws_col);
xwarnx(_("warning: screen width %d suboptimal"), win.ws_col);
procs = readproctab(PROC_FILLCOM | PROC_FILLUSR | PROC_FILLSTAT);

View File

@ -308,6 +308,7 @@ int main(int argc, char *argv[])
{0, 0, 0, 0}
};
program_invocation_name = program_invocation_short_name;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);