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

This commit is contained in:
Jari Aalto 2000-03-17 21:46:59 +00:00
commit bb70624e96
387 changed files with 28522 additions and 9334 deletions

View file

@ -3,6 +3,22 @@
# Makefile for the GNU Glob Library. #
# #
####################################################################
#
# Copyright (C) 1996 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
srcdir = @srcdir@
VPATH = .:@srcdir@
@ -31,7 +47,9 @@ LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
BASHINCDIR = ${topdir}/include
INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
@ -107,8 +125,8 @@ fnmatch.o: fnmatch.h
fnmatch.o: $(BUILD_DIR)/config.h
glob.o: $(BUILD_DIR)/config.h
glob.o: $(topdir)/bashtypes.h $(topdir)/ansi_stdlib.h $(topdir)/bashansi.h
glob.o: $(topdir)/posixstat.h $(topdir)/memalloc.h
glob.o: $(topdir)/bashtypes.h $(BASHINCDIR)/ansi_stdlib.h $(topdir)/bashansi.h
glob.o: $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/memalloc.h
glob.o: fnmatch.h
# Rules for deficient makes, like SunOS and Solaris

View file

@ -17,7 +17,7 @@
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _COLLSYMS_H_
# define _COLLSYSMS_H_

View file

@ -17,9 +17,11 @@
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
#include <stdio.h> /* for debugging */
#include "fnmatch.h"
#include "collsyms.h"
@ -66,8 +68,18 @@ static char *patscan ();
#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
#endif
/* We don't use strcoll(3) for range comparisons in bracket expressions,
even if we have it, since it can have unwanted side effects in locales
other than POSIX or US. For instance, in the de locale, [A-Z] matches
all characters. So, for ranges we use ASCII collation, and for
collating symbol equivalence we use strcoll(). The casts to int are
to handle tests that use unsigned chars. */
#define rangecmp(c1, c2) ((int)(c1) - (int)(c2))
#if defined (HAVE_STRCOLL)
static int rangecmp (c1, c2)
/* Helper function for collating symbol equivalence. */
static int rangecmp2 (c1, c2)
int c1, c2;
{
static char s1[2] = { ' ', '\0' };
@ -89,14 +101,14 @@ static int rangecmp (c1, c2)
return (c1 - c2);
}
#else /* !HAVE_STRCOLL */
# define rangecmp(c1, c2) ((c1) - (c2))
# define rangecmp2(c1, c2) ((int)(c1) - (int)(c2))
#endif /* !HAVE_STRCOLL */
#if defined (HAVE_STRCOLL)
static int collequiv (c1, c2)
int c1, c2;
{
return (rangecmp (c1, c2) == 0);
return (rangecmp2 (c1, c2) == 0);
}
#else
# define collequiv(c1, c2) ((c1) == (c2))
@ -253,7 +265,7 @@ gmatch (string, se, pattern, pe, flags)
that's OK, since we can match 0 or more occurrences.
We need to skip the glob pattern and see if we
match the rest of the string. */
newn = patscan (p, pe, 0);
newn = patscan (p + 1, pe, 0);
p = newn;
}
#endif
@ -587,6 +599,8 @@ patscan (string, end, delim)
pnest = bnest = 0;
for (s = string; c = *s; s++)
{
if (s >= end)
return (s);
switch (c)
{
case '\0':
@ -603,10 +617,15 @@ patscan (string, end, delim)
pnest++;
break;
case ')':
#if 0
if (bnest == 0)
pnest--;
if (pnest <= 0)
return ++s;
#else
if (bnest == 0 && pnest-- <= 0)
return ++s;
#endif
break;
case '|':
if (bnest == 0 && pnest == 0 && delim == '|')
@ -614,6 +633,7 @@ patscan (string, end, delim)
break;
}
}
return (char *)0;
}
@ -658,16 +678,22 @@ extmatch (xc, s, se, p, pe, flags)
char *srest; /* pointer to rest of string */
int m1, m2;
#if 0
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);
#endif
prest = patscan (p + (*p == '('), pe, 0); /* ) */
if (prest == 0)
/* If PREST is 0, we failed to scan a valid pattern. In this
case, we just want to compare the two as strings. */
return (strcompare (p - 1, pe, s, se));
switch (xc)
{
case '+': /* match one or more occurrences */
case '*': /* match zero or more occurrences */
prest = patscan (p, pe, 0);
if (prest == 0)
/* If PREST is 0, we failed to scan a valid pattern. In this
case, we just want to compare the two as strings. */
return (strcompare (p - 1, pe, s, se));
/* 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. */
@ -701,10 +727,6 @@ extmatch (xc, s, se, p, pe, flags)
case '?': /* match zero or one of the patterns */
case '@': /* match exactly one of the patterns */
prest = patscan (p, pe, 0);
if (prest == 0)
return (strcompare (p - 1, pe, s, se));
/* 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. */
@ -730,10 +752,6 @@ extmatch (xc, s, se, p, pe, flags)
return (FNM_NOMATCH);
case '!': /* match anything *except* one of the patterns */
prest = patscan (p, pe, 0);
if (prest == 0)
return (strcompare (p - 1, pe, s, se));
for (srest = s; srest <= se; srest++)
{
m1 = 0;

View file

@ -13,8 +13,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1

View file

@ -3,7 +3,7 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* To whomever it may concern: I have never seen the code which most
Unix programs use to perform this function. I wrote this from scratch
@ -67,7 +67,7 @@
# endif
#endif /* !HAVE_DIRENT_H */
#if defined (_POSIX_SOURCE)
#if defined (_POSIX_SOURCE) && !defined (STRUCT_DIRENT_HAS_D_INO)
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
# define REAL_DIR_ENTRY(dp) 1

View file

@ -3,7 +3,7 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _GLOB_H_
#define _GLOB_H_