This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

locale and pthreads do not work together


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;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]