This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
locale and pthreads do not work together
- To: "glibc-linux at ricardo dot ecn dot wfu dot edu" <glibc-linux at ricardo dot ecn dot wfu dot edu>
- Subject: locale and pthreads do not work together
- From: jury gerold <gjury at grips dot com>
- Date: Wed, 07 Feb 2001 09:27:59 +0100
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
The following little program fails on various versions of glibc + linux-threads
up to version 2.2.1
I regenerated all the locales, used localedef in various ways.
Nothing helps.
As soon as the pthreads library is involved, locales refuse to work for me.
Anyone with an idea what i am doing wrong ?
Best Regards
Gerold
/*
compile with
gcc -Wall -D_REENTRANT -o formattest formattest.c -lpthread
formattest 12345 -> segfault
compile with
gcc -Wall -D_REENTRANT -o formattest formattest.c
formattest 12345 -> ok
compile with
gcc -Wall -o formattest formattest.c
formattest 12345 -> ok
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <monetary.h>
int main( int argc, char *argv[] )
{
char *fail = 0;
double d;
char rbuf[128];
if( argc < 2 ) {
printf( "usage : %s number\n", argv[0] );
return 0;
}
setlocale( LC_MONETARY, "" );
d = strtod( argv[1], &fail );
strfmon( rbuf, sizeof( rbuf ), "%n", d );
printf( "%s\n", rbuf );
return 0;
}