1
/* Copyright (C) 1995-1998, 2000-2001, 2003 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 it
5
under the terms of the GNU Library General Public License as published
6
by 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 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 this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
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 @@ */
41
_nl_find_language (const char *name)
43
while (name[0] != '\0' && name[0] != '_' && name[0] != '@'
44
&& name[0] != '+' && name[0] != ',')
52
_nl_explode_name (char *name,
53
const char **language, const char **modifier,
54
const char **territory, const char **codeset,
55
const char **normalized_codeset, const char **special,
56
const char **sponsor, const char **revision)
58
enum { undecided, xpg, cen } syntax;
65
*normalized_codeset = NULL;
70
/* Now we determine the single parts of the locale name. First
71
look for the language. Termination symbols are `_' and `@' if
72
we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
75
*language = cp = name;
76
cp = _nl_find_language (*language);
79
/* This does not make sense: language has to be specified. Use
80
this entry as it is without exploding. Perhaps it is an alias. */
81
cp = strchr (*language, '\0');
82
else if (cp[0] == '_')
84
/* Next is the territory. */
88
while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@'
89
&& cp[0] != '+' && cp[0] != ',' && cp[0] != '_')
96
/* 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 (strcmp (*codeset, *normalized_codeset) == 0)
111
free ((char *) *normalized_codeset);
113
mask |= XPG_NORM_CODESET;
118
if (cp[0] == '@' || (syntax != xpg && cp[0] == '+'))
120
/* Next is the modifier. */
121
syntax = cp[0] == '@' ? xpg : cen;
125
while (syntax == cen && cp[0] != '\0' && cp[0] != '+'
126
&& cp[0] != ',' && cp[0] != '_')
129
mask |= XPG_MODIFIER | CEN_AUDIENCE;
132
if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_'))
138
/* Next is special application (CEN syntax). */
142
while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_')
150
/* Next is sponsor (CEN syntax). */
154
while (cp[0] != '\0' && cp[0] != '_')
162
/* Next is revision (CEN syntax). */
166
mask |= CEN_REVISION;
170
/* For CEN syntax values it might be important to have the
171
separator character in the file name, not for XPG syntax. */
174
if (*territory != NULL && (*territory)[0] == '\0')
177
if (*codeset != NULL && (*codeset)[0] == '\0')
178
mask &= ~XPG_CODESET;
180
if (*modifier != NULL && (*modifier)[0] == '\0')
181
mask &= ~XPG_MODIFIER;