Paul Eggert <[EMAIL PROTECTED]> wrote: > The letter from Andreas about 'uniq' prompted me to look for other > instances of 'strcoll' in coreutils. I found two problematic > instances, both in expr.c. One instance should be strcmp; the other > instance should report an error if strcoll fails. While looking at > expr.c I noticed another problem with POSIX conformance: it doesn't > distinguish between exit status 2 and 3 as POSIX 1003.1-2001 requires. > > Here is a proposed patch for both problems. > > diff -pru coreutils/ChangeLog coreutils-strcoll/ChangeLog > --- coreutils/ChangeLog Mon Jul 14 23:55:22 2003 > +++ coreutils-strcoll/ChangeLog Thu Jul 17 14:47:27 2003 > @@ -1,3 +1,22 @@ > +2003-07-17 Paul Eggert <[EMAIL PROTECTED]> > + > + * src/expr.c: Include "exitfail.h", "quotearg.h". > + (EXPR_INVALID, EXPR_ERROR): New constants. > + (nomoreargs, null, toarith, nextarg): Return bool, not int. > + (syntax_error): New function, exiting with status 2. Use it > + insteading of printing "syntax error" ourselves. > + (main): Initialize exit_failure to EXPR_ERROR. > + Exit with EXPR_INVALID on syntax error (too few arguments). > + (nextarg): Use strcmp, not strcoll; strcoll might return > + an undesirable 0, or might fail. > + (docolon, eval4, eval3): Exit with status 3 on invalid argument type > + or other such error. > + (eval2): Report an error if strcoll fails in a string comparison. > + * src/sort.c: Include "exitfail.h". > + (main): Set exit_failure, not xalloc_exit_failure and > + xmemcoll_exit_failure. > + * tests/expr/basic: Invalid value exits with status 3, not 2.
Thanks a lot! I've applied nearly all of that. The sole exception is this hunk: > diff -pru coreutils/lib/xalloc.h coreutils-strcoll/lib/xalloc.h > --- coreutils/lib/xalloc.h Wed Jun 18 01:10:03 2003 > +++ coreutils-strcoll/lib/xalloc.h Thu Jul 17 11:30:11 2003 ... > @@ -56,10 +53,10 @@ void *xcalloc (size_t n, size_t s); > void *xrealloc (void *p, size_t n); > char *xstrdup (const char *str); > > -# 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)) > +# 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))) > > /* Declare and alloc memory for VAR of type TYPE. */ > # define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1) I suspect you did not mean to reintroduce those anachronistic casts. _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-coreutils
