1 /* Copyright (C) 1995, 1996 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
26 _nl_explode_name (name
, language
, modifier
, territory
, codeset
,
27 normalized_codeset
, special
, sponsor
, revision
)
29 const char **language
;
30 const char **modifier
;
31 const char **territory
;
33 const char **normalized_codeset
;
36 const char **revision
;
38 enum { undecided
, xpg
, cen
} syntax
;
45 *normalized_codeset
= NULL
;
50 /* Now we determine the single parts of the locale name. First
51 look for the language. Termination symbols are `_' and `@' if
52 we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
55 *language
= cp
= name
;
56 while (cp
[0] != '\0' && cp
[0] != '_' && cp
[0] != '@'
57 && cp
[0] != '+' && cp
[0] != ',')
61 /* This does not make sense: language has to be specified. Use
62 this entry as it is without exploding. Perhaps it is an alias. */
63 cp
= strchr (*language
, '\0');
64 else if (cp
[0] == '_')
66 /* Next is the territory. */
70 while (cp
[0] != '\0' && cp
[0] != '.' && cp
[0] != '@'
71 && cp
[0] != '+' && cp
[0] != ',' && cp
[0] != '_')
78 /* Next is the codeset. */
83 while (cp
[0] != '\0' && cp
[0] != '@')
88 if (*codeset
!= cp
&& (*codeset
)[0] != '\0')
90 *normalized_codeset
= _nl_normalize_codeset (*codeset
,
92 if (strcmp (*codeset
, *normalized_codeset
) == 0)
93 free ((char *) *normalized_codeset
);
95 mask
|= XPG_NORM_CODESET
;
100 if (cp
[0] == '@' || (syntax
!= xpg
&& cp
[0] == '+'))
102 /* Next is the modifier. */
103 syntax
= cp
[0] == '@' ? xpg
: cen
;
107 while (syntax
== cen
&& cp
[0] != '\0' && cp
[0] != '+'
108 && cp
[0] != ',' && cp
[0] != '_')
111 mask
|= XPG_MODIFIER
| CEN_AUDIENCE
;
114 if (syntax
!= xpg
&& (cp
[0] == '+' || cp
[0] == ',' || cp
[0] == '_'))
120 /* Next is special application (CEN syntax). */
124 while (cp
[0] != '\0' && cp
[0] != ',' && cp
[0] != '_')
132 /* Next is sponsor (CEN syntax). */
136 while (cp
[0] != '\0' && cp
[0] != '_')
144 /* Next is revision (CEN syntax). */
148 mask
|= CEN_REVISION
;
152 /* For CEN sytnax values it might be important to have the
153 separator character in the file name, not for XPG syntax. */
156 if (*territory
!= NULL
&& (*territory
)[0] == '\0')
159 if (*codeset
!= NULL
&& (*codeset
)[0] == '\0')
160 mask
&= ~XPG_CODESET
;
162 if (*modifier
!= NULL
&& (*modifier
)[0] == '\0')
163 mask
&= ~XPG_MODIFIER
;