From 8f15281c9cf4ffcf39fd8b2fb353aa103f3a528d Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Mon, 1 Sep 2003 09:47:09 +0000 Subject: Rework a few things. --- libc/misc/intl/Makefile | 3 ++- libc/misc/intl/intl.c | 54 +++++++++++++++++++++++++++++++++++++++++++++---- libintl/intl.c | 29 ++++++++++++++++---------- 3 files changed, 70 insertions(+), 16 deletions(-) diff --git a/libc/misc/intl/Makefile b/libc/misc/intl/Makefile index 9975e5eb1..140ae31f3 100644 --- a/libc/misc/intl/Makefile +++ b/libc/misc/intl/Makefile @@ -25,7 +25,8 @@ TOPDIR=../../../ include $(TOPDIR)Rules.mak MSRC= intl.c -MOBJ= __uClibc_dgettext.o __uClibc_dcgettext.o +MOBJ= __uClibc_dgettext.o __uClibc_dcgettext.o \ + __uClibc_textdomain.o __uClibc_bindtextdomain.o # for libstd++ OBJS=$(MOBJ) diff --git a/libc/misc/intl/intl.c b/libc/misc/intl/intl.c index eca6fa96a..f3255828c 100644 --- a/libc/misc/intl/intl.c +++ b/libc/misc/intl/intl.c @@ -17,6 +17,9 @@ /* * Supply some weaks for use by strerror*(), etc. + * + * Aug 30, 2003 + * Add some hidden names to support locale-enabled libstd++. */ #include @@ -35,19 +38,62 @@ char *__uClibc_dgettext(const char *domainname, return (char *) msgid; } -weak_alias (__uClibc_dgettext, __dgettext) +weak_alias(__uClibc_dgettext, __dgettext) #endif /**********************************************************************/ #ifdef L___uClibc_dcgettext -char * __uClibc_dcgettext(const char *domainname, - const char *msgid, int category) +char *__uClibc_dcgettext(const char *domainname, + const char *msgid, int category) { return (char *) msgid; } -weak_alias (__uClibc_dcgettext, __dcgettext) +weak_alias(__uClibc_dcgettext, __dcgettext) + +#endif +/**********************************************************************/ +#ifdef L___uClibc_textdomain + +char *__uClibc_textdomain(const char *domainname) +{ + static const char default_str[] = "messages"; + + if (domainname && *domainname && strcmp(domainname, default_str)) { + __set_errno(EINVAL); + return NULL; + } + return (char *) default_str; +} + +weak_alias(__uClibc_textdomain, __textdomain) + +#endif +/**********************************************************************/ +#ifdef L___uClibc_bindtextdomain + +char *__uClibc_bindtextdomain(const char *domainname, const char *dirname) +{ + static const char dir[] = "/"; + + if (!domainname || !*domainname + || (dirname +#if 1 + && ((dirname[0] != '/') || dirname[1]) +#else + && strcmp(dirname, dir) +#endif + ) + ) { + __set_errno(EINVAL); + return NULL; + } + + return (char *) dir; +} + +weak_alias(__uClibc_bindtextdomain, __bindtextdomain) #endif /**********************************************************************/ diff --git a/libintl/intl.c b/libintl/intl.c index 4c79aaa5f..51765a99e 100644 --- a/libintl/intl.c +++ b/libintl/intl.c @@ -17,6 +17,9 @@ /* * Stub version of libintl. + * + * Aug 30, 2003 + * Add some hidden names to support locale-enabled libstd++. */ #include @@ -44,26 +47,26 @@ char *__dgettext(const char *domainname, return (char *) msgid; } -weak_alias (__dgettext, dgettext) +strong_alias(__dgettext, dgettext) #endif /**********************************************************************/ #ifdef L_dcgettext -char * __dcgettext(const char *domainname, - const char *msgid, int category) +char *__dcgettext(const char *domainname, + const char *msgid, int category) { return (char *) msgid; } -weak_alias (__dcgettext, dcgettext) +strong_alias(__dcgettext, dcgettext) #endif /**********************************************************************/ #ifdef L_ngettext char *ngettext(const char *msgid1, const char *msgid2, - unsigned long int n) + unsigned long int n) { return (char *) ((n == 1) ? msgid1 : msgid2); } @@ -73,7 +76,7 @@ char *ngettext(const char *msgid1, const char *msgid2, #ifdef L_dngettext char *dngettext(const char *domainname, const char *msgid1, - const char *msgid2, unsigned long int n) + const char *msgid2, unsigned long int n) { return (char *) ((n == 1) ? msgid1 : msgid2); } @@ -83,8 +86,8 @@ char *dngettext(const char *domainname, const char *msgid1, #ifdef L_dcngettext char *dcngettext(const char *domainname, const char *msgid1, - const char *msgid2, unsigned long int n, - int category) + const char *msgid2, unsigned long int n, + int category) { return (char *) ((n == 1) ? msgid1 : msgid2); } @@ -93,7 +96,7 @@ char *dcngettext(const char *domainname, const char *msgid1, /**********************************************************************/ #ifdef L_textdomain -char *textdomain(const char *domainname) +char *__textdomain(const char *domainname) { static const char default_str[] = "messages"; @@ -104,11 +107,13 @@ char *textdomain(const char *domainname) return (char *) default_str; } +strong_alias(__textdomain, textdomain) + #endif /**********************************************************************/ #ifdef L_bindtextdomain -char *bindtextdomain(const char *domainname, const char *dirname) +char *__bindtextdomain(const char *domainname, const char *dirname) { static const char dir[] = "/"; @@ -128,6 +133,8 @@ char *bindtextdomain(const char *domainname, const char *dirname) return (char *) dir; } +strong_alias(__bindtextdomain, bindtextdomain) + #endif /**********************************************************************/ #ifdef L_bind_textdomain_codeset @@ -151,7 +158,7 @@ char *bind_textdomain_codeset(const char *domainname, const char *_nl_expand_alias(const char * name) { - return NULL; /* uClibc does not support locale aliases. */ + return NULL; /* uClibc does not support locale aliases. */ } #endif -- cgit v1.2.3