coreutils
[Top][All Lists]
Advanced

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

Re: [coreutils] [PATCH] sort: don't assume ASCII when parsing K, M, G su


From: Pádraig Brady
Subject: Re: [coreutils] [PATCH] sort: don't assume ASCII when parsing K, M, G suffixes
Date: Mon, 26 Jul 2010 23:38:30 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 26/07/10 20:14, Paul Eggert wrote:
> * src/sort.c (find_unit_order): Don't assume ASCII.
> ---
>  src/sort.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/src/sort.c b/src/sort.c
> index 577521d..1fd4ce7 100644
> --- a/src/sort.c
> +++ b/src/sort.c
> @@ -1818,7 +1818,11 @@ find_unit_order (char const *number, struct keyfield 
> *key, char const **endptr)
>  {
>    static char const orders[UCHAR_LIM] =
>      {
> -#if SOME_DAY_WE_WILL_REQUIRE_C99
> +#if ! ('K' == 75 && 'M' == 77 && 'G' == 71 && 'T' == 84 && 'P' == 80 \
> +       && 'E' == 69 && 'Z' == 90 && 'Y' == 89 && 'k' == 107)
> +      /* This initializer syntax works on all C99 hosts.  For now, use
> +         it only on non-ASCII hosts, to ease the pain of porting to
> +         pre-C99 ASCII hosts.  */
>        ['K']=1, ['M']=2, ['G']=3, ['T']=4, ['P']=5, ['E']=6, ['Z']=7, ['Y']=8,
>        ['k']=1,
>  #else

Good one. That tries the C99 syntax where it's needed.
The alternative below would not try the C99 syntax on
non C99 EBCIDIC hosts and so fail silently.

#if __STDC_VERSION__ >= 199901L || __GNUC__

cheers,
Pádraig.



reply via email to

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