Bug#287801: Bug? setlocale() can't find the right data file while run through rc.d during reboot
Package: glibc
Version: 2.3.2-95.20.1AX
I am root and using Linux 2.4.21-9.38AX i686(Miracle3.0) with
glibc-2.3.2-95.20.1AX
When I used the following code in a program and start it in rc3.d(such
as S99abc, the last one in the rc3.d)
#define _(String) gettext(String)
strcpy(moname,"test");
setlocale(LC_ALL, "ja_JP");
bindtextdomain(moname, "/home/local/mo");
textdomain(moname);
memset(uid, 0, MAX_LINE);
memset(lpBuffer, 0, 1000);;
strcpy(uid, "0xC0040903");
strcpy(lpBuffer, _(uid));
the dir structure of /usr/local/mo is list below:
/home/local/mo
-|en_US
-|LC_MESSAGES
-|ja_JP
-|LC_MESSAGES
when I reboot the machine, gettext("0xC0040903") return the string
defined in en_US .mo file instead of in ja_JP .mo file.
But when I run the same program after reboot(say, through shell) ,it
return the right string that define in ja_JP .mo file.
-----Test program-------
#include <stdarg.h>
#include <dlfcn.h>
#include <ctype.h>
#include <stdio.h>
#include <syslog.h>
#include <sys/types.h>
#include <unistd.h>
#include <libintl.h>
#include <locale.h>
#define MAX_LINE 64
#define _(String) gettext(String)
int main(int argc ,char * argv[])
{
char moname[MAX_LINE];
char uid[MAX_LINE];
char lpBuffer[1000];
memset(moname,0,MAX_LINE);
strcpy(moname,"test");
setlocale(LC_ALL, "ja_JP");
bindtextdomain(moname, "/home/local/mo");
textdomain(moname);
memset(uid, 0, MAX_LINE);
memset(lpBuffer, 0, 1000);
strcpy(uid, "0xC0040903");
strcpy(lpBuffer, _(uid));
printf("lpBuffer = %s\n",lpBuffer);
syslog(6,"lpBuffer = %s",lpBuffer);
return strlen(lpBuffer);
}
Reply to: