OSDN Git Service

Rework a few things.
[uclinux-h8/uClibc.git] / libc / misc / intl / 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  *  Supply some weaks for use by strerror*(), etc.
20  *
21  *  Aug 30, 2003
22  *  Add some hidden names to support locale-enabled libstd++.
23  */
24
25 #include <stdlib.h>
26 #include <string.h>
27 #include <errno.h>
28
29 #undef __OPTIMIZE__
30 #include <libintl.h>
31
32 /**********************************************************************/
33 #ifdef L___uClibc_dgettext
34
35 char *__uClibc_dgettext(const char *domainname,
36                                                 const char *msgid)
37 {
38         return (char *) msgid;
39 }
40
41 weak_alias(__uClibc_dgettext, __dgettext)
42
43 #endif
44 /**********************************************************************/
45 #ifdef L___uClibc_dcgettext
46
47 char *__uClibc_dcgettext(const char *domainname,
48                                                  const char *msgid, int category)
49 {
50         return (char *) msgid;
51 }
52
53 weak_alias(__uClibc_dcgettext, __dcgettext)
54
55 #endif
56 /**********************************************************************/
57 #ifdef L___uClibc_textdomain
58
59 char *__uClibc_textdomain(const char *domainname)
60 {
61         static const char default_str[] = "messages";
62
63         if (domainname && *domainname && strcmp(domainname, default_str)) {
64                 __set_errno(EINVAL);
65                 return NULL;
66         }
67         return (char *) default_str;
68 }
69
70 weak_alias(__uClibc_textdomain, __textdomain)
71
72 #endif
73 /**********************************************************************/
74 #ifdef L___uClibc_bindtextdomain
75
76 char *__uClibc_bindtextdomain(const char *domainname, const char *dirname)
77 {
78         static const char dir[] = "/";
79
80         if (!domainname || !*domainname
81                 || (dirname
82 #if 1
83                         && ((dirname[0] != '/') || dirname[1])
84 #else
85                         && strcmp(dirname, dir)
86 #endif
87                         )
88                 ) {
89                 __set_errno(EINVAL);
90                 return NULL;
91         }
92
93         return (char *) dir;
94 }
95
96 weak_alias(__uClibc_bindtextdomain, __bindtextdomain)
97
98 #endif
99 /**********************************************************************/