Mercurial > hg > octave-nkf > gnulib-hg
changeset 4473:fd6696a97000
Sync with coreutils xalloc.h, xmalloc.c, xmemcoll.h, xmemcoll.c.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 22 Jul 2003 22:10:55 +0000 |
parents | 32c0ab3ac0a0 |
children | f1650b772bb6 |
files | ChangeLog lib/ChangeLog lib/xalloc.h lib/xmalloc.c lib/xmemcoll.c lib/xmemcoll.h modules/xalloc modules/xmemcoll |
diffstat | 8 files changed, 37 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-07-22 Paul Eggert <eggert@twinsun.com> + + * modules/xalloc (Depends-on): Add exitfail. + * modules/xmemcoll: Likewise. + 2003-07-20 Jim Meyering <jim@meyering.net> * modules/closeout (Depends-on): Add exitfail.
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,22 @@ +2003-07-22 Paul Eggert <eggert@twinsun.com> + + * xalloc.h (XCALLOC, XREALLOC, CCLONE): Fix under- and + over-parenthesization in macros. + + Sync with coreutils. + + * xalloc.h (XMALLOC, XCALLOC, XREALLOC): Remove casts not + required by C99. + + Use `exit_failure' for xalloc and xmemcoll instead of their own + private exit-failure variables. + * xalloc.h (xalloc_exit_failure): Remove. + * xmalloc.c: Likewise. Include exitfail.h. + (xalloc_die): Use exit_failure instead of xalloc_exit_failure. + * xmemcoll.h (xmemcoll_exit_failure): Remove. + * xmemcoll.c: Likewise. Include exitfail.h. + (xmemcoll): Use exit_failure instead of xalloc_exit_failure. + 2003-07-18 Paul Eggert <eggert@twinsun.com> * closeout.h (close_stdout_set_status, close_stdout_status): Remove.
--- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -32,11 +32,6 @@ # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # endif -/* Exit value when the requested amount of memory is not available. - It is initialized to EXIT_FAILURE, but the caller may set it to - some other value. */ -extern int xalloc_exit_failure; - /* If this pointer is non-zero, run the specified function upon each allocation failure. It is initialized to zero. */ extern void (*xalloc_fail_func) (void); @@ -47,7 +42,8 @@ extern char const xalloc_msg_memory_exhausted[]; /* This function is always triggered when memory is exhausted. It is - in charge of honoring the three previous items. This is the + in charge of honoring the two previous items. It exits with status + exit_failure (defined in exitfail.h). This is the function to call when one wants the program to die because of a memory allocation failure. */ extern void xalloc_die (void) ATTRIBUTE_NORETURN; @@ -57,10 +53,9 @@ void *xrealloc (void *p, size_t n); char *xstrdup (const char *str); -# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items))) -# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items))) -# define XREALLOC(Ptr, Type, N_items) \ - ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items))) +# define XMALLOC(Type, N_items) xmalloc (sizeof (Type) * (N_items)) +# define XCALLOC(Type, N_items) xcalloc (sizeof (Type), N_items) +# define XREALLOC(Ptr, Type, N_items) xrealloc (Ptr, sizeof (Type) * (N_items)) /* Declare and alloc memory for VAR of type TYPE. */ # define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1) @@ -74,7 +69,7 @@ /* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */ # define CCLONE(Src, Num) \ - (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num))) + (memcpy (xmalloc (sizeof *(Src) * (Num)), Src, sizeof *(Src) * (Num))) /* Return a malloc'ed copy of SRC. */ # define CLONE(Src) CCLONE (Src, 1)
--- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -37,6 +37,7 @@ #define N_(msgid) msgid #include "error.h" +#include "exitfail.h" #include "xalloc.h" #ifndef EXIT_FAILURE @@ -53,10 +54,6 @@ "you must run the autoconf test for a GNU libc compatible realloc" #endif -/* Exit value when the requested amount of memory is not available. - The caller may set it to some other value. */ -int xalloc_exit_failure = EXIT_FAILURE; - /* If non NULL, call this function when memory is exhausted. */ void (*xalloc_fail_func) (void) = 0; @@ -69,7 +66,7 @@ { if (xalloc_fail_func) (*xalloc_fail_func) (); - error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted)); + error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted)); /* The `noreturn' cannot be given to error, since it may return if its first argument is 0. To help compilers understand the xalloc_die does terminate, call exit. */
--- a/lib/xmemcoll.c +++ b/lib/xmemcoll.c @@ -1,5 +1,5 @@ /* Locale-specific memory comparison. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 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 @@ -32,14 +32,11 @@ #define _(msgid) gettext (msgid) #include "error.h" +#include "exitfail.h" #include "memcoll.h" #include "quotearg.h" #include "xmemcoll.h" -/* Exit value when xmemcoll fails. - The caller may set it to some other value. */ -int xmemcoll_exit_failure = EXIT_FAILURE; - /* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according to the LC_COLLATE locale. S1 and S2 do not overlap, and are not adjacent. Temporarily modify the bytes after S1 and S2, but @@ -56,7 +53,7 @@ { error (0, collation_errno, _("string comparison failed")); error (0, 0, _("Set LC_ALL='C' to work around the problem.")); - error (xmemcoll_exit_failure, 0, + error (exit_failure, 0, _("The strings compared were %s and %s."), quotearg_n_style_mem (0, locale_quoting_style, s1, s1len), quotearg_n_style_mem (1, locale_quoting_style, s2, s2len));
--- a/lib/xmemcoll.h +++ b/lib/xmemcoll.h @@ -1,3 +1,2 @@ #include <stddef.h> -extern int xmemcoll_exit_failure; int xmemcoll (char *, size_t, char *, size_t);