Subject: strange setlocale() issue
To: None <tech-userlevel@NetBSD.org>
From: Markus Illenseer <markus@core.de>
List: tech-userlevel
Date: 10/13/2003 22:46:56
This small programm does not work as expected:

#include <stdio.h>
#include <locale.h>

int main(void)
{
        const char *foo = "bar";
        printf("Start\n");
        if( NULL == setlocale(LC_ALL, "zh_TW.eucTW") )
        {
                printf("Start1\n");
                /* yes, I know, the 2nd argument should not be NULL */
                printf("error! locale is: %s\n", setlocale(LC_ALL, NULL));
        }
        else
        {
                printf("Start2\n");
                printf("OK %s\n", foo);
        }
        printf("End\n");
}

 It does print "Start" and then exits (!) with no error, coredump or
whatsoever. The other printf() commands are completely ignored, which
makes me believe, that the setlocale() in the if-clause crashes. A ktrace,
ktruss and gdb trace did not reveal anything, though.

 Any idea what might happen here?

 I am hunting down this bug for several days now, which started as a crash
of my Apache/PHP when using the above setlocale().

Markus Illenseer