bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'c-strcase'


From: Paul Eggert
Subject: Re: new module 'c-strcase'
Date: Mon, 10 Oct 2005 12:55:32 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> More precisely, one of the string arguments must be an ASCII string;
> the other one can also contain non-ASCII characters (but then the
> comparison result will be nonzero).

Why is this restriction needed?  Doesn't the code simply
compare bytes after converting 'A'-'Z' to 'a'-'z'?  In that case,
it is not really required that one argument must be an ASCII string;
both strings can be non-ASCII but the result is still well-defined.

>   return c1 - c2;

A nit: in theory this could result in integer overflow.
The following would be portable to machines where char == int.

   return UCHAR_MAX <= INT_MAX ? c1 - c2 : c1 < c2 ? -1 : c1 > c2;

Such machines do exist.  They are unlikely targets for big GNU
apps but are potential targets for this module.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]