Bash-4.4 distribution sources and documentation

This commit is contained in:
Chet Ramey 2016-09-15 16:59:08 -04:00
commit a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions

View file

@ -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 */