more ANSI/ISO C cleanups

This commit is contained in:
Chet Ramey
2023-03-28 16:34:56 -04:00
parent 1efe6d6b69
commit 727e92c806
38 changed files with 3332 additions and 220 deletions
+28
View File
@@ -5848,6 +5848,7 @@ support/printenv.c,support/signames.c,support/bashversion.c
support/memtest.c,support/endian.c
lib/glob/gm_loop.c
- some cleanups for function prototypes and other stdc requirements
From Paul Eggert <eggert@cs.ucla.edu>
lib/readline/doc/{rltech.texi,hstech.texi}
- add prototypes and stdc requirements to the examples
@@ -5857,3 +5858,30 @@ builtins/complete.def
filename completions are treated in case someone uses compgen in
the foreground.
From a report by Grisha Levit <grishalevit@gmail.com>
3/28
----
aclocal.m4
builtins/enable.def,builtins/gen-helpfiles.c,builtins/help.def,builtins/printf.def
general.h,hashlib.h
include/ansi_stdlib.h,include/ocache.h
lib/glob/collsyms.h,lib/glob/glob.c
lib/readline/history.h,lib/readline/xmalloc.h
xmalloc.c,xmalloc.h
lib/sh/strtrans.c
lib/tilde/tilde.c
mksyntax.c
support/endian.c
- don't bother with __STDC__ if we are just using C89 features like
const, function prototypes, etc.
From Paul Eggert <eggert@cs.ucla.edu>
externs.h
- prototype the list functions that take GENERIC_LIST *
From Paul Eggert <eggert@cs.ucla.edu>
builtins/common.c,examples/loadables/getconf.c
execute_cmd.c,pcomplete.c,subst.c
lib/sh/stringlist.c,lib/sh/stringvec.c
- changes and casts now that the generic list functions are prototyped
From Paul Eggert <eggert@cs.ucla.edu>
+31
View File
@@ -0,0 +1,31 @@
The version of bash in this directory has been compiled on the
following systems:
By chet:
SunOS 4.1.4
SunOS 5.5
BSDI BSD/OS 2.1
FreeBSD 2.2
NetBSD 1.2
AIX 4.2
AIX 4.1.4
HP/UX 9.05, 10.01, 10.10, 10.20
Linux 2.0.29 (libc 5.3.12)
Linux 2.0.4 (libc 5.3.12)
By other testers:
SCO ODT 2.0
SCO 3.2v5.0, 3.2v4.2
SunOS 5.3
SunOS 5.5
BSD/OS 2.1
FreeBSD 2.2
SunOS 4.1.3
Irix 5.3
Irix 6.2
Linux 2.0 (unknown distribution)
Digital OSF/1 3.2
GNU Hurd 0.1
SVR4.2
File diff suppressed because it is too large Load Diff
Vendored
+1 -29
View File
@@ -563,18 +563,8 @@ AC_CACHE_VAL(bash_cv_getenv_redef,
# include <unistd.h>
#endif
#include <stdlib.h>
#ifndef __STDC__
# ifndef const
# define const
# endif
#endif
char *
getenv (name)
#if defined (__linux__) || defined (__bsdi__) || defined (convex)
const char *name;
#else
char const *name;
#endif /* !__linux__ && !__bsdi__ && !convex */
getenv (const char *name)
{
return "42";
}
@@ -613,16 +603,7 @@ AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv,
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifndef __STDC__
# ifndef const
# define const
# endif
#endif
#ifdef PROTOTYPES
extern int putenv (char *);
#else
extern int putenv ();
#endif
]], [[return (putenv == 0);]] )],
[bash_cv_std_putenv=yes], [bash_cv_std_putenv=no]
)])
@@ -643,16 +624,7 @@ AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unset
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifndef __STDC__
# ifndef const
# define const
# endif
#endif
#ifdef PROTOTYPES
extern int unsetenv (const char *);
#else
extern int unsetenv ();
#endif
]], [[return (unsetenv == 0);]] )],
[bash_cv_std_unsetenv=yes], [bash_cv_std_unsetenv=no]
)])
+4 -1
View File
@@ -9,7 +9,7 @@
* chet@ins.cwru.edu
*/
/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
/* Copyright (C) 1997-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -1119,6 +1119,7 @@ quote_string(char *s)
return savestring(s);
}
void
print_element(ARRAY_ELEMENT *ae)
{
char lbuf[INT_STRLEN_BOUND (intmax_t) + 1];
@@ -1128,12 +1129,14 @@ print_element(ARRAY_ELEMENT *ae)
element_value(ae));
}
void
print_array(ARRAY *a)
{
printf("\n");
array_walk(a, print_element, (void *)NULL);
}
int
main(int c, char **v)
{
ARRAY *a, *new_a, *copy_of_a;
+3
View File
@@ -1177,6 +1177,7 @@ quote_string(char *s)
return savestring(s);
}
void
print_element(ARRAY_ELEMENT *ae)
{
char lbuf[INT_STRLEN_BOUND (intmax_t) + 1];
@@ -1186,12 +1187,14 @@ print_element(ARRAY_ELEMENT *ae)
element_value(ae));
}
void
print_array(ARRAY *a)
{
printf("\n");
array_walk(a, print_element, (void *)NULL);
}
int
main(int c, char **v)
{
ARRAY *a, *new_a, *copy_of_a;
+1 -1
View File
@@ -389,7 +389,7 @@ remember_args (WORD_LIST *list, int destructive)
{
dispose_words (rest_of_args);
rest_of_args = copy_word_list (list);
posparam_count += list_length (list);
posparam_count += list_length ((GENERIC_LIST *)list);
}
if (destructive)
-4
View File
@@ -488,11 +488,7 @@ delete_builtin (struct builtin *b)
struct builtin *new_shell_builtins;
/* XXX - funky pointer arithmetic - XXX */
#ifdef __STDC__
ind = b - shell_builtins;
#else
ind = ((int)b - (int)shell_builtins) / sizeof (struct builtin);
#endif
size = num_shell_builtins * sizeof (struct builtin);
new_shell_builtins = (struct builtin *)xmalloc (size);
+1 -5
View File
@@ -1,6 +1,6 @@
/* gen-helpfiles - create files containing builtin help text */
/* Copyright (C) 2012-2022 Free Software Foundation, Inc.
/* Copyright (C) 2012-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -72,10 +72,6 @@
extern int errno;
#endif
#if !defined (__STDC__) && !defined (strcpy)
extern char *strcpy ();
#endif /* !__STDC__ && !strcpy */
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
/* Flag values that builtins can have. */
+1 -9
View File
@@ -193,20 +193,12 @@ void
builtin_help (void)
{
int ind;
ptrdiff_t d;
current_builtin = builtin_address_internal (this_command_name, 0);
if (current_builtin == 0)
return;
d = current_builtin - shell_builtins;
#if defined (__STDC__)
ind = (int)d;
#else
ind = (int)d / sizeof (struct builtin);
#endif
ind = current_builtin - shell_builtins;
printf ("%s: %s\n", this_command_name, _(shell_builtins[ind].short_doc));
show_longdoc (ind);
}
-4
View File
@@ -1038,11 +1038,7 @@ tescape (char *estart, char *cp, int *lenp, int *sawc)
switch (c = *p++)
{
#if defined (__STDC__)
case 'a': *cp = '\a'; break;
#else
case 'a': *cp = '\007'; break;
#endif
case 'b': *cp = '\b'; break;
+4 -1
View File
@@ -345,8 +345,11 @@
#undef uintmax_t
/* Define to integer type wide enough to hold a pointer if <stdint.h> doesn't define. */
#undef intptr_t
/* Define to unsigned integer type wide enough to hold a pointer if <stdint.h> doesn't define. */
#undef uintptr_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
Vendored
+37 -29
View File
@@ -17203,6 +17203,42 @@ printf "%s\n" "#define size_t unsigned int" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
if test "x$ac_cv_type_intptr_t" = xyes
then :
printf "%s\n" "#define HAVE_INTPTR_T 1" >>confdefs.h
else $as_nop
for ac_type in 'int' 'long int' 'long long int'; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
int
main (void)
{
static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
printf "%s\n" "#define intptr_t $ac_type" >>confdefs.h
ac_type=
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
test -z "$ac_type" && break
done
fi
ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
if test "x$ac_cv_type_uintptr_t" = xyes
then :
@@ -20005,18 +20041,8 @@ else $as_nop
# include <unistd.h>
#endif
#include <stdlib.h>
#ifndef __STDC__
# ifndef const
# define const
# endif
#endif
char *
getenv (name)
#if defined (__linux__) || defined (__bsdi__) || defined (convex)
const char *name;
#else
char const *name;
#endif /* !__linux__ && !__bsdi__ && !convex */
getenv (const char *name)
{
return "42";
}
@@ -20488,16 +20514,7 @@ else $as_nop
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifndef __STDC__
# ifndef const
# define const
# endif
#endif
#ifdef PROTOTYPES
extern int putenv (char *);
#else
extern int putenv ();
#endif
int
main (void)
@@ -20546,16 +20563,7 @@ else $as_nop
#if HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifndef __STDC__
# ifndef const
# define const
# endif
#endif
#ifdef PROTOTYPES
extern int unsetenv (const char *);
#else
extern int unsetenv ();
#endif
int
main (void)
+1
View File
@@ -965,6 +965,7 @@ AC_TYPE_MODE_T
AC_TYPE_UID_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_INTPTR_T
AC_TYPE_UINTPTR_T
AC_CHECK_TYPE(ssize_t, int)
+1
View File
@@ -1,3 +1,4 @@
cmp
wc
paste
timeout
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 1991-2021,2022 Free Software Foundation, Inc.
/* Copyright (C) 1991-2023 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
@@ -1135,7 +1135,7 @@ getconf_builtin (WORD_LIST *list)
}
list = loptend;
if ((aflag == 0 && list == 0) || (aflag && list) || list_length(list) > 2)
if ((aflag == 0 && list == 0) || (aflag && list) || list_length((GENERIC_LIST *)list) > 2)
{
builtin_usage();
return (EX_USAGE);
+6 -6
View File
@@ -570,7 +570,7 @@ execute_command_internal (COMMAND *command, int asynchronous, int pipe_in, int p
volatile int save_line_number;
#if defined (PROCESS_SUBSTITUTION)
volatile int ofifo, nfifo, osize, saved_fifo;
volatile void *ofifo_list;
void *ofifo_list; /* void * volatile ofifo_list; */
#endif
if (breaking || continuing)
@@ -791,7 +791,7 @@ execute_command_internal (COMMAND *command, int asynchronous, int pipe_in, int p
#if defined (PROCESS_SUBSTITUTION)
if (saved_fifo)
{
free ((void *)ofifo_list);
free (ofifo_list);
discard_unwind_frame ("internal_fifos");
}
#endif
@@ -1104,7 +1104,7 @@ execute_command_internal (COMMAND *command, int asynchronous, int pipe_in, int p
nfifo = num_fifos ();
if (nfifo > ofifo)
close_new_fifos ((void *)ofifo_list, osize);
free ((void *)ofifo_list);
free (ofifo_list);
discard_unwind_frame ("internal_fifos");
}
#endif
@@ -1340,7 +1340,7 @@ time_command (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, str
# if defined (HAVE_STRUCT_TIMEZONE)
gettimeofday (&before, &dtz);
# else
gettimeofday (&before, (void *)NULL);
gettimeofday (&before, NULL);
# endif /* !HAVE_STRUCT_TIMEZONE */
getrusage (RUSAGE_SELF, &selfb);
getrusage (RUSAGE_CHILDREN, &kidsb);
@@ -1390,7 +1390,7 @@ time_command (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, str
# if defined (HAVE_STRUCT_TIMEZONE)
gettimeofday (&after, &dtz);
# else
gettimeofday (&after, (void *)NULL);
gettimeofday (&after, NULL);
# endif /* !HAVE_STRUCT_TIMEZONE */
getrusage (RUSAGE_SELF, &selfa);
getrusage (RUSAGE_CHILDREN, &kidsa);
@@ -3365,7 +3365,7 @@ execute_select_command (SELECT_COM *select_command)
/* command and arithmetic substitution, parameter and variable expansion,
word splitting, pathname expansion, and quote removal. */
list = releaser = expand_words_no_vars (select_command->map_list);
list_len = list_length (list);
list_len = list_length ((GENERIC_LIST *)list);
if (list == 0 || list_len == 0)
{
if (list)
+4 -6
View File
@@ -152,12 +152,10 @@ extern int locale_decpoint (void);
/* Declarations for functions defined in list.c. */
extern void list_walk (GENERIC_LIST *, sh_glist_func_t *);
extern void wlist_walk (WORD_LIST *, sh_icpfunc_t *);
/* type punning used to pass arbitrary list types to list_reverse, et al so
there are no prototypes. */
extern GENERIC_LIST *list_reverse ();
extern int list_length ();
extern GENERIC_LIST *list_append ();
extern GENERIC_LIST *list_remove (); /* unused */
extern GENERIC_LIST *list_reverse (GENERIC_LIST *);
extern int list_length (GENERIC_LIST *);
extern GENERIC_LIST *list_append (GENERIC_LIST *, GENERIC_LIST *);
extern GENERIC_LIST *list_emove (GENERIC_LIST **, sh_gcp_func_t *, char *); /* unused */
/* Declarations for functions defined in stringlib.c */
extern int find_string_in_alist (char *, STRING_INT_ALIST *, int);
-9
View File
@@ -45,15 +45,6 @@
#include "xmalloc.h"
/* NULL pointer type. */
#if !defined (NULL)
# if defined (__STDC__)
# define NULL ((void *) 0)
# else
# define NULL 0x0
# endif /* !__STDC__ */
#endif /* !NULL */
/* Hardly used anymore */
#define pointer_to_int(x) (int)((char *)x - (char *)0)
+1 -13
View File
@@ -24,11 +24,7 @@
#include "stdc.h"
#ifndef PTR_T
# ifdef __STDC__
# define PTR_T void *
# else
# define PTR_T char *
# endif
# define PTR_T void *
#endif
typedef struct bucket_contents {
@@ -81,12 +77,4 @@ extern unsigned int hash_string (const char *);
#define HASH_NOSRCH 0x01
#define HASH_CREATE 0x02
#if !defined (NULL)
# if defined (__STDC__)
# define NULL ((void *) 0)
# else
# define NULL 0x0
# endif /* !__STDC__ */
#endif /* !NULL */
#endif /* _HASHLIB_H */
+1 -7
View File
@@ -2,7 +2,7 @@
/* A minimal stdlib.h containing extern declarations for those functions
that bash uses. */
/* Copyright (C) 1993 Free Software Foundation, Inc.
/* Copyright (C) 1993,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -32,13 +32,7 @@ extern double strtod ();
/* Memory allocation functions. */
/* Generic pointer type. */
#ifndef PTR_T
#if defined (__STDC__)
# define PTR_T void *
#else
# define PTR_T char *
#endif
#endif /* PTR_T */
extern PTR_T malloc ();
+1 -7
View File
@@ -1,6 +1,6 @@
/* ocache.h -- a minimal object caching implementation. */
/* Copyright (C) 2002 Free Software Foundation, Inc.
/* Copyright (C) 2002,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -22,13 +22,7 @@
#define _OCACHE_H_ 1
#ifndef PTR_T
#if defined (__STDC__)
# define PTR_T void *
#else
# define PTR_T char *
#endif
#endif /* PTR_T */
#define OC_MEMSET(memp, xch, nbytes) \
+1 -5
View File
@@ -1,7 +1,7 @@
/* collsyms.h -- collating symbol names and their corresponding characters
(in ascii) as given by POSIX.2 in table 2.8. */
/* Copyright (C) 1997-2002 Free Software Foundation, Inc.
/* Copyright (C) 1997-2002,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -38,11 +38,7 @@ static __COLLSYM POSIXCOLL [] =
{ L("EOT"), L('\004') },
{ L("ENQ"), L('\005') },
{ L("ACK"), L('\006') },
#ifdef __STDC__
{ L("alert"), L('\a') },
#else
{ L("alert"), L('\007') },
#endif
{ L("BS"), L('\010') },
{ L("backspace"), L('\b') },
{ L("HT"), L('\011') },
-8
View File
@@ -60,14 +60,6 @@
# define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
#endif /* !HAVE_BCOPY && !bcopy */
#if !defined (NULL)
# if defined (__STDC__)
# define NULL ((void *) 0)
# else
# define NULL 0x0
# endif /* __STDC__ */
#endif /* !NULL */
#if !defined (FREE)
# define FREE(x) if (x) free (x)
#endif
-4
View File
@@ -36,11 +36,7 @@ extern "C" {
# include <readline/rltypedefs.h>
#endif
#ifdef __STDC__
typedef void *histdata_t;
#else
typedef char *histdata_t;
#endif
/* Let's not step on anyone else's define for now, since we don't use this yet. */
#ifndef HS_HISTORY_VERSION
+2 -8
View File
@@ -1,6 +1,6 @@
/* xmalloc.h -- memory allocation that aborts on errors. */
/* Copyright (C) 1999-2009,2010-2021 Free Software Foundation, Inc.
/* Copyright (C) 1999-2009,2010-2023 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -29,13 +29,7 @@
#endif
#ifndef PTR_T
#ifdef __STDC__
# define PTR_T void *
#else
# define PTR_T char *
#endif
# define PTR_T void *
#endif /* !PTR_T */
extern PTR_T xmalloc (size_t);
+1 -1
View File
@@ -253,7 +253,7 @@ strlist_from_word_list (WORD_LIST *list, int alloc, int starting_index, int *ip)
*ip = 0;
return ((STRINGLIST *)0);
}
slen = list_length (list);
slen = list_length ((GENERIC_LIST *)list);
ret = (STRINGLIST *)xmalloc (sizeof (STRINGLIST));
ret->list = strvec_from_word_list (list, alloc, starting_index, &len);
ret->list_size = slen + starting_index;
+1 -1
View File
@@ -206,7 +206,7 @@ strvec_from_word_list (WORD_LIST *list, int alloc, int starting_index, int *ip)
int count;
char **array;
count = list_length (list);
count = list_length ((GENERIC_LIST *)list);
array = (char **)xmalloc ((1 + count + starting_index) * sizeof (char *));
for (count = 0; count < starting_index; count++)
-11
View File
@@ -95,13 +95,8 @@ ansicstr (const char *string, size_t len, int flags, int *sawc, size_t *rlen)
{
switch (c = *s++)
{
#if defined (__STDC__)
case 'a': c = '\a'; break;
case 'v': c = '\v'; break;
#else
case 'a': c = (int) 0x07; break;
case 'v': c = (int) 0x0B; break;
#endif
case 'b': c = '\b'; break;
case 'e': case 'E': /* ESC -- non-ANSI */
c = ESC; break;
@@ -257,14 +252,8 @@ ansic_quote (const char *str, int flags, int *rlen)
switch (c)
{
case ESC: c = 'E'; break;
#ifdef __STDC__
case '\a': c = 'a'; break;
case '\v': c = 'v'; break;
#else
case 0x07: c = 'a'; break;
case 0x0b: c = 'v'; break;
#endif
case '\b': c = 'b'; break;
case '\f': c = 'f'; break;
case '\n': c = 'n'; break;
-8
View File
@@ -68,14 +68,6 @@ extern struct passwd *getpwnam (const char *);
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
#endif /* !savestring */
#if !defined (NULL)
# if defined (__STDC__)
# define NULL ((void *) 0)
# else
# define NULL 0x0
# endif /* !__STDC__ */
#endif /* !NULL */
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
+1 -6
View File
@@ -2,7 +2,7 @@
* mksyntax.c - construct shell syntax table for fast char attribute lookup.
*/
/* Copyright (C) 2000-2009,2012,2022 Free Software Foundation, Inc.
/* Copyright (C) 2000-2009,2012,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -128,13 +128,8 @@ cdesc (int i)
switch (i)
{
#ifdef __STDC__
case '\a': xbuf[1] = 'a'; break;
case '\v': xbuf[1] = 'v'; break;
#else
case '\007': xbuf[1] = 'a'; break;
case 0x0B: xbuf[1] = 'v'; break;
#endif
case '\b': xbuf[1] = 'b'; break;
case '\f': xbuf[1] = 'f'; break;
case '\n': xbuf[1] = 'n'; break;
+1 -1
View File
@@ -893,7 +893,7 @@ gen_wordlist_matches (COMPSPEC *cs, const char *text)
l2 = expand_words_shellexp (l);
dispose_words (l);
nw = list_length (l2);
nw = list_length ((GENERIC_LIST *)l2);
sl = strlist_create (nw + 1);
ntxt = bash_dequote_text (text);
+2 -2
View File
@@ -12053,7 +12053,7 @@ glob_expand_word_list (WORD_LIST *tlist, int eflags)
if (glob_list)
{
output_list = (WORD_LIST *)list_append (glob_list, output_list);
output_list = (WORD_LIST *)list_append ((GENERIC_LIST *)glob_list, (GENERIC_LIST *)output_list);
PREPEND_LIST (tlist, disposables);
}
else if (fail_glob_expansion != 0)
@@ -12532,7 +12532,7 @@ shell_expand_word_list (WORD_LIST *tlist, int eflags)
}
expanded = REVERSE_LIST (temp_list, WORD_LIST *);
new_list = (WORD_LIST *)list_append (expanded, new_list);
new_list = (WORD_LIST *)list_append ((GENERIC_LIST *)expanded, (GENERIC_LIST *)new_list);
}
if (orig_list)
+1 -5
View File
@@ -1,6 +1,6 @@
/* endian.c -- A trick for determining the byte order of a machine. */
/* Copyright (C) 1993 Free Software Foundation, Inc.
/* Copyright (C) 1993,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -42,11 +42,7 @@ char nstring[9];
int
main (int argc, char **argv)
{
#if defined (__STDC__)
register size_t i;
#else
register int i;
#endif /* !__STDC__ */
FILE *stream = (FILE *)NULL;
char *stream_name = "stdout";
union {
+7 -7
View File
@@ -301,23 +301,23 @@ $ 1
$ 2
$ 3
$ exit
6
6
$ 1
$ 2
$ 3
$ 4
$ 5
$ exit
6
6
$ 1
$ 2
$ exit
4
4
$ e 1
$ e 2
$ e 3
$ exit
3
3
e 1
e 2
e 3
@@ -327,17 +327,17 @@ $ x 3
$ x 4
$ x 5
$ exit
3
3
x 3
x 4
x 5
$ y 1
$ y 2
$ exit
2
2
y 1
y 2
$ 1
$ 2
$ exit
0
0
+8 -7
View File
@@ -12,6 +12,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# test history file truncation for various values of $HISTFILESIZE
. ./test-glue-functions
: ${THIS_SH:=./bash}
: ${TMPDIR:=/var/tmp}
@@ -25,19 +26,19 @@ rm -f $HISTFILE
# exactly the number of lines
${THIS_SH} --norc -in <<<$'1\n2\n3'
wc -l < $HISTFILE
wc -l < $HISTFILE | _cut_leading_spaces
rm -f $HISTFILE
# truncating to fewer lines
${THIS_SH} --norc -in <<<$'1\n2\n3\n4\n5'
wc -l < $HISTFILE
wc -l < $HISTFILE | _cut_leading_spaces
rm -f $HISTFILE
# the history file contains fewer lines than $HISTFILESIZE
${THIS_SH} --norc -in <<<$'1\n2'
wc -l < $HISTFILE
wc -l < $HISTFILE | _cut_leading_spaces
rm -f $HISTFILE
@@ -46,21 +47,21 @@ unset HISTTIMEFORMAT
# exactly the number of lines
${THIS_SH} --norc -in <<<$'e 1\ne 2\ne 3'
wc -l < $HISTFILE
wc -l < $HISTFILE | _cut_leading_spaces
cat $HISTFILE
rm -f $HISTFILE
# truncating to fewer lines
${THIS_SH} --norc -in <<<$'x 1\nx 2\nx 3\nx 4\nx 5'
wc -l < $HISTFILE
wc -l < $HISTFILE | _cut_leading_spaces
cat $HISTFILE
rm -f $HISTFILE
# the history file contains fewer lines than $HISTFILESIZE
${THIS_SH} --norc -in <<<$'y 1\ny 2'
wc -l < $HISTFILE
wc -l < $HISTFILE | _cut_leading_spaces
cat $HISTFILE
rm -f $HISTFILE
@@ -68,6 +69,6 @@ rm -f $HISTFILE
# we want to truncate the history file to zero length
HISTFILESIZE=0
${THIS_SH} --norc -in <<<$'1\n2'
wc -l < $HISTFILE
wc -l < $HISTFILE | _cut_leading_spaces
rm -f $HISTFILE
+2 -6
View File
@@ -1,6 +1,6 @@
/* xmalloc.c -- safe versions of malloc and realloc */
/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
/* Copyright (C) 1991-2016,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the GNU Bourne Again SHell.
@@ -40,11 +40,7 @@
#include "bashintl.h"
#if !defined (PTR_T)
# if defined (__STDC__)
# define PTR_T void *
# else
# define PTR_T char *
# endif /* !__STDC__ */
# define PTR_T void *
#endif /* !PTR_T */
#if HAVE_SBRK && !HAVE_DECL_SBRK
+1 -7
View File
@@ -1,6 +1,6 @@
/* xmalloc.h -- defines for the `x' memory allocation functions */
/* Copyright (C) 2001-2022 Free Software Foundation, Inc.
/* Copyright (C) 2001-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -26,13 +26,7 @@
/* Generic pointer type. */
#ifndef PTR_T
#if defined (__STDC__)
# define PTR_T void *
#else
# define PTR_T char *
#endif
#endif /* PTR_T */
/* Allocation functions in xmalloc.c */