Subject: Re: added bootstrap support for IRIX 5
To: Georg Schwarz <geos@epost.de>
From: grant beattie <grant@NetBSD.org>
List: tech-pkg
Date: 04/04/2004 13:32:44
--EK9OvA4pujAs5S2B
Content-Type: multipart/mixed; boundary="nDT5KaoIdRowUDKE"
Content-Disposition: inline


--nDT5KaoIdRowUDKE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Apr 03, 2004 at 08:59:27PM +0200, Georg Schwarz wrote:

> I have added bootstrap support for IRIX 5 and maybe earlier (differs quit=
e a bit
> from the current IRIX 6.5) to the current pkgsrc. Here are the diffs with=
 a few
> remarks. I would appreciate it they could make their way into pkgsrc. Com=
ments
> would be welcome.
>=20
> One problem with IRIX 5 is that it does not have libregex and libfnmatch.
> Therefore one first has to manually get some GNU equivalents and install =
them.
> Any suggestion how to improve this and how to properly ingetrage it would=
 be
> appreciated.

Georg,

try this patch and the attached files for fnmatch(3). I've taken this
straight from the NetBSD sources and don't really expect it to build
everywhere, but I don't have access to any platforms which don't
have fnmatch so I can't test it on those.

grant.


--nDT5KaoIdRowUDKE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=fnmatch
Content-Transfer-Encoding: quoted-printable

Index: Makefile.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /work/netbsd/cvsroot/pkgsrc/pkgtools/libnbcompat/files/Makefile.i=
n,v
retrieving revision 1.22
diff -u -r1.22 Makefile.in
--- Makefile.in	10 Dec 2003 07:21:20 -0000	1.22
+++ Makefile.in	4 Apr 2004 02:06:43 -0000
@@ -22,7 +22,8 @@
 INCS=3D		nbcompat.h nbcompat/err.h nbcompat/fts.h nbcompat/getopt.h \
 		nbcompat/glob.h nbcompat/md5.h nbcompat/nbconfig.h \
 		nbcompat/nbtypes.h nbcompat/poll.h nbcompat/rmd160.h \
-		nbcompat/sha1.h nbcompat/statfs.h nbcompat/vis.h
+		nbcompat/sha1.h nbcompat/statfs.h nbcompat/vis.h \
+		nbcompat/fnmatch.h
=20
 # always use our local glob() implementation.
 OBJS=3D		glob.o @LIBOBJS@
Index: configure
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /work/netbsd/cvsroot/pkgsrc/pkgtools/libnbcompat/files/configure,v
retrieving revision 1.37
diff -u -r1.37 configure
--- configure	11 Mar 2004 18:35:29 -0000	1.37
+++ configure	4 Apr 2004 02:14:41 -0000
@@ -3297,9 +3297,12 @@
=20
=20
=20
-for ac_header in arpa/nameser.h assert.h bind/bitypes.h dirent.h err.h \
-	errno.h fcntl.h fts.h inttypes.h libutil.h limits.h \
-	machine/endian.h memory.h ndir.h netdb.h netinet/in6_machtypes.h \
+
+
+
+for ac_header in arpa/nameser.h assert.h bind/bitypes.h ctype.h dirent.h e=
rr.h \
+	errno.h fcntl.h fnmatch.h fts.h inttypes.h libutil.h limits.h \
+	machine/endian.h machine/limits.h memory.h ndir.h netdb.h netinet/in6_mac=
htypes.h \
 	paths.h poll.h pwd.h stdint.h stdlib.h stringlist.h strings.h \
 	string.h sys/bitypes.h sys/byteorder.h sys/cdefs.h sys/dir.h \
 	sys/endian.h sys/file.h sys/mkdev.h sys/ndir.h \
@@ -6966,7 +6969,8 @@
=20
=20
=20
-for ac_func in err fgetln fparseln fseeko getenv inet_ntop \
+
+for ac_func in err fgetln fnmatch fparseln fseeko getenv inet_ntop \
 	inet_pton isblank lchflags lchmod lchown lutimes mkstemp mkdtemp \
 	poll setprogname snprintf strdup strerror strlcat strlcpy \
 	strmode strptime strsep strtoll timegm usleep utimes
Index: configure.ac
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /work/netbsd/cvsroot/pkgsrc/pkgtools/libnbcompat/files/configure.=
ac,v
retrieving revision 1.38
diff -u -r1.38 configure.ac
--- configure.ac	11 Mar 2004 18:35:29 -0000	1.38
+++ configure.ac	4 Apr 2004 02:14:31 -0000
@@ -32,9 +32,9 @@
 AC_HEADER_STDC
 AC_HEADER_TIME
=20
-AC_CHECK_HEADERS([arpa/nameser.h assert.h bind/bitypes.h dirent.h err.h \
-	errno.h fcntl.h fts.h inttypes.h libutil.h limits.h \
-	machine/endian.h memory.h ndir.h netdb.h netinet/in6_machtypes.h \
+AC_CHECK_HEADERS([arpa/nameser.h assert.h bind/bitypes.h ctype.h dirent.h =
err.h \
+	errno.h fcntl.h fnmatch.h fts.h inttypes.h libutil.h limits.h \
+	machine/endian.h machine/limits.h memory.h ndir.h netdb.h netinet/in6_mac=
htypes.h \
 	paths.h poll.h pwd.h stdint.h stdlib.h stringlist.h strings.h \
 	string.h sys/bitypes.h sys/byteorder.h sys/cdefs.h sys/dir.h \
 	sys/endian.h sys/file.h sys/mkdev.h sys/ndir.h \
@@ -135,7 +135,7 @@
 AC_FUNC_STRERROR_R
 AC_FUNC_VPRINTF
=20
-AC_REPLACE_FUNCS([err fgetln fparseln fseeko getenv inet_ntop \
+AC_REPLACE_FUNCS([err fgetln fnmatch fparseln fseeko getenv inet_ntop \
 	inet_pton isblank lchflags lchmod lchown lutimes mkstemp mkdtemp \
 	poll setprogname snprintf strdup strerror strlcat strlcpy \
 	strmode strptime strsep strtoll timegm usleep utimes])
Index: nbcompat/config.h.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /work/netbsd/cvsroot/pkgsrc/pkgtools/libnbcompat/files/nbcompat/c=
onfig.h.in,v
retrieving revision 1.7
diff -u -r1.7 config.h.in
--- nbcompat/config.h.in	11 Mar 2004 13:28:45 -0000	1.7
+++ nbcompat/config.h.in	4 Apr 2004 02:14:39 -0000
@@ -18,6 +18,9 @@
 /* Define to 1 if you have the `bzero' function. */
 #undef HAVE_BZERO
=20
+/* Define to 1 if you have the <ctype.h> header file. */
+#undef HAVE_CTYPE_H
+
 /* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
    don't. */
 #undef HAVE_DECL_STRERROR_R
@@ -43,6 +46,12 @@
 /* Define to 1 if you have the `fgetln' function. */
 #undef HAVE_FGETLN
=20
+/* Define to 1 if you have the `fnmatch' function. */
+#undef HAVE_FNMATCH
+
+/* Define to 1 if you have the <fnmatch.h> header file. */
+#undef HAVE_FNMATCH_H
+
 /* Define to 1 if you have the `fparseln' function. */
 #undef HAVE_FPARSELN
=20
@@ -127,6 +136,9 @@
 /* Define to 1 if you have the <machine/endian.h> header file. */
 #undef HAVE_MACHINE_ENDIAN_H
=20
+/* Define to 1 if you have the <machine/limits.h> header file. */
+#undef HAVE_MACHINE_LIMITS_H
+
 /* Define to 1 if your system has a GNU libc compatible `malloc' function,=
 and
    to 0 otherwise. */
 #undef HAVE_MALLOC

--nDT5KaoIdRowUDKE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="fnmatch.c"
Content-Transfer-Encoding: quoted-printable

/*	$NetBSD: fnmatch.c,v 1.20 2003/08/07 16:42:48 agc Exp $	*/

/*
 * Copyright (c) 1989, 1993, 1994
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Guido van Rossum.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO=
SE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTI=
AL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRI=
CT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#if 0
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] =3D "@(#)fnmatch.c	8.2 (Berkeley) 4/16/94";
#else
__RCSID("$NetBSD: fnmatch.c,v 1.20 2003/08/07 16:42:48 agc Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#endif

#include "nbcompat.h"

/*
 * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
 * Compares a filename or pathname to a pattern.
 */

#include "namespace.h"

#if HAVE_ASSERT_H
#include <assert.h>
#endif
#if HAVE_CTYPE_H
#include <ctype.h>
#endif
#if HAVE_FNMATCH_H
#include <fnmatch.h>
#else
#include <nbcompat/fnmatch.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#endif

#if 0
#ifdef __weak_alias
__weak_alias(fnmatch,_fnmatch)
#endif
#endif

#define	EOS	'\0'

static const char *rangematch(const char *, int, int);

static __inline int
foldcase(int ch, int flags)
{

	if ((flags & FNM_CASEFOLD) !=3D 0 && isupper(ch))
		return (tolower(ch));
	return (ch);
}

#define	FOLDCASE(ch, flags)	foldcase((unsigned char)(ch), (flags))

int
fnmatch(pattern, string, flags)
	const char *pattern, *string;
	int flags;
{
	const char *stringstart;
	char c, test;

	_DIAGASSERT(pattern !=3D NULL);
	_DIAGASSERT(string !=3D NULL);

	for (stringstart =3D string;;)
		switch (c =3D FOLDCASE(*pattern++, flags)) {
		case EOS:
			if ((flags & FNM_LEADING_DIR) && *string =3D=3D '/')
				return (0);
			return (*string =3D=3D EOS ? 0 : FNM_NOMATCH);
		case '?':
			if (*string =3D=3D EOS)
				return (FNM_NOMATCH);
			if (*string =3D=3D '/' && (flags & FNM_PATHNAME))
				return (FNM_NOMATCH);
			if (*string =3D=3D '.' && (flags & FNM_PERIOD) &&
			    (string =3D=3D stringstart ||
			    ((flags & FNM_PATHNAME) && *(string - 1) =3D=3D '/')))
				return (FNM_NOMATCH);
			++string;
			break;
		case '*':
			c =3D FOLDCASE(*pattern, flags);
			/* Collapse multiple stars. */
			while (c =3D=3D '*')
				c =3D FOLDCASE(*++pattern, flags);

			if (*string =3D=3D '.' && (flags & FNM_PERIOD) &&
			    (string =3D=3D stringstart ||
			    ((flags & FNM_PATHNAME) && *(string - 1) =3D=3D '/')))
				return (FNM_NOMATCH);

			/* Optimize for pattern with * at end or before /. */
			if (c =3D=3D EOS) {
				if (flags & FNM_PATHNAME)
					return ((flags & FNM_LEADING_DIR) ||
					    strchr(string, '/') =3D=3D NULL ?
					    0 : FNM_NOMATCH);
				else
					return (0);
			} else if (c =3D=3D '/' && flags & FNM_PATHNAME) {
				if ((string =3D strchr(string, '/')) =3D=3D NULL)
					return (FNM_NOMATCH);
				break;
			}

			/* General case, use recursion. */
			while ((test =3D FOLDCASE(*string, flags)) !=3D EOS) {
				if (!fnmatch(pattern, string,
					     flags & ~FNM_PERIOD))
					return (0);
				if (test =3D=3D '/' && flags & FNM_PATHNAME)
					break;
				++string;
			}
			return (FNM_NOMATCH);
		case '[':
			if (*string =3D=3D EOS)
				return (FNM_NOMATCH);
			if (*string =3D=3D '/' && flags & FNM_PATHNAME)
				return (FNM_NOMATCH);
			if ((pattern =3D
			    rangematch(pattern, FOLDCASE(*string, flags),
				       flags)) =3D=3D NULL)
				return (FNM_NOMATCH);
			++string;
			break;
		case '\\':
			if (!(flags & FNM_NOESCAPE)) {
				if ((c =3D FOLDCASE(*pattern++, flags)) =3D=3D EOS) {
					c =3D '\\';
					--pattern;
				}
			}
			/* FALLTHROUGH */
		default:
			if (c !=3D FOLDCASE(*string++, flags))
				return (FNM_NOMATCH);
			break;
		}
	/* NOTREACHED */
}

static const char *
rangematch(pattern, test, flags)
	const char *pattern;
	int test, flags;
{
	int negate, ok;
	char c, c2;

	_DIAGASSERT(pattern !=3D NULL);

	/*
	 * A bracket expression starting with an unquoted circumflex
	 * character produces unspecified results (IEEE 1003.2-1992,
	 * 3.13.2).  This implementation treats it like '!', for
	 * consistency with the regular expression syntax.
	 * J.T. Conklin (conklin@ngai.kaleida.com)
	 */
	if ((negate =3D (*pattern =3D=3D '!' || *pattern =3D=3D '^')) !=3D 0)
		++pattern;
=09
	for (ok =3D 0; (c =3D FOLDCASE(*pattern++, flags)) !=3D ']';) {
		if (c =3D=3D '\\' && !(flags & FNM_NOESCAPE))
			c =3D FOLDCASE(*pattern++, flags);
		if (c =3D=3D EOS)
			return (NULL);
		if (*pattern =3D=3D '-'=20
		    && (c2 =3D FOLDCASE(*(pattern+1), flags)) !=3D EOS &&
		        c2 !=3D ']') {
			pattern +=3D 2;
			if (c2 =3D=3D '\\' && !(flags & FNM_NOESCAPE))
				c2 =3D FOLDCASE(*pattern++, flags);
			if (c2 =3D=3D EOS)
				return (NULL);
			if (c <=3D test && test <=3D c2)
				ok =3D 1;
		} else if (c =3D=3D test)
			ok =3D 1;
	}
	return (ok =3D=3D negate ? NULL : pattern);
}

--nDT5KaoIdRowUDKE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="fnmatch.h"

/*	$NetBSD: fnmatch.h,v 1.11 2003/08/07 09:44:10 agc Exp $	*/

/*-
 * Copyright (c) 1992, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)fnmatch.h	8.1 (Berkeley) 6/2/93
 */

#ifndef	_FNMATCH_H_
#define	_FNMATCH_H_

#if HAVE_SYS_FEATURETEST_H
#include <sys/featuretest.h>
#endif

#define	FNM_NOMATCH	1	/* Match failed. */
#define	FNM_NOSYS	2	/* Function not implemented. */

#define	FNM_NOESCAPE	0x01	/* Disable backslash escaping. */
#define	FNM_PATHNAME	0x02	/* Slash must be matched by slash. */
#define	FNM_PERIOD	0x04	/* Period must be matched by period. */
#define	FNM_CASEFOLD	0x08	/* Pattern is matched case-insensitive */
#define	FNM_LEADING_DIR	0x10	/* Ignore /<tail> after Imatch. */

#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif

int	 fnmatch(const char *, const char *, int);

#endif /* !_FNMATCH_H_ */

--nDT5KaoIdRowUDKE--

--EK9OvA4pujAs5S2B
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iD8DBQFAb4HcluYOb9yiFXoRAmS8AJ9zRExGX1uvqtSqdqdK4Je1gjRScACfYcgC
gzWPM1YB//fyXhZad2fHxMQ=
=h5Uy
-----END PGP SIGNATURE-----

--EK9OvA4pujAs5S2B--