Bash-4.4 distribution sources and documentation
This commit is contained in:
parent
30a978b7d8
commit
a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions
|
|
@ -20,7 +20,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
VPATH = @srcdir@
|
||||
topdir = @top_srcdir@
|
||||
BUILD_DIR = @BUILD_DIR@
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ BASHINCDIR = ${topdir}/include
|
|||
|
||||
INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib
|
||||
|
||||
CCFLAGS = $(PROFILE_FLAGS) $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) ${INCLUDES} \
|
||||
CCFLAGS = $(PROFILE_FLAGS) $(DEFS) $(LOCAL_DEFS) ${INCLUDES} $(CPPFLAGS) \
|
||||
$(LOCAL_CFLAGS) $(CFLAGS)
|
||||
|
||||
# Here is a rule for making .o files from .c files that doesn't force
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ struct globval
|
|||
};
|
||||
|
||||
extern void throw_to_top_level __P((void));
|
||||
extern int sh_eaccess __P((char *, int));
|
||||
extern int sh_eaccess __P((const char *, int));
|
||||
extern char *sh_makepath __P((const char *, const char *, int));
|
||||
extern int signal_is_pending __P((int));
|
||||
extern void run_pending_traps __P((void));
|
||||
|
|
@ -1061,7 +1061,10 @@ glob_filename (pathname, flags)
|
|||
directory_name = (char *) malloc (directory_len + 1);
|
||||
|
||||
if (directory_name == 0) /* allocation failed? */
|
||||
return (NULL);
|
||||
{
|
||||
free (result);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
bcopy (pathname, directory_name, directory_len);
|
||||
directory_name[directory_len] = '\0';
|
||||
|
|
@ -1249,7 +1252,12 @@ glob_filename (pathname, flags)
|
|||
(char **)realloc (result, (result_size + l) * sizeof (char *));
|
||||
|
||||
if (result == NULL)
|
||||
goto memory_error;
|
||||
{
|
||||
for (l = 0; array[l]; ++l)
|
||||
free (array[l]);
|
||||
free ((char *)array);
|
||||
goto memory_error;
|
||||
}
|
||||
|
||||
for (l = 0; array[l] != NULL; ++l)
|
||||
result[result_size++ - 1] = array[l];
|
||||
|
|
@ -1281,7 +1289,11 @@ only_filename:
|
|||
{
|
||||
result = (char **) realloc ((char *) result, 2 * sizeof (char *));
|
||||
if (result == NULL)
|
||||
return (NULL);
|
||||
{
|
||||
if (free_dirname)
|
||||
free (directory_name);
|
||||
return (NULL);
|
||||
}
|
||||
/* Handle GX_MARKDIRS here. */
|
||||
result[0] = (char *) malloc (directory_len + 1);
|
||||
if (result[0] == NULL)
|
||||
|
|
|
|||
|
|
@ -28,9 +28,14 @@
|
|||
|
||||
#include "bashansi.h"
|
||||
#include "shmbutil.h"
|
||||
#include "chartypes.h"
|
||||
|
||||
#include "stdc.h"
|
||||
|
||||
#ifndef FNM_CASEFOLD
|
||||
# include "strmatch.h"
|
||||
#endif
|
||||
|
||||
#ifndef LPAREN
|
||||
# define LPAREN '('
|
||||
#endif
|
||||
|
|
@ -42,25 +47,31 @@
|
|||
#define WLPAREN L'('
|
||||
#define WRPAREN L')'
|
||||
|
||||
/* Make sure these names continue to agree with what's in smatch.c */
|
||||
extern char *glob_patscan __P((char *, char *, int));
|
||||
extern wchar_t *glob_patscan_wc __P((wchar_t *, wchar_t *, int));
|
||||
|
||||
#define FOLD(c) ((flags & FNM_CASEFOLD) && iswupper (c) ? towlower (c) : (c))
|
||||
|
||||
/* Return 1 of the first character of WSTRING could match the first
|
||||
character of pattern WPAT. Wide character version. */
|
||||
character of pattern WPAT. Wide character version. FLAGS is a
|
||||
subset of strmatch flags; used to do case-insensitive matching for now. */
|
||||
int
|
||||
match_pattern_wchar (wpat, wstring)
|
||||
match_pattern_wchar (wpat, wstring, flags)
|
||||
wchar_t *wpat, *wstring;
|
||||
int flags;
|
||||
{
|
||||
wchar_t wc;
|
||||
|
||||
if (*wstring == 0)
|
||||
return (0);
|
||||
return (*wpat == L'*'); /* XXX - allow only * to match empty string */
|
||||
|
||||
switch (wc = *wpat++)
|
||||
{
|
||||
default:
|
||||
return (*wstring == wc);
|
||||
return (FOLD(*wstring) == FOLD(wc));
|
||||
case L'\\':
|
||||
return (*wstring == *wpat);
|
||||
return (FOLD(*wstring) == FOLD(*wpat));
|
||||
case L'?':
|
||||
return (*wpat == WLPAREN ? 1 : (*wstring != L'\0'));
|
||||
case L'*':
|
||||
|
|
@ -68,7 +79,7 @@ match_pattern_wchar (wpat, wstring)
|
|||
case L'+':
|
||||
case L'!':
|
||||
case L'@':
|
||||
return (*wpat == WLPAREN ? 1 : (*wstring == wc));
|
||||
return (*wpat == WLPAREN ? 1 : (FOLD(*wstring) == FOLD(wc)));
|
||||
case L'[':
|
||||
return (*wstring != L'\0');
|
||||
}
|
||||
|
|
@ -221,23 +232,31 @@ extglob_pattern_p (pat)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#undef FOLD
|
||||
#define FOLD(c) ((flags & FNM_CASEFOLD) \
|
||||
? TOLOWER ((unsigned char)c) \
|
||||
: ((unsigned char)c))
|
||||
|
||||
/* Return 1 of the first character of STRING could match the first
|
||||
character of pattern PAT. Used to avoid n2 calls to strmatch(). */
|
||||
character of pattern PAT. Used to avoid n2 calls to strmatch().
|
||||
FLAGS is a subset of strmatch flags; used to do case-insensitive
|
||||
matching for now. */
|
||||
int
|
||||
match_pattern_char (pat, string)
|
||||
match_pattern_char (pat, string, flags)
|
||||
char *pat, *string;
|
||||
int flags;
|
||||
{
|
||||
char c;
|
||||
|
||||
if (*string == 0)
|
||||
return (0);
|
||||
return (*pat == '*'); /* XXX - allow only * to match empty string */
|
||||
|
||||
switch (c = *pat++)
|
||||
{
|
||||
default:
|
||||
return (*string == c);
|
||||
return (FOLD(*string) == FOLD(c));
|
||||
case '\\':
|
||||
return (*string == *pat);
|
||||
return (FOLD(*string) == FOLD(*pat));
|
||||
case '?':
|
||||
return (*pat == LPAREN ? 1 : (*string != '\0'));
|
||||
case '*':
|
||||
|
|
@ -245,7 +264,7 @@ match_pattern_char (pat, string)
|
|||
case '+':
|
||||
case '!':
|
||||
case '@':
|
||||
return (*pat == LPAREN ? 1 : (*string == c));
|
||||
return (*pat == LPAREN ? 1 : (FOLD(*string) == FOLD(c)));
|
||||
case '[':
|
||||
return (*string != '\0');
|
||||
}
|
||||
|
|
@ -378,6 +397,7 @@ bad_bracket:
|
|||
return matlen;
|
||||
}
|
||||
|
||||
#if defined (EXTENDED_GLOB)
|
||||
/* Skip characters in PAT and return the final occurrence of DIRSEP. This
|
||||
is only called when extended_glob is set, so we have to skip over extglob
|
||||
patterns x(...) */
|
||||
|
|
@ -408,3 +428,4 @@ glob_dirscan (pat, dirsep)
|
|||
}
|
||||
return d;
|
||||
}
|
||||
#endif /* EXTENDED_GLOB */
|
||||
|
|
|
|||
|
|
@ -119,9 +119,6 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
|
|||
break;
|
||||
|
||||
case '*': /* Match zero or more characters */
|
||||
if (p == pe)
|
||||
return 0;
|
||||
|
||||
if ((flags & FNM_PERIOD) && sc == L('.') &&
|
||||
(n == string || ((flags & FNM_PATHNAME) && n[-1] == L('/'))))
|
||||
/* `*' cannot match a `.' if it is the first character of the
|
||||
|
|
@ -129,6 +126,9 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
|
|||
we are matching a pathname. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (p == pe)
|
||||
return 0;
|
||||
|
||||
/* Collapse multiple consecutive `*' and `?', but make sure that
|
||||
one character of the string is consumed for each `?'. */
|
||||
for (c = *p++; (c == L('?') || c == L('*')); c = *p++)
|
||||
|
|
@ -140,14 +140,26 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
|
|||
else if ((flags & FNM_EXTMATCH) && c == L('?') && *p == L('(')) /* ) */
|
||||
{
|
||||
CHAR *newn;
|
||||
|
||||
#if 0
|
||||
for (newn = n; newn < se; ++newn)
|
||||
{
|
||||
if (EXTMATCH (c, newn, se, p, pe, flags) == 0)
|
||||
return (0);
|
||||
}
|
||||
/* We didn't match. If we have a `?(...)', we can match 0
|
||||
or 1 times. */
|
||||
return 0;
|
||||
#else
|
||||
/* We can match 0 or 1 times. If we match, return success */
|
||||
if (EXTMATCH (c, n, se, p, pe, flags) == 0)
|
||||
return (0);
|
||||
#endif
|
||||
|
||||
/* We didn't match the extended glob pattern, but
|
||||
that's OK, since we can match 0 or 1 occurrences.
|
||||
We need to skip the glob pattern and see if we
|
||||
match the rest of the string. */
|
||||
newn = PATSCAN (p + 1, pe, 0);
|
||||
/* If NEWN is 0, we have an ill-formed pattern. */
|
||||
p = newn ? newn : pe;
|
||||
}
|
||||
#endif
|
||||
else if (c == L('?'))
|
||||
|
|
@ -187,6 +199,22 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
|
|||
break;
|
||||
}
|
||||
|
||||
/* The wildcards are the last element of the pattern. The name
|
||||
cannot match completely if we are looking for a pathname and
|
||||
it contains another slash, unless FNM_LEADING_DIR is set. */
|
||||
if (c == L('\0'))
|
||||
{
|
||||
int r = (flags & FNM_PATHNAME) == 0 ? 0 : FNM_NOMATCH;
|
||||
if (flags & FNM_PATHNAME)
|
||||
{
|
||||
if (flags & FNM_LEADING_DIR)
|
||||
r = 0;
|
||||
else if (MEMCHR (n, L('/'), se - n) == NULL)
|
||||
r = 0;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/* If we've hit the end of the pattern and the last character of
|
||||
the pattern was handled by the loop above, we've succeeded.
|
||||
Otherwise, we need to match that last character. */
|
||||
|
|
@ -205,13 +233,30 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
|
|||
}
|
||||
#endif
|
||||
|
||||
/* If we stop at a slash in the pattern and we are looking for a
|
||||
pathname ([star]/foo), then consume enough of the string to stop
|
||||
at any slash and then try to match the rest of the pattern. If
|
||||
the string doesn't contain a slash, fail */
|
||||
if (c == L('/') && (flags & FNM_PATHNAME))
|
||||
{
|
||||
while (n < se && *n != L('/'))
|
||||
++n;
|
||||
if (n < se && *n == L('/') && (GMATCH (n+1, se, p, pe, flags) == 0))
|
||||
return 0;
|
||||
return FNM_NOMATCH; /* XXX */
|
||||
}
|
||||
|
||||
/* General case, use recursion. */
|
||||
{
|
||||
U_CHAR c1;
|
||||
const CHAR *endp;
|
||||
|
||||
endp = MEMCHR (n, (flags & FNM_PATHNAME) ? L('/') : L('\0'), se - n);
|
||||
if (endp == 0)
|
||||
endp = se;
|
||||
c1 = ((flags & FNM_NOESCAPE) == 0 && c == L('\\')) ? *p : c;
|
||||
c1 = FOLD (c1);
|
||||
for (--p; n < se; ++n)
|
||||
for (--p; n < endp; ++n)
|
||||
{
|
||||
/* Only call strmatch if the first character indicates a
|
||||
possible match. We can check the first character if
|
||||
|
|
@ -533,7 +578,8 @@ matched:
|
|||
embedded () and []. If DELIM is 0, we scan until a matching `)'
|
||||
because we're scanning a `patlist'. Otherwise, we scan until we see
|
||||
DELIM. In all cases, we never scan past END. The return value is the
|
||||
first character after the matching DELIM. */
|
||||
first character after the matching DELIM or NULL if the pattern is
|
||||
empty or invalid. */
|
||||
/*static*/ CHAR *
|
||||
PATSCAN (string, end, delim)
|
||||
CHAR *string, *end;
|
||||
|
|
@ -797,6 +843,7 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
|
|||
#undef STRCOLL
|
||||
#undef STRLEN
|
||||
#undef STRCMP
|
||||
#undef MEMCHR
|
||||
#undef COLLEQUIV
|
||||
#undef RANGECMP
|
||||
#undef L
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ is_cclass (c, name)
|
|||
#define STRCOMPARE strcompare
|
||||
#define EXTMATCH extmatch
|
||||
#define STRCHR(S, C) strchr((S), (C))
|
||||
#define MEMCHR(S, C, N) memchr((S), (C), (N))
|
||||
#define STRCOLL(S1, S2) strcoll((S1), (S2))
|
||||
#define STRLEN(S) strlen(S)
|
||||
#define STRCMP(S1, S2) strcmp((S1), (S2))
|
||||
|
|
@ -333,6 +334,8 @@ is_wcclass (wc, name)
|
|||
|
||||
memset (&state, '\0', sizeof (mbstate_t));
|
||||
mbs = (char *) malloc (wcslen(name) * MB_CUR_MAX + 1);
|
||||
if (mbs == 0)
|
||||
return -1;
|
||||
mbslength = wcsrtombs (mbs, (const wchar_t **)&name, (wcslen(name) * MB_CUR_MAX + 1), &state);
|
||||
|
||||
if (mbslength == (size_t)-1 || mbslength == (size_t)-2)
|
||||
|
|
@ -363,6 +366,7 @@ is_wcclass (wc, name)
|
|||
#define STRCOMPARE wscompare
|
||||
#define EXTMATCH extmatch_wc
|
||||
#define STRCHR(S, C) wcschr((S), (C))
|
||||
#define MEMCHR(S, C, N) wmemchr((S), (C), (N))
|
||||
#define STRCOLL(S1, S2) wcscoll((S1), (S2))
|
||||
#define STRLEN(S) wcslen(S)
|
||||
#define STRCMP(S1, S2) wcscmp((S1), (S2))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue