OSDN Git Service

Fix a few bugs in the new extended locale functions.
[uclinux-h8/uClibc.git] / libintl / intl.c
1 /*  Copyright (C) 2003     Manuel Novoa III
2  *
3  *  This library is free software; you can redistribute it and/or
4  *  modify it under the terms of the GNU Library General Public
5  *  License as published by the Free Software Foundation; either
6  *  version 2 of the License, or (at your option) any later version.
7  *
8  *  This library is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  *  Library General Public License for more details.
12  *
13  *  You should have received a copy of the GNU Library General Public
14  *  License along with this library; if not, write to the Free
15  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  */
17
18 /*
19  *  Stub version of libintl.
20  */
21
22 #include <stdlib.h>
23 #include <string.h>
24 #include <errno.h>
25
26 #undef __OPTIMIZE__
27 #include <libintl.h>
28
29 /**********************************************************************/
30 #ifdef L_gettext
31
32 char *gettext(const char *msgid)
33 {
34         return (char *) msgid;
35 }
36
37 #endif
38 /**********************************************************************/
39 #ifdef L_dgettext
40
41 char *__dgettext(const char *domainname,
42                                  const char *msgid)
43 {
44         return (char *) msgid;
45 }
46
47 weak_alias (__dgettext, dgettext)
48
49 #endif
50 /**********************************************************************/
51 #ifdef L_dcgettext
52
53 char * __dcgettext(const char *domainname,
54                                    const char *msgid, int category)
55 {
56         return (char *) msgid;
57 }
58
59 weak_alias (__dcgettext, dcgettext)
60
61 #endif
62 /**********************************************************************/
63 #ifdef L_ngettext
64
65 char *ngettext(const char *msgid1, const char *msgid2,
66                                                          unsigned long int n)
67 {
68         return (char *) ((n == 1) ? msgid1 : msgid2);
69 }
70
71 #endif
72 /**********************************************************************/
73 #ifdef L_dngettext
74
75 char *dngettext(const char *domainname, const char *msgid1,
76                                                           const char *msgid2, unsigned long int n)
77 {
78         return (char *) ((n == 1) ? msgid1 : msgid2);
79 }
80
81 #endif
82 /**********************************************************************/
83 #ifdef L_dcngettext
84
85 char *dcngettext(const char *domainname, const char *msgid1,
86                                                            const char *msgid2, unsigned long int n,
87                                                            int category)
88 {
89         return (char *) ((n == 1) ? msgid1 : msgid2);
90 }
91
92 #endif
93 /**********************************************************************/
94 #ifdef L_textdomain
95
96 char *textdomain(const char *domainname)
97 {
98         static const char default_str[] = "messages";
99
100         if (domainname && *domainname && strcmp(domainname, default_str)) {
101                 __set_errno(EINVAL);
102                 return NULL;
103         }
104         return (char *) default_str;
105 }
106
107 #endif
108 /**********************************************************************/
109 #ifdef L_bindtextdomain
110
111 char *bindtextdomain(const char *domainname, const char *dirname)
112 {
113         static const char dir[] = "/";
114
115         if (!domainname || !*domainname
116                 || (dirname
117 #if 1
118                         && ((dirname[0] != '/') || dirname[1])
119 #else
120                         && strcmp(dirname, dir)
121 #endif
122                         )
123                 ) {
124                 __set_errno(EINVAL);
125                 return NULL;
126         }
127
128         return (char *) dir;
129 }
130
131 #endif
132 /**********************************************************************/
133 #ifdef L_bind_textdomain_codeset
134
135 /* Specify the character encoding in which the messages from the
136    DOMAINNAME message catalog will be returned.  */
137 char *bind_textdomain_codeset(const char *domainname,
138                                                                                         const char *codeset)
139 {
140         if (!domainname || !*domainname || codeset) {
141                 __set_errno(EINVAL);
142         }
143         return NULL;
144 }
145
146 #endif
147 /**********************************************************************/
148 #ifdef L__nl_expand_alias
149
150 /* glibc-ism */
151
152 const char *_nl_expand_alias(const char * name)
153 {
154         return NULL;                            /* uClibc does not support locale aliases. */
155 }
156
157 #endif
158 /**********************************************************************/
159 #ifdef L__nl_msg_cat_cntr
160
161 /* glibc-ism */
162
163 int _nl_msg_cat_cntr = 0;
164
165 #endif
166 /**********************************************************************/