Imported from ../bash-3.2.tar.gz.

This commit is contained in:
Jari Aalto 2006-10-10 14:15:34 +00:00
commit 0628567a28
182 changed files with 17647 additions and 9477 deletions

View file

@ -33,7 +33,7 @@ CC = @CC@
RANLIB = @RANLIB@
AR = @AR@
ARFLAGS = @ARFLAGS@
RM = rm
RM = rm -f
CP = cp
MV = mv
@ -59,6 +59,7 @@ CCFLAGS = $(PROFILE_FLAGS) $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) ${INCLUDES} \
# Here is a rule for making .o files from .c files that doesn't force
# the type of the machine (like -sun3) into the flags.
.c.o:
$(RM) $@
$(CC) -c $(CCFLAGS) $<
# The name of the library target.

View file

@ -73,7 +73,7 @@
#endif
extern void throw_to_top_level __P((void));
extern int test_eaccess __P((char *, int));
extern int sh_eaccess __P((char *, int));
extern int extended_glob;
@ -184,7 +184,7 @@ mbskipname (pat, dname)
{
int ret;
wchar_t *pat_wc, *dn_wc;
size_t pat_n, dn_n, n;
size_t pat_n, dn_n;
pat_n = xdupmbstowcs (&pat_wc, NULL, pat);
dn_n = xdupmbstowcs (&dn_wc, NULL, dname);
@ -293,7 +293,7 @@ dequote_pathname (pathname)
# define GLOB_TESTNAME(name) (lstat (name, &finfo))
#else /* !HAVE_LSTAT */
# if !defined (AFS)
# define GLOB_TESTNAME(name) (test_eaccess (nextname, F_OK))
# define GLOB_TESTNAME(name) (sh_eaccess (nextname, F_OK))
# else /* AFS */
# define GLOB_TESTNAME(name) (access (nextname, F_OK))
# endif /* AFS */
@ -360,6 +360,7 @@ glob_vector (pat, dir, flags)
count = lose = skip = 0;
firstmalloc = 0;
nalloca = 0;
/* If PAT is empty, skip the loop, but return one (empty) filename. */
if (pat == 0 || *pat == '\0')
@ -469,7 +470,7 @@ glob_vector (pat, dir, flags)
while (1)
{
/* Make globbing interruptible in the shell. */
if (interrupt_state)
if (interrupt_state || terminating_signal)
{
lose = 1;
break;
@ -540,12 +541,17 @@ glob_vector (pat, dir, flags)
/* Here free the strings we have got. */
while (lastlink)
{
/* Since we build the list in reverse order, the first N entries
will be allocated with malloc, if firstmalloc is set, from
lastlink to firstmalloc. */
if (firstmalloc)
{
if (lastlink == firstmalloc)
firstmalloc = 0;
tmplink = lastlink;
}
else
tmplink = 0;
free (lastlink->name);
lastlink = lastlink->next;
FREE (tmplink);

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1991-2005 Free Software Foundation, Inc.
/* Copyright (C) 1991-2006 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -15,7 +15,6 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
int FCT __P((CHAR *, CHAR *, int));
static int GMATCH __P((CHAR *, CHAR *, CHAR *, CHAR *, int));
@ -638,12 +637,13 @@ EXTMATCH (xc, s, se, p, pe, flags)
CHAR *psub; /* pointer to sub-pattern */
CHAR *pnext; /* pointer to next sub-pattern */
CHAR *srest; /* pointer to rest of string */
int m1, m2;
int m1, m2, xflags; /* xflags = flags passed to recursive matches */
#if DEBUG_MATCHING
fprintf(stderr, "extmatch: xc = %c\n", xc);
fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se);
fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
fprintf(stderr, "extmatch: flags = %d\n", flags);
#endif
prest = PATSCAN (p + (*p == L('(')), pe, 0); /* ) */
@ -677,8 +677,12 @@ fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
string matches the rest of the pattern. Also handle
multiple matches of the pattern. */
if (m1)
m2 = (GMATCH (srest, se, prest, pe, flags) == 0) ||
(s != srest && GMATCH (srest, se, p - 1, pe, flags) == 0);
{
/* if srest > s, we are not at start of string */
xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
m2 = (GMATCH (srest, se, prest, pe, xflags) == 0) ||
(s != srest && GMATCH (srest, se, p - 1, pe, xflags) == 0);
}
if (m1 && m2)
return (0);
}
@ -688,7 +692,7 @@ fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
return (FNM_NOMATCH);
case L('?'): /* match zero or one of the patterns */
case L('@'): /* match exactly one of the patterns */
case L('@'): /* match one (or more) of the patterns */
/* If we can get away with no matches, don't even bother. Just
call gmatch on the rest of the pattern and return success if
it succeeds. */
@ -704,8 +708,10 @@ fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
srest = (prest == pe) ? se : s;
for ( ; srest <= se; srest++)
{
/* if srest > s, we are not at start of string */
xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
if (GMATCH (s, srest, psub, pnext - 1, flags) == 0 &&
GMATCH (srest, se, prest, pe, flags) == 0)
GMATCH (srest, se, prest, pe, xflags) == 0)
return (0);
}
if (pnext == prest)
@ -726,7 +732,9 @@ fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
if (pnext == prest)
break;
}
if (m1 == 0 && GMATCH (srest, se, prest, pe, flags) == 0)
/* if srest > s, we are not at start of string */
xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
if (m1 == 0 && GMATCH (srest, se, prest, pe, xflags) == 0)
return (0);
}
return (FNM_NOMATCH);

View file

@ -247,7 +247,6 @@ rangecmp_wc (c1, c2)
{
static wchar_t s1[2] = { L' ', L'\0' };
static wchar_t s2[2] = { L' ', L'\0' };
int ret;
if (c1 == c2)
return 0;

View file

@ -145,7 +145,8 @@ xdupmbstowcs (destp, indicesp, src)
/* In case SRC or DESP is NULL, conversion doesn't take place. */
if (src == NULL || destp == NULL)
{
*destp = NULL;
if (destp)
*destp = NULL;
return (size_t)-1;
}