]> granicus.if.org Git - procps-ng/commitdiff
Changed the err and warns to macros
authorCraig Small <csmall@enc.com.au>
Tue, 3 Jan 2012 07:48:43 +0000 (18:48 +1100)
committerCraig Small <csmall@enc.com.au>
Tue, 3 Jan 2012 07:48:43 +0000 (18:48 +1100)
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.

15 files changed:
free.c
include/c.h
lib/strutils.c
pgrep.c
pmap.c
proc/procps.h
pwdx.c
skill.c
slabtop.c
sysctl.c
tload.c
uptime.c
vmstat.c
w.c
watch.c

diff --git a/free.c b/free.c
index 0ff64b11ffbace4134126e3c231326d168579414..cd1b1455f1690d2a65ebb3491c31c52bdbaca8a1 100644 (file)
--- a/free.c
+++ b/free.c
@@ -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:
index 950bca2ccfae0eb83b940242ccf6475fe2c92094..2be74950a0f0e1edfd18d064248ad572bfad5f93 100644 (file)
 #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.
index 65ef998ff9faa83fc94bc00b15c560667b5f0bd5..14d4de75324f6c08cb911f930f87551af561af1b 100644 (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;
 }
 
diff --git a/pgrep.c b/pgrep.c
index 9575d0539536f09f130a8404391de014619edfb9..1229be187ec0c8df6ccd3a4ec3926d60d1f545c5 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -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) {
diff --git a/pmap.c b/pmap.c
index 8b816572ea7310fd05d0efca3476a74e729f0f80..3296ea704ae7496eb3174b3e1604a0d1cc02479f 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -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);
 
index abbab98df5419fa9f01519d008e99d0b6882a22d..70514b41c236558ffc787ec1686e9ae55fc51517 100644 (file)
 #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__))
diff --git a/pwdx.c b/pwdx.c
index e4fcdd006b91ba72136385dd24c67218ab6dc664..2743040a191bdee91e10a2001910cf2032c9954b 100644 (file)
--- a/pwdx.c
+++ b/pwdx.c
@@ -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);
diff --git a/skill.c b/skill.c
index e9ce5ddc11a9d3fafc3252d92a7d024d5737dde2..b6e9d87a567ec6d80e2984cef4d0f769a71a29f8 100644 (file)
--- a/skill.c
+++ b/skill.c
@@ -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();
index 6647b2ce983734eb6d254e508de3ee06351c1f25..b84cda57c3430049a3b3cabbf7ee2919f2c7c55f 100644 (file)
--- a/slabtop.c
+++ b/slabtop.c
@@ -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);
index cde270b62c834c4fb72dc0ba6164694f07617c14..872eceb56c2565a94f6fd0a71bbae587bcff5609 100644 (file)
--- a/sysctl.c
+++ b/sysctl.c
@@ -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);
 
diff --git a/tload.c b/tload.c
index 784f69d049da9e8c8a09376c32382d5cfb256220..56a0b1c874c8f3674190dfd1858be44820e9ca9f 100644 (file)
--- a/tload.c
+++ b/tload.c
@@ -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);
 
index 6ad5d1fd71d65eda289c1d392b354e4a7aaf44f5..8957ce14c683e5ef1d37313f7bdf805a57496ac4 100644 (file)
--- a/uptime.c
+++ b/uptime.c
@@ -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);
index 34379c802b769be6371721f8555ba1c28e1c2680..8fbe5455e11b1832297013cab5ae4c46e3407b9f 100644 (file)
--- a/vmstat.c
+++ b/vmstat.c
@@ -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;
        }
diff --git a/w.c b/w.c
index 5b573df25eecfcb8126aef3e25ab6c3595b59036..3964e4f25db657bb3fb98907806ddbfc703ee35b 100644 (file)
--- a/w.c
+++ b/w.c
@@ -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);
 
diff --git a/watch.c b/watch.c
index af5813e37c317a4279c30ec32e4e5bb830a0ed84..aa015e065040a222faf913e086120c644df93561 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -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);