Exit-status fixes from coreutils.
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Jan 2004 07:22:33 +0000 (07:22 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Jan 2004 07:22:33 +0000 (07:22 +0000)
ChangeLog
lib/ChangeLog
lib/argmatch.c
lib/argmatch.h
lib/long-options.c
lib/obstack.c
lib/xstrtol.h
modules/argmatch
modules/obstack
modules/xstrtol

index 1323ac0..90e9a71 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-01-23  Paul Eggert  <eggert@twinsun.com>
+
+       * modules/argmatch, modules/obstack, modules/xstrtol:
+       Depend on exitfail.
+
 2004-01-20  Bruno Haible  <bruno@clisp.org>
 
        * modules/setenv: Depend on allocsa instead of alloca.
index 1efa890..6a0abc6 100644 (file)
@@ -1,3 +1,23 @@
+2004-01-23  Paul Eggert  <eggert@twinsun.com>
+
+       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  <jim@meyering.net>
 
        * 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  <eggert@twinsun.com>
+
+       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  <bruno@clisp.org>
 
        Safer stack allocation.
index 972a085..210689b 100644 (file)
@@ -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
index deb908f..e8bb23c 100644 (file)
@@ -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;
 
index ada070e..1c4e74a 100644 (file)
@@ -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':
          {
index d8bea0a..123a7a5 100644 (file)
@@ -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 <obstack.h>
+# include <obstack.h>
 #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 <stdlib.h>
-# 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
 \f
 int
 _obstack_memory_used (struct obstack *h)
index f3b9295..5765c88 100644 (file)
@@ -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 <inttypes.h>
@@ -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)
index 9ee248e..87a5380 100644 (file)
@@ -12,6 +12,7 @@ quotearg
 quote
 unlocked-io
 exit
+exitfail
 
 configure.ac:
 
index 9406f53..c916a26 100644 (file)
@@ -9,6 +9,7 @@ m4/obstack.m4
 Depends-on:
 gettext
 exit
+exitfail
 
 configure.ac:
 gl_OBSTACK
index 904aaa8..a3e53c1 100644 (file)
@@ -14,6 +14,7 @@ m4/intmax_t.m4
 m4/xstrtol.m4
 
 Depends-on:
+exitfail
 
 configure.ac:
 gl_XSTRTOL