2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* SetLocale.c 1.1 - Fujitsu source for CDEnext 95/11/06 20:31:29 */
24 /* $XConsortium: _falSetLocale.c /main/1 1996/04/08 15:15:08 cde-fuj $ */
27 * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
28 * and Nippon Telegraph and Telephone Corporation
30 * Permission to use, copy, modify, distribute, and sell this software and its
31 * documentation for any purpose is hereby granted without fee, provided that
32 * the above copyright notice appear in all copies and that both that
33 * copyright notice and this permission notice appear in supporting
34 * documentation, and that the names of OMRON, NTT Software, and NTT
35 * not be used in advertising or publicity pertaining to distribution of the
36 * software without specific, written prior permission. OMRON, NTT Software,
37 * and NTT make no representations about the suitability of this
38 * software for any purpose. It is provided "as is" without express or
41 * OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD
42 * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
43 * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT, BE
44 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
45 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
46 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
47 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49 * Authors: Li Yuhong OMRON Corporation
50 * Tetsuya Kato NTT Software Corporation
51 * Hiroshi Kuribayashi OMRON Corporation
56 Copyright (c) 1987 X Consortium
58 Permission is hereby granted, free of charge, to any person obtaining
59 a copy of this software and associated documentation files (the
60 "Software"), to deal in the Software without restriction, including
61 without limitation the rights to use, copy, modify, merge, publish,
62 distribute, sublicense, and/or sell copies of the Software, and to
63 permit persons to whom the Software is furnished to do so, subject to
64 the following conditions:
66 The above copyright notice and this permission notice shall be included
67 in all copies or substantial portions of the Software.
69 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
70 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
72 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
73 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
74 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
75 OTHER DEALINGS IN THE SOFTWARE.
77 Except as contained in this notice, the name of the X Consortium shall
78 not be used in advertising or otherwise to promote the sale, use or
79 other dealings in this Software without prior written authorization
80 from the X Consortium.
84 #include "_fallibint.h"
85 #include "_fallcint.h"
86 #include <X11/Xlocale.h>
91 /* alternative setlocale() for when the OS does not provide one */
94 extern char *getenv();
97 #define MAXLOCALE 64 /* buffer size of locale name */
99 #if NeedFunctionPrototypes
107 _falsetlocale(category, name)
112 static char *xsl_name;
117 if (category != LC_CTYPE && category != LC_ALL)
125 name = getenv("LC_CTYPE");
127 name = getenv("LANG");
131 xsl_name = (char *)name;
132 methods = _falrmInitParseInfo(&state);
136 name = (*methods->lcname)(state);
137 xsl_name = Xmalloc(strlen(name) + 1);
140 (*methods->destroy)(state);
143 strcpy(xsl_name, name);
146 (*methods->destroy)(state);
153 * _fallcMapOSLocaleName is an implementation dependent routine that derives
154 * the LC_CTYPE locale name as used in the sample implementation from that
155 * returned by setlocale.
156 * Should match the code in Xt ExtractLocaleName.
160 _fallcMapOSLocaleName(osname, siname)
164 #if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(__osf__) || defined(AIXV3) || defined(ultrix) || defined(WIN32)
167 #define STARTCHAR ':'
172 #define STARTCHAR '\001'
173 #define ENDCHAR '\001'
177 #define STARTCHAR '='
181 #if defined(__osf__) || defined(AIXV3)
182 #define STARTCHAR ' '
185 #if !defined(sun) || defined(SVR4)
186 #define STARTCHAR '/'
204 --n >= 0 && start && (start = strchr (start, STARTCHAR));
211 if (start && (start = strchr (start, STARTCHAR))) {
214 if (end = strchr (start, ENDCHAR)) {
216 strncpy(siname, start, len);
217 *(siname + len) = '\0';
219 for (start = siname; start = strchr(start, ' '); )
228 if (strchr(osname, ' ')) {
229 strcpy(siname, osname);
230 for (start = siname; start = strchr(start, ' '); )
242 #endif /* X_LOCALE */