/* Implementation of the internal dcigettext function.
- Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
# define alloca __builtin_alloca
# define HAVE_ALLOCA 1
#else
-# ifdef _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
+# if defined HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
# else
-# if defined HAVE_ALLOCA_H || defined _LIBC
-# include <alloca.h>
-# else
-# ifdef _AIX
+# ifdef _AIX
#pragma alloca
-# else
-# ifndef alloca
+# else
+# ifndef alloca
char *alloca ();
-# endif
# endif
# endif
# endif
}
#endif
-#ifndef INTVARDEF
-# define INTVARDEF(name)
-#endif
-#ifndef INTUSE
-# define INTUSE(name) name
-#endif
-
/* Name of the default domain used for gettext(3) prior any call to
textdomain(3). The default value for this is "messages". */
const char _nl_default_default_domain[] attribute_hidden = "messages";
extern const char _nl_default_dirname[];
#else
const char _nl_default_dirname[] = LOCALEDIR;
-INTVARDEF (_nl_default_dirname)
#endif
/* List with bindings of specific domains created by bindtextdomain()
const char *translation,
size_t translation_len))
internal_function;
+static const char *category_to_name PARAMS ((int category)) internal_function;
static const char *guess_category_value PARAMS ((int category,
const char *categoryname))
internal_function;
-#ifdef _LIBC
-# include "../locale/localeinfo.h"
-# define category_to_name(category) _nl_category_names[category]
-#else
-static const char *category_to_name PARAMS ((int category)) internal_function;
-#endif
/* For those loosing systems which don't have `alloca' we have to add
if (msgid1 == NULL)
return NULL;
-#ifdef _LIBC
- if (category < 0 || category >= __LC_LAST || category == LC_ALL)
- /* Bogus. */
- return (plural == 0
- ? (char *) msgid1
- /* Use the Germanic plural rule. */
- : n == 1 ? (char *) msgid1 : (char *) msgid2);
-#endif
-
__libc_rwlock_rdlock (_nl_state_lock);
/* If DOMAINNAME is NULL, we are interested in the default domain. If
}
if (binding == NULL)
- dirname = (char *) INTUSE(_nl_default_dirname);
+ dirname = (char *) _nl_default_dirname;
else if (IS_ABSOLUTE_PATH (binding->dirname))
dirname = binding->dirname;
else
}
if (ret == NULL)
- /* We cannot get the current working directory. Don't signal an
- error but simply return the default string. */
- goto return_untranslated;
+ {
+ /* We cannot get the current working directory. Don't signal an
+ error but simply return the default string. */
+ FREE_BLOCKS (block_list);
+ __libc_rwlock_unlock (_nl_state_lock);
+ __set_errno (saved_errno);
+ return (plural == 0
+ ? (char *) msgid1
+ /* Use the Germanic plural rule. */
+ : n == 1 ? (char *) msgid1 : (char *) msgid2);
+ }
stpcpy (stpcpy (strchr (dirname, '\0'), "/"), binding->dirname);
}
domain. Return the MSGID. */
if (strcmp (single_locale, "C") == 0
|| strcmp (single_locale, "POSIX") == 0)
- break;
+ {
+ FREE_BLOCKS (block_list);
+ __libc_rwlock_unlock (_nl_state_lock);
+ __set_errno (saved_errno);
+ return (plural == 0
+ ? (char *) msgid1
+ /* Use the Germanic plural rule. */
+ : n == 1 ? (char *) msgid1 : (char *) msgid2);
+ }
+
/* Find structure describing the message catalog matching the
DOMAINNAME and CATEGORY. */
/* Found the translation of MSGID1 in domain DOMAIN:
starting at RETVAL, RETLEN bytes. */
FREE_BLOCKS (block_list);
+ __set_errno (saved_errno);
#if defined HAVE_TSEARCH || defined _LIBC
if (foundp == NULL)
{
(*foundp)->translation_length = retlen;
}
#endif
- __set_errno (saved_errno);
-
/* Now deal with plural. */
if (plural)
retval = plural_lookup (domain, n, retval, retlen);
}
}
}
-
- return_untranslated:
- /* Return the untranslated MSGID. */
- FREE_BLOCKS (block_list);
- __libc_rwlock_unlock (_nl_state_lock);
-#ifndef _LIBC
- if (!ENABLE_SECURE)
- {
- extern void _nl_log_untranslated PARAMS ((const char *logfilename,
- const char *domainname,
- const char *msgid1,
- const char *msgid2,
- int plural));
- const char *logfilename = getenv ("GETTEXT_LOG_UNTRANSLATED");
-
- if (logfilename != NULL && logfilename[0] != '\0')
- _nl_log_untranslated (logfilename, domainname, msgid1, msgid2, plural);
- }
-#endif
- __set_errno (saved_errno);
- return (plural == 0
- ? (char *) msgid1
- /* Use the Germanic plural rule. */
- : n == 1 ? (char *) msgid1 : (char *) msgid2);
+ /* NOTREACHED */
}
return (char *) p;
}
-#ifndef _LIBC
+
/* Return string representation of locale CATEGORY. */
static const char *
internal_function
return retval;
}
-#endif
/* Guess value of current locale from value of the environment variables. */
static const char *
`LC_xxx', and `LANG'. On some systems this can be done by the
`setlocale' function itself. */
#ifdef _LIBC
- retval = __current_locale_name (category);
+ retval = setlocale (category, NULL);
#else
retval = _nl_locale_name (category, categoryname);
#endif
#ifdef _LIBC
/* If we want to free all resources we have to do some work at
program's end. */
-libc_freeres_fn (free_mem)
+static void __attribute__ ((unused))
+free_mem (void)
{
void *old;
{
struct binding *oldp = _nl_domain_bindings;
_nl_domain_bindings = _nl_domain_bindings->next;
- if (oldp->dirname != INTUSE(_nl_default_dirname))
+ if (oldp->dirname != _nl_default_dirname)
/* Yes, this is a pointer comparison. */
free (oldp->dirname);
free (oldp->codeset);
free (old);
}
}
+
+text_set_element (__libc_subfreeres, free_mem);
#endif