summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-01-22 20:55:26 +0000
committerJim Meyering <jim@meyering.net>2004-01-22 20:55:26 +0000
commit0d9b52c3c2cd2c2d41978d33a32146d6cdb1d47c (patch)
tree6bcf61f74c605948f44526cefd63a801bc579172 /src/sort.c
parent3d8656e3e23ad73f25004702ed9359da3ff260f4 (diff)
downloadcoreutils-0d9b52c3c2cd2c2d41978d33a32146d6cdb1d47c.tar.xz
(usage): Use EXIT_SUCCESS, not 0, for clarity.
(main): Use initialize_exit_failure rather than setting exit_failure directly; this optimizes away redundant assignments. Don't include <assert.h>. (SORT_OUT_OF_ORDER, SORT_FAILURE): Now enums, not macros. (usage): Don't use 'assert'. (main): Remove redundant assignment to exit_failure.
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/sort.c b/src/sort.c
index 547d7893a..1ad3e06c9 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1,5 +1,5 @@
/* sort - sort lines of text (with all kinds of options).
- Copyright (C) 88, 1991-2003 Free Software Foundation, Inc.
+ Copyright (C) 88, 1991-2004 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
@@ -27,10 +27,8 @@
#include <sys/types.h>
#include <signal.h>
#include <stdio.h>
-#include <assert.h>
#include "system.h"
#include "error.h"
-#include "exitfail.h"
#include "hard-locale.h"
#include "inttostr.h"
#include "long-options.h"
@@ -73,13 +71,17 @@ double strtod ();
# define DEFAULT_TMPDIR "/tmp"
#endif
-/* Use this as exit status in case of error, not EXIT_FAILURE. This
- is necessary because EXIT_FAILURE is usually 1 and POSIX requires
- that sort exit with status 1 IFF invoked with -c and the input is
- not properly sorted. Any other irregular exit must exit with a
- status code greater than 1. */
-#define SORT_FAILURE 2
-#define SORT_OUT_OF_ORDER 1
+/* Exit statuses. */
+enum
+ {
+ /* POSIX says to exit with status 1 if invoked with -c and the
+ input is not properly sorted. */
+ SORT_OUT_OF_ORDER = 1,
+
+ /* POSIX says any other irregular exit must exit with a status
+ code greater than 1. */
+ SORT_FAILURE = 2
+ };
#define C_DECIMAL_POINT '.'
#define NEGATION_SIGN '-'
@@ -266,7 +268,7 @@ static void sortlines_temp (struct line *, size_t, struct line *);
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -340,10 +342,7 @@ native byte values.\n\
"), stdout );
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- /* Don't use EXIT_FAILURE here in case it is defined to be 1.
- POSIX requires that sort return 1 IFF invoked with -c and
- the input is not properly sorted. */
- assert (status == 0 || status == SORT_FAILURE);
+
exit (status);
}
@@ -2240,7 +2239,7 @@ main (int argc, char **argv)
atexit (cleanup);
- exit_failure = SORT_FAILURE;
+ initialize_exit_failure (SORT_FAILURE);
atexit (close_stdout);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
@@ -2270,9 +2269,6 @@ main (int argc, char **argv)
have_read_stdin = false;
inittables ();
- /* Change the way library functions fail. */
- exit_failure = SORT_FAILURE;
-
#ifdef SA_NOCLDSTOP
{
unsigned int i;