2020-01-01 00:14:33 +00:00
|
|
|
/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
|
1997-06-23 21:55:26 +00:00
|
|
|
This file is part of the GNU C Library.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1997-06-23 21:55:26 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00: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-02-18 01:27:10 +00:00
|
|
|
|
1997-06-23 21:55:26 +00: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 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1995-02-18 01:27:10 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1999-07-21 16:46:32 +00:00
|
|
|
#include <libintl.h>
|
1995-02-18 01:27:10 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <mach/error.h>
|
1995-05-08 09:11:25 +00:00
|
|
|
#include <errorlib.h>
|
1998-01-25 17:01:47 +00:00
|
|
|
#include <sys/param.h>
|
2012-03-20 23:00:23 +00:00
|
|
|
#include <_itoa.h>
|
1995-02-18 01:27:10 +00:00
|
|
|
|
1996-10-22 23:29:26 +00:00
|
|
|
/* It is critical here that we always use the `dcgettext' function for
|
|
|
|
the message translation. Since <libintl.h> only defines the macro
|
|
|
|
`dgettext' to use `dcgettext' for optimizing programs this is not
|
|
|
|
always guaranteed. */
|
|
|
|
#ifndef dgettext
|
|
|
|
# include <locale.h> /* We need LC_MESSAGES. */
|
|
|
|
# define dgettext(domainname, msgid) dcgettext (domainname, msgid, LC_MESSAGES)
|
|
|
|
#endif
|
|
|
|
|
1995-02-18 01:27:10 +00:00
|
|
|
/* Return a string describing the errno code in ERRNUM. */
|
|
|
|
char *
|
1998-04-14 16:51:08 +00:00
|
|
|
__strerror_r (int errnum, char *buf, size_t buflen)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
1995-11-07 21:46:52 +00:00
|
|
|
int system;
|
1995-02-18 01:27:10 +00:00
|
|
|
int sub;
|
|
|
|
int code;
|
|
|
|
const struct error_system *es;
|
|
|
|
extern void __mach_error_map_compat (int *);
|
|
|
|
|
|
|
|
__mach_error_map_compat (&errnum);
|
|
|
|
|
|
|
|
system = err_get_system (errnum);
|
|
|
|
sub = err_get_sub (errnum);
|
|
|
|
code = err_get_code (errnum);
|
|
|
|
|
1995-05-08 09:11:25 +00:00
|
|
|
if (system > err_max_system || ! __mach_error_systems[system].bad_sub)
|
1995-02-18 01:27:10 +00:00
|
|
|
{
|
1998-01-25 17:01:47 +00:00
|
|
|
/* Buffer we use to print the number in. For a maximum size for
|
|
|
|
`int' of 8 bytes we never need more than 20 digits. */
|
|
|
|
char numbuf[21];
|
1995-10-17 05:49:48 +00:00
|
|
|
const char *unk = _("Error in unknown error system: ");
|
|
|
|
const size_t unklen = strlen (unk);
|
1998-01-25 17:01:47 +00:00
|
|
|
char *p, *q;
|
|
|
|
|
|
|
|
numbuf[20] = '\0';
|
|
|
|
p = _itoa_word (errnum, &numbuf[20], 16, 1);
|
|
|
|
|
|
|
|
/* Now construct the result while taking care for the destination
|
|
|
|
buffer size. */
|
|
|
|
q = __mempcpy (buf, unk, MIN (unklen, buflen));
|
|
|
|
if (unklen < buflen)
|
Update.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* string/strxfrm.c (strxfrm, wcsxfrm): Include <sys/param.h>.
If nrules == 0 and srclen < n, copy only srclen + 1 characters.
* sysdeps/generic/getdomain.c (getdomainname): Include <sys/param.h>.
If the result is fits in the buffer, copy only as many bytes as needed.
* sysdeps/generic/_strerror.c (__strerror_r): Don't zero-fill the
buffer after copying numbuf into it.
* sysdeps/mach/_strerror.c (__strerror_r): Likewise.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* posix/confstr.c (confstr): When string_len > len, NUL-terminate
the result. When string_len < len, don't clear the rest of the buffer.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
Support for new LC_COLLATE format.
* locale/coll-lookup.h: New file.
* locale/weightwc.h (findidx): When size == 0, call
collidx_table_lookup.
* wcsmbs/wcscoll.c: Include coll-lookup.h.
* wcsmbs/wcsxfrm.c: Likewise.
* posix/fnmatch.c: Likewise.
* posix/fnmatch_loop.c (internal_fnwmatch): When size == 0, call
collseq_table_lookup.
* locale/programs/3level.h: New file.
* locale/programs/ld-ctype.c: (wcwidth_table, wctrans_table): Define
by including "3level.h".
* locale/programs/ld-collate.c (wchead_table, collidx_table,
collseq_table): New types, defined by including "3level.h".
(locale_collate_t): New wcheads_3level, wcseqorder_3level fields.
(encoding_mask, encoding_byte): Remove.
(utf8_encode): Use simple shifts instead.
(collate_finish): When !oldstyle_tables, set plane_size and plane_cnt
to 0, and initialize and fill wcheads_3level and wcseqorder_3level.
(collate_output): New local variable tablewc_3level. When
!oldstyle_tables, set table_size to 0 and names to NULL and fill
tablewc_3level instead of tablewc. Change format of TABLEWC and
COLLSEQWC entries written to the file.
* locale/C-collate.c (collseqwc): Change format.
(_nl_C_LC_COLLATE): Set HASH_SIZE and HASH_LAYERS to 0, change format
of COLLSEQWC.
* locale/Makefile (distribute): Add coll-lookup.h, programs/3level.h.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* locale/programs/ld-ctype.c (MAX_CHARNAMES_IDX): New macro.
(locale_ctype_t): New charnames_idx field.
(ctype_startup): Initialize charnames_idx field.
(find_idx): Speed up dramatically by using charnames_idx inverse table.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* locale/C-ctype.c: Switch to new locale format.
(_nl_C_LC_CTYPE_names): Remove array.
(STRUCT_CTYPE_CLASS): New macro.
(_nl_C_LC_CTYPE_class_{upper,lower,alpha,digit,xdigit,space,print,
graph,blank,cntrl,punct,alnum}, _nl_C_LC_CTYPE_map_{toupper,tolower}):
New three-level tables.
(_nl_C_LC_CTYPE_width): Change from array to three-level table.
(_nl_C_LC_CTYPE): Fix nstrings value. Set HASH_SIZE and HASH_LAYERS
to 0. Change WIDTH format. Set CLASS_OFFSET and MAP_OFFSET. Add
12 class tables and 2 map tables at the end.
* ctype/ctype-info.c (_nl_C_LC_CTYPE_names): Remove declaration.
(_nl_C_LC_CTYPE_class_{upper,lower,alpha,digit,xdigit,space,print,
graph,blank,cntrl,punct,alnum}, _nl_C_LC_CTYPE_map_{toupper,tolower}):
New declarations.
(b): Remove trailing semicolon.
(__ctype_names, __ctype_width): Don't initialize.
(__ctype32_wctype, __ctype32_wctrans, __ctype32_width): Initialize.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* elf/dl-load.c (open_path): Add a argument telling whether *dirsp
is guaranteed to be allocated with the same malloc() and may be
passed to free().
(_dl_map_object): Update open_path calls. If rtld_search_dirs has
been set to empty by an earlier open_path call, don't pass it again.
2000-08-29 01:20:23 +00:00
|
|
|
memcpy (q, p, MIN (&numbuf[21] - p, buflen - unklen));
|
1998-01-25 17:01:47 +00:00
|
|
|
|
|
|
|
/* Terminate the string in any case. */
|
|
|
|
if (buflen > 0)
|
|
|
|
buf[buflen - 1] = '\0';
|
|
|
|
|
|
|
|
return buf;
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
es = &__mach_error_systems[system];
|
|
|
|
|
|
|
|
if (sub >= es->max_sub)
|
|
|
|
return (char *) es->bad_sub;
|
|
|
|
|
|
|
|
if (code >= es->subsystem[sub].max_code)
|
|
|
|
{
|
1998-01-25 17:01:47 +00:00
|
|
|
/* Buffer we use to print the number in. For a maximum size for
|
|
|
|
`int' of 8 bytes we never need more than 20 digits. */
|
|
|
|
char numbuf[21];
|
1995-10-17 05:49:48 +00:00
|
|
|
const char *unk = _("Unknown error ");
|
|
|
|
const size_t unklen = strlen (unk);
|
1998-01-25 17:01:47 +00:00
|
|
|
char *p, *q;
|
1995-05-09 07:03:38 +00:00
|
|
|
size_t len = strlen (es->subsystem[sub].subsys_name);
|
1998-01-25 17:01:47 +00:00
|
|
|
|
|
|
|
numbuf[20] = '\0';
|
|
|
|
p = _itoa_word (errnum, &numbuf[20], 10, 0);
|
|
|
|
|
|
|
|
/* Now construct the result while taking care for the destination
|
|
|
|
buffer size. */
|
|
|
|
q = __mempcpy (buf, unk, MIN (unklen, buflen));
|
|
|
|
if (unklen < buflen)
|
|
|
|
{
|
|
|
|
q = __mempcpy (q, es->subsystem[sub].subsys_name,
|
|
|
|
MIN (len, buflen - unklen));
|
|
|
|
if (unklen + len < buflen)
|
|
|
|
{
|
|
|
|
*q++ = ' ';
|
|
|
|
if (unklen + len + 1 < buflen)
|
Update.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* string/strxfrm.c (strxfrm, wcsxfrm): Include <sys/param.h>.
If nrules == 0 and srclen < n, copy only srclen + 1 characters.
* sysdeps/generic/getdomain.c (getdomainname): Include <sys/param.h>.
If the result is fits in the buffer, copy only as many bytes as needed.
* sysdeps/generic/_strerror.c (__strerror_r): Don't zero-fill the
buffer after copying numbuf into it.
* sysdeps/mach/_strerror.c (__strerror_r): Likewise.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* posix/confstr.c (confstr): When string_len > len, NUL-terminate
the result. When string_len < len, don't clear the rest of the buffer.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
Support for new LC_COLLATE format.
* locale/coll-lookup.h: New file.
* locale/weightwc.h (findidx): When size == 0, call
collidx_table_lookup.
* wcsmbs/wcscoll.c: Include coll-lookup.h.
* wcsmbs/wcsxfrm.c: Likewise.
* posix/fnmatch.c: Likewise.
* posix/fnmatch_loop.c (internal_fnwmatch): When size == 0, call
collseq_table_lookup.
* locale/programs/3level.h: New file.
* locale/programs/ld-ctype.c: (wcwidth_table, wctrans_table): Define
by including "3level.h".
* locale/programs/ld-collate.c (wchead_table, collidx_table,
collseq_table): New types, defined by including "3level.h".
(locale_collate_t): New wcheads_3level, wcseqorder_3level fields.
(encoding_mask, encoding_byte): Remove.
(utf8_encode): Use simple shifts instead.
(collate_finish): When !oldstyle_tables, set plane_size and plane_cnt
to 0, and initialize and fill wcheads_3level and wcseqorder_3level.
(collate_output): New local variable tablewc_3level. When
!oldstyle_tables, set table_size to 0 and names to NULL and fill
tablewc_3level instead of tablewc. Change format of TABLEWC and
COLLSEQWC entries written to the file.
* locale/C-collate.c (collseqwc): Change format.
(_nl_C_LC_COLLATE): Set HASH_SIZE and HASH_LAYERS to 0, change format
of COLLSEQWC.
* locale/Makefile (distribute): Add coll-lookup.h, programs/3level.h.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* locale/programs/ld-ctype.c (MAX_CHARNAMES_IDX): New macro.
(locale_ctype_t): New charnames_idx field.
(ctype_startup): Initialize charnames_idx field.
(find_idx): Speed up dramatically by using charnames_idx inverse table.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* locale/C-ctype.c: Switch to new locale format.
(_nl_C_LC_CTYPE_names): Remove array.
(STRUCT_CTYPE_CLASS): New macro.
(_nl_C_LC_CTYPE_class_{upper,lower,alpha,digit,xdigit,space,print,
graph,blank,cntrl,punct,alnum}, _nl_C_LC_CTYPE_map_{toupper,tolower}):
New three-level tables.
(_nl_C_LC_CTYPE_width): Change from array to three-level table.
(_nl_C_LC_CTYPE): Fix nstrings value. Set HASH_SIZE and HASH_LAYERS
to 0. Change WIDTH format. Set CLASS_OFFSET and MAP_OFFSET. Add
12 class tables and 2 map tables at the end.
* ctype/ctype-info.c (_nl_C_LC_CTYPE_names): Remove declaration.
(_nl_C_LC_CTYPE_class_{upper,lower,alpha,digit,xdigit,space,print,
graph,blank,cntrl,punct,alnum}, _nl_C_LC_CTYPE_map_{toupper,tolower}):
New declarations.
(b): Remove trailing semicolon.
(__ctype_names, __ctype_width): Don't initialize.
(__ctype32_wctype, __ctype32_wctrans, __ctype32_width): Initialize.
2000-08-27 Bruno Haible <haible@clisp.cons.org>
* elf/dl-load.c (open_path): Add a argument telling whether *dirsp
is guaranteed to be allocated with the same malloc() and may be
passed to free().
(_dl_map_object): Update open_path calls. If rtld_search_dirs has
been set to empty by an earlier open_path call, don't pass it again.
2000-08-29 01:20:23 +00:00
|
|
|
memcpy (q, p,
|
|
|
|
MIN (&numbuf[21] - p, buflen - unklen - len - 1));
|
1998-01-25 17:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate the string in any case. */
|
|
|
|
if (buflen > 0)
|
|
|
|
buf[buflen - 1] = '\0';
|
|
|
|
|
|
|
|
return buf;
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
|
|
|
|
1995-10-17 05:49:48 +00:00
|
|
|
return (char *) _(es->subsystem[sub].codes[code]);
|
1995-02-18 01:27:10 +00:00
|
|
|
}
|
2002-08-30 01:31:18 +00:00
|
|
|
libc_hidden_def (__strerror_r)
|
1998-04-14 16:51:08 +00:00
|
|
|
weak_alias (__strerror_r, strerror_r)
|