1 /* Copyright (C) 1995-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
25 #include <sys/types.h>
29 /* On some strange systems still no definition of NULL is found. Sigh! */
31 # if defined __STDC__ && __STDC__
32 # define NULL ((void *) 0)
38 /* @@ end of prolog @@ */
40 static char *_nl_find_language
PARAMS ((const char *name
));
43 _nl_find_language (name
)
46 while (name
[0] != '\0' && name
[0] != '_' && name
[0] != '@' && name
[0] != '.')
54 _nl_explode_name (name
, language
, modifier
, territory
, codeset
,
57 const char **language
;
58 const char **modifier
;
59 const char **territory
;
61 const char **normalized_codeset
;
69 *normalized_codeset
= NULL
;
71 /* Now we determine the single parts of the locale name. First
72 look for the language. Termination symbols are `_', '.', and `@'. */
74 *language
= cp
= name
;
75 cp
= _nl_find_language (*language
);
78 /* This does not make sense: language has to be specified. Use
79 this entry as it is without exploding. Perhaps it is an alias. */
80 cp
= __rawmemchr (*language
, '\0');
81 else if (cp
[0] != '@')
85 /* Next is the territory. */
89 while (cp
[0] != '\0' && cp
[0] != '.' && cp
[0] != '@')
92 mask
|= XPG_TERRITORY
;
97 /* Next is the codeset. */
101 while (cp
[0] != '\0' && cp
[0] != '@')
106 if (*codeset
!= cp
&& (*codeset
)[0] != '\0')
108 *normalized_codeset
= _nl_normalize_codeset (*codeset
,
110 if (*normalized_codeset
== NULL
)
112 else if (strcmp (*codeset
, *normalized_codeset
) == 0)
113 free ((char *) *normalized_codeset
);
115 mask
|= XPG_NORM_CODESET
;
122 /* Next is the modifier. */
127 mask
|= XPG_MODIFIER
;
130 if (*territory
!= NULL
&& (*territory
)[0] == '\0')
131 mask
&= ~XPG_TERRITORY
;
133 if (*codeset
!= NULL
&& (*codeset
)[0] == '\0')
134 mask
&= ~XPG_CODESET
;