From e89390843fe30c85bba83fe7bc90fdfdfa15e253 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 24 Jan 2004 07:22:33 +0000 Subject: [PATCH] Exit-status fixes from coreutils. --- ChangeLog | 5 +++++ lib/ChangeLog | 37 +++++++++++++++++++++++++++++++++++++ lib/argmatch.c | 7 ++++--- lib/argmatch.h | 6 ++++-- lib/long-options.c | 6 +++--- lib/obstack.c | 23 +++++++++++++---------- lib/xstrtol.h | 6 ++++-- modules/argmatch | 1 + modules/obstack | 1 + modules/xstrtol | 1 + 10 files changed, 73 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1323ac07b..90e9a716c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-01-23 Paul Eggert + + * modules/argmatch, modules/obstack, modules/xstrtol: + Depend on exitfail. + 2004-01-20 Bruno Haible * modules/setenv: Depend on allocsa instead of alloca. diff --git a/lib/ChangeLog b/lib/ChangeLog index 1efa890a1..6a0abc6a8 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,23 @@ +2004-01-23 Paul Eggert + + Exit-status fix from coreutils. + + Use exit_failure consistently in place of EXIT_FAILURE, + so that program exit statuses are consistent on failure. + + * argmatch.c (ARGMATCH_DIE) [! defined ARGMATCH_DIE]: + Include "exitfail.h", and use exit_failure rather than EXIT_FAILURE. + * argmatch.h: Comment fix to match the above. + * obstack.c (obstack_exit_failure) [!defined _LIBC]: + Now a macro referring to exit_failure, instead of a separate + variable. Include "exitfail.h" to get it. + * xstrtol.h: Include "exitfail.h". + (STRTOL_FATAL_ERROR): Exit with status exit_failure, not 2. + + * long-options.c (parse_long_options): Use prototype + for usage function arg. Pass it EXIT_SUCCESS rather than 0, + for clarity. + 2004-01-21 Jim Meyering * mktime.c (__mktime_internal) [!_LIBC]: Define to mktime_internal @@ -6,6 +26,23 @@ * timegm.c (__mktime_internal) [!_LIBC]: Likewise. Problem building statically-linked `ls' reported by Michael Brunnbauer. +2004-01-18 Paul Eggert + + Merge from diffutils. + + * file-type.c (file_type): Add typed memory objects. + * file-type.h (S_TYPEISTMO): New macro. + + * c-stack.h (c_stack_action): Remove argv argument. + * c-stack.c (c_stack_action): Likewise. All uses changed. + (die): Don't calculate message unless segv_action returns. + (get_stack_location, min_address_from_argv, max_address_from_argv, + volatile stack_base, volatile_stack_size): Remove. + (segv_handler): If ! HAVE_XSI_STACK_OVERFLOW_HEURISTIC, assume + that every segmentation violation is a stack overflow. (Ouch!) + See Debian bug 136249 (still outstanding) for more info about why + HAVE_XSI_STACK_OVERFLOW_HEURISTIC fails on Linux kernels. + 2003-11-30 Bruno Haible Safer stack allocation. diff --git a/lib/argmatch.c b/lib/argmatch.c index 972a085e9..210689ba3 100644 --- a/lib/argmatch.c +++ b/lib/argmatch.c @@ -1,7 +1,7 @@ /* argmatch.c -- find a match for a string in an array - Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003 Free Software - Foundation, Inc. + Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 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 @@ -49,7 +49,8 @@ /* Non failing version of argmatch call this function after failing. */ #ifndef ARGMATCH_DIE -# define ARGMATCH_DIE exit (EXIT_FAILURE) +# include "exitfail.h" +# define ARGMATCH_DIE exit (exit_failure) #endif #ifdef ARGMATCH_DIE_DECL diff --git a/lib/argmatch.h b/lib/argmatch.h index deb908fb9..e8bb23c66 100644 --- a/lib/argmatch.h +++ b/lib/argmatch.h @@ -1,5 +1,7 @@ /* argmatch.h -- definitions and prototypes for argmatch.c - Copyright (C) 1990, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. + + Copyright (C) 1990, 1998, 1999, 2001, 2002, 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 @@ -55,7 +57,7 @@ int argmatch (char const *arg, char const *const *arglist, /* xargmatch calls this function when it fails. This function should not return. By default, this is a function that calls ARGMATCH_DIE which - in turn defaults to `exit (EXIT_FAILURE)'. */ + in turn defaults to `exit (exit_failure)'. */ typedef void (*argmatch_exit_fn) (void); extern argmatch_exit_fn argmatch_die; diff --git a/lib/long-options.c b/lib/long-options.c index ada070eb0..1c4e74a00 100644 --- a/lib/long-options.c +++ b/lib/long-options.c @@ -1,6 +1,6 @@ /* Utility to accept --help and --version options as unobtrusively as possible. - Copyright (C) 1993, 1994, 1998, 1999, 2000, 2002, 2003 Free + Copyright (C) 1993, 1994, 1998, 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -49,7 +49,7 @@ parse_long_options (int argc, const char *command_name, const char *package, const char *version, - void (*usage_func)(), + void (*usage_func) (int), /* const char *author1, ...*/ ...) { int c; @@ -66,7 +66,7 @@ parse_long_options (int argc, switch (c) { case 'h': - (*usage_func) (0); + (*usage_func) (EXIT_SUCCESS); case 'v': { diff --git a/lib/obstack.c b/lib/obstack.c index d8bea0acd..123a7a5d4 100644 --- a/lib/obstack.c +++ b/lib/obstack.c @@ -1,7 +1,8 @@ /* obstack.c - subroutines used implicitly by object stack macros Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, - 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + 1998, 1999, 2000, 2001, 2002, 2003, 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 @@ -22,9 +23,9 @@ #endif #ifdef _LIBC -#include +# include #else -#include "obstack.h" +# include "obstack.h" #endif /* NOTE BEFORE MODIFYING THIS FILE: This version number must be @@ -86,10 +87,12 @@ void (*obstack_alloc_failed_handler) (void) = print_and_abort; /* Exit value used when `print_and_abort' is used. */ # include -# ifndef _LIBC -# include "exit.h" -# endif +# ifdef _LIBC int obstack_exit_failure = EXIT_FAILURE; +# else +# include "exitfail.h" +# define obstack_exit_failure exit_failure +# endif /* The non-GNU-C macros copy the obstack into this global variable to avoid multiple evaluation. */ @@ -286,9 +289,9 @@ _obstack_newchunk (struct obstack *h, int length) /* The new chunk certainly contains no empty object yet. */ h->maybe_empty_object = 0; } -#ifdef _LIBC +# ifdef _LIBC libc_hidden_def (_obstack_newchunk) -#endif +# endif /* Return nonzero if object OBJ has been allocated from obstack H. This is here for debugging. @@ -351,11 +354,11 @@ obstack_free (struct obstack *h, void *obj) abort (); } -#ifdef _LIBC +# ifdef _LIBC /* Older versions of libc used a function _obstack_free intended to be called by non-GCC compilers. */ strong_alias (obstack_free, _obstack_free) -#endif +# endif int _obstack_memory_used (struct obstack *h) diff --git a/lib/xstrtol.h b/lib/xstrtol.h index f3b9295f3..5765c88e2 100644 --- a/lib/xstrtol.h +++ b/lib/xstrtol.h @@ -1,6 +1,6 @@ /* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003 Free + Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -20,6 +20,8 @@ #ifndef XSTRTOL_H_ # define XSTRTOL_H_ 1 +# include "exitfail.h" + /* Get uintmax_t. */ # if HAVE_INTTYPES_H # include @@ -81,7 +83,7 @@ _DECLARE_XSTRTOL (xstrtoumax, uintmax_t) while (0) # define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \ - _STRTOL_ERROR (2, Str, Argument_type_string, Err) + _STRTOL_ERROR (exit_failure, Str, Argument_type_string, Err) # define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \ _STRTOL_ERROR (0, Str, Argument_type_string, Err) diff --git a/modules/argmatch b/modules/argmatch index 9ee248e75..87a538086 100644 --- a/modules/argmatch +++ b/modules/argmatch @@ -12,6 +12,7 @@ quotearg quote unlocked-io exit +exitfail configure.ac: diff --git a/modules/obstack b/modules/obstack index 9406f53de..c916a26ad 100644 --- a/modules/obstack +++ b/modules/obstack @@ -9,6 +9,7 @@ m4/obstack.m4 Depends-on: gettext exit +exitfail configure.ac: gl_OBSTACK diff --git a/modules/xstrtol b/modules/xstrtol index 904aaa8f5..a3e53c188 100644 --- a/modules/xstrtol +++ b/modules/xstrtol @@ -14,6 +14,7 @@ m4/intmax_t.m4 m4/xstrtol.m4 Depends-on: +exitfail configure.ac: gl_XSTRTOL -- 2.11.0