/* 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
#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"
# 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 '-'
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
"), 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);
}
atexit (cleanup);
- exit_failure = SORT_FAILURE;
+ initialize_exit_failure (SORT_FAILURE);
atexit (close_stdout);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
have_read_stdin = false;
inittables ();
- /* Change the way library functions fail. */
- exit_failure = SORT_FAILURE;
-
#ifdef SA_NOCLDSTOP
{
unsigned int i;