bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: thousands separator


From: Gary Ashburn
Subject: Re: thousands separator
Date: Thu, 09 Jul 2009 00:32:22 -0400

the little heart is right but I'm not sure where I got "char 142" from.

loc.grouping seems to be blank with "gcc grouping.c" and "3" with gcc -mno-cygwin grouping.c

~/thoussep> vi grouping.c
~/thoussep> gcc grouping.c
~/thoussep> a
thousands_sep =
~/thoussep>
~/thoussep> gcc -mno-cygwin grouping.c
~/thoussep> a
thousands_sep = ,
loc.grouping[0] = 3
~/thoussep>



At 04:09 PM 7/8/2009, Aharon Robbins wrote:
Hi All.

> Date: Wed, 08 Jul 2009 20:16:24 +0300
> From: Eli Zaretskii <address@hidden>
> Subject: Re: thousands separator
> To: Aharon Robbins <address@hidden>
> Cc: address@hidden, address@hidden
>
> > Date: Wed, 08 Jul 2009 08:22:30 +0300
> > From: Aharon Robbins <address@hidden>
> > Cc: address@hidden, address@hidden
> >
> > > So I'm beginning to suspect that there's a bug in Gawk, after all.
> >
> > Eli,
> >
> > What do you get for
> >
> >     BEGIIN { printf("%'d\n", 1234567 }
> >
> > A random character each time?
>
> No, I get the same result, "1234567", every time.  But the thousands
> separator printed by your test program is a comma.

Strange. There is still something weird going on. The "grouping" field
is actually supposed to be an array of small values.  A new program
is below. Here is what the output looks like on my Linux box:

        $ LC_ALL=en_US.UTF-8 ./thousep
        thousands_sep = ,
        loc.grouping[0] = 3
        loc.grouping[1] = 3

I'd like to know what we get on XP and on Vista.

Thanks,

Arnold
------------------- thousep.c ----------------
#include <stdio.h>
#include <limits.h>
#include <locale.h>

struct lconv loc;               /* current locale */

int
main(int argc, char **argv)
{
        int i;

        setlocale(LC_NUMERIC, "");
        loc = *localeconv();

        printf("thousands_sep = %s\n", loc.thousands_sep);
for (i = 0; i < 12 && loc.grouping[i] != 0 && loc.grouping[i] != CHAR_MAX; i++) {
                printf("loc.grouping[%d] = %d\n", i, loc.grouping[i]);
        }
        if (loc.grouping[i] == CHAR_MAX)
                printf("loc.grouping[%d] = CHAR_MAX\n", i);

        return 0;
}






reply via email to

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