1 /* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
2 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
23 #if defined STDC_HEADERS || defined _LIBC
27 #if defined HAVE_STRING_H || defined _LIBC
32 #include <sys/types.h>
36 /* On some strange systems still no definition of NULL is found. Sigh! */
38 # if defined __STDC__ && __STDC__
39 # define NULL ((void *) 0)
45 /* @@ end of prolog @@ */
48 _nl_find_language (name
)
51 while (name
[0] != '\0' && name
[0] != '_' && name
[0] != '@'
52 && name
[0] != '+' && name
[0] != ',')
60 _nl_explode_name (name
, language
, modifier
, territory
, codeset
,
61 normalized_codeset
, special
, sponsor
, revision
)
63 const char **language
;
64 const char **modifier
;
65 const char **territory
;
67 const char **normalized_codeset
;
70 const char **revision
;
72 enum { undecided
, xpg
, cen
} syntax
;
79 *normalized_codeset
= NULL
;
84 /* Now we determine the single parts of the locale name. First
85 look for the language. Termination symbols are `_' and `@' if
86 we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
89 *language
= cp
= name
;
90 cp
= _nl_find_language (*language
);
93 /* This does not make sense: language has to be specified. Use
94 this entry as it is without exploding. Perhaps it is an alias. */
95 cp
= strchr (*language
, '\0');
96 else if (cp
[0] == '_')
98 /* Next is the territory. */
102 while (cp
[0] != '\0' && cp
[0] != '.' && cp
[0] != '@'
103 && cp
[0] != '+' && cp
[0] != ',' && cp
[0] != '_')
110 /* Next is the codeset. */
115 while (cp
[0] != '\0' && cp
[0] != '@')
120 if (*codeset
!= cp
&& (*codeset
)[0] != '\0')
122 *normalized_codeset
= _nl_normalize_codeset (*codeset
,
124 if (strcmp (*codeset
, *normalized_codeset
) == 0)
125 free ((char *) *normalized_codeset
);
127 mask
|= XPG_NORM_CODESET
;
132 if (cp
[0] == '@' || (syntax
!= xpg
&& cp
[0] == '+'))
134 /* Next is the modifier. */
135 syntax
= cp
[0] == '@' ? xpg
: cen
;
139 while (syntax
== cen
&& cp
[0] != '\0' && cp
[0] != '+'
140 && cp
[0] != ',' && cp
[0] != '_')
143 mask
|= XPG_MODIFIER
| CEN_AUDIENCE
;
146 if (syntax
!= xpg
&& (cp
[0] == '+' || cp
[0] == ',' || cp
[0] == '_'))
152 /* Next is special application (CEN syntax). */
156 while (cp
[0] != '\0' && cp
[0] != ',' && cp
[0] != '_')
164 /* Next is sponsor (CEN syntax). */
168 while (cp
[0] != '\0' && cp
[0] != '_')
176 /* Next is revision (CEN syntax). */
180 mask
|= CEN_REVISION
;
184 /* For CEN syntax values it might be important to have the
185 separator character in the file name, not for XPG syntax. */
188 if (*territory
!= NULL
&& (*territory
)[0] == '\0')
191 if (*codeset
!= NULL
&& (*codeset
)[0] == '\0')
192 mask
&= ~XPG_CODESET
;
194 if (*modifier
!= NULL
&& (*modifier
)[0] == '\0')
195 mask
&= ~XPG_MODIFIER
;