/* Compatibility code for gettext-using-catgets interface. Copyright (C) 1995, 1997 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H # include <config.h> #endif
#include <stdio.h>
#ifdef STDC_HEADERS # include <stdlib.h> # include <string.h> #else char *getenv (); # ifdef HAVE_MALLOC_H # include <malloc.h> # endif #endif
#ifdef HAVE_NL_TYPES_H # include <nl_types.h> #endif
#include"libgettext.h"
/* @@ end of prolog @@ */
/* XPG3 defines the result of `setlocale (category, NULL)' as: ``Directs `setlocale()' to query `category' and return the current setting of `local'.'' However it does not specify the exact format. And even worse: POSIX defines this not at all. So we can use this feature only on selected
system (e.g. those using GNU C Library). */ #ifdef _LIBC # define HAVE_LOCALE_NULL #endif
/* Name of the default catalog. */ staticconstchar default_catalog_name[] = "messages";
/* Name of currently used catalog. */ staticconstchar *catalog_name = default_catalog_name;
/* Get ID for given string. If not found return -1. */ staticint msg_to_cat_id PARAMS ((constchar *msg));
/* Substitution for systems lacking this function in their C library. */ #if !_LIBC && !HAVE_STPCPY staticchar *stpcpy PARAMS ((char *dest, constchar *src)); #endif
/* Set currently used domain/catalog. */ char *
textdomain (domainname) constchar *domainname;
{
nl_catd new_catalog; char *new_name;
size_t new_name_len; char *lang;
#ifdefined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES \
&& defined HAVE_LOCALE_NULL
lang = setlocale (LC_MESSAGES, NULL); #else
lang = getenv ("LC_ALL"); if (lang == NULL || lang[0] == '\0')
{
lang = getenv ("LC_MESSAGES"); if (lang == NULL || lang[0] == '\0')
lang = getenv ("LANG");
} #endif if (lang == NULL || lang[0] == '\0')
lang = "C";
/* See whether name of currently used domain is asked. */ if (domainname == NULL) return (char *) catalog_name;
if (domainname[0] == '\0')
domainname = default_catalog_name;
/* This does not make much sense here but to be compatible do it. */ if (domainname == NULL) return NULL;
/* Compute length of added path element. If we use setenv we don't need the first byts for NLSPATH=, but why complicate the code for this
peanuts. */
new_val_len = sizeof ("NLSPATH=") - 1 + strlen (dirname)
+ sizeof ("/%L/LC_MESSAGES/%N.cat");
# if HAVE_SETENV
setenv ("NLSPATH", new_val, 1);
free (new_val); # else
putenv (new_val); /* Do *not* free the environment entry we just entered. It is used
from now on. */ # endif
/* Get the message from the catalog. We always use set number 1. The message ID is computed by the function `msg_to_cat_id'
which works on the table generated by `po-to-tbl'. */
msgid = msg_to_cat_id (msg); if (msgid == -1) return (char *) msg;
/* Look through the table `_msg_tbl' which has `_msg_tbl_length' entries for the one equal to msg. If it is found return the ID. In case when
the string is not found return -1. */ staticint
msg_to_cat_id (msg) constchar *msg;
{ int cnt;
for (cnt = 0; cnt < _msg_tbl_length; ++cnt) if (strcmp (msg, _msg_tbl[cnt]._msg) == 0) return _msg_tbl[cnt]._msg_number;
return -1;
}
/* @@ begin of epilog @@ */
/* We don't want libintl.a to depend on any other library. So we avoid the non-standard function stpcpy. In GNU C Library this function is available, though. Also allow the symbol HAVE_STPCPY
to be defined. */ #if !_LIBC && !HAVE_STPCPY staticchar *
stpcpy (dest, src) char *dest; constchar *src;
{ while ((*dest++ = *src++) != '\0') /* Do nothing. */ ; return dest - 1;
} #endif
¤ Dauer der Verarbeitung: 0.27 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.