1 /* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
2 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program 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
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 #if defined STDC_HEADERS || defined _LIBC
26 #if defined HAVE_STRING_H || defined _LIBC
31 #include <sys/types.h>
35 /* On some strange systems still no definition of NULL is found. Sigh! */
37 # if defined __STDC__ && __STDC__
38 # define NULL ((void *) 0)
44 /* @@ end of prolog @@ */
47 _nl_explode_name (name
, language
, modifier
, territory
, codeset
,
48 normalized_codeset
, special
, sponsor
, revision
)
50 const char **language
;
51 const char **modifier
;
52 const char **territory
;
54 const char **normalized_codeset
;
57 const char **revision
;
59 enum { undecided
, xpg
, cen
} syntax
;
66 *normalized_codeset
= NULL
;
71 /* Now we determine the single parts of the locale name. First
72 look for the language. Termination symbols are `_' and `@' if
73 we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
76 *language
= cp
= name
;
77 while (cp
[0] != '\0' && cp
[0] != '_' && cp
[0] != '@'
78 && cp
[0] != '+' && cp
[0] != ',')
82 /* This does not make sense: language has to be specified. Use
83 this entry as it is without exploding. Perhaps it is an alias. */
84 cp
= strchr (*language
, '\0');
85 else if (cp
[0] == '_')
87 /* Next is the territory. */
91 while (cp
[0] != '\0' && cp
[0] != '.' && cp
[0] != '@'
92 && cp
[0] != '+' && cp
[0] != ',' && cp
[0] != '_')
99 /* Next is the codeset. */
104 while (cp
[0] != '\0' && cp
[0] != '@')
109 if (*codeset
!= cp
&& (*codeset
)[0] != '\0')
111 *normalized_codeset
= _nl_normalize_codeset (*codeset
,
113 if (strcmp (*codeset
, *normalized_codeset
) == 0)
114 free ((char *) *normalized_codeset
);
116 mask
|= XPG_NORM_CODESET
;
121 if (cp
[0] == '@' || (syntax
!= xpg
&& cp
[0] == '+'))
123 /* Next is the modifier. */
124 syntax
= cp
[0] == '@' ? xpg
: cen
;
128 while (syntax
== cen
&& cp
[0] != '\0' && cp
[0] != '+'
129 && cp
[0] != ',' && cp
[0] != '_')
132 mask
|= XPG_MODIFIER
| CEN_AUDIENCE
;
135 if (syntax
!= xpg
&& (cp
[0] == '+' || cp
[0] == ',' || cp
[0] == '_'))
141 /* Next is special application (CEN syntax). */
145 while (cp
[0] != '\0' && cp
[0] != ',' && cp
[0] != '_')
153 /* Next is sponsor (CEN syntax). */
157 while (cp
[0] != '\0' && cp
[0] != '_')
165 /* Next is revision (CEN syntax). */
169 mask
|= CEN_REVISION
;
173 /* For CEN syntax values it might be important to have the
174 separator character in the file name, not for XPG syntax. */
177 if (*territory
!= NULL
&& (*territory
)[0] == '\0')
180 if (*codeset
!= NULL
&& (*codeset
)[0] == '\0')
181 mask
&= ~XPG_CODESET
;
183 if (*modifier
!= NULL
&& (*modifier
)[0] == '\0')
184 mask
&= ~XPG_MODIFIER
;
This page took 0.032958 seconds and 4 git commands to generate.