#include <stdio.h>#include <sys/types.h>#include <stdlib.h>#include <string.h>#include "gettextP.h"#include "libgnuintl.h"Go to the source code of this file.
Functions | |
| loaded_l10nfile *internal_function | _nl_find_domain (char *dirname, char *locale, const char *domainname, struct binding *domainbinding) const |
Variables | |
| loaded_l10nfile * | _nl_loaded_domains |
|
||||||||||||||||||||
|
Definition at line 50 of file finddomain.c. 00055 {
00056 struct loaded_l10nfile *retval;
00057 const char *language;
00058 const char *modifier;
00059 const char *territory;
00060 const char *codeset;
00061 const char *normalized_codeset;
00062 const char *special;
00063 const char *sponsor;
00064 const char *revision;
00065 const char *alias_value;
00066 int mask;
00067
00068 /* LOCALE can consist of up to four recognized parts for the XPG syntax:
00069
00070 language[_territory[.codeset]][@modifier]
00071
00072 and six parts for the CEN syntax:
00073
00074 language[_territory][+audience][+special][,[sponsor][_revision]]
00075
00076 Beside the first part all of them are allowed to be missing. If
00077 the full specified locale is not found, the less specific one are
00078 looked for. The various parts will be stripped off according to
00079 the following order:
00080 (1) revision
00081 (2) sponsor
00082 (3) special
00083 (4) codeset
00084 (5) normalized codeset
00085 (6) territory
00086 (7) audience/modifier
00087 */
00088
00089 /* If we have already tested for this locale entry there has to
00090 be one data set in the list of loaded domains. */
00091 retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
00092 strlen (dirname) + 1, 0, locale, NULL, NULL,
00093 NULL, NULL, NULL, NULL, NULL, domainname, 0);
00094 if (retval != NULL)
00095 {
00096 /* We know something about this locale. */
00097 int cnt;
00098
00099 if (retval->decided == 0)
00100 _nl_load_domain (retval, domainbinding);
00101
00102 if (retval->data != NULL)
00103 return retval;
00104
00105 for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
00106 {
00107 if (retval->successor[cnt]->decided == 0)
00108 _nl_load_domain (retval->successor[cnt], domainbinding);
00109
00110 if (retval->successor[cnt]->data != NULL)
00111 break;
00112 }
00113 return cnt >= 0 ? retval : NULL;
00114 /* NOTREACHED */
00115 }
00116
00117 /* See whether the locale value is an alias. If yes its value
00118 *overwrites* the alias name. No test for the original value is
00119 done. */
00120 alias_value = _nl_expand_alias (locale);
00121 if (alias_value != NULL)
00122 {
00123 #if defined _LIBC || defined HAVE_STRDUP
00124 locale = strdup (alias_value);
00125 if (locale == NULL)
00126 return NULL;
00127 #else
00128 size_t len = strlen (alias_value) + 1;
00129 locale = (char *) malloc (len);
00130 if (locale == NULL)
00131 return NULL;
00132
00133 memcpy (locale, alias_value, len);
00134 #endif
00135 }
00136
00137 /* Now we determine the single parts of the locale name. First
00138 look for the language. Termination symbols are `_' and `@' if
00139 we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
00140 mask = _nl_explode_name (locale, &language, &modifier, &territory,
00141 &codeset, &normalized_codeset, &special,
00142 &sponsor, &revision);
00143
00144 /* Create all possible locale entries which might be interested in
00145 generalization. */
00146 retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
00147 strlen (dirname) + 1, mask, language, territory,
00148 codeset, normalized_codeset, modifier, special,
00149 sponsor, revision, domainname, 1);
00150 if (retval == NULL)
00151 /* This means we are out of core. */
00152 return NULL;
00153
00154 if (retval->decided == 0)
00155 _nl_load_domain (retval, domainbinding);
00156 if (retval->data == NULL)
00157 {
00158 int cnt;
00159 for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
00160 {
00161 if (retval->successor[cnt]->decided == 0)
00162 _nl_load_domain (retval->successor[cnt], domainbinding);
00163 if (retval->successor[cnt]->data != NULL)
00164 break;
00165 }
00166 }
00167
00168 /* The room for an alias was dynamically allocated. Free it now. */
00169 if (alias_value != NULL)
00170 free (locale);
00171
00172 /* The space for normalized_codeset is dynamically allocated. Free it. */
00173 if (mask & XPG_NORM_CODESET)
00174 free ((void *) normalized_codeset);
00175
00176 return retval;
00177 }
|
|
|
Definition at line 42 of file finddomain.c. |
1.3.9.1