* locale/xlocale.c (_nl_C_locobj): Update initializer.
* locale/global-locale.c (_nl_global_locale): Likewise.
* locale/duplocale.c (__duplocale): strdup __names elements.
* locale/freelocale.c (__freelocale): Free __names elements.
* locale/localename.c (_nl_current_names): Variable removed.
(__current_locale_name): Use _NL_CURRENT_LOCALE->__names instead.
* locale/localeinfo.h (_nl_current_names): Removed decl.
* locale/setlocale.c: Use _nl_global_locale->__names in place of
_nl_current_names throughout.
* locale/setlocale.c (setlocale): strdup -> __strdup (not ISO C).
* sysdeps/gnu/errlist-compat.awk: Emit link_warnings for sys_errlist
and sys_nerr in the output file.
* sunrpc/Makefile (rpcgen-cmd): Pass CPP in rpcgen's environment.
* scripts/cpp: Just use the environment variable.
* libio/tst-mmap-setvbuf.c (main): Use 'm' fopen flag.
* libio/tst-mmap-offend.c (do_test): Likewise.
* libio/tst-mmap-fflushsync.c (do_test): Likewise.
* libio/tst-mmap-eofsync.c (do_test): Likewise.
* libio/tst-mmap2-eofsync.c (do_test): Likewise.
2002-08-30 Roland McGrath <roland@redhat.com>
+ * locale/xlocale.h (struct __locale_struct): New member `__names'.
+ * locale/xlocale.c (_nl_C_locobj): Update initializer.
+ * locale/global-locale.c (_nl_global_locale): Likewise.
+ * locale/duplocale.c (__duplocale): strdup __names elements.
+ * locale/freelocale.c (__freelocale): Free __names elements.
+ * locale/localename.c (_nl_current_names): Variable removed.
+ (__current_locale_name): Use _NL_CURRENT_LOCALE->__names instead.
+ * locale/localeinfo.h (_nl_current_names): Removed decl.
+ * locale/setlocale.c: Use _nl_global_locale->__names in place of
+ _nl_current_names throughout.
+
+ * locale/setlocale.c (setlocale): strdup -> __strdup (not ISO C).
+
+ * sysdeps/gnu/errlist-compat.awk: Emit link_warnings for sys_errlist
+ and sys_nerr in the output file.
+
+ * sunrpc/Makefile (rpcgen-cmd): Pass CPP in rpcgen's environment.
+ * scripts/cpp: Just use the environment variable.
+
+ * libio/tst-mmap-setvbuf.c (main): Use 'm' fopen flag.
+ * libio/tst-mmap-offend.c (do_test): Likewise.
+ * libio/tst-mmap-fflushsync.c (do_test): Likewise.
+ * libio/tst-mmap-eofsync.c (do_test): Likewise.
+ * libio/tst-mmap2-eofsync.c (do_test): Likewise.
+
* locale/localename.c: If the current locale is the global locale, use
_nl_current_names; otherwise use the locale object.
int result = 0;
int c;
- f = fopen (temp_file, "r");
+ f = fopen (temp_file, "rm");
if (f == NULL)
{
perror (temp_file);
int result = 0;
int c;
- f = fopen (temp_file, "r");
+ f = fopen (temp_file, "rm");
if (f == NULL)
{
perror (temp_file);
{
unsigned char buffer[8192];
int result = 0;
- FILE *f = fopen (temp_file, "r");
+ FILE *f = fopen (temp_file, "rm");
size_t cc;
if (f == NULL)
fputs (test, f);
fclose (f);
- f = fopen (name, "r");
+ f = fopen (name, "rm");
if (f == NULL)
{
printf ("%u: cannot fopen temporary file: %m\n", __LINE__);
int result = 0;
int c;
- f = fopen (temp_file, "r");
+ f = fopen (temp_file, "rm");
if (f == NULL)
{
perror (temp_file);
__duplocale (__locale_t dataset)
{
__locale_t result;
+ int cnt;
/* We modify global data. */
__libc_lock_lock (__libc_setlocale_lock);
/* Get memory. */
result = (__locale_t) malloc (sizeof (struct __locale_struct));
+
+ if (result != NULL)
+ /* Duplicate the names in a separate loop first so we can
+ bail out if strdup fails and not have touched usage_counts. */
+ for (cnt = 0; cnt < __LC_LAST; ++cnt)
+ if (cnt != LC_ALL)
+ {
+ if (dataset->__names[cnt] == _nl_C_name)
+ result->__names[cnt] = _nl_C_name;
+ else
+ {
+ result->__names[cnt] = __strdup (dataset->__names[cnt]);
+ if (result->__names[cnt] == NULL)
+ {
+ while (cnt-- > 0)
+ if (dataset->__names[cnt] != _nl_C_name)
+ free ((char *) dataset->__names[cnt]);
+ free (result);
+ result = NULL;
+ break;
+ }
+ }
+ }
+
if (result != NULL)
{
- int cnt;
for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL)
{
__libc_lock_lock (__libc_setlocale_lock);
for (cnt = 0; cnt < __LC_LAST; ++cnt)
- if (cnt != LC_ALL && dataset->__locales[cnt]->usage_count != UNDELETABLE)
- /* We can remove the data. */
- _nl_remove_locale (cnt, dataset->__locales[cnt]);
+ if (cnt != LC_ALL)
+ {
+ if (dataset->__locales[cnt]->usage_count != UNDELETABLE)
+ /* We can remove the data. */
+ _nl_remove_locale (cnt, dataset->__locales[cnt]);
+ if (dataset->__names[cnt] != _nl_C_name)
+ free ((char *) dataset->__names[cnt]);
+ }
/* Free the locale_t handle itself. */
free (dataset);
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = &_nl_C_##category,
#include "categories.def"
+#undef DEFINE_CATEGORY
+ },
+ .__names =
+ {
+ [LC_ALL] = _nl_C_name,
+#define DEFINE_CATEGORY(category, category_name, items, a) \
+ [category] = _nl_C_name,
+#include "categories.def"
#undef DEFINE_CATEGORY
},
.__ctype_b = (const unsigned short int *) _nl_C_LC_CTYPE_class + 128,
/* The standard codeset. */
extern const char _nl_C_codeset[] attribute_hidden;
-/* Name of current locale for each individual category.
- Each is malloc'd unless it is _nl_C_name. */
-extern const char *_nl_current_names[] attribute_hidden;
-
/* This is the internal locale_t object that holds the global locale
controlled by calls to setlocale. A thread's TSD locale pointer
points to this when `uselocale (LC_GLOBAL_LOCALE)' is in effect. */
#include "localeinfo.h"
-/* Name of current locale for each individual category.
- Each is malloc'd unless it is _nl_C_name. */
-const char *_nl_current_names[] attribute_hidden =
- {
-#define DEFINE_CATEGORY(category, category_name, items, a) \
- [category] = _nl_C_name,
-#include "categories.def"
-#undef DEFINE_CATEGORY
- [LC_ALL] = _nl_C_name /* For LC_ALL. */
- };
-
const char *
attribute_hidden
__current_locale_name (int category)
{
- return (_NL_CURRENT_LOCALE == &_nl_global_locale
- ? _nl_current_names[category]
- : _NL_CURRENT_LOCALE->__locales[category]->name);
+ return _NL_CURRENT_LOCALE->__names[category];
}
{
const char *name = (category == LC_ALL ? newnames[i] :
category == i ? newnames[0] :
- _nl_current_names[i]);
+ _nl_global_locale.__names[i]);
last_len = strlen (name);
cumlen += _nl_category_name_sizes[i] + 1 + last_len + 1;
if (i > 0 && same && strcmp (name, newnames[0]) != 0)
/* Add "CATEGORY=NAME;" to the string. */
const char *name = (category == LC_ALL ? newnames[i] :
category == i ? newnames[0] :
- _nl_current_names[i]);
+ _nl_global_locale.__names[i]);
p = __stpcpy (p, _nl_category_names[i]);
*p++ = '=';
p = __stpcpy (p, name);
}
-/* Put NAME in _nl_current_names. */
+/* Put NAME in _nl_global_locale.__names. */
static inline void
setname (int category, const char *name)
{
- if (_nl_current_names[category] == name)
+ if (_nl_global_locale.__names[category] == name)
return;
- if (_nl_current_names[category] != _nl_C_name)
- free ((char *) _nl_current_names[category]);
+ if (_nl_global_locale.__names[category] != _nl_C_name)
+ free ((char *) _nl_global_locale.__names[category]);
- _nl_current_names[category] = name;
+ _nl_global_locale.__names[category] = name;
}
/* Put DATA in *_nl_current[CATEGORY]. */
/* Does user want name of current locale? */
if (locale == NULL)
- return (char *) _nl_current_names[category];
+ return (char *) _nl_global_locale.__names[category];
- if (strcmp (locale, _nl_current_names[category]) == 0)
+ if (strcmp (locale, _nl_global_locale.__names[category]) == 0)
/* Changing to the same thing. */
- return (char *) _nl_current_names[category];
+ return (char *) _nl_global_locale.__names[category];
/* We perhaps really have to load some data. So we determine the
path in which to look for the data now. The environment variable
/* Make a copy of locale name. */
if (newnames[category] != _nl_C_name)
{
- newnames[category] = strdup (newnames[category]);
+ newnames[category] = __strdup (newnames[category]);
if (newnames[category] == NULL)
break;
}
/* Make a copy of locale name. */
if (newname[0] != _nl_C_name)
{
- newname[0] = strdup (newname[0]);
+ newname[0] = __strdup (newname[0]);
if (newname[0] == NULL)
goto abort_single;
}
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = &_nl_C_##category,
#include "categories.def"
+#undef DEFINE_CATEGORY
+ },
+ .__names =
+ {
+ [LC_ALL] = _nl_C_name,
+#define DEFINE_CATEGORY(category, category_name, items, a) \
+ [category] = _nl_C_name,
+#include "categories.def"
#undef DEFINE_CATEGORY
},
.__ctype_b = (const unsigned short int *) _nl_C_LC_CTYPE_class + 128,
/* Definition of locale datatype.
- Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997,2000,02 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
{
/* Note: LC_ALL is not a valid index into this array. */
struct locale_data *__locales[13]; /* 13 = __LC_LAST. */
+ const char *__names[13];
/* To increase the speed of this solution we add some special members. */
const unsigned short int *__ctype_b;
#! /bin/sh
-cpp=`which cpp 2>/dev/null`
-if test $? -ne 0; then
- if type cpp 2>/dev/null >/dev/null; then
- cpp=`type cpp 2>/dev/null | awk '{ print $NF }'`
- else
- cpp=`gcc -print-file-name=cpp 2>/dev/null`
- if test $? -ne 0; then
- if test -x /lib/cpp; then
- cpp=/lib/cpp
- else
- echo "cpp not found" 1>&2
- exit 1
- fi
- fi
- fi
-fi
-exec $cpp $*
-Local Variables:
-mode: sh
-End:
+# This script is used solely by rpcgen when run by sunrpc/Makefile,
+# which passes CPP in the environment to tell us what to run.
+
+exec ${CPP} "$@"
$(+link)
# Tell rpcgen where to find the C preprocessor.
-rpcgen-cmd = $(built-program-cmd) -Y ../scripts
+rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-cmd) -Y ../scripts
# Install the rpc data base file.
$(inst_sysconfdir)/rpc: etc.rpc $(+force)
versioned_symbol (libc, _sys_nerr_internal, sys_nerr, %s);\n\
versioned_symbol (libc, __sys_nerr_internal, _sys_nerr, %s);\n", \
lastv, lastv, lastv, lastv;
+
+ print "\n\
+link_warning (sys_errlist, \"\
+`sys_errlist' is deprecated; use `strerror' or `strerror_r' instead\")\n\
+link_warning (sys_nerr, \"\
+`sys_nerr' is deprecated; use `strerror' or `strerror_r' instead\")";
}