00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef HAVE_CONFIG_H
00020 # include <config.h>
00021 #endif
00022
00023 #include <stdlib.h>
00024 #include <string.h>
00025 #include <sys/types.h>
00026
00027 #include "loadinfo.h"
00028
00029
00030 #ifndef NULL
00031 # if defined __STDC__ && __STDC__
00032 # define NULL ((void *) 0)
00033 # else
00034 # define NULL 0
00035 # endif
00036 #endif
00037
00038
00039
00040 char *
00041 _nl_find_language (name)
00042 const char *name;
00043 {
00044 while (name[0] != '\0' && name[0] != '_' && name[0] != '@'
00045 && name[0] != '+' && name[0] != ',')
00046 ++name;
00047
00048 return (char *) name;
00049 }
00050
00051
00052 int
00053 _nl_explode_name (name, language, modifier, territory, codeset,
00054 normalized_codeset, special, sponsor, revision)
00055 char *name;
00056 const char **language;
00057 const char **modifier;
00058 const char **territory;
00059 const char **codeset;
00060 const char **normalized_codeset;
00061 const char **special;
00062 const char **sponsor;
00063 const char **revision;
00064 {
00065 enum { undecided, xpg, cen } syntax;
00066 char *cp;
00067 int mask;
00068
00069 *modifier = NULL;
00070 *territory = NULL;
00071 *codeset = NULL;
00072 *normalized_codeset = NULL;
00073 *special = NULL;
00074 *sponsor = NULL;
00075 *revision = NULL;
00076
00077
00078
00079
00080 mask = 0;
00081 syntax = undecided;
00082 *language = cp = name;
00083 cp = _nl_find_language (*language);
00084
00085 if (*language == cp)
00086
00087
00088 cp = strchr (*language, '\0');
00089 else if (cp[0] == '_')
00090 {
00091
00092 cp[0] = '\0';
00093 *territory = ++cp;
00094
00095 while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@'
00096 && cp[0] != '+' && cp[0] != ',' && cp[0] != '_')
00097 ++cp;
00098
00099 mask |= TERRITORY;
00100
00101 if (cp[0] == '.')
00102 {
00103
00104 syntax = xpg;
00105 cp[0] = '\0';
00106 *codeset = ++cp;
00107
00108 while (cp[0] != '\0' && cp[0] != '@')
00109 ++cp;
00110
00111 mask |= XPG_CODESET;
00112
00113 if (*codeset != cp && (*codeset)[0] != '\0')
00114 {
00115 *normalized_codeset = _nl_normalize_codeset (*codeset,
00116 cp - *codeset);
00117 if (strcmp (*codeset, *normalized_codeset) == 0)
00118 free ((char *) *normalized_codeset);
00119 else
00120 mask |= XPG_NORM_CODESET;
00121 }
00122 }
00123 }
00124
00125 if (cp[0] == '@' || (syntax != xpg && cp[0] == '+'))
00126 {
00127
00128 syntax = cp[0] == '@' ? xpg : cen;
00129 cp[0] = '\0';
00130 *modifier = ++cp;
00131
00132 while (syntax == cen && cp[0] != '\0' && cp[0] != '+'
00133 && cp[0] != ',' && cp[0] != '_')
00134 ++cp;
00135
00136 mask |= XPG_MODIFIER | CEN_AUDIENCE;
00137 }
00138
00139 if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_'))
00140 {
00141 syntax = cen;
00142
00143 if (cp[0] == '+')
00144 {
00145
00146 cp[0] = '\0';
00147 *special = ++cp;
00148
00149 while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_')
00150 ++cp;
00151
00152 mask |= CEN_SPECIAL;
00153 }
00154
00155 if (cp[0] == ',')
00156 {
00157
00158 cp[0] = '\0';
00159 *sponsor = ++cp;
00160
00161 while (cp[0] != '\0' && cp[0] != '_')
00162 ++cp;
00163
00164 mask |= CEN_SPONSOR;
00165 }
00166
00167 if (cp[0] == '_')
00168 {
00169
00170 cp[0] = '\0';
00171 *revision = ++cp;
00172
00173 mask |= CEN_REVISION;
00174 }
00175 }
00176
00177
00178
00179 if (syntax == xpg)
00180 {
00181 if (*territory != NULL && (*territory)[0] == '\0')
00182 mask &= ~TERRITORY;
00183
00184 if (*codeset != NULL && (*codeset)[0] == '\0')
00185 mask &= ~XPG_CODESET;
00186
00187 if (*modifier != NULL && (*modifier)[0] == '\0')
00188 mask &= ~XPG_MODIFIER;
00189 }
00190
00191 return mask;
00192 }