Change `error (1, ...' to `error (EXIT_FAILURE, ...'.
authorJim Meyering <jim@meyering.net>
Fri, 30 Aug 2002 23:04:53 +0000 (23:04 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 30 Aug 2002 23:04:53 +0000 (23:04 +0000)
31 files changed:
src/chgrp.c
src/chmod.c
src/chown.c
src/chroot.c
src/cp.c
src/date.c
src/dd.c
src/du.c
src/hostname.c
src/id.c
src/install.c
src/ln.c
src/mkdir.c
src/mkfifo.c
src/mknod.c
src/nice.c
src/pinky.c
src/printf.c
src/pwd.c
src/shred.c
src/sleep.c
src/stty.c
src/su.c
src/tac-pipe.c
src/tail.c
src/tee.c
src/touch.c
src/uname.c
src/uptime.c
src/users.c
src/who.c

index 3253b0f..4914330 100644 (file)
@@ -90,7 +90,7 @@ parse_group (const char *name, gid_t *g)
   struct group *grp;
 
   if (*name == '\0')
-    error (1, 0, _("cannot change to null group"));
+    error (EXIT_FAILURE, 0, _("cannot change to null group"));
 
   grp = getgrnam (name);
   if (grp == NULL)
@@ -99,14 +99,14 @@ parse_group (const char *name, gid_t *g)
       unsigned long int tmp_long;
 
       if (!ISDIGIT (*name))
-       error (1, 0, _("invalid group name %s"), quote (name));
+       error (EXIT_FAILURE, 0, _("invalid group name %s"), quote (name));
 
       s_err = xstrtoul (name, NULL, 0, &tmp_long, NULL);
       if (s_err != LONGINT_OK)
        STRTOL_FATAL_ERROR (name, _("group number"), s_err);
 
       if (tmp_long > MAXGID)
-       error (1, 0, _("invalid group number %s"), quote (name));
+       error (EXIT_FAILURE, 0, _("invalid group number %s"), quote (name));
 
       *g = tmp_long;
     }
@@ -215,7 +215,7 @@ main (int argc, char **argv)
     {
       struct stat ref_stats;
       if (stat (reference_file, &ref_stats))
-       error (1, errno, _("failed to get attributes of %s"),
+       error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
               quote (reference_file));
 
       chopt.group_name = gid_to_name (ref_stats.st_gid);
index 852fe47..8abbd61 100644 (file)
@@ -1,5 +1,5 @@
 /* chmod -- change permission modes of files
-   Copyright (C) 89, 90, 91, 1995-2001 Free Software Foundation, Inc.
+   Copyright (C) 89, 90, 91, 1995-2002 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
@@ -318,7 +318,7 @@ main (int argc, char **argv)
            {
              static char char_string[2] = {0, 0};
              char_string[0] = c;
-             error (1, 0, _("invalid character %s in mode string %s"),
+             error (EXIT_FAILURE, 0, _("invalid character %s in mode string %s"),
                     quote_n (0, char_string), quote_n (1, argv[thisind]));
            }
          modeind = thisind;
@@ -358,11 +358,12 @@ main (int argc, char **argv)
             : mode_compile (argv[modeind], MODE_MASK_ALL));
 
   if (changes == MODE_INVALID)
-    error (1, 0, _("invalid mode string: %s"), quote (argv[modeind]));
+    error (EXIT_FAILURE, 0,
+          _("invalid mode string: %s"), quote (argv[modeind]));
   else if (changes == MODE_MEMORY_EXHAUSTED)
     xalloc_die ();
   else if (changes == MODE_BAD_REFERENCE)
-    error (1, errno, _("failed to get attributes of %s"),
+    error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
           quote (reference_file));
 
   for (; optind < argc; ++optind)
index a95ff01..5320f7a 100644 (file)
@@ -181,7 +181,7 @@ main (int argc, char **argv)
                                             &old_uid, &old_gid,
                                             &u_dummy, &g_dummy);
            if (e)
-             error (1, 0, "%s: %s", quote (optarg), e);
+             error (EXIT_FAILURE, 0, "%s: %s", quote (optarg), e);
            break;
          }
        case 'R':
@@ -217,7 +217,7 @@ main (int argc, char **argv)
       struct stat ref_stats;
 
       if (stat (reference_file, &ref_stats))
-       error (1, errno, _("failed to get attributes of %s"),
+       error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
               quote (reference_file));
 
       uid = ref_stats.st_uid;
@@ -230,7 +230,7 @@ main (int argc, char **argv)
       const char *e = parse_user_spec (argv[optind], &uid, &gid,
                                       &chopt.user_name, &chopt.group_name);
       if (e)
-        error (1, 0, "%s: %s", quote (argv[optind]), e);
+        error (EXIT_FAILURE, 0, "%s: %s", quote (argv[optind]), e);
 
       /* FIXME: set it to the empty string?  */
       if (chopt.user_name == NULL)
index 4904c84..f63ab2a 100644 (file)
@@ -1,5 +1,5 @@
 /* chroot -- run command or shell with special root directory
-   Copyright (C) 95, 96, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 95, 96, 1997, 1999-2002 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
@@ -80,10 +80,11 @@ main (int argc, char **argv)
     }
 
   if (chroot (argv[1]))
-    error (1, errno, _("cannot change root directory to %s"), argv[1]);
+    error (EXIT_FAILURE, errno,
+          _("cannot change root directory to %s"), argv[1]);
 
   if (chdir ("/"))
-    error (1, errno, _("cannot chdir to root directory"));
+    error (EXIT_FAILURE, errno, _("cannot chdir to root directory"));
 
   if (argc == 2)
     {
index 676e2fb..36a66e0 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -968,7 +968,8 @@ main (int argc, char **argv)
 #ifdef S_ISLNK
          x.symbolic_link = 1;
 #else
-         error (1, 0, _("symbolic links are not supported on this system"));
+         error (EXIT_FAILURE, 0,
+                _("symbolic links are not supported on this system"));
 #endif
          break;
 
index 0aaed81..bc0c81a 100644 (file)
@@ -244,7 +244,7 @@ batch_convert (const char *input_filename, const char *format)
       in_stream = fopen (input_filename, "r");
       if (in_stream == NULL)
        {
-         error (1, errno, "`%s'", input_filename);
+         error (EXIT_FAILURE, errno, "`%s'", input_filename);
        }
     }
 
@@ -444,7 +444,7 @@ argument must be a format string beginning with `+'."),
          if (reference != NULL)
            {
              if (stat (reference, &refstats))
-               error (1, errno, "%s", reference);
+               error (EXIT_FAILURE, errno, "%s", reference);
              when.tv_sec = refstats.st_mtime;
              when.tv_nsec = TIMESPEC_NS (refstats.st_mtim);
            }
@@ -459,7 +459,7 @@ argument must be a format string beginning with `+'."),
        }
 
       if (! valid_date)
-       error (1, 0, _("invalid date `%s'"), datestr);
+       error (EXIT_FAILURE, 0, _("invalid date `%s'"), datestr);
 
       if (set_date)
        {
index c394a94..da3c87d 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -383,9 +383,11 @@ cleanup (void)
 {
   print_stats ();
   if (close (STDIN_FILENO) < 0)
-    error (1, errno, _("closing input file %s"), quote (input_file));
+    error (EXIT_FAILURE, errno,
+          _("closing input file %s"), quote (input_file));
   if (close (STDOUT_FILENO) < 0)
-    error (1, errno, _("closing output file %s"), quote (output_file));
+    error (EXIT_FAILURE, errno,
+          _("closing output file %s"), quote (output_file));
 }
 
 static inline void
@@ -610,7 +612,7 @@ scanargs (int argc, char **argv)
            }
 
          if (invalid)
-           error (1, 0, _("invalid number %s"), quote (val));
+           error (EXIT_FAILURE, 0, _("invalid number %s"), quote (val));
        }
     }
 
@@ -640,7 +642,7 @@ apply_translations (void)
       || (MX (C_LCASE | C_UCASE) > 1)
       || (MX (C_UNBLOCK | C_SYNC) > 1))
     {
-      error (1, 0, _("\
+      error (EXIT_FAILURE, 0, _("\
 only one conv in {ascii,ebcdic,ibm}, {lcase,ucase}, {block,unblock}, {unblock,sync}"));
     }
 #undef MX
@@ -1163,7 +1165,7 @@ main (int argc, char **argv)
   if (input_file != NULL)
     {
       if (open_fd (STDIN_FILENO, input_file, O_RDONLY, 0) < 0)
-       error (1, errno, _("opening %s"), quote (input_file));
+       error (EXIT_FAILURE, errno, _("opening %s"), quote (input_file));
     }
   else
     input_file = _("standard input");
@@ -1181,7 +1183,7 @@ main (int argc, char **argv)
       if ((! seek_records
           || open_fd (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0)
          && open_fd (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) < 0)
-       error (1, errno, _("opening %s"), quote (output_file));
+       error (EXIT_FAILURE, errno, _("opening %s"), quote (output_file));
 
 #if HAVE_FTRUNCATE
       if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
@@ -1189,10 +1191,10 @@ main (int argc, char **argv)
          struct stat stdout_stat;
          off_t o = seek_records * output_blocksize;
          if (o / output_blocksize != seek_records)
-           error (1, 0, _("file offset out of range"));
+           error (EXIT_FAILURE, 0, _("file offset out of range"));
 
          if (fstat (STDOUT_FILENO, &stdout_stat) != 0)
-           error (1, errno, _("cannot fstat %s"), quote (output_file));
+           error (EXIT_FAILURE, errno, _("cannot fstat %s"), quote (output_file));
 
          /* Complain only when ftruncate fails on a regular file, a
             directory, or a shared memory object, as the 2000-08
@@ -1205,7 +1207,8 @@ main (int argc, char **argv)
                  || S_TYPEISSHM (&stdout_stat)))
            {
              char buf[LONGEST_HUMAN_READABLE + 1];
-             error (1, errno, _("advancing past %s bytes in output file %s"),
+             error (EXIT_FAILURE, errno,
+                    _("advancing past %s bytes in output file %s"),
                     human_readable (o, buf, 1, 1),
                     quote (output_file));
            }
index d25cb11..7e29a96 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -385,7 +385,7 @@ pop_dir (struct saved_cwd *cwd, const char *curr_dir_name)
     }
   else if (chdir ("..") < 0)
     {
-      error (1, errno, _("cannot change to `..' from directory %s"),
+      error (EXIT_FAILURE, errno, _("cannot change to `..' from directory %s"),
             quote (curr_dir_name));
     }
 }
@@ -618,7 +618,7 @@ main (int argc, char **argv)
        case MAX_DEPTH_OPTION:          /* --max-depth=N */
          if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
              || tmp_long < 0 || tmp_long > INT_MAX)
-           error (1, 0, _("invalid maximum depth %s"), quote (optarg));
+           error (EXIT_FAILURE, 0, _("invalid maximum depth %s"), quote (optarg));
 
          max_depth_specified = 1;
          max_depth = (int) tmp_long;
@@ -659,7 +659,7 @@ main (int argc, char **argv)
        case 'X':
          if (add_exclude_file (add_exclude, exclude, optarg,
                                EXCLUDE_WILDCARDS, '\n'))
-           error (1, errno, "%s", quote (optarg));
+           error (EXIT_FAILURE, errno, "%s", quote (optarg));
          break;
 
        case EXCLUDE_OPTION:
index fe4aeb6..c004523 100644 (file)
@@ -101,12 +101,12 @@ main (int argc, char **argv)
       /* Set hostname to argv[1].  */
       err = sethostname (argv[1], strlen (argv[1]));
       if (err != 0)
-       error (1, errno, _("cannot set hostname to `%s'"), argv[1]);
+       error (EXIT_FAILURE, errno, _("cannot set hostname to `%s'"), argv[1]);
       exit (0);
     }
 #else
   if (argc == 2)
-    error (1, 0,
+    error (EXIT_FAILURE, 0,
           _("cannot set hostname; this system lacks the functionality"));
 #endif
 
@@ -114,7 +114,7 @@ main (int argc, char **argv)
     {
       hostname = xgethostname ();
       if (hostname == NULL)
-       error (1, errno, _("cannot determine hostname"));
+       error (EXIT_FAILURE, errno, _("cannot determine hostname"));
       printf ("%s\n", hostname);
     }
   else
index a4a2207..9f2bd46 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -1,5 +1,5 @@
 /* id -- print real and effective UIDs and GIDs
-   Copyright (C) 1989-2001 Free Software Foundation, Inc.
+   Copyright (C) 1989-2002 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
@@ -159,10 +159,11 @@ main (int argc, char **argv)
     }
 
   if (just_user + just_group + just_group_list > 1)
-    error (1, 0, _("cannot print only user and only group"));
+    error (EXIT_FAILURE, 0, _("cannot print only user and only group"));
 
   if (just_user + just_group + just_group_list == 0 && (use_real || use_name))
-    error (1, 0, _("cannot print only names or real IDs in default format"));
+    error (EXIT_FAILURE, 0,
+          _("cannot print only names or real IDs in default format"));
 
   if (argc - optind > 1)
     usage (1);
@@ -171,7 +172,7 @@ main (int argc, char **argv)
     {
       struct passwd *pwd = getpwnam (argv[optind]);
       if (pwd == NULL)
-       error (1, 0, _("%s: No such user"), argv[optind]);
+       error (EXIT_FAILURE, 0, _("%s: No such user"), argv[optind]);
       ruid = euid = pwd->pw_uid;
       rgid = egid = pwd->pw_gid;
     }
index 0d1bc09..1afcdca 100644 (file)
@@ -269,7 +269,7 @@ main (int argc, char **argv)
 
   /* Check for invalid combinations of arguments. */
   if (dir_arg && strip_files)
-    error (1, 0,
+    error (EXIT_FAILURE, 0,
           _("the strip option may not be used when installing a directory"));
 
   if (backup_suffix_string)
@@ -293,7 +293,7 @@ main (int argc, char **argv)
     {
       struct mode_change *change = mode_compile (specified_mode, 0);
       if (change == MODE_INVALID)
-       error (1, 0, _("invalid mode %s"), quote (specified_mode));
+       error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
       else if (change == MODE_MEMORY_EXHAUSTED)
        xalloc_die ();
       mode = mode_adjust (0, change);
@@ -529,18 +529,18 @@ strip (const char *path)
   switch (pid)
     {
     case -1:
-      error (1, errno, _("fork system call failed"));
+      error (EXIT_FAILURE, errno, _("fork system call failed"));
       break;
     case 0:                    /* Child. */
       execlp ("strip", "strip", path, NULL);
-      error (1, errno, _("cannot run strip"));
+      error (EXIT_FAILURE, errno, _("cannot run strip"));
       break;
     default:                   /* Parent. */
       /* Parent process. */
       while (pid != wait (&status))    /* Wait for kid to finish. */
        /* Do nothing. */ ;
       if (status)
-       error (1, 0, _("strip failed"));
+       error (EXIT_FAILURE, 0, _("strip failed"));
       break;
     }
 }
@@ -561,7 +561,7 @@ get_ids (void)
          long int tmp_long;
          if (xstrtol (owner_name, NULL, 0, &tmp_long, NULL) != LONGINT_OK
              || tmp_long < 0 || tmp_long > UID_T_MAX)
-           error (1, 0, _("invalid user %s"), quote (owner_name));
+           error (EXIT_FAILURE, 0, _("invalid user %s"), quote (owner_name));
          owner_id = (uid_t) tmp_long;
        }
       else
@@ -579,7 +579,7 @@ get_ids (void)
          long int tmp_long;
          if (xstrtol (group_name, NULL, 0, &tmp_long, NULL) != LONGINT_OK
              || tmp_long < 0 || tmp_long > GID_T_MAX)
-           error (1, 0, _("invalid group %s"), quote (group_name));
+           error (EXIT_FAILURE, 0, _("invalid group %s"), quote (group_name));
          group_id = (gid_t) tmp_long;
        }
       else
index 82c347b..06589f5 100644 (file)
--- a/src/ln.c
+++ b/src/ln.c
@@ -460,7 +460,8 @@ main (int argc, char **argv)
 #ifdef S_ISLNK
          symbolic_link = 1;
 #else
-         error (1, 0, _("symbolic links are not supported on this system"));
+         error (EXIT_FAILURE, 0,
+                _("symbolic links are not supported on this system"));
 #endif
          break;
        case TARGET_DIRECTORY_OPTION:
@@ -537,7 +538,7 @@ main (int argc, char **argv)
                                    : n_files - 2);
 
       if (!target_directory_specified && !dest_is_dir)
-       error (1, 0,
+       error (EXIT_FAILURE, 0,
           _("when making multiple links, last argument must be a directory"));
       for (i = 0; i <= last_file_idx; ++i)
        errors += do_link (file[i], target_directory);
index 75e44fd..877fd98 100644 (file)
@@ -137,7 +137,7 @@ main (int argc, char **argv)
       struct mode_change *change = mode_compile (specified_mode, 0);
       newmode &= ~ umask (0);
       if (change == MODE_INVALID)
-       error (1, 0, _("invalid mode %s"), quote (specified_mode));
+       error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
       else if (change == MODE_MEMORY_EXHAUSTED)
        xalloc_die ();
       newmode = mode_adjust (newmode, change);
index ed67360..ae2ee32 100644 (file)
@@ -120,7 +120,7 @@ main (int argc, char **argv)
       newmode &= ~ umask (0);
       change = mode_compile (specified_mode, 0);
       if (change == MODE_INVALID)
-       error (1, 0, _("invalid mode"));
+       error (EXIT_FAILURE, 0, _("invalid mode"));
       else if (change == MODE_MEMORY_EXHAUSTED)
        xalloc_die ();
       newmode = mode_adjust (newmode, change);
index 104426d..66ccba0 100644 (file)
@@ -1,5 +1,5 @@
 /* mknod -- make special files
-   Copyright (C) 90, 91, 1995-2001 Free Software Foundation, Inc.
+   Copyright (C) 90, 91, 1995-2002 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
@@ -128,7 +128,7 @@ main (int argc, char **argv)
       newmode &= ~ umask (0);
       change = mode_compile (specified_mode, 0);
       if (change == MODE_INVALID)
-       error (1, 0, _("invalid mode"));
+       error (EXIT_FAILURE, 0, _("invalid mode"));
       else if (change == MODE_MEMORY_EXHAUSTED)
        xalloc_die ();
       newmode = mode_adjust (newmode, change);
@@ -186,20 +186,22 @@ numbers must be specified"));
 
        if (xstrtoumax (s_major, NULL, 0, &i_major, NULL) != LONGINT_OK
            || i_major != (major_t) i_major)
-         error (1, 0, _("invalid major device number %s"), quote (s_major));
+         error (EXIT_FAILURE, 0,
+                _("invalid major device number %s"), quote (s_major));
 
        if (xstrtoumax (s_minor, NULL, 0, &i_minor, NULL) != LONGINT_OK
            || i_minor != (minor_t) i_minor)
-         error (1, 0, _("invalid minor device number %s"), quote (s_minor));
+         error (EXIT_FAILURE, 0,
+                _("invalid minor device number %s"), quote (s_minor));
 
        device = makedev (i_major, i_minor);
 #ifdef NODEV
        if (device == NODEV)
-         error (1, 0, _("invalid device %s %s"), s_major, s_minor);
+         error (EXIT_FAILURE, 0, _("invalid device %s %s"), s_major, s_minor);
 #endif
 
        if (mknod (argv[optind], newmode | node_type, device) != 0)
-         error (1, errno, "%s", quote (argv[optind]));
+         error (EXIT_FAILURE, errno, "%s", quote (argv[optind]));
       }
       break;
 
@@ -214,7 +216,7 @@ major and minor device numbers may not be specified for fifo files"));
          usage (1);
        }
       if (mkfifo (argv[optind], newmode))
-       error (1, errno, "%s", quote (argv[optind]));
+       error (EXIT_FAILURE, errno, "%s", quote (argv[optind]));
 #endif
       break;
 
index c7ff18d..13122d9 100644 (file)
@@ -106,7 +106,7 @@ main (int argc, char **argv)
          && posix2_version () < 200112)
        {
          if (xstrtol (&s[2], NULL, 10, &adjustment, "") != LONGINT_OK)
-           error (1, 0, _("invalid option `%s'"), s);
+           error (EXIT_FAILURE, 0, _("invalid option `%s'"), s);
 
          minusflag = 1;
          adjustment_given = 1;
@@ -119,7 +119,7 @@ main (int argc, char **argv)
          if (s[1] == '+')
            ++s;
          if (xstrtol (&s[1], NULL, 10, &adjustment, "") != LONGINT_OK)
-           error (1, 0, _("invalid option `%s'"), s);
+           error (EXIT_FAILURE, 0, _("invalid option `%s'"), s);
 
          minusflag = 0;
          adjustment_given = 1;
@@ -144,7 +144,7 @@ main (int argc, char **argv)
                case 'n':
                  if (xstrtol (optarg, NULL, 10, &adjustment, "")
                      != LONGINT_OK)
-                   error (1, 0, _("invalid priority `%s'"), optarg);
+                   error (EXIT_FAILURE, 0, _("invalid priority `%s'"), optarg);
 
                  minusflag = 0;
                  adjustment_given = 1;
@@ -175,7 +175,7 @@ main (int argc, char **argv)
       errno = 0;
       current_priority = GET_PRIORITY ();
       if (current_priority == -1 && errno != 0)
-       error (1, errno, _("cannot get priority"));
+       error (EXIT_FAILURE, errno, _("cannot get priority"));
       printf ("%d\n", current_priority);
       exit (0);
     }
@@ -184,12 +184,12 @@ main (int argc, char **argv)
   errno = 0;
   current_priority = GET_PRIORITY ();
   if (current_priority == -1 && errno != 0)
-    error (1, errno, _("cannot get priority"));
+    error (EXIT_FAILURE, errno, _("cannot get priority"));
   if (setpriority (PRIO_PROCESS, 0, current_priority + adjustment))
 #else
   if (nice (adjustment) == -1)
 #endif
-    error (1, errno, _("cannot set priority"));
+    error (EXIT_FAILURE, errno, _("cannot set priority"));
 
   execvp (argv[i], &argv[i]);
 
index 6377d48..d25317e 100644 (file)
@@ -444,7 +444,7 @@ short_pinky (const char *filename,
   int fail = read_utmp (filename, &n_users, &utmp_buf);
 
   if (fail)
-    error (1, errno, "%s", filename);
+    error (EXIT_FAILURE, errno, "%s", filename);
 
   scan_entries (n_users, utmp_buf, argc_names, argv_names);
 }
index 8496446..38e02c9 100644 (file)
@@ -248,7 +248,7 @@ print_esc (const char *escstart)
           ++esc_length, ++p)
        esc_value = esc_value * 16 + hextobin (*p);
       if (esc_length == 0)
-       error (1, 0, _("missing hexadecimal number in escape"));
+       error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
       putchar (esc_value);
     }
   else if (*p == '0')
@@ -272,7 +272,7 @@ print_esc (const char *escstart)
           --esc_length, ++p)
        {
          if (!ISXDIGIT (*p))
-           error (1, 0, _("missing hexadecimal number in escape"));
+           error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape"));
          uni_value = uni_value * 16 + hextobin (*p);
        }
 
@@ -284,13 +284,13 @@ print_esc (const char *escstart)
       if ((uni_value >= 0x00 && uni_value <= 0x9f
           && uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60)
          || (uni_value >= 0xd800 && uni_value <= 0xdfff))
-       error (1, 0, _("invalid universal character name \\%c%0*x"),
+       error (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"),
               esc_char, (esc_char == 'u' ? 4 : 8), uni_value);
 
       print_unicode_char (stdout, uni_value, 0);
     }
   else
-    error (1, 0, _("\\%c: invalid escape"), *p);
+    error (EXIT_FAILURE, 0, _("\\%c: invalid escape"), *p);
   return p - escstart - 1;
 }
 
@@ -498,7 +498,7 @@ print_formatted (const char *format, int argc, char **argv)
              ++direc_length;
            }
          if (!strchr ("diouxXfeEgGcs", *f))
-           error (1, 0, _("%%%c: invalid directive"), *f);
+           error (EXIT_FAILURE, 0, _("%%%c: invalid directive"), *f);
          ++direc_length;
          if (argc > 0)
            {
index 7b94113..6a4ce2a 100644 (file)
--- a/src/pwd.c
+++ b/src/pwd.c
@@ -76,7 +76,7 @@ main (int argc, char **argv)
 
   wd = xgetcwd ();
   if (wd == NULL)
-    error (1, errno, _("cannot get current directory"));
+    error (EXIT_FAILURE, errno, _("cannot get current directory"));
   printf ("%s\n", wd);
 
   exit (0);
index fb77dca..da2b788 100644 (file)
@@ -1556,7 +1556,7 @@ main (int argc, char **argv)
                || (word32) tmp != tmp
                || ((size_t) (tmp * sizeof (int)) / sizeof (int) != tmp))
              {
-               error (1, 0, _("%s: invalid number of passes"),
+               error (EXIT_FAILURE, 0, _("%s: invalid number of passes"),
                       quotearg_colon (optarg));
              }
            flags.n_iterations = (size_t) tmp;
@@ -1573,7 +1573,7 @@ main (int argc, char **argv)
            if (xstrtoumax (optarg, NULL, 0, &tmp, "cbBkKMGTPEZY0")
                != LONGINT_OK)
              {
-               error (1, 0, _("%s: invalid file size"),
+               error (EXIT_FAILURE, 0, _("%s: invalid file size"),
                       quotearg_colon (optarg));
              }
            flags.size = tmp;
index 57be102..62b1f16 100644 (file)
@@ -173,7 +173,7 @@ clock_get_realtime (struct timespec *ts)
 #endif
 
   if (fail)
-    error (1, errno, _("cannot read realtime clock"));
+    error (EXIT_FAILURE, errno, _("cannot read realtime clock"));
 
   return ts;
 }
index 3fe28c0..ed9ec55 100644 (file)
@@ -1,5 +1,5 @@
 /* stty -- change and print terminal line settings
-   Copyright (C) 1990-2001 Free Software Foundation, Inc.
+   Copyright (C) 1990-2002 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
@@ -900,10 +900,10 @@ mutually exclusive"));
       device_name = file_name;
       fd = open (device_name, O_RDONLY | O_NONBLOCK);
       if (fd < 0)
-       error (1, errno, "%s", device_name);
+       error (EXIT_FAILURE, errno, "%s", device_name);
       if ((fdflags = fcntl (fd, F_GETFL)) == -1
          || fcntl (fd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
-       error (1, errno, _("%s: couldn't reset non-blocking mode"),
+       error (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"),
               device_name);
     }
   else
@@ -916,7 +916,7 @@ mutually exclusive"));
      spurious difference in an uninitialized portion of the structure.  */
   memset (&mode, 0, sizeof (mode));
   if (tcgetattr (fd, &mode))
-    error (1, errno, "%s", device_name);
+    error (EXIT_FAILURE, errno, "%s", device_name);
 
   if (verbose_output || recoverable_output || noargs)
     {
@@ -1078,7 +1078,7 @@ mutually exclusive"));
       struct termios new_mode;
 
       if (tcsetattr (fd, TCSADRAIN, &mode))
-       error (1, errno, "%s", device_name);
+       error (EXIT_FAILURE, errno, "%s", device_name);
 
       /* POSIX (according to Zlotnick's book) tcsetattr returns zero if
         it performs *any* of the requested operations.  This means it
@@ -1091,7 +1091,7 @@ mutually exclusive"));
         spurious difference in an uninitialized portion of the structure.  */
       memset (&new_mode, 0, sizeof (new_mode));
       if (tcgetattr (fd, &new_mode))
-       error (1, errno, "%s", device_name);
+       error (EXIT_FAILURE, errno, "%s", device_name);
 
       /* Normally, one shouldn't use memcmp to compare structures that
         may have `holes' containing uninitialized data, but we have been
@@ -1116,7 +1116,7 @@ mutually exclusive"));
          if (speed_was_set || memcmp (&mode, &new_mode, sizeof (mode)) != 0)
 #endif
            {
-             error (1, 0,
+             error (EXIT_FAILURE, 0,
                     _("%s: unable to perform all requested operations"),
                     device_name);
 #ifdef TESTING
@@ -1397,7 +1397,7 @@ set_window_size (int rows, int cols, int fd, const char *device_name)
   if (get_win_size (fd, &win))
     {
       if (errno != EINVAL)
-       error (1, errno, "%s", device_name);
+       error (EXIT_FAILURE, errno, "%s", device_name);
       memset (&win, 0, sizeof (win));
     }
 
@@ -1439,16 +1439,16 @@ set_window_size (int rows, int cols, int fd, const char *device_name)
       win.ws_col = 1;
 
       if (ioctl (fd, TIOCSWINSZ, (char *) &win))
-       error (1, errno, "%s", device_name);
+       error (EXIT_FAILURE, errno, "%s", device_name);
 
       if (ioctl (fd, TIOCSSIZE, (char *) &ttysz))
-       error (1, errno, "%s", device_name);
+       error (EXIT_FAILURE, errno, "%s", device_name);
       return;
     }
 # endif
 
   if (ioctl (fd, TIOCSWINSZ, (char *) &win))
-    error (1, errno, "%s", device_name);
+    error (EXIT_FAILURE, errno, "%s", device_name);
 }
 
 static void
@@ -1459,9 +1459,10 @@ display_window_size (int fancy, int fd, const char *device_name)
   if (get_win_size (fd, &win))
     {
       if (errno != EINVAL)
-       error (1, errno, "%s", device_name);
+       error (EXIT_FAILURE, errno, "%s", device_name);
       if (!fancy)
-       error (1, 0, _("%s: no size information for this device"), device_name);
+       error (EXIT_FAILURE, 0,
+              _("%s: no size information for this device"), device_name);
     }
   else
     {
index 3d83467..5b1328c 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -347,13 +347,13 @@ change_identity (const struct passwd *pw)
 #ifdef HAVE_INITGROUPS
   errno = 0;
   if (initgroups (pw->pw_name, pw->pw_gid) == -1)
-    error (1, errno, _("cannot set groups"));
+    error (EXIT_FAILURE, errno, _("cannot set groups"));
   endgrent ();
 #endif
   if (setgid (pw->pw_gid))
-    error (1, errno, _("cannot set group id"));
+    error (EXIT_FAILURE, errno, _("cannot set group id"));
   if (setuid (pw->pw_uid))
-    error (1, errno, _("cannot set user id"));
+    error (EXIT_FAILURE, errno, _("cannot set user id"));
 }
 
 /* Run SHELL, or DEFAULT_SHELL if SHELL is empty.
@@ -526,7 +526,7 @@ main (int argc, char **argv)
 
   pw = getpwnam (new_user);
   if (pw == 0)
-    error (1, 0, _("user %s does not exist"), new_user);
+    error (EXIT_FAILURE, 0, _("user %s does not exist"), new_user);
   endpwent ();
 
   /* Make sure pw->pw_shell is non-NULL.  It may be NULL when NEW_USER
@@ -549,7 +549,7 @@ main (int argc, char **argv)
 #ifdef SYSLOG_FAILURE
       log_su (pw, 0);
 #endif
-      error (1, 0, _("incorrect password"));
+      error (EXIT_FAILURE, 0, _("incorrect password"));
     }
 #ifdef SYSLOG_SUCCESS
   else
index 8e21d1c..e8e41ae 100644 (file)
@@ -54,7 +54,7 @@ buf_init_from_stdin (Buf *x, int eol_byte)
        }
       bytes_read = full_read (STDIN_FILENO, buf, BUFFER_SIZE);
       if (bytes_read < 0)
-       error (1, errno, _("read error"));
+       error (EXIT_FAILURE, errno, _("read error"));
 
       {
        struct B_pair bp;
index 773f32c..c1d6034 100644 (file)
@@ -397,15 +397,16 @@ xlseek (int fd, off_t offset, int whence, char const *filename)
   switch (whence)
     {
     case SEEK_SET:
-      error (1, errno, _("%s: cannot seek to offset %s%s"),
+      error (EXIT_FAILURE, errno, _("%s: cannot seek to offset %s%s"),
             filename, sign, s);
       break;
     case SEEK_CUR:
-      error (1, errno, _("%s: cannot seek to relative offset %s%s"),
+      error (EXIT_FAILURE, errno, _("%s: cannot seek to relative offset %s%s"),
             filename, sign, s);
       break;
     case SEEK_END:
-      error (1, errno, _("%s: cannot seek to end-relative offset %s%s"),
+      error (EXIT_FAILURE, errno,
+            _("%s: cannot seek to end-relative offset %s%s"),
             filename, sign, s);
       break;
     default:
index 6fdd5f7..f89f298 100644 (file)
--- a/src/tee.c
+++ b/src/tee.c
@@ -148,7 +148,7 @@ main (int argc, char **argv)
 
   errs = tee (argc - optind, (const char **) &argv[optind]);
   if (close (STDIN_FILENO) != 0)
-    error (1, errno, _("standard input"));
+    error (EXIT_FAILURE, errno, _("standard input"));
 
   exit (errs);
 }
index 2cbe761..836277e 100644 (file)
@@ -302,7 +302,7 @@ main (int argc, char **argv)
          flexible_date++;
          newtime = get_date (optarg, NULL);
          if (newtime == (time_t) -1)
-           error (1, 0, _("invalid date format %s"), quote (optarg));
+           error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (optarg));
          date_set++;
          break;
 
@@ -322,7 +322,7 @@ main (int argc, char **argv)
          posix_date++;
          if (! posixtime (&newtime, optarg,
                           PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS))
-           error (1, 0, _("invalid date format %s"), quote (optarg));
+           error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (optarg));
          date_set++;
          break;
 
@@ -353,7 +353,8 @@ main (int argc, char **argv)
   if (use_ref)
     {
       if (stat (ref_file, &ref_stats))
-       error (1, errno, _("failed to get attributes of %s"), quote (ref_file));
+       error (EXIT_FAILURE, errno,
+              _("failed to get attributes of %s"), quote (ref_file));
       date_set++;
     }
 
index 3b94037..e35abfb 100644 (file)
@@ -223,7 +223,7 @@ main (int argc, char **argv)
       struct utsname name;
 
       if (uname (&name) == -1)
-       error (1, errno, _("cannot get system name"));
+       error (EXIT_FAILURE, errno, _("cannot get system name"));
 
       if (toprint & PRINT_KERNEL_NAME)
        print_element (name.sysname);
index 5c644c4..a2468e3 100644 (file)
@@ -126,7 +126,7 @@ print_uptime (int n, const STRUCT_UTMP *this)
 #endif
     {
       if (boot_time == 0)
-       error (1, errno, _("couldn't get boot time"));
+       error (EXIT_FAILURE, errno, _("couldn't get boot time"));
       uptime = time_now - boot_time;
     }
   updays = uptime / 86400;
@@ -175,7 +175,7 @@ uptime (const char *filename)
   int fail = read_utmp (filename, &n_users, &utmp_buf);
 
   if (fail)
-    error (1, errno, "%s", filename);
+    error (EXIT_FAILURE, errno, "%s", filename);
 
   print_uptime (n_users, utmp_buf);
 }
index 6067724..83192ae 100644 (file)
@@ -102,7 +102,7 @@ users (const char *filename)
   int fail = read_utmp (filename, &n_users, &utmp_buf);
 
   if (fail)
-    error (1, errno, "%s", filename);
+    error (EXIT_FAILURE, errno, "%s", filename);
 
   list_entries_users (n_users, utmp_buf);
 }
index 95db2d5..4f8deff 100644 (file)
--- a/src/who.c
+++ b/src/who.c
@@ -555,7 +555,7 @@ who (const char *filename)
   int fail = read_utmp (filename, &n_users, &utmp_buf);
 
   if (fail)
-    error (1, errno, "%s", filename);
+    error (EXIT_FAILURE, errno, "%s", filename);
 
   if (short_list)
     list_entries_who (n_users, utmp_buf);