gettext_real.c revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A const char *,
Nlstmp **,
char **,
int *,
int *);
2N/A char *,
char *,
char *,
char *,
int *,
size_t *);
2N/A unsigned int n = (
unsigned int)
ln;
/* we don't need long for n */ 2N/A gprintf(0,
"*************** _real_gettext_u(\"%s\", \"%s\", " 2N/A "\"%s\", %d, %d, %d)\n",
2N/A * category may be LC_MESSAGES or LC_TIME 2N/A * locale contains the value of 'category' 2N/A * LANGUAGE is an empty string or 2N/A * LANGUAGE contains '/'. 2N/A * Query the current domain if domain argument is NULL pointer 2N/A * if NULL is specified for domainname, 2N/A * use the currently bound domain. 2N/A * if an empty string is specified 2N/A /* domain is invalid, return msg_id */ 2N/A /* no NLSPATH is defined in the environ */ 2N/A * return the original msgid immediately. 2N/A /* NLSPATH is set */ 2N/A /* error occurred */ 2N/A * Spec1170 requires that we use NLSPATH if it's defined, to 2N/A * override any system default variables. If NLSPATH is not 2N/A * defined or if a message catalog is not found in any of the 2N/A * components (bindings) specified by NLSPATH, dcgettext_u() will 2N/A * search for the message catalog in either a) the binding path set 2N/A * by any previous application calls to bindtextdomain() or 2N/A * binding path so that we can search it if the message catalog 2N/A * is not found via NLSPATH. The original binding is restored before 2N/A * returning from this routine because the gettext routines should 2N/A * not change the binding set by the application. This allows 2N/A * bindtextdomain() to be called once for all gettext() calls in the 2N/A * First, examine NLSPATH 2N/A * NLSPATH binding has been successfully built 2N/A gprintf(0,
"************************** examining NLSPATH\n");
2N/A * Next, examine LANGUAGE 2N/A /* valid msg found in GNU MO */ 2N/A * handle_lang() may have overridden locale 2N/A * Handle a single binding. 2N/A * Lastly, check with obsoleted and canonical locale names. 2N/A}
/* _real_gettext_u */ 2N/A * Populate templates as a linked list, nt, based on NLSPATH, locale, and 2N/A * Collect language, territory, and codeset from the locale name 2N/A * based on the following locale naming convention: 2N/A * language[_territory][.codeset][@modifier] 2N/A while (*s !=
'\0') {
2N/A }
else if (*s ==
'.') {
2N/A }
else if (*s ==
'@') {
2N/A * Process NLSPATH and populate templates. 2N/A * The domain_len and the len used at below includes '\0'. 2N/A * process_nlspath(): process the NLSPATH environment variable. 2N/A * This routine looks at NLSPATH in the environment, 2N/A * and will try to build up the binding list based 2N/A * on the settings of NLSPATH. It will not only use 2N/A * the locale name supplied but also, if available, 2N/A * obsoleted Solaris locale names based on the supplied 2N/A * locale name and also canonical locale name in case 2N/A * the supplied is an alias. 2N/A * -1: Error occurred 2N/A * 0: No error, but no binding list has been built 2N/A * 1: No error, and a binding list has been built or found 2N/A gprintf(0,
"*************** process_nlspath(%s, %s, " 2N/A * This routine will replace substitution parameters in NLSPATH 2N/A * with appropiate values. 2N/A while (*s && *s !=
':') {
2N/A * %% is considered a single % character (XPG). 2N/A * %L : LC_MESSAGES (XPG4) LANG(XPG3) 2N/A * %l : The language element from the current locale. 2N/A else if (*++s ==
'N') {
2N/A }
else if (*s ==
'L') {
2N/A }
else if (*s ==
'l') {
2N/A while (*u && (*u !=
'_') &&
2N/A }
else if (*s ==
't') {
2N/A while (*u && (*u !=
'.') &&
2N/A }
else if (*s ==
'c') {
2N/A /* too long pathname */ 2N/A gprintf(0,
"*************** _real_bindtextdomain_u(\"%s\", " 2N/A "\"%s\", \"%s\")\n",
2N/A * If domain is a NULL pointer, no change will occur regardless 2N/A * of binding value. Just return NULL. 2N/A * Global Binding is not supported any more. 2N/A * Just return NULL if domain is NULL string. 2N/A /* linear search for binding, rebind if found, add if not */ 2N/A prev =
NULL;
/* Two pointers needed for pointer operations */ 2N/A * if binding is null, then query 2N/A /* replace existing binding with new binding */ 2N/A }
/* while (bind) */ 2N/A /* domain has not been found in the list at this point */ 2N/A * domain is not found, but binding is not NULL. 2N/A * Then add a new node to the end of linked list. 2N/A /* reached the end of list */ 2N/A /* list was empty */ 2N/A * Query of domain which is not found in the list 2N/A * for bindtextdomain, returns defaultbind 2N/A * for bind_textdomain_codeset, returns NULL 2N/A }
/* if (binding) */ 2N/A /* Must not reach here */ 2N/A}
/* _real_bindtextdomain_u */ 2N/A gprintf(0,
"*************** _textdomain_u(\"%s\", 0x%p)\n",
2N/A /* Query is performed for NULL domain pointer */ 2N/A /* check for error. */ 2N/A * domain is limited to TEXTDOMAINMAX bytes 2N/A * excluding a null termination. 2N/A * Calling textdomain() with a null domain string sets 2N/A * the domain to the default domain. 2N/A * If non-null string is passwd, current domain is changed 2N/A * to the new domain. 2N/A /* actually this if clause should be protected from signals */ 2N/A}
/* _textdomain_u */ 2N/A * key_2_text() translates msd_id into target string. 2N/A gprintf(0,
"*************** key_2_text(0x%p, \"%s\")\n",
2N/A * To maintain the compatibility with Zeus mo file, 2N/A * msg_id's are stored in descending order. 2N/A * and switch msg_id_str and key_string in the following 2N/A * strcmp() statement. 2N/A * mnp - message node 2N/A * addr - address to the mmapped file 2N/A * size - size of the file 2N/A * 0 - either T_SUN_MO or T_ILL_MO has been set 2N/A * 1 - not a valid sun mo file 2N/A /* invalid mo file */ 2N/A * Not a valid sun mo file 2N/A /* candidate for sun mo */ 2N/A /* invalid mo file */ 2N/A /* valid sun mo file */ 2N/A * mnp - message node 2N/A * addr - address to the mmapped file 2N/A * size - size of the file 2N/A * *ngettext is called against 2N/A /* no valid msg found */ 2N/A /* valid msg found */ 2N/A /* this should never happen */ 2N/A * handle_mo() returns NULL if invalid MO found. 2N/A gprintf(0,
"*************** handle_mo(0x%p)\n", (
void *)
mp);
2N/A * Valid entry not found in the cache