mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-28 16:09:51 +02:00
more fixes for using bool and the stdckdint functions for integer overflow; another update to test from coreutils-9.2 changes; fix memleak in parser state on parse error; Makefile changes for macOS
This commit is contained in:
+77
-3
@@ -8920,6 +8920,80 @@ test.c
|
||||
- term: if we see a left paren, scan forward for a closing right paren
|
||||
and use posixtest() if there are 1-4 arguments between the parens to
|
||||
avoid ambiguous behavior for expressions like true -a \( ! -a \),
|
||||
which a user would expect to return false instead of an error
|
||||
message
|
||||
Picked up from coreutils test
|
||||
which, though it's horribly ambiguous, a user would expect to
|
||||
return false instead of an error message
|
||||
Picked up from coreutils-9.2 test
|
||||
|
||||
3/25
|
||||
----
|
||||
bashansi.c
|
||||
- HAVE_C_BOOL: prefer if defined, fall back to stdbool.h if bool isn't
|
||||
a compiler builtin
|
||||
|
||||
braces.c
|
||||
- mkseq: simplify break condition
|
||||
|
||||
builtins/printf.def
|
||||
- decodeint: let the caller decide what to do with an overflow return,
|
||||
don't return -1 after calling report_erange(). This will honor a
|
||||
precision even if the field width overflows
|
||||
- printf_builtin: check for overflow when adjusting precision for
|
||||
string length with %Q
|
||||
- printstr,printwidestr: now that the code uses decodeint, we don't
|
||||
need to check the precision against INT_MAX
|
||||
|
||||
bashansi.h
|
||||
- include stddef.h if we have it, otherwise define replacements for
|
||||
NULL and offsetof()
|
||||
|
||||
builtins/help.def,lib/sh/fmtulong.c,lib/sh/getcwd.c,lib/sh/makepath.c,
|
||||
lib/sh/snprintf.c,lib/sh/strtod.c,lib/sh/strtol.c,unwind_prot.c,
|
||||
lib/readline/shell.c
|
||||
- include bashansi.h instead of stddef.h, or remove a stddef.h include
|
||||
if bashansi.h is already included
|
||||
- remove extra definitions that appear in stddef.h or bashansi.h
|
||||
|
||||
lib/sh/reallocarray.c,externs.h
|
||||
- implementation of reallocarray(), originally from OpenBSD, from
|
||||
Paul Eggert
|
||||
|
||||
configure.ac
|
||||
- use AC_REPLACE_FUNCS for reallocarray
|
||||
|
||||
xmalloc.c,xmalloc.h
|
||||
- xreallocarray: implementation of reallocarray that uses xrealloc
|
||||
- sh_xreallocarray: implementation of reallocarray that uses
|
||||
sh_xrealloc and has file and line information for error messages
|
||||
|
||||
lib/sh/stringvec.c
|
||||
- strvec_create, strvec_resize: rewrite in terms of xreallocarray
|
||||
- strvec_mcreate, strvec_mresize: rewrite in terms of reallocarray
|
||||
- strvec_remove, strvec_search, strvec_copy, strvec_from_word_list,
|
||||
strvec_to_word_list: use size_t instead of int where appropriate
|
||||
|
||||
lib/sh/stringvec.c,externs.h
|
||||
- strvec_search: return a value of type ptrdiff_t, since size_t is
|
||||
unsigned and we want to return -1 if not found
|
||||
|
||||
All from a report and patch by Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
test.c
|
||||
- term: change paren scan algorithm to count open and close parens so
|
||||
we handle nested subexpressions. Still not compatible in the case
|
||||
of something like test true -a \( ! -a \) \)
|
||||
|
||||
3/27
|
||||
----
|
||||
parse.y
|
||||
- flush_parser_state: new function, deallocates the members of a
|
||||
parser state struct that are dynamically allocated
|
||||
- parse_comsub: call flush_parser_state in places where we will
|
||||
return an error or jump to the top level
|
||||
Fixes memory leaks on error reported by bug_reports00@protonmail.com
|
||||
|
||||
Makefile.in
|
||||
- CREATED_MACOS: list of dSYM directories created by building and
|
||||
testing
|
||||
- distclean,maintainer-clean: remove $(CREATED_HEADERS) and
|
||||
$(CREATED_MACOS)
|
||||
- maintainer-clean: remove ctags/etags files
|
||||
|
||||
@@ -466,6 +466,7 @@ lib/sh/oslib.c f
|
||||
lib/sh/pathcanon.c f
|
||||
lib/sh/pathphys.c f
|
||||
lib/sh/random.c f
|
||||
lib/sh/reallocarray.c f
|
||||
lib/sh/rename.c f
|
||||
lib/sh/setlinebuf.c f
|
||||
lib/sh/shmatch.c f
|
||||
|
||||
+9
-4
@@ -1,4 +1,4 @@
|
||||
# Makefile for bash-5.3, version 5.4
|
||||
# Makefile for bash-5.3, version 5.5
|
||||
#
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
|
||||
@@ -583,6 +583,8 @@ CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \
|
||||
mksignames$(EXEEXT) lsignames.h \
|
||||
mksyntax${EXEEXT} syntax.c $(VERSPROG) $(VERSOBJ) \
|
||||
buildversion.o mksignames.o signames.o buildsignames.o
|
||||
CREATED_MACOS = recho.dSYM zecho.dSYM printenv.dSYM xcase.dSYM \
|
||||
bashversion.dSYM mksyntax.dSYM ${DEFDIR}/psize.aux.dSYM
|
||||
CREATED_CONFIGURE = config.h config.cache config.status config.log \
|
||||
stamp-h po/POTFILES config.status.lineno
|
||||
CREATED_MAKEFILES = Makefile builtins/Makefile doc/Makefile \
|
||||
@@ -949,6 +951,7 @@ clean: basic-clean
|
||||
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
|
||||
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
|
||||
$(RM) $(CREATED_SUPPORT)
|
||||
$(RM) -rf $(CREATED_MACOS)
|
||||
|
||||
mostlyclean: basic-clean
|
||||
( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
|
||||
@@ -970,7 +973,8 @@ distclean: basic-clean maybe-clean
|
||||
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
|
||||
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
|
||||
$(RM) $(CREATED_CONFIGURE) tags TAGS
|
||||
$(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) pathnames.h
|
||||
$(RM) $(CREATED_SUPPORT) Makefile $(CREATED_MAKEFILES) $(CREATED_HEADERS)
|
||||
$(RM) -rf $(CREATED_MACOS)
|
||||
|
||||
maintainer-clean: basic-clean
|
||||
@echo This command is intended for maintainers to use.
|
||||
@@ -984,8 +988,9 @@ maintainer-clean: basic-clean
|
||||
done
|
||||
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
|
||||
-( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ )
|
||||
$(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES)
|
||||
$(RM) $(CREATED_SUPPORT) Makefile pathnames.h
|
||||
$(RM) $(CREATED_CONFIGURE) Makefile $(CREATED_MAKEFILES) tags TAGS
|
||||
$(RM) $(CREATED_SUPPORT) $(CREATED_HEADERS)
|
||||
$(RM) -rf $(CREATED_MACOS)
|
||||
|
||||
maybe-clean:
|
||||
-if test X"`cd $(topdir) && pwd -P`" != X"`cd $(BUILD_DIR) && pwd -P`" ; then \
|
||||
|
||||
+19
-5
@@ -35,14 +35,28 @@
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* !HAVE_STDLIB_H */
|
||||
|
||||
/* Prefer stdbool.h if we have it, maybe have to rethink this later */
|
||||
#if defined (HAVE_STDBOOL_H)
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# ifndef HAVE_C_BOOL
|
||||
/* If bool is not a compiler builtin, prefer stdbool.h if we have it */
|
||||
#if !defined (HAVE_C_BOOL)
|
||||
# if defined (HAVE_STDBOOL_H)
|
||||
# include <stdbool.h>
|
||||
# else
|
||||
# undef bool
|
||||
typedef unsigned char bool;
|
||||
# define true 1
|
||||
# define false 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Include <stddef.h>, or define substitutes (config.h handles ptrdiff_t). */
|
||||
#ifdef HAVE_STDDEF_H
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
/* Substitutes for definitions in stddef.h */
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
#ifndef offsetof
|
||||
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
|
||||
#endif /* !_BASHANSI_H_ */
|
||||
|
||||
@@ -399,7 +399,7 @@ mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width)
|
||||
QUIT;
|
||||
#endif
|
||||
if (type == ST_INT)
|
||||
result[i++] = t = itos (n);
|
||||
t = itos (n);
|
||||
else if (type == ST_ZINT)
|
||||
{
|
||||
size_t tlen;
|
||||
@@ -419,7 +419,6 @@ mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width)
|
||||
memset (t + (n < 0), '0', width - tlen);
|
||||
}
|
||||
}
|
||||
result[i++] = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -428,9 +427,10 @@ mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width)
|
||||
t[0] = n;
|
||||
t[1] = '\0';
|
||||
}
|
||||
result[i++] = t;
|
||||
}
|
||||
|
||||
result[i++] = t;
|
||||
|
||||
/* We failed to allocate memory for this number, so we bail. */
|
||||
if (t == 0)
|
||||
{
|
||||
@@ -445,11 +445,8 @@ mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, size_t width)
|
||||
}
|
||||
|
||||
n += incr;
|
||||
|
||||
if (i == nelem - 1)
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
while (i < nelem - 1);
|
||||
|
||||
result[i] = (char *)0;
|
||||
return (result);
|
||||
|
||||
+3
-1
@@ -1,7 +1,7 @@
|
||||
This file is fc.def, from which is created fc.c.
|
||||
It implements the builtin "fc" in Bash.
|
||||
|
||||
Copyright (C) 1987-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -45,6 +45,8 @@ A useful alias to use with this is r='fc -s', so that typing `r cc'
|
||||
runs the last command beginning with `cc' and typing `r' re-executes
|
||||
the last command.
|
||||
|
||||
The history builtin also operates on the history list.
|
||||
|
||||
Exit Status:
|
||||
Returns success or status of executed command; non-zero if an error occurs.
|
||||
$END
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
This file is help.def, from which is created help.c.
|
||||
It implements the builtin "help" in Bash.
|
||||
|
||||
Copyright (C) 1987-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -58,7 +58,7 @@ $END
|
||||
#include <errno.h>
|
||||
|
||||
#include <filecntl.h>
|
||||
#include <stddef.h>
|
||||
#include "../bashansi.h"
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
This file is history.def, from which is created history.c.
|
||||
It implements the builtin "history" in Bash.
|
||||
|
||||
Copyright (C) 1987-2023 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -50,6 +50,8 @@ if HISTFILE has a value, that is used. If FILENAME is not supplied
|
||||
and HISTFILE is unset or null, the -a, -n, -r, and -w options have
|
||||
no effect and return success.
|
||||
|
||||
The fc builtin also operates on the history list.
|
||||
|
||||
If the HISTTIMEFORMAT variable is set and not null, its value is used
|
||||
as a format string for strftime(3) to print the time stamp associated
|
||||
with each displayed history entry. No time stamps are printed otherwise.
|
||||
|
||||
+9
-8
@@ -262,10 +262,7 @@ decodeint (char **str, int diagnose, int overflow_return)
|
||||
v |= ckd_add (&pr, pr, *ps - '0');
|
||||
}
|
||||
if (v && diagnose)
|
||||
{
|
||||
report_erange (*str, ps);
|
||||
return -1;
|
||||
}
|
||||
report_erange (*str, ps);
|
||||
|
||||
*str = ps;
|
||||
return (v ? overflow_return : pr);
|
||||
@@ -699,8 +696,12 @@ printf_builtin (WORD_LIST *list)
|
||||
slen = strlen (xp);
|
||||
if (convch == 'Q')
|
||||
{
|
||||
if (slen > precision)
|
||||
precision = slen;
|
||||
/* check for string length overflow when adjusting precision */
|
||||
if (ckd_add (&precision, slen, 0))
|
||||
{
|
||||
builtin_error (_("%%Q: string length: %s"), strerror (ERANGE));
|
||||
precision = -1;
|
||||
}
|
||||
}
|
||||
/* Use printstr to get fieldwidth and precision right. */
|
||||
r = printstr (start, xp, slen, fieldwidth, precision);
|
||||
@@ -904,7 +905,7 @@ printstr (char *fmt, char *string, size_t len, int fieldwidth, int precision)
|
||||
pr = decodeint (&fmt, 1, -1);
|
||||
/* pr < precision means we adjusted precision in printf_builtin
|
||||
for the quoted string length (%Q), so we use the adjusted value */
|
||||
if (pr < precision && precision < INT_MAX)
|
||||
if (pr < precision)
|
||||
pr = precision;
|
||||
}
|
||||
else
|
||||
@@ -1002,7 +1003,7 @@ printwidestr (char *fmt, wchar_t *wstring, size_t len, int fieldwidth, int preci
|
||||
pr = decodeint (&fmt, 1, -1);
|
||||
/* pr < precision means we adjusted precision in printf_builtin
|
||||
for the quoted string length (%Q), so we use the adjusted value */
|
||||
if (pr < precision && precision < INT_MAX)
|
||||
if (pr < precision)
|
||||
pr = precision;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
# From configure.ac for Bash 5.3, version 5.062.
|
||||
# From configure.ac for Bash 5.3, version 5.063.
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.71 for bash 5.3-devel.
|
||||
#
|
||||
@@ -15865,6 +15865,20 @@ esac
|
||||
|
||||
fi
|
||||
|
||||
ac_fn_c_check_func "$LINENO" "reallocarray" "ac_cv_func_reallocarray"
|
||||
if test "x$ac_cv_func_reallocarray" = xyes
|
||||
then :
|
||||
printf "%s\n" "#define HAVE_REALLOCARRAY 1" >>confdefs.h
|
||||
|
||||
else $as_nop
|
||||
case " $LIBOBJS " in
|
||||
*" reallocarray.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS reallocarray.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
|
||||
ac_fn_c_check_header_compile "$LINENO" "libaudit.h" "ac_cv_header_libaudit_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_libaudit_h" = xyes
|
||||
|
||||
+2
-1
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_REVISION([for Bash 5.3, version 5.062])dnl
|
||||
AC_REVISION([for Bash 5.3, version 5.063])dnl
|
||||
|
||||
define(bashvers, 5.3)
|
||||
define(relstatus, devel)
|
||||
@@ -887,6 +887,7 @@ AC_REPLACE_FUNCS(dprintf)
|
||||
AC_REPLACE_FUNCS(strchrnul)
|
||||
AC_REPLACE_FUNCS(strdup)
|
||||
AC_REPLACE_FUNCS(strlcpy)
|
||||
AC_REPLACE_FUNCS(reallocarray)
|
||||
|
||||
AC_CHECK_HEADERS(libaudit.h)
|
||||
AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include <linux/audit.h>]])
|
||||
|
||||
+3
-2
@@ -5,14 +5,14 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet.ramey@case.edu
|
||||
.\"
|
||||
.\" Last Change: Mon Feb 19 16:52:45 EST 2024
|
||||
.\" Last Change: Mon Mar 25 10:56:35 EDT 2024
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.\" avoid a warning about an undefined register
|
||||
.\" .if !rzY .nr zY 0
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2024 February 19" "GNU Bash 5.3"
|
||||
.TH BASH 1 "2024 March 25" "GNU Bash 5.3"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
@@ -3683,6 +3683,7 @@ Produces a possibly-quoted version of the value of \fIparameter\fP,
|
||||
except that it prints the values of
|
||||
indexed and associative arrays as a sequence of quoted key-value pairs
|
||||
(see \fBArrays\fP above).
|
||||
The keys and values are quoted in a format that can be reused as input.
|
||||
.TP
|
||||
.B a
|
||||
The expansion is a string consisting of flag values representing
|
||||
|
||||
@@ -2609,6 +2609,7 @@ Produces a possibly-quoted version of the value of @var{parameter},
|
||||
except that it prints the values of
|
||||
indexed and associative arrays as a sequence of quoted key-value pairs
|
||||
(@pxref{Arrays}).
|
||||
The keys and values are quoted in a format that can be reused as input.
|
||||
@item a
|
||||
The expansion is a string consisting of flag values representing
|
||||
@var{parameter}'s attributes.
|
||||
|
||||
+3
-3
@@ -2,10 +2,10 @@
|
||||
Copyright (C) 1988-2024 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Mon Feb 19 16:52:26 EST 2024
|
||||
@set LASTCHANGE Mon Mar 25 10:56:49 EDT 2024
|
||||
|
||||
@set EDITION 5.3
|
||||
@set VERSION 5.3
|
||||
|
||||
@set UPDATED 19 February 2024
|
||||
@set UPDATED-MONTH February 2024
|
||||
@set UPDATED 25 March 2024
|
||||
@set UPDATED-MONTH March 2024
|
||||
|
||||
@@ -333,6 +333,9 @@ extern void seedrand (void); /* seed generator randomly */
|
||||
extern void seedrand32 (void);
|
||||
extern u_bits32_t get_urandom32 (void);
|
||||
|
||||
/* declarations for functions defined in lib/sh/reallocarray.c */
|
||||
extern void *reallocarray (void *, size_t, size_t);
|
||||
|
||||
/* declarations for functions defined in lib/sh/setlinebuf.c */
|
||||
#ifdef NEED_SH_SETLINEBUF_DECL
|
||||
extern int sh_setlinebuf (FILE *);
|
||||
@@ -429,7 +432,7 @@ extern void strvec_flush (char **);
|
||||
extern void strvec_dispose (char **);
|
||||
extern int strvec_remove (char **, const char *);
|
||||
extern size_t strvec_len (char * const *);
|
||||
extern int strvec_search (char **, const char *);
|
||||
extern ptrdiff_t strvec_search (char **, const char *);
|
||||
extern char **strvec_copy (char * const *);
|
||||
extern int strvec_posixcmp (char **, char **);
|
||||
extern int strvec_strcmp (char **, char **);
|
||||
|
||||
@@ -67,10 +67,6 @@
|
||||
extern struct passwd *getpwuid (uid_t);
|
||||
#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
+5
-1
@@ -95,7 +95,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
|
||||
ufuncs.c casemod.c dprintf.c input_avail.c mbscasecmp.c fnxform.c \
|
||||
strchrnul.c unicode.c wcswidth.c wcsnwidth.c shmbchar.c strdup.c \
|
||||
strvis.c strlcpy.c strscpy.c utf8.c random.c gettimeofday.c \
|
||||
timers.c anonfile.c compat.c
|
||||
timers.c anonfile.c reallocarray.c compat.c
|
||||
|
||||
# The header files for this library.
|
||||
HSOURCES =
|
||||
@@ -178,6 +178,7 @@ oslib.o: oslib.c
|
||||
pathcanon.o: pathcanon.c
|
||||
pathphys.o: pathphys.c
|
||||
random.o: random.c
|
||||
reallocarray.o: reallocarray.c
|
||||
rename.o: rename.c
|
||||
setlinebuf.o: setlinebuf.c
|
||||
shmatch.o: shmatch.c
|
||||
@@ -265,6 +266,7 @@ oslib.o: ${BUILD_DIR}/config.h
|
||||
pathcanon.o: ${BUILD_DIR}/config.h
|
||||
pathphys.o: ${BUILD_DIR}/config.h
|
||||
random.o: ${BUILD_DIR}/config.h
|
||||
reallocarray.o: ${BUILD_DIR}/config.h
|
||||
rename.o: ${BUILD_DIR}/config.h
|
||||
setlinebuf.o: ${BUILD_DIR}/config.h
|
||||
shmatch.o: ${BUILD_DIR}/config.h
|
||||
@@ -691,6 +693,8 @@ anonfile.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
|
||||
anonfile.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
|
||||
anonfile.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
|
||||
|
||||
reallocarray.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
|
||||
compat.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
compat.o: ${topdir}/bashtypes.h
|
||||
compat.o: ${BASHINCDIR}/filecntl.h
|
||||
|
||||
+1
-4
@@ -1,6 +1,6 @@
|
||||
/* fmtulong.c -- Convert unsigned long int to string. */
|
||||
|
||||
/* Copyright (C) 1998-2011,2023 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1998-2011,2023-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
#endif
|
||||
|
||||
#include <bashansi.h>
|
||||
#ifdef HAVE_STDDEF_H
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
|
||||
+1
-5
@@ -1,6 +1,6 @@
|
||||
/* getcwd.c -- get pathname of current directory */
|
||||
|
||||
/* Copyright (C) 1991, 2022 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 2022, 2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -64,10 +64,6 @@ extern int errno;
|
||||
# define lstat stat
|
||||
#endif
|
||||
|
||||
#if !defined (NULL)
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
/* If the d_fileno member of a struct dirent doesn't return anything useful,
|
||||
we need to check inode number equivalence the hard way. Return 1 if
|
||||
the inode corresponding to PATH/DIR is identical to THISINO. */
|
||||
|
||||
+1
-5
@@ -1,6 +1,6 @@
|
||||
/* makepath.c - glue PATH and DIR together into a full pathname. */
|
||||
|
||||
/* Copyright (C) 1987-2020,2022-2023 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2020,2022-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -32,10 +32,6 @@
|
||||
|
||||
#include <tilde/tilde.h>
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
/* MAKE SURE THESE AGREE WITH ../../externs.h. */
|
||||
|
||||
#ifndef MP_DOTILDE
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* reallocarray.c - reallocate memory for an array given type size and
|
||||
number of elements */
|
||||
|
||||
/* Copyright (C) 2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "bashansi.h"
|
||||
#include <stdckdint.h>
|
||||
|
||||
#include <errno.h>
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
void *
|
||||
reallocarray (void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
if (ckd_mul (&nbytes, nmemb, size))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return realloc (ptr, nbytes);
|
||||
}
|
||||
+1
-4
@@ -9,7 +9,7 @@
|
||||
Unix snprintf implementation.
|
||||
derived from inetutils/libinetutils/snprintf.c Version 1.1
|
||||
|
||||
Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -94,9 +94,6 @@
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#include <bashansi.h>
|
||||
#ifdef HAVE_STDDEF_H
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
#include <chartypes.h>
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
|
||||
+10
-19
@@ -37,34 +37,26 @@
|
||||
char **
|
||||
strvec_create (size_t n)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
return ckd_mul (&nbytes, n, sizeof (char *)) ? NULL : xmalloc (nbytes);
|
||||
return ((char **)xreallocarray (NULL, n, sizeof (char *)));
|
||||
}
|
||||
|
||||
/* Allocate an array of strings with room for N members. */
|
||||
char **
|
||||
strvec_mcreate (size_t n)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
return ckd_mul (&nbytes, n, sizeof (char *)) ? NULL : malloc (nbytes);
|
||||
return ((char **)reallocarray (NULL, n, sizeof (char *)));
|
||||
}
|
||||
|
||||
char **
|
||||
strvec_resize (char **array, size_t nsize)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
return ckd_mul (&nbytes, nsize, sizeof (char *)) ? NULL : (char **)xrealloc (array, nbytes);
|
||||
return ((char **)xreallocarray (array, nsize, sizeof (char *)));
|
||||
}
|
||||
|
||||
char **
|
||||
strvec_mresize (char **array, size_t nsize)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
return ckd_mul (&nbytes, nsize, sizeof (char *)) ? NULL : (char **)realloc (array, nbytes);
|
||||
return ((char **)reallocarray (array, nsize, sizeof (char *)));
|
||||
}
|
||||
|
||||
/* Return the length of ARRAY, a NULL terminated array of char *. */
|
||||
@@ -103,7 +95,7 @@ strvec_dispose (char **array)
|
||||
int
|
||||
strvec_remove (char **array, const char *name)
|
||||
{
|
||||
register int i, j;
|
||||
size_t i, j;
|
||||
char *x;
|
||||
|
||||
if (array == 0)
|
||||
@@ -123,10 +115,10 @@ strvec_remove (char **array, const char *name)
|
||||
|
||||
/* Find NAME in ARRAY. Return the index of NAME, or -1 if not present.
|
||||
ARRAY should be NULL terminated. */
|
||||
int
|
||||
ptrdiff_t
|
||||
strvec_search (char **array, const char *name)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; array[i]; i++)
|
||||
if (STREQ (name, array[i]))
|
||||
@@ -139,8 +131,7 @@ strvec_search (char **array, const char *name)
|
||||
char **
|
||||
strvec_copy (char * const *array)
|
||||
{
|
||||
int i;
|
||||
size_t len;
|
||||
size_t i, len;
|
||||
char **ret;
|
||||
|
||||
len = strvec_len (array);
|
||||
@@ -212,7 +203,7 @@ strvec_sort (char **array, int posix)
|
||||
char **
|
||||
strvec_from_word_list (WORD_LIST *list, int alloc, int starting_index, int *ip)
|
||||
{
|
||||
int count;
|
||||
size_t count;
|
||||
char **array;
|
||||
|
||||
count = list_length ((GENERIC_LIST *)list);
|
||||
@@ -239,7 +230,7 @@ strvec_to_word_list (char **array, int alloc, int starting_index)
|
||||
{
|
||||
WORD_LIST *list;
|
||||
WORD_DESC *w;
|
||||
int i, count;
|
||||
size_t i, count;
|
||||
|
||||
if (array == 0 || array[0] == 0)
|
||||
return (WORD_LIST *)NULL;
|
||||
|
||||
+1
-5
@@ -1,6 +1,6 @@
|
||||
/* strtod.c - convert string to double-precision floating-point value. */
|
||||
|
||||
/* Copyright (C) 1991, 1992, 2022 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 2022-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -41,10 +41,6 @@ extern int errno;
|
||||
|
||||
#include <bashansi.h>
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef HUGE_VAL
|
||||
# define HUGE_VAL HUGE
|
||||
#endif
|
||||
|
||||
+1
-5
@@ -1,6 +1,6 @@
|
||||
/* strtol - convert string representation of a number into a long integer value. */
|
||||
|
||||
/* Copyright (C) 1991-2001,2022 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -42,10 +42,6 @@ extern int errno;
|
||||
#include <stdc.h>
|
||||
#include <bashansi.h>
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
/* Nonzero if we are defining `strtoul' or `strtoull', operating on
|
||||
unsigned integers. */
|
||||
#ifndef UNSIGNED
|
||||
|
||||
@@ -4497,6 +4497,8 @@ parse_comsub (int qc, int open, int close, size_t *lenp, int flags)
|
||||
/* yyparse() has already called yyerror() and reset_parser(), so we set
|
||||
PST_NOERROR to avoid a redundant error message. */
|
||||
parser_state |= PST_NOERROR;
|
||||
|
||||
flush_parser_state (&ps);
|
||||
return (&matched_pair_error);
|
||||
}
|
||||
else if (r != 0)
|
||||
@@ -4513,6 +4515,7 @@ parse_comsub (int qc, int open, int close, size_t *lenp, int flags)
|
||||
shell_eof_token = ps.eof_token;
|
||||
expand_aliases = ps.expand_aliases;
|
||||
|
||||
flush_parser_state (&ps);
|
||||
jump_to_top_level (DISCARD); /* XXX - return (&matched_pair_error)? */
|
||||
}
|
||||
}
|
||||
@@ -4529,6 +4532,7 @@ INTERNAL_DEBUG(("current_token (%d) != shell_eof_token (%c)", current_token, she
|
||||
shell_eof_token = ps.eof_token;
|
||||
expand_aliases = ps.expand_aliases;
|
||||
|
||||
flush_parser_state (&ps);
|
||||
return (&matched_pair_error);
|
||||
}
|
||||
|
||||
@@ -7191,6 +7195,27 @@ restore_parser_state (sh_parser_state_t *ps)
|
||||
shell_eof_token = ps->eof_token;
|
||||
}
|
||||
|
||||
/* Free the parts of a parser state struct that have allocated memory. */
|
||||
void
|
||||
flush_parser_state (sh_parser_state_t *ps)
|
||||
{
|
||||
if (ps == 0)
|
||||
return;
|
||||
|
||||
FREE (ps->token_state);
|
||||
ps->token_state = 0;
|
||||
|
||||
if (ps->pipestatus)
|
||||
array_dispose (ps->pipestatus);
|
||||
ps->pipestatus = 0;
|
||||
|
||||
/* We want to free the saved token and leave the current token for error
|
||||
reporting and cleanup. */
|
||||
FREE (ps->token);
|
||||
ps->token = 0;
|
||||
ps->token_buffer_size = 0;
|
||||
}
|
||||
|
||||
sh_input_line_state_t *
|
||||
save_input_line_state (sh_input_line_state_t *ls)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ msgstr ""
|
||||
"Project-Id-Version: bash 5.2-rc1\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-01-11 14:50-0500\n"
|
||||
"PO-Revision-Date: 2024-03-11 21:33+0100\n"
|
||||
"PO-Revision-Date: 2024-03-24 13:13+0100\n"
|
||||
"Last-Translator: Nils Naumann <nau@gmx.net>\n"
|
||||
"Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
|
||||
"Language: de\n"
|
||||
@@ -4326,7 +4326,6 @@ msgstr ""
|
||||
|
||||
# test
|
||||
#: builtins.c:1262
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Evaluate conditional expression.\n"
|
||||
" \n"
|
||||
@@ -4408,13 +4407,13 @@ msgid ""
|
||||
msgstr ""
|
||||
"Bedingten Ausdruck auswerten.\n"
|
||||
" \n"
|
||||
" Wird Status 0 (wahr) oder 1 (falsch) abhängig vom Ergebnis des\n"
|
||||
" Ausdrucks. Die Ausdrücke können unär oder binär sein. Unäre\n"
|
||||
" Gibt den Status 0 (wahr) oder 1 (falsch) abhängig vom Ergebnis des\n"
|
||||
" Ausdrucks zurück. Die Ausdrücke können unär oder binär sein. Unäre\n"
|
||||
" Ausdrücke werden häufig verwendet, um den Dateistatus zu ermitteln.\n"
|
||||
" Es gibt weiterhin Zeichenketten und numerische Vergeichsoperatoren.\n"
|
||||
" \n"
|
||||
" Das Verhalten von test hängt von der Argumentanzahl ab. Die\n"
|
||||
" bash Handbuchseite enthält deren vollständige Beschreibung.\n"
|
||||
" Das Verhalten hängt von der Argumentanzahl ab. Die bash\n"
|
||||
" Handbuchseite enthält deren vollständige Beschreibung.\n"
|
||||
" \n"
|
||||
" Dateioperatoren:\n"
|
||||
" \n"
|
||||
@@ -4432,7 +4431,7 @@ msgstr ""
|
||||
" -r Datei Wahr, wenn die Datei für den aktuellen Nutzer lesbar ist.\n"
|
||||
" -s Datei Wahr, wenn die Datei existiert und nicht leer ist.\n"
|
||||
" -S Datei Wahr, wenn die Datei ein Socket ist.\n"
|
||||
" -t FD Wahr, wenn FD auf einem Terminal geöffnet ist.\n"
|
||||
" -t FD Wahr, wenn FD auf einem Terminal geöffnet ist.\n"
|
||||
" -u Datei Wahr, wenn das SetUID-Bit der Datei gesetzt ist.\n"
|
||||
" -w Datei Wahr, wenn die Datei für den aktuellen Nutzer schreibbar ist.\n"
|
||||
" -x Datei Wahr, wenn die Datei vom aktuellen Nutzer ausführbar ist.\n"
|
||||
@@ -4441,23 +4440,23 @@ msgstr ""
|
||||
" -N Datei Wahr, wenn die Datei seit dem letzten Lesen geändert wurde.\n"
|
||||
" \n"
|
||||
" Datei1 -nt Datei2 Wahr, wenn Datei1 neuer als Datei2 ist (gemäß\n"
|
||||
" Änderungsdatum).\n"
|
||||
" Änderungsdatum).\n"
|
||||
" \n"
|
||||
" Datei1 -ot Datei2 Wahr, wenn Datei1 älter als Datei2 ist.\n"
|
||||
" \n"
|
||||
" Datei1 -ef Datei2 Wahr, wenn Datei1 ein harter Link zu Datei2 ist.\n"
|
||||
" \n"
|
||||
" Zeichenfolgenoperatoren:\n"
|
||||
" Zeichenkettenoperatoren:\n"
|
||||
" \n"
|
||||
" -z STRING Wahr, wenn die Zeichenfolge leer ist.\n"
|
||||
" -z STRING Wahr, wenn die Zeichenkette leer ist.\n"
|
||||
" \n"
|
||||
" -n STRING\n"
|
||||
" STRING Wahr, wenn die Zeichenfolge nicht leer ist.\n"
|
||||
" STRING Wahr, wenn die Zeichenkette nicht leer ist.\n"
|
||||
" \n"
|
||||
" STRING1 = STRING2\n"
|
||||
" Wahr, wenn die Zeichenfolgen gleich sind.\n"
|
||||
" Wahr, wenn die Zeichenketten gleich sind.\n"
|
||||
" STRING1 != STRING2\n"
|
||||
" Wahr, wenn die Zeichenfolgen nicht gleich sind.\n"
|
||||
" Wahr, wenn die Zeichenketten nicht gleich sind.\n"
|
||||
" STRING1 < STRING2\n"
|
||||
" Wahr, wenn STRING1 lexikografisch vor STRING2\n"
|
||||
" sortiert wird.\n"
|
||||
@@ -4468,9 +4467,9 @@ msgstr ""
|
||||
" Andere Operatoren:\n"
|
||||
" \n"
|
||||
" -o OPTION Wahr, wenn die Shell-Option OPTION aktiviert ist.\n"
|
||||
" -v VAR Wahr, wenn die Shell-Variable VAR gesetzt ist.\n"
|
||||
" -R VAR Wahr, wenn die Variable gesetzt ist und ein Nameref ist.\n"
|
||||
" ! EXPR Wahr, wenn Ausdruck falsch ist.\n"
|
||||
" -v VAR Wahr, wenn die Shell-Variable VAR gesetzt ist.\n"
|
||||
" -R VAR Wahr, wenn die Variable gesetzt ist und ein Nameref ist.\n"
|
||||
" ! EXPR Wahr, wenn Ausdruck falsch ist.\n"
|
||||
" EXPR1 -a EXPR2 Wahr, wenn sowohl expr1 als auch expr2 wahr sind.\n"
|
||||
" EXPR1 -o EXPR2 Wahr, wenn entweder expr1 ODER expr2 wahr ist.\n"
|
||||
" \n"
|
||||
@@ -4830,6 +4829,7 @@ msgid ""
|
||||
" Returns the status of the last command executed."
|
||||
msgstr ""
|
||||
|
||||
# coproc
|
||||
#: builtins.c:1672
|
||||
msgid ""
|
||||
"Create a coprocess named NAME.\n"
|
||||
@@ -4842,6 +4842,16 @@ msgid ""
|
||||
" Exit Status:\n"
|
||||
" The coproc command returns an exit status of 0."
|
||||
msgstr ""
|
||||
"Startet einen Koprozess mit dem angegebenen Namen.\n"
|
||||
" \n"
|
||||
" Führt das angegebene Kommando asynchron in einem Kindprozess aus.\n"
|
||||
" Deren Standardaus- und -eingabe werden mit jeweils einer Pipe\n"
|
||||
" verbunden. Deren Dateideskriptoren sind in den Indexen 0 und 1 der\n"
|
||||
" Feldvariable mit dem angegebenen Namen verknüpft.\n"
|
||||
" Der Standardname ist „COPROC“.\n"
|
||||
" \n"
|
||||
" Rückgabewert:\n"
|
||||
" Der Befehl gibt immer 0 zurück."
|
||||
|
||||
# function
|
||||
#: builtins.c:1686
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* shell.h -- The data structures used by the shell */
|
||||
|
||||
/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -239,6 +239,7 @@ extern char *parser_remaining_input (void);
|
||||
|
||||
extern sh_parser_state_t *save_parser_state (sh_parser_state_t *);
|
||||
extern void restore_parser_state (sh_parser_state_t *);
|
||||
extern void flush_parser_state (sh_parser_state_t *);
|
||||
|
||||
extern sh_input_line_state_t *save_input_line_state (sh_input_line_state_t *);
|
||||
extern void restore_input_line_state (sh_input_line_state_t *);
|
||||
|
||||
@@ -267,15 +267,23 @@ term (void)
|
||||
/* A paren-bracketed argument. */
|
||||
if (argv[pos][0] == '(' && argv[pos][1] == '\0') /* ) */
|
||||
{
|
||||
int nargs;
|
||||
int nargs, count;
|
||||
|
||||
advance (1);
|
||||
/* Steal an idea from coreutils and scan forward to check where the right
|
||||
paren appears to prevent some ambiguity. If we find a valid sub-
|
||||
expression that has 1-4 arguments, call posixtest on it ( */
|
||||
for (nargs = 1; pos + nargs < argc && ISTOKEN (argv[pos+nargs], ')') == 0; nargs++)
|
||||
;
|
||||
/* only do this if we have a valid parenthesized expression */
|
||||
expression that has 1-4 arguments, call posixtest on it. Handle
|
||||
nested subexpressions. ( */
|
||||
for (nargs = count = 1; pos + nargs < argc; nargs++)
|
||||
{
|
||||
if (ISTOKEN (argv[pos+nargs], ')'))
|
||||
count--;
|
||||
else if (ISTOKEN (argv[pos+nargs], '(')) /*)*/
|
||||
count++;
|
||||
if (count == 0)
|
||||
break;
|
||||
}
|
||||
/* only use posixtest if we have a valid parenthesized expression */
|
||||
value = (pos + nargs < argc && nargs <= 4) ? posixtest (nargs) : expr ();
|
||||
if (argv[pos] == 0) /* ( */
|
||||
test_syntax_error (_("`)' expected"), (char *)NULL);
|
||||
|
||||
+1
-9
@@ -3,7 +3,7 @@
|
||||
/* I can't stand it anymore! Please can't we just write the
|
||||
whole Unix system in lisp or something? */
|
||||
|
||||
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -35,14 +35,6 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDDEF_H)
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
|
||||
#include "command.h"
|
||||
#include "general.h"
|
||||
#include "unwind_prot.h"
|
||||
|
||||
@@ -29,11 +29,8 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
#include "bashansi.h"
|
||||
#include <stdckdint.h>
|
||||
|
||||
#include "error.h"
|
||||
|
||||
@@ -131,6 +128,22 @@ xrealloc (PTR_T pointer, size_t bytes)
|
||||
return (temp);
|
||||
}
|
||||
|
||||
/* Reallocate the storage addressed by POINTER so that it is of
|
||||
size NMEMB*SIZE, preserving contents like realloc does.
|
||||
If POINTER is null, allocate new storage. This is like
|
||||
glibc reallocarray except that it never returns a null pointer;
|
||||
if storage is exhausted it reports an error and exits. */
|
||||
PTR_T
|
||||
xreallocarray (PTR_T ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
if (ckd_mul (&nbytes, nmemb, size))
|
||||
allocerr ("xreallocarray", (size_t)-1);
|
||||
|
||||
return xrealloc (ptr, nbytes);
|
||||
}
|
||||
|
||||
/* Use this as the function to call when adding unwind protects so we
|
||||
don't need to know what free() returns. */
|
||||
void
|
||||
@@ -192,6 +205,17 @@ sh_xrealloc (PTR_T pointer, size_t bytes, char *file, int line)
|
||||
return (temp);
|
||||
}
|
||||
|
||||
PTR_T
|
||||
sh_xreallocarray (PTR_T ptr, size_t nmemb, size_t size, const char *file, int line)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
if (ckd_mul (&nbytes, nmemb, size))
|
||||
sh_allocerr ("xreallocarray", (size_t)-1, file, line);
|
||||
|
||||
return sh_xrealloc (ptr, nbytes, file, line);
|
||||
}
|
||||
|
||||
void
|
||||
sh_xfree (PTR_T string, char *file, int line)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* xmalloc.h -- defines for the `x' memory allocation functions */
|
||||
|
||||
/* Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -32,15 +32,18 @@
|
||||
/* Allocation functions in xmalloc.c */
|
||||
extern PTR_T xmalloc (size_t);
|
||||
extern PTR_T xrealloc (void *, size_t);
|
||||
extern PTR_T xreallocarray (void *, size_t, size_t);
|
||||
extern void xfree (void *);
|
||||
|
||||
#if defined(USING_BASH_MALLOC) && !defined (DISABLE_MALLOC_WRAPPERS)
|
||||
extern PTR_T sh_xmalloc (size_t, const char *, int);
|
||||
extern PTR_T sh_xrealloc (void *, size_t, const char *, int);
|
||||
extern PTR_T sh_xreallocarray (void *, size_t, size_t, const char *, int);
|
||||
extern void sh_xfree (void *, const char *, int);
|
||||
|
||||
#define xmalloc(x) sh_xmalloc((x), __FILE__, __LINE__)
|
||||
#define xrealloc(x, n) sh_xrealloc((x), (n), __FILE__, __LINE__)
|
||||
#define xreallocarray(x, n, s) sh_xreallocarray((x), (n), (s), __FILE__, __LINE__)
|
||||
#define xfree(x) sh_xfree((x), __FILE__, __LINE__)
|
||||
|
||||
#ifdef free
|
||||
|
||||
Reference in New Issue
Block a user