1
/* Copyright (C) 1995-1998, 2000-2001, 2003, 2005, 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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
/* Split a locale name NAME into a leading language part and all the
41
rest. Return a pointer to the first character after the language,
42
i.e. to the first byte of the rest. */
43
static char *_nl_find_language (const char *name);
46
_nl_find_language (const char *name)
48
while (name[0] != '\0' && name[0] != '_' && name[0] != '@' && name[0] != '.')
56
_nl_explode_name (char *name,
57
const char **language, const char **modifier,
58
const char **territory, const char **codeset,
59
const char **normalized_codeset)
67
*normalized_codeset = NULL;
69
/* Now we determine the single parts of the locale name. First
70
look for the language. Termination symbols are `_', '.', and `@'. */
72
*language = cp = name;
73
cp = _nl_find_language (*language);
76
/* This does not make sense: language has to be specified. Use
77
this entry as it is without exploding. Perhaps it is an alias. */
78
cp = strchr (*language, '\0');
83
/* Next is the territory. */
87
while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@')
90
mask |= XPG_TERRITORY;
95
/* Next is the codeset. */
99
while (cp[0] != '\0' && cp[0] != '@')
104
if (*codeset != cp && (*codeset)[0] != '\0')
106
*normalized_codeset = _nl_normalize_codeset (*codeset,
108
if (*normalized_codeset == NULL)
110
else if (strcmp (*codeset, *normalized_codeset) == 0)
111
free ((char *) *normalized_codeset);
113
mask |= XPG_NORM_CODESET;
120
/* Next is the modifier. */
125
mask |= XPG_MODIFIER;
128
if (*territory != NULL && (*territory)[0] == '\0')
129
mask &= ~XPG_TERRITORY;
131
if (*codeset != NULL && (*codeset)[0] == '\0')
132
mask &= ~XPG_CODESET;