Bash-5.3-alpha release

This commit is contained in:
Chet Ramey
2024-04-22 10:33:38 -04:00
parent f3b6bd1945
commit 622d318652
700 changed files with 136534 additions and 96420 deletions
+97 -109
View File
@@ -1,6 +1,6 @@
/* general.h -- defines that everybody likes to use. */
/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
/* Copyright (C) 1993-2024 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -43,26 +43,14 @@
# include <limits.h>
#endif
#include "unlocked-io.h"
#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)
#if defined (alpha) && defined (__GNUC__) && !defined (strchr) && !defined (__STDC__)
extern char *strchr (), *strrchr ();
#endif
#if !defined (strcpy) && (defined (HAVE_DECL_STRCPY) && !HAVE_DECL_STRCPY)
extern char *strcpy PARAMS((char *, const char *));
extern char *strcpy (char *, const char *);
#endif
#if !defined (savestring)
@@ -163,9 +151,19 @@ typedef struct {
#endif /* !__GNUC__ */
/* String comparisons that possibly save a function call each. */
#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
#define STREQN(a, b, n) ((n == 0) ? (1) \
: ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
static inline int
STREQ(const char *a, const char *b)
{
return ((a)[0] == (b)[0] && strcmp(a, b) == 0);
}
static inline int
STREQN(const char *a, const char *b, size_t n)
{
return ((n == 0) ||
(n == 1 && a[0] == b[0]) ||
((a)[0] == (b)[0] && strncmp(a, b, n) == 0));
}
/* More convenience definitions that possibly save system or libc calls. */
#define STRLEN(s) (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)
@@ -190,62 +188,54 @@ typedef struct {
} \
} while (0)
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction (); /* no longer used */
typedef char **CPPFunction (); /* no longer used */
#endif /* _FUNCTION_DEF */
#ifndef SH_FUNCTION_TYPEDEF
# define SH_FUNCTION_TYPEDEF
/* Shell function typedefs with prototypes */
/* `Generic' function pointer typedefs */
typedef int sh_intfunc_t PARAMS((int));
typedef int sh_ivoidfunc_t PARAMS((void));
typedef int sh_icpfunc_t PARAMS((char *));
typedef int sh_icppfunc_t PARAMS((char **));
typedef int sh_iptrfunc_t PARAMS((PTR_T));
typedef int sh_intfunc_t (int);
typedef int sh_ivoidfunc_t (void);
typedef int sh_icpfunc_t (char *);
typedef int sh_icppfunc_t (char **);
typedef int sh_iptrfunc_t (PTR_T);
typedef void sh_voidfunc_t PARAMS((void));
typedef void sh_vintfunc_t PARAMS((int));
typedef void sh_vcpfunc_t PARAMS((char *));
typedef void sh_vcppfunc_t PARAMS((char **));
typedef void sh_vptrfunc_t PARAMS((PTR_T));
typedef void sh_voidfunc_t (void);
typedef void sh_vintfunc_t (int);
typedef void sh_vcpfunc_t (char *);
typedef void sh_vcppfunc_t (char **);
typedef void sh_vptrfunc_t (PTR_T);
typedef int sh_wdesc_func_t PARAMS((WORD_DESC *));
typedef int sh_wlist_func_t PARAMS((WORD_LIST *));
typedef int sh_wdesc_func_t (WORD_DESC *);
typedef int sh_wlist_func_t (WORD_LIST *);
typedef int sh_glist_func_t PARAMS((GENERIC_LIST *));
typedef int sh_glist_func_t (GENERIC_LIST *);
typedef int sh_gcp_func_t (GENERIC_LIST *, char *);
typedef char *sh_string_func_t PARAMS((char *)); /* like savestring, et al. */
typedef char *sh_string_func_t (char *); /* like savestring, et al. */
typedef int sh_msg_func_t PARAMS((const char *, ...)); /* printf(3)-like */
typedef void sh_vmsg_func_t PARAMS((const char *, ...)); /* printf(3)-like */
typedef int sh_msg_func_t (const char *, ...); /* printf(3)-like */
typedef void sh_vmsg_func_t (const char *, ...); /* printf(3)-like */
/* Specific function pointer typedefs. Most of these could be done
with #defines. */
typedef void sh_sv_func_t PARAMS((char *)); /* sh_vcpfunc_t */
typedef void sh_free_func_t PARAMS((PTR_T)); /* sh_vptrfunc_t */
typedef void sh_resetsig_func_t PARAMS((int)); /* sh_vintfunc_t */
typedef void sh_sv_func_t (const char *);
typedef void sh_free_func_t (PTR_T); /* sh_vptrfunc_t */
typedef void sh_resetsig_func_t (int); /* sh_vintfunc_t */
typedef int sh_ignore_func_t PARAMS((const char *)); /* sh_icpfunc_t */
typedef int sh_ignore_func_t (const char *); /* sh_icpfunc_t */
typedef int sh_assign_func_t PARAMS((const char *));
typedef int sh_wassign_func_t PARAMS((WORD_DESC *, int));
typedef int sh_assign_func_t (const char *);
typedef int sh_wassign_func_t (const WORD_DESC *, int);
typedef int sh_load_func_t PARAMS((char *));
typedef void sh_unload_func_t PARAMS((char *));
typedef int sh_load_func_t (char *);
typedef void sh_unload_func_t (char *);
typedef int sh_builtin_func_t PARAMS((WORD_LIST *)); /* sh_wlist_func_t */
typedef int sh_builtin_func_t (WORD_LIST *); /* sh_wlist_func_t */
#endif /* SH_FUNCTION_TYPEDEF */
#define NOW ((time_t) time ((time_t *) 0))
#define NOW getnow()
#define GETTIME(tv) gettimeofday(&(tv), NULL)
/* Some defines for calling file status functions. */
@@ -261,11 +251,7 @@ typedef int sh_builtin_func_t PARAMS((WORD_LIST *)); /* sh_wlist_func_t */
#define HIGH_FD_MAX 256
/* The type of function passed as the fourth argument to qsort(3). */
#ifdef __STDC__
typedef int QSFUNC (const void *, const void *);
#else
typedef int QSFUNC ();
#endif
/* Some useful definitions for Unix pathnames. Argument convention:
x == string, c == character */
@@ -296,77 +282,79 @@ typedef int QSFUNC ();
#if 0
/* Declarations for functions defined in xmalloc.c */
extern PTR_T xmalloc PARAMS((size_t));
extern PTR_T xrealloc PARAMS((void *, size_t));
extern void xfree PARAMS((void *));
extern PTR_T xmalloc (size_t);
extern PTR_T xrealloc (void *, size_t);
extern void xfree (void *);
#endif
/* Declarations for functions defined in general.c */
extern void posix_initialize PARAMS((int));
extern void posix_initialize (int);
extern int num_posix_options PARAMS((void));
extern char *get_posix_options PARAMS((char *));
extern void set_posix_options PARAMS((const char *));
extern size_t num_posix_options (void);
extern char *get_posix_options (char *);
extern void set_posix_options (const char *);
extern void save_posix_options PARAMS((void));
extern void save_posix_options (void);
#if defined (RLIMTYPE)
extern RLIMTYPE string_to_rlimtype PARAMS((char *));
extern void print_rlimtype PARAMS((RLIMTYPE, int));
extern RLIMTYPE string_to_rlimtype (const char *, char **);
extern void print_rlimtype (RLIMTYPE, int);
#endif
extern int all_digits PARAMS((const char *));
extern int legal_number PARAMS((const char *, intmax_t *));
extern int legal_identifier PARAMS((const char *));
extern int importable_function_name PARAMS((const char *, size_t));
extern int exportable_function_name PARAMS((const char *));
extern int check_identifier PARAMS((WORD_DESC *, int));
extern int valid_nameref_value PARAMS((const char *, int));
extern int check_selfref PARAMS((const char *, char *, int));
extern int legal_alias_name PARAMS((const char *, int));
extern int line_isblank PARAMS((const char *));
extern int assignment PARAMS((const char *, int));
extern int all_digits (const char *);
extern int valid_number (const char *, intmax_t *);
extern int valid_identifier (const char *);
extern int importable_function_name (const char *, size_t);
extern int exportable_function_name (const char *);
extern int check_identifier (WORD_DESC *, int);
extern int valid_nameref_value (const char *, int);
extern int check_selfref (const char *, char *, int);
extern int valid_alias_name (const char *, int);
extern int valid_function_name (const char *, int);
extern int valid_function_word (WORD_DESC *, int);
extern int line_isblank (const char *);
extern int assignment (const char *, int);
extern int sh_unset_nodelay_mode PARAMS((int));
extern int sh_setclexec PARAMS((int));
extern int sh_validfd PARAMS((int));
extern int fd_ispipe PARAMS((int));
extern void check_dev_tty PARAMS((void));
extern int move_to_high_fd PARAMS((int, int, int));
extern int check_binary_file PARAMS((const char *, int));
extern int sh_unset_nodelay_mode (int);
extern int sh_setclexec (int);
extern int sh_validfd (int);
extern int fd_ispipe (int);
extern void check_dev_tty (void);
extern int move_to_high_fd (int, int, int);
extern int check_binary_file (const char *, int);
#ifdef _POSIXSTAT_H_
extern int same_file PARAMS((const char *, const char *, struct stat *, struct stat *));
extern int same_file (const char *, const char *, struct stat *, struct stat *);
#endif
extern int sh_openpipe PARAMS((int *));
extern int sh_closepipe PARAMS((int *));
extern int sh_openpipe (int *);
extern int sh_closepipe (int *);
extern int file_exists PARAMS((const char *));
extern int file_isdir PARAMS((const char *));
extern int file_iswdir PARAMS((const char *));
extern int path_dot_or_dotdot PARAMS((const char *));
extern int absolute_pathname PARAMS((const char *));
extern int absolute_program PARAMS((const char *));
extern int file_exists (const char *);
extern int file_isdir (const char *);
extern int file_iswdir (const char *);
extern int path_dot_or_dotdot (const char *);
extern int absolute_pathname (const char *);
extern int absolute_program (const char *);
extern char *make_absolute PARAMS((const char *, const char *));
extern char *base_pathname PARAMS((char *));
extern char *full_pathname PARAMS((char *));
extern char *polite_directory_format PARAMS((char *));
extern char *trim_pathname PARAMS((char *, int));
extern char *printable_filename PARAMS((char *, int));
extern char *make_absolute (const char *, const char *);
extern char *base_pathname (char *);
extern char *full_pathname (char *);
extern char *polite_directory_format (char *);
extern char *trim_pathname (char *, int);
extern char *printable_filename (char *, int);
extern char *extract_colon_unit PARAMS((char *, int *));
extern char *extract_colon_unit (char *, int *);
extern void tilde_initialize PARAMS((void));
extern char *bash_tilde_find_word PARAMS((const char *, int, int *));
extern char *bash_tilde_expand PARAMS((const char *, int));
extern void tilde_initialize (void);
extern char *bash_tilde_find_word (const char *, int, size_t *);
extern char *bash_tilde_expand (const char *, int);
extern int group_member PARAMS((gid_t));
extern char **get_group_list PARAMS((int *));
extern int *get_group_array PARAMS((int *));
extern int group_member (gid_t);
extern char **get_group_list (int *);
extern int *get_group_array (int *);
extern char *conf_standard_path PARAMS((void));
extern int default_columns PARAMS((void));
extern char *conf_standard_path (void);
extern int default_columns (void);
#endif /* _GENERAL_H_ */