2001-08-16 19:51:43 +02:00
|
|
|
/* 4.4BSD utility functions for error messages.
|
2002-08-03 14:59:33 +02:00
|
|
|
Copyright (C) 1995,96,98,2001,02 Free Software Foundation, Inc.
|
1996-12-04 02:41:39 +01:00
|
|
|
This file is part of the GNU C Library.
|
1995-12-06 01:14:32 +01:00
|
|
|
|
1996-12-04 02:41:39 +01:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 06:58:11 +02:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1995-12-06 01:14:32 +01:00
|
|
|
|
1996-12-04 02:41:39 +01:00
|
|
|
The GNU C Library 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
|
2001-07-06 06:58:11 +02:00
|
|
|
Lesser General Public License for more details.
|
1995-12-06 01:14:32 +01:00
|
|
|
|
2001-07-06 06:58:11 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
1995-12-06 01:14:32 +01:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <err.h>
|
|
|
|
#include <stdlib.h>
|
1995-12-19 11:00:22 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
1995-12-06 01:14:32 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
1998-07-16 13:44:36 +02:00
|
|
|
#ifdef USE_IN_LIBIO
|
2001-08-16 19:51:43 +02:00
|
|
|
# include <wchar.h>
|
1998-07-16 13:44:36 +02:00
|
|
|
# define flockfile(s) _IO_flockfile (s)
|
|
|
|
# define funlockfile(s) _IO_funlockfile (s)
|
|
|
|
#endif
|
|
|
|
|
1995-12-06 01:14:32 +01:00
|
|
|
extern char *__progname;
|
|
|
|
|
|
|
|
#define VA(call) \
|
|
|
|
{ \
|
|
|
|
va_list ap; \
|
|
|
|
va_start (ap, format); \
|
|
|
|
call; \
|
|
|
|
va_end (ap); \
|
|
|
|
}
|
|
|
|
|
2001-08-16 19:51:43 +02:00
|
|
|
#ifdef USE_IN_LIBIO
|
|
|
|
static void
|
|
|
|
convert_and_print (const char *format, __gnuc_va_list ap)
|
|
|
|
{
|
|
|
|
# define ALLOCA_LIMIT 2000
|
|
|
|
size_t len;
|
|
|
|
wchar_t *wformat = NULL;
|
|
|
|
mbstate_t st;
|
|
|
|
size_t res;
|
|
|
|
const char *tmp;
|
|
|
|
|
|
|
|
if (format == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
len = strlen (format) + 1;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (len < ALLOCA_LIMIT)
|
|
|
|
wformat = (wchar_t *) alloca (len * sizeof (wchar_t));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wformat != NULL && len / 2 < ALLOCA_LIMIT)
|
|
|
|
wformat = NULL;
|
|
|
|
|
|
|
|
wformat = (wchar_t *) realloc (wformat, len * sizeof (wchar_t));
|
|
|
|
|
|
|
|
if (wformat == NULL)
|
|
|
|
{
|
2001-08-21 04:57:38 +02:00
|
|
|
fputws_unlocked (L"out of memory\n", stderr);
|
2001-08-16 19:51:43 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset (&st, '\0', sizeof (st));
|
|
|
|
tmp =format;
|
|
|
|
}
|
2001-08-17 09:51:36 +02:00
|
|
|
while ((res = __mbsrtowcs (wformat, &tmp, len, &st)) == len);
|
2001-08-16 19:51:43 +02:00
|
|
|
|
|
|
|
if (res == (size_t) -1)
|
|
|
|
/* The string cannot be converted. */
|
|
|
|
wformat = (wchar_t *) L"???";
|
|
|
|
|
2001-08-17 06:49:12 +02:00
|
|
|
__vfwprintf (stderr, wformat, ap);
|
2001-08-16 19:51:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1995-12-06 01:14:32 +01:00
|
|
|
void
|
1995-12-19 11:00:22 +01:00
|
|
|
vwarnx (const char *format, __gnuc_va_list ap)
|
1995-12-06 01:14:32 +01:00
|
|
|
{
|
1998-07-16 13:44:36 +02:00
|
|
|
flockfile (stderr);
|
2001-08-16 19:51:43 +02:00
|
|
|
#ifdef USE_IN_LIBIO
|
|
|
|
if (_IO_fwide (stderr, 0) > 0)
|
|
|
|
{
|
2001-08-17 06:49:12 +02:00
|
|
|
__fwprintf (stderr, L"%s: ", __progname);
|
2001-08-16 19:51:43 +02:00
|
|
|
convert_and_print (format, ap);
|
|
|
|
putwc_unlocked (L'\n', stderr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
fprintf (stderr, "%s: ", __progname);
|
|
|
|
if (format)
|
|
|
|
vfprintf (stderr, format, ap);
|
|
|
|
putc_unlocked ('\n', stderr);
|
|
|
|
}
|
1998-07-16 13:44:36 +02:00
|
|
|
funlockfile (stderr);
|
1995-12-06 01:14:32 +01:00
|
|
|
}
|
* locale/loadarchive.c (_nl_load_locale_from_archive): Parse locale
name to find codeset name (if any) and normalize it. If the
normalized name differs, look up only that in the archive.
* locale/programs/locarchive.c (add_locale_to_archive): If the name
contains a codeset, normalize the codeset store only the normalized
name in the archive. If not, add an alias containing the locale's
normalized codeset name. Apply codeset name normalization when
matching entries in the alias file.
* locale/programs/locarchive.c (delete_locales_from_archive): Don't
decrement HEAD->namehash_used here.
(add_locale): Only need to insert name string when name_offset != 0.
* locale/programs/localedef.c (options): Add -A/--alias-file.
(alias_file): New variable.
(parse_opt): Grok -A, set that.
* locale/programs/localedef.h: Declare it.
* locale/programs/locarchive.c (insert_name): New function, broken out
of ...
(add_locale_to_archive): ... here. Call that.
(add_alias): New function.
(add_locale): New static function, add_locale_to_archive renamed.
(add_locale_to_archive): Call that and use add_alias to add an alias
for the name with codeset if the given name lacks it.
(enlarge_archive): Call add_locale instead of add_locale_to_archive.
* locale/Makefile (routines): Add loadarchive.
* locale/loadarchive.c: New file, started from code by Ulrich Drepper.
(_nl_load_locale_from_archive): New function.
* locale/localeinfo.h: Declare it.
* locale/findlocale.c (_nl_find_locale): If using default locale path,
try _nl_load_locale_from_archive first.
* locale/loadlocale.c (_nl_intern_locale_data): New function,
broken out of _nl_load_locale.
(_nl_load_locale): Call that.
* locale/localeinfo.h: Declare it.
(struct locale_data): Replace member `mmaped' with `alloc', an enum.
(struct locale_data): Remove unused member `options'.
* locale/findlocale.c (_nl_remove_locale): Update uses.
* locale/loadlocale.c (_nl_load_locale, _nl_unload_locale): Likewise.
* locale/C-collate.c: Update initializer.
* locale/C-identification.c: Likewise.
* locale/C-measurement.c: Likewise.
* locale/C-telephone.c: Likewise.
* locale/C-address.c: Likewise.
* locale/C-name.c: Likewise.
* locale/C-paper.c: Likewise.
* locale/C-time.c: Likewise.
* locale/C-numeric.c: Likewise.
* locale/C-monetary.c: Likewise.
* locale/C-messages.c : Likewise.
* locale/C-ctype.c: Likewise.
* locale/hashval.h [! LONGBITS]: Include <limits.h> here and
use CHAR_BIT instead of BITSPERBYTE.
* locale/localeinfo.h (_nl_find_locale, _nl_load_locale,
_nl_unload_locale): Add `internal_function attribute_hidden' to decls.
* locale/findlocale.c (_nl_find_locale): Add internal_function to defn.
(_nl_remove_locale): Likewise.
* locale/loadlocale.c (_nl_load_locale, _nl_unload_locale): Likewise.
* locale/findlocale.c (_nl_default_locale_path): New variable.
(_nl_find_locale): If LOCALE_PATH is null, default to that.
* locale/localeinfo.h: Declare it.
* locale/setlocale.c (setlocale): Use _nl_default_locale_path
in place of LOCALEDIR. If no LOCPATH, pass null to _nl_find_locale.
* locale/newlocale.c (__newlocale): Likewise.
* misc/err.c (vwarnx, vwarn): Fix typos in libc_hidden_def uses.
* inet/rexec.c (rexec_af): Add libc_hidden_def.
* sysdeps/generic/morecore.c: Likewise.
* signal/allocrtsig.c (__libc_current_sigrtmin): Likewise.
(__libc_current_sigrtmax): Likewise.
2002-08-08 Roland McGrath <roland@redhat.com>
* locale/loadlocale.c (_nl_load_locale): Don't use MAP_INHERIT.
* catgets/open_catalog.c (__open_catalog): Likewise.
* locale/programs/locarchive.c (INITIAL_NUM_NAMES): Renamed
from typo INITIAL_NUM_NANES.
(create_archive): Update use.
2002-08-10 08:22:37 +02:00
|
|
|
libc_hidden_def (vwarnx)
|
1995-12-06 01:14:32 +01:00
|
|
|
|
|
|
|
void
|
1995-12-19 11:00:22 +01:00
|
|
|
vwarn (const char *format, __gnuc_va_list ap)
|
1995-12-06 01:14:32 +01:00
|
|
|
{
|
1995-12-19 11:00:22 +01:00
|
|
|
int error = errno;
|
|
|
|
|
1998-07-16 13:44:36 +02:00
|
|
|
flockfile (stderr);
|
2001-08-16 19:51:43 +02:00
|
|
|
#ifdef USE_IN_LIBIO
|
|
|
|
if (_IO_fwide (stderr, 0) > 0)
|
|
|
|
{
|
2001-08-17 06:49:12 +02:00
|
|
|
__fwprintf (stderr, L"%s: ", __progname);
|
2001-08-16 19:51:43 +02:00
|
|
|
if (format)
|
|
|
|
{
|
|
|
|
convert_and_print (format, ap);
|
|
|
|
fputws_unlocked (L": ", stderr);
|
|
|
|
}
|
|
|
|
__set_errno (error);
|
2001-08-17 06:49:12 +02:00
|
|
|
__fwprintf (stderr, L"%m\n");
|
2001-08-16 19:51:43 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
1995-12-19 11:00:22 +01:00
|
|
|
{
|
2001-08-16 19:51:43 +02:00
|
|
|
fprintf (stderr, "%s: ", __progname);
|
|
|
|
if (format)
|
|
|
|
{
|
|
|
|
vfprintf (stderr, format, ap);
|
|
|
|
fputs_unlocked (": ", stderr);
|
|
|
|
}
|
|
|
|
__set_errno (error);
|
|
|
|
fprintf (stderr, "%m\n");
|
1995-12-19 11:00:22 +01:00
|
|
|
}
|
1998-07-16 13:44:36 +02:00
|
|
|
funlockfile (stderr);
|
1995-12-06 01:14:32 +01:00
|
|
|
}
|
* include/unistd.h (seteuid, setegid): Add libc_hidden_proto.
* sysdeps/generic/seteuid.c (seteuid): Add libc_hidden_def.
* sysdeps/generic/setegid.c (setegid): Likewise.
* sysdeps/mach/hurd/seteuid.c (seteuid): Likewise.
* sysdeps/mach/hurd/setegid.c (setegid): Likewise.
* sysdeps/unix/bsd/seteuid.c (seteuid): Likewise.
* sysdeps/unix/bsd/setegid.c (setegid): Likewise.
* sysdeps/unix/sysv/aix/seteuid.c (seteuid): Likewise.
* sysdeps/unix/sysv/aix/setegid.c (setegid): Likewise.
* sysdeps/unix/sysv/linux/i386/setegid.c (setegid): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c (seteuid): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c (setegid): Likewise.
* sysdeps/unix/sysv/linux/seteuid.c (seteuid): Likewise.
* sysdeps/unix/sysv/linux/setegid.c (setegid): Likewise.
* sysdeps/unix/sysv/linux/i386/seteuid.c (seteuid): Likewise.
Remove fallback if __ASSUME_SETRESUID_SYSCALL.
* include/sys/stat.h (__fxstat_internal, __fxstat64_internal,
__lxstat_internal, __lxstat64_internal): Remove.
(__fxstat, __fxstat64, __lxstat, __lxstat64, __xstat, __xstat64):
Add hidden_proto.
* sysdeps/generic/fxstat.c (__fxstat): Add hidden_def.
Remove INTDEF where present, remove #undef at the beginning.
* sysdeps/generic/fxstat64.c (__fxstat64): Likewise.
* sysdeps/generic/lxstat.c (__lxstat): Likewise.
* sysdeps/generic/lxstat64.c (__lxstat64): Likewise.
* sysdeps/generic/xstat.c (__xstat): Likewise.
* sysdeps/generic/xstat64.c (__xstat64): Likewise.
* sysdeps/mach/hurd/dl-sysdep.c (__xstat64, __fxstat64): Likewise.
* sysdeps/mach/hurd/fxstat.c (__fxstat): Likewise.
* sysdeps/mach/hurd/fxstat64.c (__fxstat64): Likewise.
* sysdeps/mach/hurd/lxstat.c (__lxstat): Likewise.
* sysdeps/mach/hurd/lxstat64.c (__lxstat64): Likewise.
* sysdeps/mach/hurd/xstat.c (__xstat): Likewise.
* sysdeps/mach/hurd/xstat64.c (__xstat64): Likewise.
* sysdeps/unix/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/common/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/aix/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/aix/fxstat64.c (__fxstat64): Likewise.
* sysdeps/unix/sysv/aix/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/aix/lxstat64.c (__lxstat64): Likewise.
* sysdeps/unix/sysv/aix/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/aix/xstat64.c (__xstat64): Likewise.
* sysdeps/unix/sysv/linux/ia64/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/linux/ia64/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/linux/ia64/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/linux/i386/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/linux/i386/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/linux/i386/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/linux/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/linux/xstat64.c (__xstat64): Likewise.
* sysdeps/unix/sysv/linux/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/linux/fxstat64.c (__fxstat64): Likewise.
* sysdeps/unix/sysv/linux/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/linux/lxstat64.c (__lxstat64): Likewise.
* sysdeps/unix/xstat.c (__xstat): Likewise.
* include/sys/statvfs.h (statvfs, fstatvfs): Add libc_hidden_proto.
* sysdeps/generic/statvfs.c (statvfs): Add libc_hidden_def.
* sysdeps/generic/fstatvfs.c (fstatvfs): Likewise.
* sysdeps/mach/hurd/statvfs.c (statvfs): Likewise.
* sysdeps/mach/hurd/fstatvfs.c (fstatvfs): Likewise.
* sysdeps/unix/sysv/linux/statvfs.c (statvfs): Likewise.
* sysdeps/unix/sysv/linux/fstatvfs.c (fstatvfs): Likewise.
* include/unistd.h (tcgetpgrp): Add libc_hidden_proto.
* include/termios.h (tcsetattr, cfsetispeed, cfsetospeed): Likewise.
* sysdeps/generic/tcgetpgrp.c (tcgetpgrp): Add libc_hidden_def.
* sysdeps/generic/tcsetattr.c (tcsetattr): Likewise.
* sysdeps/generic/speed.c (cfsetispeed, cfsetospeed): Likewise.
* sysdeps/unix/bsd/bsd4.4/tcsetattr.c (tcgetpgrp): Likewise.
* sysdeps/unix/bsd/sun/sunos4/tcsetattr.c (tcsetattr): Likewise.
* sysdeps/unix/bsd/sun/sunos4/speed.c (cfsetispeed, cfsetospeed):
Likewise.
* sysdeps/unix/bsd/tcgetpgrp.c (tcgetpgrp): Likewise.
* sysdeps/unix/bsd/tcsetattr.c (tcsetattr): Likewise.
* sysdeps/unix/sysv/aix/tcsetattr.c (tcsetattr): Likewise.
* sysdeps/unix/sysv/aix/speed.c (cfsetispeed, cfsetospeed): Likewise.
* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
* sysdeps/unix/sysv/linux/speed.c (cfsetispeed, cfsetospeed): Likewise.
* sysdeps/unix/sysv/tcgetpgrp.c (tcgetpgrp): Likewise.
* sysdeps/unix/sysv/tcsetattr.c (tcsetattr): Likewise.
* include/string.h (strcoll): Add libc_hidden_proto.
* string/strcoll.c (strcoll): Add libc_hidden_def.
* misc/err.c (vwarn): Fix pasto in libc_hidden_def.
2002-08-13 02:24:58 +02:00
|
|
|
libc_hidden_def (vwarn)
|
1995-12-06 01:14:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
warn (const char *format, ...)
|
|
|
|
{
|
|
|
|
VA (vwarn (format, ap))
|
|
|
|
}
|
2002-08-03 14:59:33 +02:00
|
|
|
libc_hidden_def (warn)
|
1995-12-06 01:14:32 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
warnx (const char *format, ...)
|
|
|
|
{
|
|
|
|
VA (vwarnx (format, ap))
|
|
|
|
}
|
2002-08-03 14:59:33 +02:00
|
|
|
libc_hidden_def (warnx)
|
1995-12-06 01:14:32 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
verr (int status, const char *format, __gnuc_va_list ap)
|
|
|
|
{
|
|
|
|
vwarn (format, ap);
|
|
|
|
exit (status);
|
|
|
|
}
|
2002-08-03 14:59:33 +02:00
|
|
|
libc_hidden_def (verr)
|
1995-12-06 01:14:32 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
verrx (int status, const char *format, __gnuc_va_list ap)
|
|
|
|
{
|
|
|
|
vwarnx (format, ap);
|
|
|
|
exit (status);
|
|
|
|
}
|
2002-08-03 14:59:33 +02:00
|
|
|
libc_hidden_def (verrx)
|
1995-12-06 01:14:32 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
err (int status, const char *format, ...)
|
|
|
|
{
|
|
|
|
VA (verr (status, format, ap))
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
errx (int status, const char *format, ...)
|
|
|
|
{
|
|
|
|
VA (verrx (status, format, ap))
|
|
|
|
}
|