summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2004-08-16 17:24:42 +0000
committerjlam <jlam@pkgsrc.org>2004-08-16 17:24:42 +0000
commit80739d5835e2a4685b632b6bcdff6b71a94c0770 (patch)
tree94ccf316b23097db9bd5c7350071934329efea45 /pkgtools
parente3a30640243dec8b146b92d717b2dfb25c26b740 (diff)
downloadpkgsrc-80739d5835e2a4685b632b6bcdff6b71a94c0770.tar.gz
Update pkgtools/libnbcompat to 20040814. Changes from version 20040813
include: * Adding a regex(3) implementation for those platforms that don't have one, e.g. IRIX 5.3. * Allow nbcompat.h to be included multiple times in case it's needed to override values of set by config.h in bootstrap packages. This should fix problems with building pkg_install and pax on platforms that have /usr/include/glob.h. * Remove namespace.h, which should be a no-op since we're building a userland library separate from the NetBSD sources. * Remove HAVE_CONFIG_H checks from sources since we're always going to have and and we're always going to be including it. * Rename all inclusion guards in nbcompat/*.h to be _NBCOMPAT_*_H_ so that it won't get triggered by any settings in system headers. This has been tested on: FreeBSD-4.8/i386 Debian Linux 3.0 (woody) IRIX 6.5 MacOS X 10.2.8 MacOS X 10.3.5 NetBSD-1.6.2/i386 NetBSD-2.0_BETA/i386 Red Hat Linux 7.3 Solaris 7/sparc Solaris 8/sparc Solaris 9/sparc
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/libnbcompat/Makefile4
-rw-r--r--pkgtools/libnbcompat/buildlink3.mk4
-rw-r--r--pkgtools/libnbcompat/files/Makefile.in3
-rw-r--r--pkgtools/libnbcompat/files/README19
-rw-r--r--pkgtools/libnbcompat/files/__fts13.c6
-rw-r--r--pkgtools/libnbcompat/files/cclass.h104
-rw-r--r--pkgtools/libnbcompat/files/cname.h175
-rwxr-xr-xpkgtools/libnbcompat/files/configure286
-rw-r--r--pkgtools/libnbcompat/files/configure.ac15
-rw-r--r--pkgtools/libnbcompat/files/engine.c1188
-rw-r--r--pkgtools/libnbcompat/files/fnmatch.c8
-rw-r--r--pkgtools/libnbcompat/files/getopt_long.c12
-rw-r--r--pkgtools/libnbcompat/files/md5c.c5
-rw-r--r--pkgtools/libnbcompat/files/md5hl.c6
-rw-r--r--pkgtools/libnbcompat/files/namespace.h628
-rw-r--r--pkgtools/libnbcompat/files/nbcompat.h24
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/config.h.in6
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/err.h10
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/fts.h8
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/getopt.h10
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/glob.h8
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/md5.h8
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/poll.h8
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/regex.h151
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/rmd160.h8
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/sha1.h8
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/vis.h8
-rw-r--r--pkgtools/libnbcompat/files/pwcache.c6
-rw-r--r--pkgtools/libnbcompat/files/regcomp.c1926
-rw-r--r--pkgtools/libnbcompat/files/regerror.c248
-rw-r--r--pkgtools/libnbcompat/files/regex2.h209
-rw-r--r--pkgtools/libnbcompat/files/regexec.c261
-rw-r--r--pkgtools/libnbcompat/files/regfree.c149
-rw-r--r--pkgtools/libnbcompat/files/rmd160.c7
-rw-r--r--pkgtools/libnbcompat/files/rmd160hl.c7
-rw-r--r--pkgtools/libnbcompat/files/setenv.c6
-rw-r--r--pkgtools/libnbcompat/files/setmode.c8
-rw-r--r--pkgtools/libnbcompat/files/sha1.c5
-rw-r--r--pkgtools/libnbcompat/files/sha1hl.c11
-rw-r--r--pkgtools/libnbcompat/files/statvfs.c4
-rw-r--r--pkgtools/libnbcompat/files/strmode.c6
-rw-r--r--pkgtools/libnbcompat/files/unvis.c8
-rw-r--r--pkgtools/libnbcompat/files/utils.h100
-rw-r--r--pkgtools/libnbcompat/files/vis.c9
44 files changed, 4927 insertions, 763 deletions
diff --git a/pkgtools/libnbcompat/Makefile b/pkgtools/libnbcompat/Makefile
index a1136f82a95..e4bf9883bb0 100644
--- a/pkgtools/libnbcompat/Makefile
+++ b/pkgtools/libnbcompat/Makefile
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.38 2004/08/13 04:38:02 jlam Exp $
+# $NetBSD: Makefile,v 1.39 2004/08/16 17:24:56 jlam Exp $
#
# NOTE: If you update this package, it is *mandatory* that you update
# pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual
# list of tested and supported platforms.
#
-DISTNAME= libnbcompat-20040813
+DISTNAME= libnbcompat-20040814
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/libnbcompat/buildlink3.mk b/pkgtools/libnbcompat/buildlink3.mk
index 71f5ecbc89f..b4c12ed8aab 100644
--- a/pkgtools/libnbcompat/buildlink3.mk
+++ b/pkgtools/libnbcompat/buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.9 2004/08/13 04:38:02 jlam Exp $
+# $NetBSD: buildlink3.mk,v 1.10 2004/08/16 17:24:56 jlam Exp $
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
LIBNBCOMPAT_BUILDLINK3_MK:= ${LIBNBCOMPAT_BUILDLINK3_MK}+
@@ -11,7 +11,7 @@ BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Nlibnbcompat}
BUILDLINK_PACKAGES+= libnbcompat
.if !empty(LIBNBCOMPAT_BUILDLINK3_MK:M+)
-BUILDLINK_DEPENDS.libnbcompat+= libnbcompat>=20040813
+BUILDLINK_DEPENDS.libnbcompat+= libnbcompat>=20040814
BUILDLINK_PKGSRCDIR.libnbcompat?= ../../pkgtools/libnbcompat
BUILDLINK_DEPMETHOD.libnbcompat?= build
BUILDLINK_LDADD.libnbcompat= -lnbcompat
diff --git a/pkgtools/libnbcompat/files/Makefile.in b/pkgtools/libnbcompat/files/Makefile.in
index 614f5feb37b..4f3ac1e8421 100644
--- a/pkgtools/libnbcompat/files/Makefile.in
+++ b/pkgtools/libnbcompat/files/Makefile.in
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.24 2004/08/10 18:47:55 jlam Exp $
+# $NetBSD: Makefile.in,v 1.25 2004/08/16 17:24:56 jlam Exp $
#
srcdir= @srcdir@
@@ -34,6 +34,7 @@ INCS= nbcompat.h \
nbcompat/poll.h \
nbcompat/pwd.h \
nbcompat/queue.h \
+ nbcompat/regex.h \
nbcompat/rmd160.h \
nbcompat/sha1.h \
nbcompat/stat.h \
diff --git a/pkgtools/libnbcompat/files/README b/pkgtools/libnbcompat/files/README
index 3ead0acb382..9a2d364eb03 100644
--- a/pkgtools/libnbcompat/files/README
+++ b/pkgtools/libnbcompat/files/README
@@ -1,4 +1,4 @@
-$NetBSD: README,v 1.5 2004/08/13 14:18:44 jlam Exp $
+$NetBSD: README,v 1.6 2004/08/16 17:24:56 jlam Exp $
0 Introduction
==============
@@ -43,13 +43,20 @@ breakage seep in. Proper methodology for updating this package is:
*NOTE* the most recent libnbcompat.
*NOTE*
-libnbcompat-20040813 has been tested to build and install correctly
+libnbcompat-20040814 has been tested to build and install correctly
on the following operating systems:
- FreeBSD-4.8/i386 <jlam@NetBSD.org>
- MacOS X 10.2.8 <jlam@NetBSD.org>
- NetBSD-1.6.2/i386 <jlam@NetBSD.org>
- Solaris 2.7/sparc <blsecres@ssdtgsm.com>
+ FreeBSD-4.8/i386 <jlam@NetBSD.org>
+ Debian Linux 3.0 (woody) <wiz@NetBSD.org>
+ IRIX 6.5 <schmonz@NetBSD.org>
+ MacOS X 10.2.8 <jlam@NetBSD.org>
+ MacOS X 10.3.5 <schmonz@NetBSD.org>
+ NetBSD-1.6.2/i386 <jlam@NetBSD.org>
+ NetBSD-2.0_BETA/i386 <wiz@NetBSD.org>
+ Red Hat Linux 7.3 <schmonz@NetBSD.org>
+ Solaris 7/sparc <blsecres@ssdtgsm.com>
+ Solaris 8/sparc <roland.illig@gmx.de>
+ Solaris 9/sparc <schmonz@NetBSD.org>
3 Usage
diff --git a/pkgtools/libnbcompat/files/__fts13.c b/pkgtools/libnbcompat/files/__fts13.c
index 5c7971f5ce4..ed0457a8b7f 100644
--- a/pkgtools/libnbcompat/files/__fts13.c
+++ b/pkgtools/libnbcompat/files/__fts13.c
@@ -1,4 +1,4 @@
-/* $NetBSD: __fts13.c,v 1.5 2004/03/12 15:21:13 grant Exp $ */
+/* $NetBSD: __fts13.c,v 1.6 2004/08/16 17:24:56 jlam Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -29,9 +29,7 @@
* SUCH DAMAGE.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
@@ -41,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#else
-__RCSID("$NetBSD: __fts13.c,v 1.5 2004/03/12 15:21:13 grant Exp $");
+__RCSID("$NetBSD: __fts13.c,v 1.6 2004/08/16 17:24:56 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
diff --git a/pkgtools/libnbcompat/files/cclass.h b/pkgtools/libnbcompat/files/cclass.h
new file mode 100644
index 00000000000..1b72e480b6f
--- /dev/null
+++ b/pkgtools/libnbcompat/files/cclass.h
@@ -0,0 +1,104 @@
+/* $NetBSD: cclass.h,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)cclass.h 8.3 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)cclass.h 8.3 (Berkeley) 3/20/94
+ */
+
+/* character-class table */
+static const struct cclass {
+ const char *name;
+ const char *chars;
+ const char *multis;
+} cclasses[] = {
+ { "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789", "" },
+ { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
+ "" },
+ { "blank", " \t", "" },
+ { "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
+\25\26\27\30\31\32\33\34\35\36\37\177", "" },
+ { "digit", "0123456789", "" },
+ { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
+ "" },
+ { "lower", "abcdefghijklmnopqrstuvwxyz",
+ "" },
+ { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
+ "" },
+ { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
+ "" },
+ { "space", "\t\n\v\f\r ", "" },
+ { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ "" },
+ { "xdigit", "0123456789ABCDEFabcdef",
+ "" },
+ { NULL, 0, "" }
+};
diff --git a/pkgtools/libnbcompat/files/cname.h b/pkgtools/libnbcompat/files/cname.h
new file mode 100644
index 00000000000..d4b699f69aa
--- /dev/null
+++ b/pkgtools/libnbcompat/files/cname.h
@@ -0,0 +1,175 @@
+/* $NetBSD: cname.h,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)cname.h 8.3 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)cname.h 8.3 (Berkeley) 3/20/94
+ */
+
+/* character-name table */
+static const struct cname {
+ const char *name;
+ char code;
+} cnames[] = {
+ { "NUL", '\0' },
+ { "SOH", '\001' },
+ { "STX", '\002' },
+ { "ETX", '\003' },
+ { "EOT", '\004' },
+ { "ENQ", '\005' },
+ { "ACK", '\006' },
+ { "BEL", '\007' },
+ { "alert", '\007' },
+ { "BS", '\010' },
+ { "backspace", '\b' },
+ { "HT", '\011' },
+ { "tab", '\t' },
+ { "LF", '\012' },
+ { "newline", '\n' },
+ { "VT", '\013' },
+ { "vertical-tab", '\v' },
+ { "FF", '\014' },
+ { "form-feed", '\f' },
+ { "CR", '\015' },
+ { "carriage-return", '\r' },
+ { "SO", '\016' },
+ { "SI", '\017' },
+ { "DLE", '\020' },
+ { "DC1", '\021' },
+ { "DC2", '\022' },
+ { "DC3", '\023' },
+ { "DC4", '\024' },
+ { "NAK", '\025' },
+ { "SYN", '\026' },
+ { "ETB", '\027' },
+ { "CAN", '\030' },
+ { "EM", '\031' },
+ { "SUB", '\032' },
+ { "ESC", '\033' },
+ { "IS4", '\034' },
+ { "FS", '\034' },
+ { "IS3", '\035' },
+ { "GS", '\035' },
+ { "IS2", '\036' },
+ { "RS", '\036' },
+ { "IS1", '\037' },
+ { "US", '\037' },
+ { "space", ' ' },
+ { "exclamation-mark", '!' },
+ { "quotation-mark", '"' },
+ { "number-sign", '#' },
+ { "dollar-sign", '$' },
+ { "percent-sign", '%' },
+ { "ampersand", '&' },
+ { "apostrophe", '\'' },
+ { "left-parenthesis", '(' },
+ { "right-parenthesis", ')' },
+ { "asterisk", '*' },
+ { "plus-sign", '+' },
+ { "comma", ',' },
+ { "hyphen", '-' },
+ { "hyphen-minus", '-' },
+ { "period", '.' },
+ { "full-stop", '.' },
+ { "slash", '/' },
+ { "solidus", '/' },
+ { "zero", '0' },
+ { "one", '1' },
+ { "two", '2' },
+ { "three", '3' },
+ { "four", '4' },
+ { "five", '5' },
+ { "six", '6' },
+ { "seven", '7' },
+ { "eight", '8' },
+ { "nine", '9' },
+ { "colon", ':' },
+ { "semicolon", ';' },
+ { "less-than-sign", '<' },
+ { "equals-sign", '=' },
+ { "greater-than-sign", '>' },
+ { "question-mark", '?' },
+ { "commercial-at", '@' },
+ { "left-square-bracket", '[' },
+ { "backslash", '\\' },
+ { "reverse-solidus", '\\' },
+ { "right-square-bracket", ']' },
+ { "circumflex", '^' },
+ { "circumflex-accent", '^' },
+ { "underscore", '_' },
+ { "low-line", '_' },
+ { "grave-accent", '`' },
+ { "left-brace", '{' },
+ { "left-curly-bracket", '{' },
+ { "vertical-line", '|' },
+ { "right-brace", '}' },
+ { "right-curly-bracket", '}' },
+ { "tilde", '~' },
+ { "DEL", '\177' },
+ { NULL, 0 },
+};
diff --git a/pkgtools/libnbcompat/files/configure b/pkgtools/libnbcompat/files/configure
index 2eb1fc02aba..8813813c888 100755
--- a/pkgtools/libnbcompat/files/configure
+++ b/pkgtools/libnbcompat/files/configure
@@ -3986,6 +3986,292 @@ _ACEOF
+for ac_header in regex.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to grant@NetBSD.org ##
+## ------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+echo "$as_me:$LINENO: checking for regexec" >&5
+echo $ECHO_N "checking for regexec... $ECHO_C" >&6
+if test "${ac_cv_func_regexec+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define regexec to an innocuous variant, in case <limits.h> declares regexec.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define regexec innocuous_regexec
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char regexec (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef regexec
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char regexec ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_regexec) || defined (__stub___regexec)
+choke me
+#else
+char (*f) () = regexec;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != regexec;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_regexec=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_regexec=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_regexec" >&5
+echo "${ECHO_T}$ac_cv_func_regexec" >&6
+if test $ac_cv_func_regexec = yes; then
+ :
+else
+
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_NBCOMPAT_REGEX 1
+_ACEOF
+
+
+
+ case $LIBOBJS in
+ "regcomp.$ac_objext" | \
+ *" regcomp.$ac_objext" | \
+ "regcomp.$ac_objext "* | \
+ *" regcomp.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS regcomp.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "regerror.$ac_objext" | \
+ *" regerror.$ac_objext" | \
+ "regerror.$ac_objext "* | \
+ *" regerror.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS regerror.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "regexec.$ac_objext" | \
+ *" regexec.$ac_objext" | \
+ "regexec.$ac_objext "* | \
+ *" regexec.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS regexec.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "regfree.$ac_objext" | \
+ *" regfree.$ac_objext" | \
+ "regfree.$ac_objext "* | \
+ *" regfree.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS regfree.$ac_objext" ;;
+esac
+
+
+fi
+
+
+
for ac_header in md5.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
diff --git a/pkgtools/libnbcompat/files/configure.ac b/pkgtools/libnbcompat/files/configure.ac
index f15aad85171..74288e0258c 100644
--- a/pkgtools/libnbcompat/files/configure.ac
+++ b/pkgtools/libnbcompat/files/configure.ac
@@ -1,4 +1,4 @@
-dnl $NetBSD: configure.ac,v 1.46 2004/08/13 04:38:02 jlam Exp $
+dnl $NetBSD: configure.ac,v 1.47 2004/08/16 17:24:56 jlam Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
@@ -65,6 +65,19 @@ AH_TEMPLATE([HAVE_NBCOMPAT_QUEUE], [
Define to 1 if the `queue' macros are supplied by the library.
])
+AC_CHECK_HEADERS([regex.h])
+AC_CHECK_FUNC(regexec, [:], [
+ AC_DEFINE(HAVE_NBCOMPAT_REGEX)
+ AH_TEMPLATE([HAVE_NBCOMPAT_REGEX], [
+ Define to 1 if the `regex' functions are built into the
+ library.
+ ])
+ AC_LIBOBJ(regcomp)
+ AC_LIBOBJ(regerror)
+ AC_LIBOBJ(regexec)
+ AC_LIBOBJ(regfree)
+])
+
AC_CHECK_HEADERS([md5.h], [
AC_MSG_TRY_COMPILE([for MD5Init in md5.h], pkg_cv_have_md5init, [
#include <sys/types.h>
diff --git a/pkgtools/libnbcompat/files/engine.c b/pkgtools/libnbcompat/files/engine.c
new file mode 100644
index 00000000000..4c332203b8d
--- /dev/null
+++ b/pkgtools/libnbcompat/files/engine.c
@@ -0,0 +1,1188 @@
+/* $NetBSD: engine.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)engine.c 8.5 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)engine.c 8.5 (Berkeley) 3/20/94
+ */
+
+/*
+ * The matching engine and friends. This file is #included by regexec.c
+ * after suitable #defines of a variety of macros used herein, so that
+ * different state representations can be used without duplicating masses
+ * of code.
+ */
+
+#ifdef SNAMES
+#define matcher smatcher
+#define fast sfast
+#define slow sslow
+#define dissect sdissect
+#define backref sbackref
+#define step sstep
+#define print sprint
+#define at sat
+#define match smat
+#define nope snope
+#endif
+#ifdef LNAMES
+#define matcher lmatcher
+#define fast lfast
+#define slow lslow
+#define dissect ldissect
+#define backref lbackref
+#define step lstep
+#define print lprint
+#define at lat
+#define match lmat
+#define nope lnope
+#endif
+
+/* another structure passed up and down to avoid zillions of parameters */
+struct match {
+ struct re_guts *g;
+ int eflags;
+ regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
+ char *offp; /* offsets work from here */
+ char *beginp; /* start of string -- virtual NUL precedes */
+ char *endp; /* end of string -- virtual NUL here */
+ char *coldp; /* can be no match starting before here */
+ char **lastpos; /* [nplus+1] */
+ STATEVARS;
+ states st; /* current states */
+ states fresh; /* states for a fresh start */
+ states tmp; /* temporary */
+ states empty; /* empty set of states */
+};
+
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* === engine.c === */
+static int matcher __P((struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags));
+static char *dissect __P((struct match *m, char *start, char *stop, sopno startst, sopno stopst));
+static char *backref __P((struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev));
+static char *fast __P((struct match *m, char *start, char *stop, sopno startst, sopno stopst));
+static char *slow __P((struct match *m, char *start, char *stop, sopno startst, sopno stopst));
+static states step __P((struct re_guts *g, sopno start, sopno stop, states bef, int ch, states aft));
+#define BOL (OUT+1)
+#define EOL (BOL+1)
+#define BOLEOL (BOL+2)
+#define NOTHING (BOL+3)
+#define BOW (BOL+4)
+#define EOW (BOL+5)
+#define CODEMAX (BOL+5) /* highest code used */
+#define NONCHAR(c) ((c) > CHAR_MAX)
+#define NNONCHAR (CODEMAX-CHAR_MAX)
+#ifdef REDEBUG
+static void print __P((struct match *m, char *caption, states st, int ch, FILE *d));
+#endif
+#ifdef REDEBUG
+static void at __P((struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst));
+#endif
+#ifdef REDEBUG
+static char *pchar __P((int ch));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+/* ========= end header generated by ./mkh ========= */
+
+#ifdef REDEBUG
+#define SP(t, s, c) print(m, t, s, c, stdout)
+#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
+#define NOTE(str) { if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }
+static int nope = 0;
+#else
+#define SP(t, s, c) /* nothing */
+#define AT(t, p1, p2, s1, s2) /* nothing */
+#define NOTE(s) /* nothing */
+#endif
+
+/*
+ - matcher - the actual matching engine
+ == static int matcher(struct re_guts *g, char *string, \
+ == size_t nmatch, regmatch_t pmatch[], int eflags);
+ */
+static int /* 0 success, REG_NOMATCH failure */
+matcher(g, string, nmatch, pmatch, eflags)
+struct re_guts *g;
+char *string;
+size_t nmatch;
+regmatch_t pmatch[];
+int eflags;
+{
+ char *endp;
+ int i;
+ struct match mv;
+ struct match *m = &mv;
+ char *dp;
+ const sopno gf = g->firststate+1; /* +1 for OEND */
+ const sopno gl = g->laststate;
+ char *start;
+ char *stop;
+ int error = 0;
+
+ _DIAGASSERT(g != NULL);
+ _DIAGASSERT(string != NULL);
+ /* pmatch checked below */
+
+ /* simplify the situation where possible */
+ if (g->cflags&REG_NOSUB)
+ nmatch = 0;
+ if (eflags&REG_STARTEND) {
+ _DIAGASSERT(pmatch != NULL);
+ start = string + (size_t)pmatch[0].rm_so;
+ stop = string + (size_t)pmatch[0].rm_eo;
+ } else {
+ start = string;
+ stop = start + strlen(start);
+ }
+ if (stop < start)
+ return(REG_INVARG);
+
+ /* prescreening; this does wonders for this rather slow code */
+ if (g->must != NULL) {
+ for (dp = start; dp < stop; dp++)
+ if (*dp == g->must[0] && stop - dp >= g->mlen &&
+ memcmp(dp, g->must, (size_t)g->mlen) == 0)
+ break;
+ if (dp == stop) /* we didn't find g->must */
+ return(REG_NOMATCH);
+ }
+
+ /* match struct setup */
+ m->g = g;
+ m->eflags = eflags;
+ m->pmatch = NULL;
+ m->lastpos = NULL;
+ m->offp = string;
+ m->beginp = start;
+ m->endp = stop;
+ STATESETUP(m, 4);
+ SETUP(m->st);
+ SETUP(m->fresh);
+ SETUP(m->tmp);
+ SETUP(m->empty);
+ CLEAR(m->empty);
+
+ /* this loop does only one repetition except for backrefs */
+ for (;;) {
+ endp = fast(m, start, stop, gf, gl);
+ if (endp == NULL) { /* a miss */
+ error = REG_NOMATCH;
+ goto done;
+ }
+ if (nmatch == 0 && !g->backrefs)
+ break; /* no further info needed */
+
+ /* where? */
+ assert(m->coldp != NULL);
+ for (;;) {
+ NOTE("finding start");
+ endp = slow(m, m->coldp, stop, gf, gl);
+ if (endp != NULL)
+ break;
+ assert(m->coldp < m->endp);
+ m->coldp++;
+ }
+ if (nmatch == 1 && !g->backrefs)
+ break; /* no further info needed */
+
+ /* oh my, he wants the subexpressions... */
+ if (m->pmatch == NULL)
+ m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
+ sizeof(regmatch_t));
+ if (m->pmatch == NULL) {
+ error = REG_ESPACE;
+ goto done;
+ }
+ for (i = 1; i <= m->g->nsub; i++)
+ m->pmatch[i].rm_so = m->pmatch[i].rm_eo = (regoff_t)-1;
+ if (!g->backrefs && !(m->eflags&REG_BACKR)) {
+ NOTE("dissecting");
+ dp = dissect(m, m->coldp, endp, gf, gl);
+ } else {
+ if (g->nplus > 0 && m->lastpos == NULL)
+ m->lastpos = (char **)malloc((g->nplus+1) *
+ sizeof(char *));
+ if (g->nplus > 0 && m->lastpos == NULL) {
+ error = REG_ESPACE;
+ goto done;
+ }
+ NOTE("backref dissect");
+ dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
+ }
+ if (dp != NULL)
+ break;
+
+ /* uh-oh... we couldn't find a subexpression-level match */
+ assert(g->backrefs); /* must be back references doing it */
+ assert(g->nplus == 0 || m->lastpos != NULL);
+ for (;;) {
+ if (dp != NULL || endp <= m->coldp)
+ break; /* defeat */
+ NOTE("backoff");
+ endp = slow(m, m->coldp, endp-1, gf, gl);
+ if (endp == NULL)
+ break; /* defeat */
+ /* try it on a shorter possibility */
+#ifndef NDEBUG
+ for (i = 1; i <= m->g->nsub; i++) {
+ assert(m->pmatch[i].rm_so == (regoff_t)-1);
+ assert(m->pmatch[i].rm_eo == (regoff_t)-1);
+ }
+#endif
+ NOTE("backoff dissect");
+ dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
+ }
+ assert(dp == NULL || dp == endp);
+ if (dp != NULL) /* found a shorter one */
+ break;
+
+ /* despite initial appearances, there is no match here */
+ NOTE("false alarm");
+ start = m->coldp + 1; /* recycle starting later */
+ assert(start <= stop);
+ }
+
+ /* fill in the details if requested */
+ if (nmatch > 0) {
+ _DIAGASSERT(pmatch != NULL);
+ pmatch[0].rm_so = m->coldp - m->offp;
+ pmatch[0].rm_eo = endp - m->offp;
+ }
+ if (nmatch > 1) {
+ assert(m->pmatch != NULL);
+ for (i = 1; i < nmatch; i++)
+ if (i <= m->g->nsub)
+ pmatch[i] = m->pmatch[i];
+ else {
+ pmatch[i].rm_so = (regoff_t)-1;
+ pmatch[i].rm_eo = (regoff_t)-1;
+ }
+ }
+
+done:
+ if (m->pmatch != NULL) {
+ free(m->pmatch);
+ m->pmatch = NULL;
+ }
+ if (m->lastpos != NULL) {
+ free(m->lastpos);
+ m->lastpos = NULL;
+ }
+ STATETEARDOWN(m);
+ return error;
+}
+
+/*
+ - dissect - figure out what matched what, no back references
+ == static char *dissect(struct match *m, char *start, \
+ == char *stop, sopno startst, sopno stopst);
+ */
+static char * /* == stop (success) always */
+dissect(m, start, stop, startst, stopst)
+struct match *m;
+char *start;
+char *stop;
+sopno startst;
+sopno stopst;
+{
+ int i;
+ sopno ss; /* start sop of current subRE */
+ sopno es; /* end sop of current subRE */
+ char *sp; /* start of string matched by it */
+ char *stp; /* string matched by it cannot pass here */
+ char *rest; /* start of rest of string */
+ char *tail; /* string unmatched by rest of RE */
+ sopno ssub; /* start sop of subsubRE */
+ sopno esub; /* end sop of subsubRE */
+ char *ssp; /* start of string matched by subsubRE */
+ char *sep; /* end of string matched by subsubRE */
+ char *oldssp; /* previous ssp */
+#ifndef NDEBUG
+ char *dp;
+#endif
+
+ _DIAGASSERT(m != NULL);
+ _DIAGASSERT(start != NULL);
+ _DIAGASSERT(stop != NULL);
+
+ AT("diss", start, stop, startst, stopst);
+ sp = start;
+ for (ss = startst; ss < stopst; ss = es) {
+ /* identify end of subRE */
+ es = ss;
+ switch (OP(m->g->strip[es])) {
+ case OPLUS_:
+ case OQUEST_:
+ es += OPND(m->g->strip[es]);
+ break;
+ case OCH_:
+ while (OP(m->g->strip[es]) != O_CH)
+ es += OPND(m->g->strip[es]);
+ break;
+ }
+ es++;
+
+ /* figure out what it matched */
+ switch (OP(m->g->strip[ss])) {
+ case OEND:
+ assert(nope);
+ break;
+ case OCHAR:
+ sp++;
+ break;
+ case OBOL:
+ case OEOL:
+ case OBOW:
+ case OEOW:
+ break;
+ case OANY:
+ case OANYOF:
+ sp++;
+ break;
+ case OBACK_:
+ case O_BACK:
+ assert(nope);
+ break;
+ /* cases where length of match is hard to find */
+ case OQUEST_:
+ stp = stop;
+ for (;;) {
+ /* how long could this one be? */
+ rest = slow(m, sp, stp, ss, es);
+ assert(rest != NULL); /* it did match */
+ /* could the rest match the rest? */
+ tail = slow(m, rest, stop, es, stopst);
+ if (tail == stop)
+ break; /* yes! */
+ /* no -- try a shorter match for this one */
+ stp = rest - 1;
+ assert(stp >= sp); /* it did work */
+ }
+ ssub = ss + 1;
+ esub = es - 1;
+ /* did innards match? */
+ if (slow(m, sp, rest, ssub, esub) != NULL) {
+#ifdef NDEBUG
+ (void)
+#else
+ dp =
+#endif
+ dissect(m, sp, rest, ssub, esub);
+ assert(dp == rest);
+ } else /* no */
+ assert(sp == rest);
+ sp = rest;
+ break;
+ case OPLUS_:
+ stp = stop;
+ for (;;) {
+ /* how long could this one be? */
+ rest = slow(m, sp, stp, ss, es);
+ assert(rest != NULL); /* it did match */
+ /* could the rest match the rest? */
+ tail = slow(m, rest, stop, es, stopst);
+ if (tail == stop)
+ break; /* yes! */
+ /* no -- try a shorter match for this one */
+ stp = rest - 1;
+ assert(stp >= sp); /* it did work */
+ }
+ ssub = ss + 1;
+ esub = es - 1;
+ ssp = sp;
+ oldssp = ssp;
+ for (;;) { /* find last match of innards */
+ sep = slow(m, ssp, rest, ssub, esub);
+ if (sep == NULL || sep == ssp)
+ break; /* failed or matched null */
+ oldssp = ssp; /* on to next try */
+ ssp = sep;
+ }
+ if (sep == NULL) {
+ /* last successful match */
+ sep = ssp;
+ ssp = oldssp;
+ }
+ assert(sep == rest); /* must exhaust substring */
+ assert(slow(m, ssp, sep, ssub, esub) == rest);
+#ifdef NDEBUG
+ (void)
+#else
+ dp =
+#endif
+ dissect(m, ssp, sep, ssub, esub);
+ assert(dp == sep);
+ sp = rest;
+ break;
+ case OCH_:
+ stp = stop;
+ for (;;) {
+ /* how long could this one be? */
+ rest = slow(m, sp, stp, ss, es);
+ assert(rest != NULL); /* it did match */
+ /* could the rest match the rest? */
+ tail = slow(m, rest, stop, es, stopst);
+ if (tail == stop)
+ break; /* yes! */
+ /* no -- try a shorter match for this one */
+ stp = rest - 1;
+ assert(stp >= sp); /* it did work */
+ }
+ ssub = ss + 1;
+ esub = ss + OPND(m->g->strip[ss]) - 1;
+ assert(OP(m->g->strip[esub]) == OOR1);
+ for (;;) { /* find first matching branch */
+ if (slow(m, sp, rest, ssub, esub) == rest)
+ break; /* it matched all of it */
+ /* that one missed, try next one */
+ assert(OP(m->g->strip[esub]) == OOR1);
+ esub++;
+ assert(OP(m->g->strip[esub]) == OOR2);
+ ssub = esub + 1;
+ esub += OPND(m->g->strip[esub]);
+ if (OP(m->g->strip[esub]) == OOR2)
+ esub--;
+ else
+ assert(OP(m->g->strip[esub]) == O_CH);
+ }
+#ifdef NDEBUG
+ (void)
+#else
+ dp =
+#endif
+ dissect(m, sp, rest, ssub, esub);
+ assert(dp == rest);
+ sp = rest;
+ break;
+ case O_PLUS:
+ case O_QUEST:
+ case OOR1:
+ case OOR2:
+ case O_CH:
+ assert(nope);
+ break;
+ case OLPAREN:
+ i = OPND(m->g->strip[ss]);
+ assert(0 < i && i <= m->g->nsub);
+ m->pmatch[i].rm_so = sp - m->offp;
+ break;
+ case ORPAREN:
+ i = OPND(m->g->strip[ss]);
+ assert(0 < i && i <= m->g->nsub);
+ m->pmatch[i].rm_eo = sp - m->offp;
+ break;
+ default: /* uh oh */
+ assert(nope);
+ break;
+ }
+ }
+
+ assert(sp == stop);
+ return(sp);
+}
+
+/*
+ - backref - figure out what matched what, figuring in back references
+ == static char *backref(struct match *m, char *start, \
+ == char *stop, sopno startst, sopno stopst, sopno lev);
+ */
+static char * /* == stop (success) or NULL (failure) */
+backref(m, start, stop, startst, stopst, lev)
+struct match *m;
+char *start;
+char *stop;
+sopno startst;
+sopno stopst;
+sopno lev; /* PLUS nesting level */
+{
+ int i;
+ sopno ss; /* start sop of current subRE */
+ char *sp; /* start of string matched by it */
+ sopno ssub; /* start sop of subsubRE */
+ sopno esub; /* end sop of subsubRE */
+ char *ssp; /* start of string matched by subsubRE */
+ char *dp;
+ size_t len;
+ int hard;
+ sop s;
+ regoff_t offsave;
+ cset *cs;
+
+ _DIAGASSERT(m != NULL);
+ _DIAGASSERT(start != NULL);
+ _DIAGASSERT(stop != NULL);
+
+ AT("back", start, stop, startst, stopst);
+ sp = start;
+
+ /* get as far as we can with easy stuff */
+ hard = 0;
+ for (ss = startst; !hard && ss < stopst; ss++)
+ switch (OP(s = m->g->strip[ss])) {
+ case OCHAR:
+ if (sp == stop || *sp++ != (char)OPND(s))
+ return(NULL);
+ break;
+ case OANY:
+ if (sp == stop)
+ return(NULL);
+ sp++;
+ break;
+ case OANYOF:
+ cs = &m->g->sets[OPND(s)];
+ if (sp == stop || !CHIN(cs, *sp++))
+ return(NULL);
+ break;
+ case OBOL:
+ if ( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
+ (sp < m->endp && *(sp-1) == '\n' &&
+ (m->g->cflags&REG_NEWLINE)) )
+ { /* yes */ }
+ else
+ return(NULL);
+ break;
+ case OEOL:
+ if ( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
+ (sp < m->endp && *sp == '\n' &&
+ (m->g->cflags&REG_NEWLINE)) )
+ { /* yes */ }
+ else
+ return(NULL);
+ break;
+ case OBOW:
+ if (( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
+ (sp < m->endp && *(sp-1) == '\n' &&
+ (m->g->cflags&REG_NEWLINE)) ||
+ (sp > m->beginp &&
+ !ISWORD(*(sp-1))) ) &&
+ (sp < m->endp && ISWORD(*sp)) )
+ { /* yes */ }
+ else
+ return(NULL);
+ break;
+ case OEOW:
+ if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
+ (sp < m->endp && *sp == '\n' &&
+ (m->g->cflags&REG_NEWLINE)) ||
+ (sp < m->endp && !ISWORD(*sp)) ) &&
+ (sp > m->beginp && ISWORD(*(sp-1))) )
+ { /* yes */ }
+ else
+ return(NULL);
+ break;
+ case O_QUEST:
+ break;
+ case OOR1: /* matches null but needs to skip */
+ ss++;
+ s = m->g->strip[ss];
+ do {
+ assert(OP(s) == OOR2);
+ ss += OPND(s);
+ } while (OP(s = m->g->strip[ss]) != O_CH);
+ /* note that the ss++ gets us past the O_CH */
+ break;
+ default: /* have to make a choice */
+ hard = 1;
+ break;
+ }
+ if (!hard) { /* that was it! */
+ if (sp != stop)
+ return(NULL);
+ return(sp);
+ }
+ ss--; /* adjust for the for's final increment */
+
+ /* the hard stuff */
+ AT("hard", sp, stop, ss, stopst);
+ s = m->g->strip[ss];
+ switch (OP(s)) {
+ case OBACK_: /* the vilest depths */
+ i = OPND(s);
+ assert(0 < i && i <= m->g->nsub);
+ if (m->pmatch[i].rm_eo == (regoff_t)-1)
+ return(NULL);
+ assert(m->pmatch[i].rm_so != (regoff_t)-1);
+ len = (size_t)(m->pmatch[i].rm_eo - m->pmatch[i].rm_so);
+ if (len == 0)
+ return(NULL);
+ assert(stop - m->beginp >= len);
+ if (sp > stop - len)
+ return(NULL); /* not enough left to match */
+ ssp = m->offp + (size_t)m->pmatch[i].rm_so;
+ if (memcmp(sp, ssp, len) != 0)
+ return(NULL);
+ while (m->g->strip[ss] != SOP(O_BACK, i))
+ ss++;
+ return(backref(m, sp+len, stop, ss+1, stopst, lev));
+
+ case OQUEST_: /* to null or not */
+ dp = backref(m, sp, stop, ss+1, stopst, lev);
+ if (dp != NULL)
+ return(dp); /* not */
+ return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev));
+
+ case OPLUS_:
+ assert(m->lastpos != NULL);
+ assert(lev+1 <= m->g->nplus);
+ m->lastpos[lev+1] = sp;
+ return(backref(m, sp, stop, ss+1, stopst, lev+1));
+
+ case O_PLUS:
+ if (sp == m->lastpos[lev]) /* last pass matched null */
+ return(backref(m, sp, stop, ss+1, stopst, lev-1));
+ /* try another pass */
+ m->lastpos[lev] = sp;
+ dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev);
+ if (dp == NULL)
+ dp = backref(m, sp, stop, ss+1, stopst, lev-1);
+ return(dp);
+
+ case OCH_: /* find the right one, if any */
+ ssub = ss + 1;
+ esub = ss + OPND(s) - 1;
+ assert(OP(m->g->strip[esub]) == OOR1);
+ for (;;) { /* find first matching branch */
+ dp = backref(m, sp, stop, ssub, esub, lev);
+ if (dp != NULL)
+ return(dp);
+ /* that one missed, try next one */
+ if (OP(m->g->strip[esub]) == O_CH)
+ return(NULL); /* there is none */
+ esub++;
+ assert(OP(m->g->strip[esub]) == OOR2);
+ ssub = esub + 1;
+ esub += OPND(m->g->strip[esub]);
+ if (OP(m->g->strip[esub]) == OOR2)
+ esub--;
+ else
+ assert(OP(m->g->strip[esub]) == O_CH);
+ }
+
+ case OLPAREN: /* must undo assignment if rest fails */
+ i = OPND(s);
+ assert(0 < i && i <= m->g->nsub);
+ offsave = m->pmatch[i].rm_so;
+ m->pmatch[i].rm_so = sp - m->offp;
+ dp = backref(m, sp, stop, ss+1, stopst, lev);
+ if (dp != NULL)
+ return(dp);
+ m->pmatch[i].rm_so = offsave;
+ return(NULL);
+
+ case ORPAREN: /* must undo assignment if rest fails */
+ i = OPND(s);
+ assert(0 < i && i <= m->g->nsub);
+ offsave = m->pmatch[i].rm_eo;
+ m->pmatch[i].rm_eo = sp - m->offp;
+ dp = backref(m, sp, stop, ss+1, stopst, lev);
+ if (dp != NULL)
+ return(dp);
+ m->pmatch[i].rm_eo = offsave;
+ return(NULL);
+
+ default: /* uh oh */
+ assert(nope);
+ break;
+ }
+
+ /* "can't happen" */
+ assert(nope);
+ /* NOTREACHED */
+ return NULL;
+}
+
+/*
+ - fast - step through the string at top speed
+ == static char *fast(struct match *m, char *start, \
+ == char *stop, sopno startst, sopno stopst);
+ */
+static char * /* where tentative match ended, or NULL */
+fast(m, start, stop, startst, stopst)
+struct match *m;
+char *start;
+char *stop;
+sopno startst;
+sopno stopst;
+{
+ states st = m->st;
+ states fresh = m->fresh;
+ states tmp = m->tmp;
+ char *p = start;
+ int c = (start == m->beginp) ? OUT : *(start-1);
+ int lastc; /* previous c */
+ int flagch;
+ int i;
+ char *coldp; /* last p after which no match was underway */
+
+ _DIAGASSERT(m != NULL);
+ _DIAGASSERT(start != NULL);
+ _DIAGASSERT(stop != NULL);
+
+ CLEAR(st);
+ SET1(st, startst);
+ st = step(m->g, startst, stopst, st, NOTHING, st);
+ ASSIGN(fresh, st);
+ SP("start", st, *p);
+ coldp = NULL;
+ for (;;) {
+ /* next character */
+ lastc = c;
+ c = (p == m->endp) ? OUT : *p;
+ if (EQ(st, fresh))
+ coldp = p;
+
+ /* is there an EOL and/or BOL between lastc and c? */
+ flagch = '\0';
+ i = 0;
+ if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
+ (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
+ flagch = BOL;
+ i = m->g->nbol;
+ }
+ if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
+ (c == OUT && !(m->eflags&REG_NOTEOL)) ) {
+ flagch = (flagch == BOL) ? BOLEOL : EOL;
+ i += m->g->neol;
+ }
+ if (i != 0) {
+ for (; i > 0; i--)
+ st = step(m->g, startst, stopst, st, flagch, st);
+ SP("boleol", st, c);
+ }
+
+ /* how about a word boundary? */
+ if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
+ (c != OUT && ISWORD(c)) ) {
+ flagch = BOW;
+ }
+ if ( (lastc != OUT && ISWORD(lastc)) &&
+ (flagch == EOL || (c != OUT && !ISWORD(c))) ) {
+ flagch = EOW;
+ }
+ if (flagch == BOW || flagch == EOW) {
+ st = step(m->g, startst, stopst, st, flagch, st);
+ SP("boweow", st, c);
+ }
+
+ /* are we done? */
+ if (ISSET(st, stopst) || p == stop)
+ break; /* NOTE BREAK OUT */
+
+ /* no, we must deal with this character */
+ ASSIGN(tmp, st);
+ ASSIGN(st, fresh);
+ assert(c != OUT);
+ st = step(m->g, startst, stopst, tmp, c, st);
+ SP("aft", st, c);
+ assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
+ p++;
+ }
+
+ assert(coldp != NULL);
+ m->coldp = coldp;
+ if (ISSET(st, stopst))
+ return(p+1);
+ else
+ return(NULL);
+}
+
+/*
+ - slow - step through the string more deliberately
+ == static char *slow(struct match *m, char *start, \
+ == char *stop, sopno startst, sopno stopst);
+ */
+static char * /* where it ended */
+slow(m, start, stop, startst, stopst)
+struct match *m;
+char *start;
+char *stop;
+sopno startst;
+sopno stopst;
+{
+ states st = m->st;
+ states empty = m->empty;
+ states tmp = m->tmp;
+ char *p = start;
+ int c = (start == m->beginp) ? OUT : *(start-1);
+ int lastc; /* previous c */
+ int flagch;
+ int i;
+ char *matchp; /* last p at which a match ended */
+
+ _DIAGASSERT(m != NULL);
+ _DIAGASSERT(start != NULL);
+ _DIAGASSERT(stop != NULL);
+
+ AT("slow", start, stop, startst, stopst);
+ CLEAR(st);
+ SET1(st, startst);
+ SP("sstart", st, *p);
+ st = step(m->g, startst, stopst, st, NOTHING, st);
+ matchp = NULL;
+ for (;;) {
+ /* next character */
+ lastc = c;
+ c = (p == m->endp) ? OUT : *p;
+
+ /* is there an EOL and/or BOL between lastc and c? */
+ flagch = '\0';
+ i = 0;
+ if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
+ (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
+ flagch = BOL;
+ i = m->g->nbol;
+ }
+ if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
+ (c == OUT && !(m->eflags&REG_NOTEOL)) ) {
+ flagch = (flagch == BOL) ? BOLEOL : EOL;
+ i += m->g->neol;
+ }
+ if (i != 0) {
+ for (; i > 0; i--)
+ st = step(m->g, startst, stopst, st, flagch, st);
+ SP("sboleol", st, c);
+ }
+
+ /* how about a word boundary? */
+ if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
+ (c != OUT && ISWORD(c)) ) {
+ flagch = BOW;
+ }
+ if ( (lastc != OUT && ISWORD(lastc)) &&
+ (flagch == EOL || (c != OUT && !ISWORD(c))) ) {
+ flagch = EOW;
+ }
+ if (flagch == BOW || flagch == EOW) {
+ st = step(m->g, startst, stopst, st, flagch, st);
+ SP("sboweow", st, c);
+ }
+
+ /* are we done? */
+ if (ISSET(st, stopst))
+ matchp = p;
+ if (EQ(st, empty) || p == stop)
+ break; /* NOTE BREAK OUT */
+
+ /* no, we must deal with this character */
+ ASSIGN(tmp, st);
+ ASSIGN(st, empty);
+ assert(c != OUT);
+ st = step(m->g, startst, stopst, tmp, c, st);
+ SP("saft", st, c);
+ assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
+ p++;
+ }
+
+ return(matchp);
+}
+
+
+/*
+ - step - map set of states reachable before char to set reachable after
+ == static states step(struct re_guts *g, sopno start, sopno stop, \
+ == states bef, int ch, states aft);
+ == #define BOL (OUT+1)
+ == #define EOL (BOL+1)
+ == #define BOLEOL (BOL+2)
+ == #define NOTHING (BOL+3)
+ == #define BOW (BOL+4)
+ == #define EOW (BOL+5)
+ == #define CODEMAX (BOL+5) // highest code used
+ == #define NONCHAR(c) ((c) > CHAR_MAX)
+ == #define NNONCHAR (CODEMAX-CHAR_MAX)
+ */
+static states
+step(g, start, stop, bef, ch, aft)
+struct re_guts *g;
+sopno start; /* start state within strip */
+sopno stop; /* state after stop state within strip */
+states bef; /* states reachable before */
+int ch; /* character or NONCHAR code */
+states aft; /* states already known reachable after */
+{
+ cset *cs;
+ sop s;
+ sopno pc;
+ onestate here; /* note, macros know this name */
+ sopno look;
+ int i;
+
+ _DIAGASSERT(g != NULL);
+
+ for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) {
+ s = g->strip[pc];
+ switch (OP(s)) {
+ case OEND:
+ assert(pc == stop-1);
+ break;
+ case OCHAR:
+ /* only characters can match */
+ assert(!NONCHAR(ch) || ch != (char)OPND(s));
+ if (ch == (char)OPND(s))
+ FWD(aft, bef, 1);
+ break;
+ case OBOL:
+ if (ch == BOL || ch == BOLEOL)
+ FWD(aft, bef, 1);
+ break;
+ case OEOL:
+ if (ch == EOL || ch == BOLEOL)
+ FWD(aft, bef, 1);
+ break;
+ case OBOW:
+ if (ch == BOW)
+ FWD(aft, bef, 1);
+ break;
+ case OEOW:
+ if (ch == EOW)
+ FWD(aft, bef, 1);
+ break;
+ case OANY:
+ if (!NONCHAR(ch))
+ FWD(aft, bef, 1);
+ break;
+ case OANYOF:
+ cs = &g->sets[OPND(s)];
+ if (!NONCHAR(ch) && CHIN(cs, ch))
+ FWD(aft, bef, 1);
+ break;
+ case OBACK_: /* ignored here */
+ case O_BACK:
+ FWD(aft, aft, 1);
+ break;
+ case OPLUS_: /* forward, this is just an empty */
+ FWD(aft, aft, 1);
+ break;
+ case O_PLUS: /* both forward and back */
+ FWD(aft, aft, 1);
+ i = ISSETBACK(aft, OPND(s));
+ BACK(aft, aft, OPND(s));
+ if (!i && ISSETBACK(aft, OPND(s))) {
+ /* oho, must reconsider loop body */
+ pc -= OPND(s) + 1;
+ INIT(here, pc);
+ }
+ break;
+ case OQUEST_: /* two branches, both forward */
+ FWD(aft, aft, 1);
+ FWD(aft, aft, OPND(s));
+ break;
+ case O_QUEST: /* just an empty */
+ FWD(aft, aft, 1);
+ break;
+ case OLPAREN: /* not significant here */
+ case ORPAREN:
+ FWD(aft, aft, 1);
+ break;
+ case OCH_: /* mark the first two branches */
+ FWD(aft, aft, 1);
+ assert(OP(g->strip[pc+OPND(s)]) == OOR2);
+ FWD(aft, aft, OPND(s));
+ break;
+ case OOR1: /* done a branch, find the O_CH */
+ if (ISSTATEIN(aft, here)) {
+ for (look = 1;
+ OP(s = g->strip[pc+look]) != O_CH;
+ look += OPND(s))
+ assert(OP(s) == OOR2);
+ FWD(aft, aft, look);
+ }
+ break;
+ case OOR2: /* propagate OCH_'s marking */
+ FWD(aft, aft, 1);
+ if (OP(g->strip[pc+OPND(s)]) != O_CH) {
+ assert(OP(g->strip[pc+OPND(s)]) == OOR2);
+ FWD(aft, aft, OPND(s));
+ }
+ break;
+ case O_CH: /* just empty */
+ FWD(aft, aft, 1);
+ break;
+ default: /* ooooops... */
+ assert(nope);
+ break;
+ }
+ }
+
+ return(aft);
+}
+
+#ifdef REDEBUG
+/*
+ - print - print a set of states
+ == #ifdef REDEBUG
+ == static void print(struct match *m, char *caption, states st, \
+ == int ch, FILE *d);
+ == #endif
+ */
+static void
+print(m, caption, st, ch, d)
+struct match *m;
+char *caption;
+states st;
+int ch;
+FILE *d;
+{
+ struct re_guts *g = m->g;
+ int i;
+ int first = 1;
+
+ _DIAGASSERT(m != NULL);
+ _DIAGASSERT(caption != NULL);
+
+ if (!(m->eflags&REG_TRACE))
+ return;
+
+ _DIAGASSERT(d != NULL);
+
+ fprintf(d, "%s", caption);
+ if (ch != '\0')
+ fprintf(d, " %s", pchar(ch));
+ for (i = 0; i < g->nstates; i++)
+ if (ISSET(st, i)) {
+ fprintf(d, "%s%d", (first) ? "\t" : ", ", i);
+ first = 0;
+ }
+ fprintf(d, "\n");
+}
+
+/*
+ - at - print current situation
+ == #ifdef REDEBUG
+ == static void at(struct match *m, char *title, char *start, char *stop, \
+ == sopno startst, sopno stopst);
+ == #endif
+ */
+static void
+at(m, title, start, stop, startst, stopst)
+struct match *m;
+char *title;
+char *start;
+char *stop;
+sopno startst;
+sopno stopst;
+{
+
+ _DIAGASSERT(m != NULL);
+ _DIAGASSERT(title != NULL);
+ _DIAGASSERT(start != NULL);
+ _DIAGASSERT(stop != NULL);
+
+ if (!(m->eflags&REG_TRACE))
+ return;
+
+ printf("%s %s-", title, pchar(*start));
+ printf("%s ", pchar(*stop));
+ printf("%ld-%ld\n", (long)startst, (long)stopst);
+}
+
+#ifndef PCHARDONE
+#define PCHARDONE /* never again */
+/*
+ - pchar - make a character printable
+ == #ifdef REDEBUG
+ == static char *pchar(int ch);
+ == #endif
+ *
+ * Is this identical to regchar() over in debug.c? Well, yes. But a
+ * duplicate here avoids having a debugging-capable regexec.o tied to
+ * a matching debug.o, and this is convenient. It all disappears in
+ * the non-debug compilation anyway, so it doesn't matter much.
+ */
+static char * /* -> representation */
+pchar(ch)
+int ch;
+{
+ static char pbuf[10];
+
+ if (isprint(ch) || ch == ' ')
+ (void)snprintf(pbuf, sizeof pbuf, "%c", ch);
+ else
+ (void)snprintf(pbuf, sizeof pbuf, "\\%o", ch);
+ return(pbuf);
+}
+#endif
+#endif
+
+#undef matcher
+#undef fast
+#undef slow
+#undef dissect
+#undef backref
+#undef step
+#undef print
+#undef at
+#undef match
+#undef nope
diff --git a/pkgtools/libnbcompat/files/fnmatch.c b/pkgtools/libnbcompat/files/fnmatch.c
index 272f3fc005a..cbbe629312f 100644
--- a/pkgtools/libnbcompat/files/fnmatch.c
+++ b/pkgtools/libnbcompat/files/fnmatch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fnmatch.c,v 1.1 2004/08/06 16:55:09 jlam Exp $ */
+/* $NetBSD: fnmatch.c,v 1.2 2004/08/16 17:24:56 jlam Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -32,9 +32,7 @@
* SUCH DAMAGE.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
@@ -44,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
#else
-__RCSID("$NetBSD: fnmatch.c,v 1.1 2004/08/06 16:55:09 jlam Exp $");
+__RCSID("$NetBSD: fnmatch.c,v 1.2 2004/08/16 17:24:56 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -53,7 +51,7 @@ __RCSID("$NetBSD: fnmatch.c,v 1.1 2004/08/06 16:55:09 jlam Exp $");
* Compares a filename or pathname to a pattern.
*/
-#include "namespace.h"
+/* #include "namespace.h" */
#include <assert.h>
#include <ctype.h>
diff --git a/pkgtools/libnbcompat/files/getopt_long.c b/pkgtools/libnbcompat/files/getopt_long.c
index e1c0b73eb2f..8ff67c79dda 100644
--- a/pkgtools/libnbcompat/files/getopt_long.c
+++ b/pkgtools/libnbcompat/files/getopt_long.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getopt_long.c,v 1.6 2004/03/12 15:21:13 grant Exp $ */
+/* $NetBSD: getopt_long.c,v 1.7 2004/08/16 17:24:56 jlam Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -36,10 +36,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if HAVE_CONFIG_H
-#include "nbcompat/nbconfig.h"
-#endif
-
#include "nbcompat.h"
#if HAVE_SYS_CDEFS_H
@@ -47,7 +43,7 @@
#endif
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getopt_long.c,v 1.6 2004/03/12 15:21:13 grant Exp $");
+__RCSID("$NetBSD: getopt_long.c,v 1.7 2004/08/16 17:24:56 jlam Exp $");
#endif /* LIBC_SCCS and not lint */
/* #include "namespace.h" */
@@ -71,10 +67,10 @@ __RCSID("$NetBSD: getopt_long.c,v 1.6 2004/03/12 15:21:13 grant Exp $");
#endif
#ifdef REPLACE_GETOPT
+#if 0
#ifndef __ELF__
#define _getopt getopt
#else
-#if 0
#ifdef __weak_alias
__weak_alias(getopt,_getopt)
#endif
@@ -89,6 +85,7 @@ char *optarg; /* argument associated with option */
static int optreset;
#endif
+#if 0
#ifndef __ELF__
#define _getopt_long getopt_long
#else
@@ -96,6 +93,7 @@ static int optreset;
__weak_alias(getopt_long,_getopt_long)
#endif
#endif
+#endif
#if !HAVE_GETOPT_LONG
#define IGNORE_FIRST (*options == '-' || *options == '+')
diff --git a/pkgtools/libnbcompat/files/md5c.c b/pkgtools/libnbcompat/files/md5c.c
index 7362e6e2a23..4b57ef30424 100644
--- a/pkgtools/libnbcompat/files/md5c.c
+++ b/pkgtools/libnbcompat/files/md5c.c
@@ -1,4 +1,4 @@
-/* $NetBSD: md5c.c,v 1.4 2003/09/05 18:36:01 jlam Exp $ */
+/* $NetBSD: md5c.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
@@ -29,10 +29,7 @@
* documentation and/or software.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
-
#include "nbcompat/nbtypes.h"
#if defined(_KERNEL) || defined(_STANDALONE)
diff --git a/pkgtools/libnbcompat/files/md5hl.c b/pkgtools/libnbcompat/files/md5hl.c
index b41c2f7c717..c444e005717 100644
--- a/pkgtools/libnbcompat/files/md5hl.c
+++ b/pkgtools/libnbcompat/files/md5hl.c
@@ -1,16 +1,14 @@
-/* $NetBSD: md5hl.c,v 1.5 2003/09/06 23:03:03 grant Exp $ */
+/* $NetBSD: md5hl.c,v 1.6 2004/08/16 17:24:56 jlam Exp $ */
/*
* Written by Jason R. Thorpe <thorpej@netbsd.org>, April 29, 1997.
* Public domain.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
+#include "nbcompat/nbtypes.h"
/* #include "namespace.h" */
-#include "nbcompat/nbtypes.h"
#define MDALGORITHM MD5
diff --git a/pkgtools/libnbcompat/files/namespace.h b/pkgtools/libnbcompat/files/namespace.h
deleted file mode 100644
index 3294caf6b20..00000000000
--- a/pkgtools/libnbcompat/files/namespace.h
+++ /dev/null
@@ -1,628 +0,0 @@
-/* $NetBSD: namespace.h,v 1.4 2004/03/12 15:21:13 grant Exp $ */
-
-/*-
- * Copyright (c) 1997-2002 The NetBSD Foundation, Inc.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- */
-
-#ifndef _NAMESPACE_H_
-#define _NAMESPACE_H_
-
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
-#if 0
-#define brk _brk
-#define catclose _catclose
-#define catgets _catgets
-#define catopen _catopen
-#define daylight _daylight
-#define err _err
-#define errx _errx
-#define fork _fork
-#define fseeko _fseeko
-#define ftello _ftello
-#define inet_aton _inet_aton
-#define inet_pton _inet_pton
-#define pipe _pipe
-#define sbrk _sbrk
-#define strlcat _strlcat
-#define strlcpy _strlcpy
-#define strtoimax _strtoimax
-#define strtoll _strtoll
-#define strtoull _strtoull
-#define strtoumax _strtoumax
-#define sys_errlist _sys_errlist
-#define sys_nerr _sys_nerr
-#define sys_siglist _sys_siglist
-#define sys_nsig _sys_nsig
-#define sysconf __sysconf
-#define verr _verr
-#define verrx _verrx
-#define vwarn _vwarn
-#define vwarnx _vwarnx
-#define warn _warn
-#define warnx _warnx
-
-#ifdef __weak_alias
-#define MD2Final _MD2Final
-#define MD2Init _MD2Init
-#define MD2Update _MD2Update
-#define MD4Final _MD4Final
-#define MD4Init _MD4Init
-#define MD4Update _MD4Update
-#define MD5Final _MD5Final
-#define MD5Init _MD5Init
-#define MD5Update _MD5Update
-#define RMD160Data _RMD160Data
-#define RMD160End _RMD160End
-#define RMD160File _RMD160File
-#define RMD160Final _RMD160Final
-#define RMD160Init _RMD160Init
-#define RMD160Transform _RMD160Transform
-#define RMD160Update _RMD160Update
-#define SHA1Data _SHA1Data
-#define SHA1End _SHA1End
-#define SHA1File _SHA1File
-#define SHA1Final _SHA1Final
-#define SHA1Init _SHA1Init
-#define SHA1Transform _SHA1Transform
-#define SHA1Update _SHA1Update
-#define a64l _a64l
-#define adjtime _adjtime
-#define alarm _alarm
-#define alphasort _alphasort
-#define asctime_r _asctime_r
-#define asprintf _asprintf
-#define atoll _atoll
-#define authnone_create _authnone_create
-#define authunix_create _authunix_create
-#define authunix_create_default _authunix_create_default
-#define basename _basename
-#define bindresvport _bindresvport
-#define bindresvport_sa _bindresvport_sa
-#define bm_comp _bm_comp
-#define bm_exec _bm_exec
-#define bm_free _bm_free
-#define callrpc _callrpc
-#define cfgetispeed _cfgetispeed
-#define cfgetospeed _cfgetospeed
-#define cfmakeraw _cfmakeraw
-#define cfsetispeed _cfsetispeed
-#define cfsetospeed _cfsetospeed
-#define cfsetspeed _cfsetspeed
-#define cgetcap _cgetcap
-#define cgetclose _cgetclose
-#define cgetent _cgetent
-#define cgetfirst _cgetfirst
-#define cgetmatch _cgetmatch
-#define cgetnext _cgetnext
-#define cgetnum _cgetnum
-#define cgetset _cgetset
-#define cgetstr _cgetstr
-#define cgetustr _cgetustr
-#define clnt_broadcast _clnt_broadcast
-#define clnt_create _clnt_create
-#define clnt_create_vers _clnt_create_vers
-#define clnt_dg_create _clnt_dg_create
-#define clnt_pcreateerror _clnt_pcreateerror
-#define clnt_perrno _clnt_perrno
-#define clnt_perror _clnt_perror
-#define clnt_raw_create _clnt_raw_create
-#define clnt_tli_create _clnt_tli_create
-#define clnt_tp_create _clnt_tp_create
-#define clnt_spcreateerror _clnt_spcreateerror
-#define clnt_sperrno _clnt_sperrno
-#define clnt_sperror _clnt_sperror
-#define clnt_vc_create _clnt_vc_create
-#define clntraw_create _clntraw_create
-#define clnttcp_create _clnttcp_create
-#define clntudp_bufcreate _clntudp_bufcreate
-#define clntudp_create _clntudp_create
-#define clock_settime _clock_settime
-#define closedir _closedir
-#define closelog _closelog
-#define confstr _confstr
-#define ctermid _ctermid
-#define ctime_r _ctime_r
-#define daemon _daemon
-#define dbm_clearerr _dbm_clearerr
-#define dbm_close _dbm_close
-#define dbm_delete _dbm_delete
-#define dbm_dirfno _dbm_dirfno
-#define dbm_error _dbm_error
-#define dbm_fetch _dbm_fetch
-#define dbm_firstkey _dbm_firstkey
-#define dbm_nextkey _dbm_nextkey
-#define dbm_open _dbm_open
-#define dbm_store _dbm_store
-#define dbopen _dbopen
-#define devname _devname
-#define dirname _dirname
-#define dn_expand _dn_expand
-#define drand48 _drand48
-#define endfsent _endfsent
-#define endgrent _endgrent
-#define endhostent _endhostent
-#define endnetconfig _endnetconfig
-#define endnetent _endnetent
-#define endnetgrent _endnetgrent
-#define endprotoent _endprotoent
-#define endpwent _endpwent
-#define endrpcent _endrpcent
-#define endservent _endservent
-#define endttyent _endttyent
-#define endusershell _endusershell
-#define erand48 _erand48
-#define ether_aton _ether_aton
-#define ether_hostton _ether_hostton
-#define ether_line _ether_line
-#define ether_ntoa _ether_ntoa
-#define ether_ntohost _ether_ntohost
-#define execl _execl
-#define execle _execle
-#define execlp _execlp
-#define execv _execv
-#define execvp _execvp
-#define fdopen _fdopen
-#define fgetln _fgetln
-#define fnmatch _fnmatch
-#define fpgetmask _fpgetmask
-#define fpgetround _fpgetround
-#define fpgetsticky _fpgetsticky
-#define fpsetmask _fpsetmask
-#define fpsetround _fpsetround
-#define fpsetsticky _fpsetsticky
-#define freenetconfigent _freenetconfigent
-#define freeaddrinfo _freeaddrinfo
-#define freeifaddrs _freeifaddrs
-#define ftok _ftok
-#define ftruncate _ftruncate
-#define fts_children _fts_children
-#define fts_close _fts_close
-#define fts_open _fts_open
-#define fts_read _fts_read
-#define fts_set _fts_set
-#define gai_strerror _gai_strerror
-#define get_myaddress _get_myaddress
-#define getbsize _getbsize
-#define getcwd _getcwd
-#define getdiskbyname _getdiskbyname
-#define getfsent _getfsent
-#define getfsfile _getfsfile
-#define getfsspec _getfsspec
-#define getgrent _getgrent
-#define getgrgid _getgrgid
-#define getgrnam _getgrnam
-#define getgrouplist _getgrouplist
-#define getifaddrs _getifaddrs
-#define getloadavg _getloadavg
-#define getlogin _getlogin
-#define getmntinfo _getmntinfo
-#define getmode _getmode
-#define getnameinfo _getnameinfo
-#define getnetbyaddr _getnetbyaddr
-#define getnetbyname _getnetbyname
-#define getnetconfig _getnetconfig
-#define getnetconfigent _getnetconfigent
-#define getnetent _getnetent
-#define getnetgrent _getnetgrent
-#define getnetpath _getnetpath
-#define getopt _getopt
-#define getopt_long _getopt_long
-#define getpagesize _getpagesize
-#define getpass _getpass
-#define getprogname _getprogname
-#define getprotobyname _getprotobyname
-#define getprotobynumber _getprotobynumber
-#define getprotoent _getprotoent
-#define getpwent _getpwent
-#define getpwnam _getpwnam
-#define getpwuid _getpwuid
-#define getrpcbyname _getrpcbyname
-#define getrpcbynumber _getrpcbynumber
-#define getrpcent _getrpcent
-#define getrpcport _getrpcport
-#define getservbyname _getservbyname
-#define getservbyport _getservbyport
-#define getservent _getservent
-#define getsubopt _getsubopt
-#define getttyent _getttyent
-#define getttynam _getttynam
-#define getusershell _getusershell
-#define glob _glob
-#define globfree _globfree
-#define gmtime_r _gmtime_r
-#define group_from_gid _group_from_gid
-#define heapsort _heapsort
-#define herror _herror
-#define hes_error _hes_error
-#define hes_free _hes_free
-#define hes_init _hes_init
-#define hes_resolve _hes_resolve
-#define hes_to_bind _hes_to_bind
-#define hesiod_end _hesiod_end
-#define hesiod_free_list _hesiod_free_list
-#define hesiod_init _hesiod_init
-#define hesiod_resolve _hesiod_resolve
-#define hesiod_to_bind _hesiod_to_bind
-#define if_freenameindex _if_freenameindex
-#define if_indextoname _if_indextoname
-#define if_nameindex _if_nameindex
-#define if_nametoindex _if_nametoindex
-#define in6addr_any _in6addr_any
-#define in6addr_linklocal_allnodes _in6addr_linklocal_allnodes
-#define in6addr_loopback _in6addr_loopback
-#define in6addr_nodelocal_allnodes _in6addr_nodelocal_allnodes
-#define inet6_option_alloc _inet6_option_alloc
-#define inet6_option_append _inet6_option_append
-#define inet6_option_find _inet6_option_find
-#define inet6_option_init _inet6_option_init
-#define inet6_option_next _inet6_option_next
-#define inet6_option_space _inet6_option_space
-#define inet6_rthdr_add _inet6_rthdr_add
-#define inet6_rthdr_getaddr _inet6_rthdr_getaddr
-#define inet6_rthdr_getflags _inet6_rthdr_getflags
-#define inet6_rthdr_init _inet6_rthdr_init
-#define inet6_rthdr_lasthop _inet6_rthdr_lasthop
-#define inet6_rthdr_segments _inet6_rthdr_segments
-#define inet6_rthdr_space _inet6_rthdr_space
-#define inet_lnaof _inet_lnaof
-#define inet_makeaddr _inet_makeaddr
-#define inet_net_ntop _inet_net_ntop
-#define inet_net_pton _inet_net_pton
-#define inet_neta _inet_neta
-#define inet_netof _inet_netof
-#define inet_network _inet_network
-#define inet_nsap_addr _inet_nsap_addr
-#define inet_nsap_ntoa _inet_nsap_ntoa
-#define inet_ntoa _inet_ntoa
-#define inet_ntop _inet_ntop
-#define initgroups _initgroups
-#define initstate _initstate
-#define innetgr _innetgr
-#define isatty _isatty
-#define isinf _isinf
-#define isnan _isnan
-#define jrand48 _jrand48
-#define l64a _l64a
-#define l64a_r _l64a_r
-#define lcong48 _lcong48
-#define llabs _llabs
-#define lldiv _lldiv
-#define localtime_r _localtime_r
-#define lockf _lockf
-#define lrand48 _lrand48
-#define lseek _lseek
-#define mergesort _mergesort
-#define mmap _mmap
-#define mpool_close _mpool_close
-#define mpool_filter _mpool_filter
-#define mpool_get _mpool_get
-#define mpool_new _mpool_new
-#define mpool_open _mpool_open
-#define mpool_put _mpool_put
-#define mpool_sync _mpool_sync
-#define mrand48 _mrand48
-#define nc_perror _nc_perror
-#define nc_sperror _nc_sperror
-#define nice _nice
-#if 0
-#define nlist _nlist
-#endif
-#define nrand48 _nrand48
-#define ntp_adjtime _ntp_adjtime
-#define nsdispatch _nsdispatch
-#define offtime _offtime
-#define opendir _opendir
-#define openlog _openlog
-#define pause _pause
-#define pclose _pclose
-#define pmap_getmaps _pmap_getmaps
-#define pmap_getport _pmap_getport
-#define pmap_rmtcall _pmap_rmtcall
-#define pmap_set _pmap_set
-#define pmap_unset _pmap_unset
-#define popen _popen
-#define posix2time _posix2time
-#define pread _pread
-#define psignal _psignal
-#define putenv _putenv
-#define pwcache_userdb _pwcache_userdb
-#define pwcache_groupdb _pwcache_groupdb
-#define pwrite _pwrite
-#define qabs _qabs
-#define qdiv _qdiv
-#define radixsort _radixsort
-#define random _random
-#define readdir _readdir
-#define realpath _realpath
-#define regcomp _regcomp
-#define regerror _regerror
-#define regexec _regexec
-#define regfree _regfree
-#define registerrpc _registerrpc
-#define res_init _res_init
-#define res_mkquery _res_mkquery
-#define res_query _res_query
-#define res_search _res_search
-#define rewinddir _rewinddir
-#define rpc_broadcast _rpc_broadcast
-#define rpc_broadcast_exp _rpc_broadcast_exp
-#define rpc_call _rpc_call
-#define rpc_reg _rpc_reg
-#define rpcb_getmaps _rpcb_getmaps
-#define rpcb_gettime _rpcb_gettime
-#define rpcb_rmtcall _rpcb_rmtcall
-#define rpcb_set _rpcb_set
-#define rpcb_taddr2uaddr _rpcb_taddr2uaddr
-#define rpcb_uaddr2taddr _rpcb_uaddr2taddr
-#define rpcb_unset _rpcb_unset
-#define scandir _scandir
-#define seed48 _seed48
-#define seekdir _seekdir
-#define send _send
-#define setdomainname _setdomainname
-#define setenv _setenv
-#define setfsent _setfsent
-#define setgrent _setgrent
-#define setgroupent _setgroupent
-#define sethostent _sethostent
-#define sethostname _sethostname
-#define setlogmask _setlogmask
-#define setmode _setmode
-#define setnetconfig _setnetconfig
-#define setnetent _setnetent
-#define setnetgrent _setnetgrent
-#define setpassent _setpassent
-#define setnetpath _setnetpath
-#define setproctitle _setproctitle
-#define setprotoent _setprotoent
-#define setpwent _setpwent
-#define setrpcent _setrpcent
-#define setservent _setservent
-#define setstate _setstate
-#define setttyent _setttyent
-#define settimeofday _settimeofday
-#define setusershell _setusershell
-#define shm_open _shm_open
-#define shm_unlink _shm_unlink
-#define siginterrupt _siginterrupt
-#define signal _signal
-#define sl_add _sl_add
-#define sl_find _sl_find
-#define sl_free _sl_free
-#define sl_init _sl_init
-#define sleep _sleep
-#define snprintf _snprintf
-#define sradixsort _sradixsort
-#define srand48 _srand48
-#define srandom _srandom
-#define strcasecmp _strcasecmp
-#define strdup _strdup
-#define strncasecmp _strncasecmp
-#define strptime _strptime
-#define strsep _strsep
-#define strsignal _strsignal
-#define strsvis _strsvis
-#define strsvisx _strsvisx
-#define strtok_r _strtok_r
-#define strunvis _strunvis
-#define strvis _strvis
-#define strvisx _strvisx
-#define svc_auth_reg _svc_auth_reg
-#define svc_create _svc_create
-#define svc_dg_create _svc_dg_create
-#define svc_exit _svc_exit
-#define svc_fd_create _svc_fd_create
-#define svc_getreq _svc_getreq
-#define svc_getreqset _svc_getreqset
-#define svc_getreq_common _svc_getreq_common
-#define svc_raw_create _svc_raw_create
-#define svc_register _svc_register
-#define svc_reg _svc_reg
-#define svc_run _svc_run
-#define svc_sendreply _svc_sendreply
-#define svc_tli_create _svc_tli_create
-#define svc_tp_create _svc_tp_create
-#define svc_unregister _svc_unregister
-#define svc_unreg _svc_unreg
-#define svc_vc_create _svc_vc_create
-#define svcerr_auth _svcerr_auth
-#define svcerr_decode _svcerr_decode
-#define svcerr_noproc _svcerr_noproc
-#define svcerr_noprog _svcerr_noprog
-#define svcerr_progvers _svcerr_progvers
-#define svcerr_systemerr _svcerr_systemerr
-#define svcerr_weakauth _svcerr_weakauth
-#define svcfd_create _svcfd_create
-#define svcraw_create _svcraw_create
-#define svctcp_create _svctcp_create
-#define svcudp_bufcreate _svcudp_bufcreate
-#define svcudp_create _svcudp_create
-#define svcudp_enablecache _svcudp_enablecache
-#define svis _svis
-#define sysarch _sysarch
-#define sysctl _sysctl
-#define syslog _syslog
-#define tcdrain _tcdrain
-#define tcflow _tcflow
-#define tcflush _tcflush
-#define tcgetattr _tcgetattr
-#define tcgetpgrp _tcgetpgrp
-#define tcgetsid _tcgetsid
-#define tcsendbreak _tcsendbreak
-#define tcsetattr _tcsetattr
-#define tcsetpgrp _tcsetpgrp
-#define telldir _telldir
-#define time _time
-#define time2posix _time2posix
-#define timegm _timegm
-#define timelocal _timelocal
-#define timeoff _timeoff
-#define times _times
-#define ttyname _ttyname
-#define ttyslot _ttyslot
-#define tzname _tzname
-#define tzset _tzset
-#define tzsetwall _tzsetwall
-#define ualarm _ualarm
-#define uname _uname
-#define unsetenv _unsetenv
-#define unvis _unvis
-#define user_from_uid _user_from_uid
-#define usleep _usleep
-#define utime _utime
-#define valloc _valloc
-#define vis _vis
-#define vsnprintf _vsnprintf
-#define vsyslog _vsyslog
-#define wait _wait
-#define wait3 _wait3
-#define waitpid _waitpid
-#define xdr_accepted_reply _xdr_accepted_reply
-#define xdr_array _xdr_array
-#define xdr_authunix_parms _xdr_authunix_parms
-#define xdr_bool _xdr_bool
-#define xdr_bytes _xdr_bytes
-#define xdr_callhdr _xdr_callhdr
-#define xdr_callmsg _xdr_callmsg
-#define xdr_char _xdr_char
-#define xdr_datum _xdr_datum
-#define xdr_des_block _xdr_des_block
-#define xdr_domainname _xdr_domainname
-#define xdr_double _xdr_double
-#define xdr_enum _xdr_enum
-#define xdr_float _xdr_float
-#define xdr_free _xdr_free
-#define xdr_hyper _xdr_hyper
-#define xdr_int _xdr_int
-#define xdr_int16_t _xdr_int16_t
-#define xdr_int32_t _xdr_int32_t
-#define xdr_int64_t _xdr_int64_t
-#define xdr_long _xdr_long
-#define xdr_longlong_t _xdr_longlong_t
-#define xdr_mapname _xdr_mapname
-#define xdr_netbuf _xdr_netbuf
-#define xdr_netobj _xdr_netobj
-#define xdr_opaque _xdr_opaque
-#define xdr_opaque_auth _xdr_opaque_auth
-#define xdr_peername _xdr_peername
-#define xdr_pmap _xdr_pmap
-#define xdr_pmaplist _xdr_pmaplist
-#define xdr_pointer _xdr_pointer
-#define xdr_reference _xdr_reference
-#define xdr_rejected_reply _xdr_rejected_reply
-#define xdr_replymsg _xdr_replymsg
-#define xdr_rmtcall_args _xdr_rmtcall_args
-#define xdr_rmtcallres _xdr_rmtcallres
-#define xdr_rpcb _xdr_rpcb
-#define xdr_rpcb_entry _xdr_rpcb_entry
-#define xdr_rpcb_entry_list_ptr _xdr_rpcb_entry_list_ptr
-#define xdr_rpcb_rmtcallargs _xdr_rpcb_rmtcallargs
-#define xdr_rpcb_rmtcallres _xdr_rpcb_rmtcallres
-#define xdr_rpcb_stat _xdr_rpcb_stat
-#define xdr_rpcb_stat_byvers _xdr_rpcb_stat_byvers
-#define xdr_rpcblist _xdr_rpcblist
-#define xdr_rpcblist_ptr _xdr_rpcblist_ptr
-#define xdr_rpcbs_addrlist _xdr_rpcbs_addrlist
-#define xdr_rpcbs_addrlist_ptr _xdr_rpcbs_addrlist_ptr
-#define xdr_rpcbs_proc _xdr_rpcbs_proc
-#define xdr_rpcbs_rmtcalllist _xdr_rpcbs_rmtcalllist
-#define xdr_rpcbs_rmtcalllist_ptr _xdr_rpcbs_rmtcalllist_ptr
-#define xdr_rpcbs _xdr_rpcbs
-#define xdr_rpcbs _xdr_rpcbs
-#define xdr_short _xdr_short
-#define xdr_string _xdr_string
-#define xdr_u_char _xdr_u_char
-#define xdr_u_hyper _xdr_u_hyper
-#define xdr_u_int _xdr_u_int
-#define xdr_u_int16_t _xdr_u_int16_t
-#define xdr_u_int32_t _xdr_u_int32_t
-#define xdr_u_int64_t _xdr_u_int64_t
-#define xdr_u_long _xdr_u_long
-#define xdr_u_longlong_t _xdr_u_longlong_t
-#define xdr_u_short _xdr_u_short
-#define xdr_union _xdr_union
-#define xdr_vector _xdr_vector
-#define xdr_void _xdr_void
-#define xdr_wrapstring _xdr_wrapstring
-#define xdr_yp_inaddr _xdr_yp_inaddr
-#define xdr_ypall _xdr_ypall
-#define xdr_ypbind_resp _xdr_ypbind_resp
-#define xdr_ypbind_setdom _xdr_ypbind_setdom
-#define xdr_ypdomain_wrap_string _xdr_ypdomain_wrap_string
-#define xdr_ypmap_parms _xdr_ypmap_parms
-#define xdr_ypmap_wrap_string _xdr_ypmap_wrap_string
-#define xdr_ypmaplist _xdr_ypmaplist
-#define xdr_ypowner_wrap_string _xdr_ypowner_wrap_string
-#define xdr_yppushresp_xfr _xdr_yppushresp_xfr
-#define xdr_ypreq_key _xdr_ypreq_key
-#define xdr_ypreq_nokey _xdr_ypreq_nokey
-#define xdr_ypreq_xfr _xdr_ypreq_xfr
-#define xdr_ypresp_key_val _xdr_ypresp_key_val
-#define xdr_ypresp_maplist _xdr_ypresp_maplist
-#define xdr_ypresp_master _xdr_ypresp_master
-#define xdr_ypresp_order _xdr_ypresp_order
-#define xdr_ypresp_val _xdr_ypresp_val
-#define xdrmem_create _xdrmem_create
-#define xdrrec_create _xdrrec_create
-#define xdrrec_endofrecord _xdrrec_endofrecord
-#define xdrrec_eof _xdrrec_eof
-#define xdrrec_skiprecord _xdrrec_skiprecord
-#define xdrstdio_create _xdrstdio_create
-#define xprt_register _xprt_register
-#define xprt_unregister _xprt_unregister
-#define yp_all _yp_all
-#define yp_bind _yp_bind
-#define yp_first _yp_first
-#define yp_get_default_domain _yp_get_default_domain
-#define yp_maplist _yp_maplist
-#define yp_master _yp_master
-#define yp_match _yp_match
-#define yp_next _yp_next
-#define yp_order _yp_order
-#define yp_unbind _yp_unbind
-#define yperr_string _yperr_string
-#define ypprot_err _ypprot_err
-#define dlopen __dlopen
-#define dlclose __dlclose
-#define dlsym __dlsym
-#define dlerror __dlerror
-#define dladdr __dladdr
-#define fmtcheck __fmtcheck
-#endif /* __weak_alias */
-#endif
-
-#endif /* _NAMESPACE_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat.h b/pkgtools/libnbcompat/files/nbcompat.h
index 8bdad20bc46..ebef57a033c 100644
--- a/pkgtools/libnbcompat/files/nbcompat.h
+++ b/pkgtools/libnbcompat/files/nbcompat.h
@@ -1,4 +1,4 @@
-/* $NetBSD: nbcompat.h,v 1.36 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: nbcompat.h,v 1.37 2004/08/16 17:24:56 jlam Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -33,9 +33,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _NBCOMPAT_H
-#define _NBCOMPAT_H
-
#include <nbcompat/nbconfig.h>
#include <nbcompat/nbtypes.h>
@@ -114,6 +111,13 @@
# include <nbcompat/glob.h>
#endif
+#if HAVE_NBCOMPAT_REGEX
+# if HAVE_REGEX_H
+# undef HAVE_REGEX_H
+# endif
+# include <nbcompat/regex.h>
+#endif
+
#if HAVE_SYS_MKDEV_H
# include <sys/mkdev.h>
# if !defined(makedev) && defined(mkdev)
@@ -174,15 +178,19 @@ void tputs(const char *, int, int (*)(int));
#endif
#if !HAVE_D_NAMLEN
-# define DIRENT_MISSING_D_NAMLEN
+# ifndef DIRENT_MISSING_D_NAMLEN
+# define DIRENT_MISSING_D_NAMLEN
+# endif
#endif
#if !HAVE_ISBLANK
-int isblank(int);
+int isblank(int);
#endif
#if HAVE_GETPASSPHRASE
-# define getpass getpassphrase
+# ifndef getpass
+# define getpass getpassphrase
+# endif
#endif
#if !defined(MIN)
@@ -191,5 +199,3 @@ int isblank(int);
#if !defined(MAX)
# define MAX(a, b) ((a) < (b) ? (b) : (a))
#endif
-
-#endif /* !_NBCOMPAT_H */
diff --git a/pkgtools/libnbcompat/files/nbcompat/config.h.in b/pkgtools/libnbcompat/files/nbcompat/config.h.in
index 7836f1d8d76..5904fbc6d8e 100644
--- a/pkgtools/libnbcompat/files/nbcompat/config.h.in
+++ b/pkgtools/libnbcompat/files/nbcompat/config.h.in
@@ -173,6 +173,9 @@
/* Define to 1 if the `queue' macros are supplied by the library. */
#undef HAVE_NBCOMPAT_QUEUE
+/* Define to 1 if the `regex' functions are built into the library. */
+#undef HAVE_NBCOMPAT_REGEX
+
/* Define to 1 if the `RMD160*' functions are built into the library. */
#undef HAVE_NBCOMPAT_RMD160
@@ -216,6 +219,9 @@
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
+/* Define to 1 if you have the <regex.h> header file. */
+#undef HAVE_REGEX_H
+
/* Define to 1 if you have the <rmd160.h> header file. */
#undef HAVE_RMD160_H
diff --git a/pkgtools/libnbcompat/files/nbcompat/err.h b/pkgtools/libnbcompat/files/nbcompat/err.h
index d3d73140ae4..5aac0839b9c 100644
--- a/pkgtools/libnbcompat/files/nbcompat/err.h
+++ b/pkgtools/libnbcompat/files/nbcompat/err.h
@@ -1,4 +1,4 @@
-/* $NetBSD: err.h,v 1.2 2003/09/15 08:29:51 grant Exp $ */
+/* $NetBSD: err.h,v 1.3 2004/08/16 17:24:57 jlam Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -35,10 +35,10 @@
* @(#)fts.h 8.3 (Berkeley) 8/14/94
*/
-#ifndef _ERR_H_
-#define _ERR_H_
+#ifndef _NBCOMPAT_ERR_H_
+#define _NBCOMPAT_ERR_H_
-#ifndef HAVE_ERR
+#if !HAVE_ERR
void err(int, const char *, ...);
void errx(int, const char *, ...);
void verr(int, const char *, va_list);
@@ -49,4 +49,4 @@ void vwarn(const char *, va_list);
void vwarnx(const char *, va_list);
#endif
-#endif /* !_ERR_H_ */
+#endif /* !_NBCOMPAT_ERR_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/fts.h b/pkgtools/libnbcompat/files/nbcompat/fts.h
index f7a6df1a867..7f0ba15e6dd 100644
--- a/pkgtools/libnbcompat/files/nbcompat/fts.h
+++ b/pkgtools/libnbcompat/files/nbcompat/fts.h
@@ -1,4 +1,4 @@
-/* $NetBSD: fts.h,v 1.3 2003/12/19 22:23:00 grant Exp $ */
+/* $NetBSD: fts.h,v 1.4 2004/08/16 17:24:57 jlam Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -31,8 +31,8 @@
* @(#)fts.h 8.3 (Berkeley) 8/14/94
*/
-#ifndef _FTS_H_
-#define _FTS_H_
+#ifndef _NBCOMPAT_FTS_H_
+#define _NBCOMPAT_FTS_H_
typedef struct {
struct _ftsent *fts_cur; /* current node */
@@ -124,4 +124,4 @@ FTS *fts_open (char * const *, int,
FTSENT *fts_read (FTS *);
int fts_set (FTS *, FTSENT *, int);
-#endif /* !_FTS_H_ */
+#endif /* !_NBCOMPAT_FTS_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/getopt.h b/pkgtools/libnbcompat/files/nbcompat/getopt.h
index 3a73ef1bc74..04ed5a6cb76 100644
--- a/pkgtools/libnbcompat/files/nbcompat/getopt.h
+++ b/pkgtools/libnbcompat/files/nbcompat/getopt.h
@@ -1,4 +1,4 @@
-/* $NetBSD: getopt.h,v 1.2 2003/12/05 15:42:13 erh Exp $ */
+/* $NetBSD: getopt.h,v 1.3 2004/08/16 17:24:57 jlam Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -36,8 +36,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _GETOPT_H_
-#define _GETOPT_H_
+#ifndef _NBCOMPAT_GETOPT_H_
+#define _NBCOMPAT_GETOPT_H_
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
@@ -50,7 +50,6 @@
/*
* Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
*/
-#if (!defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(__linux__) || defined(_AIX)
#define no_argument 0
#define required_argument 1
#define optional_argument 2
@@ -73,6 +72,5 @@ __BEGIN_DECLS
int getopt_long (int, char * const *, const char *,
const struct option *, int *);
__END_DECLS
-#endif
-#endif /* !_GETOPT_H_ */
+#endif /* !_NBCOMPAT_GETOPT_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/glob.h b/pkgtools/libnbcompat/files/nbcompat/glob.h
index a01178623e5..c5f1a96cc83 100644
--- a/pkgtools/libnbcompat/files/nbcompat/glob.h
+++ b/pkgtools/libnbcompat/files/nbcompat/glob.h
@@ -1,4 +1,4 @@
-/* $Id: glob.h,v 1.2 2003/12/19 22:16:14 grant Exp $ */
+/* $Id: glob.h,v 1.3 2004/08/16 17:24:57 jlam Exp $ */
/* from NetBSD: glob.h,v 1.13 2001/03/16 21:02:42 christos Exp */
/*
@@ -35,8 +35,8 @@
* @(#)glob.h 8.1 (Berkeley) 6/2/93
*/
-#ifndef _GLOB_H_
-#define _GLOB_H_
+#ifndef _NBCOMPAT_GLOB_H_
+#define _NBCOMPAT_GLOB_H_
typedef struct {
int gl_pathc; /* Count of total paths so far. */
@@ -85,4 +85,4 @@ typedef struct {
int glob(const char *, int, int (*)(const char *, int), glob_t *);
void globfree(glob_t *);
-#endif /* !_GLOB_H_ */
+#endif /* !_NBCOMPAT_GLOB_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/md5.h b/pkgtools/libnbcompat/files/nbcompat/md5.h
index 157bb7d4e02..b2592b7e91f 100644
--- a/pkgtools/libnbcompat/files/nbcompat/md5.h
+++ b/pkgtools/libnbcompat/files/nbcompat/md5.h
@@ -1,4 +1,4 @@
-/* $NetBSD: md5.h,v 1.1 2003/09/05 18:36:07 jlam Exp $ */
+/* $NetBSD: md5.h,v 1.2 2004/08/16 17:24:57 jlam Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
@@ -29,8 +29,8 @@
* documentation and/or software.
*/
-#ifndef _SYS_MD5_H_
-#define _SYS_MD5_H_
+#ifndef _NBCOMPAT_SYS_MD5_H_
+#define _NBCOMPAT_SYS_MD5_H_
/* MD5 context. */
typedef struct MD5Context {
@@ -50,4 +50,4 @@ char *MD5Data __P((const unsigned char *, unsigned int, char *));
#endif /* _KERNEL */
__END_DECLS
-#endif /* _SYS_MD5_H_ */
+#endif /* !_NBCOMPAT_SYS_MD5_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/poll.h b/pkgtools/libnbcompat/files/nbcompat/poll.h
index d4342cca56c..042b9c8b43b 100644
--- a/pkgtools/libnbcompat/files/nbcompat/poll.h
+++ b/pkgtools/libnbcompat/files/nbcompat/poll.h
@@ -1,4 +1,4 @@
-/* $NetBSD: poll.h,v 1.1 2003/09/03 13:35:52 jlam Exp $ */
+/* $NetBSD: poll.h,v 1.2 2004/08/16 17:24:57 jlam Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -36,8 +36,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _POLL_H_
-#define _POLL_H_
+#ifndef _NBCOMPAT_POLL_H_
+#define _NBCOMPAT_POLL_H_
typedef unsigned int nfds_t;
@@ -69,4 +69,4 @@ __BEGIN_DECLS
int poll (struct pollfd *, nfds_t, int);
__END_DECLS
-#endif /* !_POLL_H_ */
+#endif /* !_NBCOMPAT_POLL_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/regex.h b/pkgtools/libnbcompat/files/nbcompat/regex.h
new file mode 100644
index 00000000000..c4d5cc3fb2f
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/regex.h
@@ -0,0 +1,151 @@
+/* $NetBSD: regex.h,v 1.1 2004/08/16 17:24:57 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * 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.
+ *
+ * @(#)regex.h 8.2 (Berkeley) 1/3/94
+ */
+
+/*-
+ * Copyright (c) 1992 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)regex.h 8.2 (Berkeley) 1/3/94
+ */
+
+#ifndef _NBCOMPAT_REGEX_H_
+#define _NBCOMPAT_REGEX_H_
+
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+/* types */
+#if 1 /* __LIBC12_SOURCE__ - should go away */
+typedef off_t regoff_t;
+#else
+typedef size_t regoff_t;
+#endif
+
+typedef struct {
+ int re_magic;
+ size_t re_nsub; /* number of parenthesized subexpressions */
+ const char *re_endp; /* end pointer for REG_PEND */
+ struct re_guts *re_g; /* none of your business :-) */
+} regex_t;
+
+typedef struct {
+ regoff_t rm_so; /* start of match */
+ regoff_t rm_eo; /* end of match */
+} regmatch_t;
+
+/* regcomp() flags */
+#define REG_BASIC 0000
+#define REG_EXTENDED 0001
+#define REG_ICASE 0002
+#define REG_NOSUB 0004
+#define REG_NEWLINE 0010
+#define REG_NOSPEC 0020
+#define REG_PEND 0040
+#define REG_DUMP 0200
+
+/* regerror() flags */
+#define REG_NOMATCH 1
+#define REG_BADPAT 2
+#define REG_ECOLLATE 3
+#define REG_ECTYPE 4
+#define REG_EESCAPE 5
+#define REG_ESUBREG 6
+#define REG_EBRACK 7
+#define REG_EPAREN 8
+#define REG_EBRACE 9
+#define REG_BADBR 10
+#define REG_ERANGE 11
+#define REG_ESPACE 12
+#define REG_BADRPT 13
+#define REG_EMPTY 14
+#define REG_ASSERT 15
+#define REG_INVARG 16
+#define REG_ENOSYS 17
+#define REG_ATOI 255 /* convert name to number (!) */
+#define REG_ITOA 0400 /* convert number to name (!) */
+
+/* regexec() flags */
+#define REG_NOTBOL 00001
+#define REG_NOTEOL 00002
+#define REG_STARTEND 00004
+#define REG_TRACE 00400 /* tracing of execution */
+#define REG_LARGE 01000 /* force large representation */
+#define REG_BACKR 02000 /* force use of backref code */
+
+__BEGIN_DECLS
+int regcomp __P((regex_t * __restrict, const char * __restrict, int));
+size_t regerror __P((int, const regex_t * __restrict, char * __restrict,
+ size_t));
+int regexec __P((const regex_t * __restrict,
+ const char * __restrict, size_t, regmatch_t [], int));
+void regfree __P((regex_t *));
+__END_DECLS
+
+#endif /* !_NBCOMPAT_REGEX_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/rmd160.h b/pkgtools/libnbcompat/files/nbcompat/rmd160.h
index c21303f15cf..f2e1ecc8571 100644
--- a/pkgtools/libnbcompat/files/nbcompat/rmd160.h
+++ b/pkgtools/libnbcompat/files/nbcompat/rmd160.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rmd160.h,v 1.1 2003/09/05 18:36:08 jlam Exp $ */
+/* $NetBSD: rmd160.h,v 1.2 2004/08/16 17:24:57 jlam Exp $ */
/********************************************************************\
*
@@ -21,8 +21,8 @@
* from OpenBSD: rmd160.h,v 1.4 1999/08/16 09:59:04 millert Exp
*/
-#ifndef _RMD160_H_
-#define _RMD160_H_
+#ifndef _NBCOMPAT_RMD160_H_
+#define _NBCOMPAT_RMD160_H_
typedef struct {
u_int32_t state[5]; /* state (ABCDE) */
@@ -43,4 +43,4 @@ char *RMD160Data(const u_char *, size_t, char *);
#endif /* _KERNEL */
__END_DECLS
-#endif /* !_RMD160_H_ */
+#endif /* !_NBCOMPAT_RMD160_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/sha1.h b/pkgtools/libnbcompat/files/nbcompat/sha1.h
index 342ecd7034d..7c0fe101548 100644
--- a/pkgtools/libnbcompat/files/nbcompat/sha1.h
+++ b/pkgtools/libnbcompat/files/nbcompat/sha1.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sha1.h,v 1.1 2003/09/05 18:36:08 jlam Exp $ */
+/* $NetBSD: sha1.h,v 1.2 2004/08/16 17:24:57 jlam Exp $ */
/*
* SHA-1 in C
@@ -6,8 +6,8 @@
* 100% Public Domain
*/
-#ifndef _SYS_SHA1_H_
-#define _SYS_SHA1_H_
+#ifndef _NBCOMPAT_SYS_SHA1_H_
+#define _NBCOMPAT_SYS_SHA1_H_
typedef struct {
u_int32_t state[5];
@@ -25,4 +25,4 @@ char *SHA1File __P((char *, char *));
char *SHA1Data __P((const u_char *, size_t, char *));
#endif /* _KERNEL */
-#endif /* _SYS_SHA1_H_ */
+#endif /* _NBCOMPAT_SYS_SHA1_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/vis.h b/pkgtools/libnbcompat/files/nbcompat/vis.h
index a144a129df6..04614595e33 100644
--- a/pkgtools/libnbcompat/files/nbcompat/vis.h
+++ b/pkgtools/libnbcompat/files/nbcompat/vis.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.h,v 1.1 2003/09/03 13:35:54 jlam Exp $ */
+/* $NetBSD: vis.h,v 1.2 2004/08/16 17:24:57 jlam Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -35,8 +35,8 @@
* @(#)vis.h 8.1 (Berkeley) 6/2/93
*/
-#ifndef _VIS_H_
-#define _VIS_H_
+#ifndef _NBCOMPAT_VIS_H_
+#define _NBCOMPAT_VIS_H_
/*
* to select alternate encoding format
@@ -104,4 +104,4 @@ int unvis (char *, int, int *, int) __RENAME(__unvis13);
#endif
__END_DECLS
-#endif /* !_VIS_H_ */
+#endif /* !_NBCOMPAT_VIS_H_ */
diff --git a/pkgtools/libnbcompat/files/pwcache.c b/pkgtools/libnbcompat/files/pwcache.c
index 7151dea3a88..33d5578a3ea 100644
--- a/pkgtools/libnbcompat/files/pwcache.c
+++ b/pkgtools/libnbcompat/files/pwcache.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pwcache.c,v 1.6 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: pwcache.c,v 1.7 2004/08/16 17:24:56 jlam Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@@ -66,9 +66,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
@@ -78,7 +76,7 @@
#if 0
static char sccsid[] = "@(#)cache.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pwcache.c,v 1.6 2004/08/10 18:47:55 jlam Exp $");
+__RCSID("$NetBSD: pwcache.c,v 1.7 2004/08/16 17:24:56 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
diff --git a/pkgtools/libnbcompat/files/regcomp.c b/pkgtools/libnbcompat/files/regcomp.c
new file mode 100644
index 00000000000..dbca3717cf0
--- /dev/null
+++ b/pkgtools/libnbcompat/files/regcomp.c
@@ -0,0 +1,1926 @@
+/* $NetBSD: regcomp.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)regcomp.c 8.5 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)regcomp.c 8.5 (Berkeley) 3/20/94
+ */
+
+#include "nbcompat.h"
+
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
+#else
+__RCSID("$NetBSD: regcomp.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* #include "namespace.h" */
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_ASSERT_H
+#include <assert.h>
+#endif
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#if HAVE_REGEX_H
+#include <regex.h>
+#endif
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(regcomp,_regcomp)
+#endif
+#endif
+
+#include "utils.h"
+#include "regex2.h"
+
+#include "cclass.h"
+#include "cname.h"
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+/*
+ * parse structure, passed up and down to avoid global variables and
+ * other clumsinesses
+ */
+struct parse {
+ char *next; /* next character in RE */
+ char *end; /* end of string (-> NUL normally) */
+ int error; /* has an error been seen? */
+ sop *strip; /* malloced strip */
+ sopno ssize; /* malloced strip size (allocated) */
+ sopno slen; /* malloced strip length (used) */
+ int ncsalloc; /* number of csets allocated */
+ struct re_guts *g;
+# define NPAREN 10 /* we need to remember () 1-9 for back refs */
+ sopno pbegin[NPAREN]; /* -> ( ([0] unused) */
+ sopno pend[NPAREN]; /* -> ) ([0] unused) */
+};
+
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* === regcomp.c === */
+static void p_ere __P((struct parse *p, int stop));
+static void p_ere_exp __P((struct parse *p));
+static void p_str __P((struct parse *p));
+static void p_bre __P((struct parse *p, int end1, int end2));
+static int p_simp_re __P((struct parse *p, int starordinary));
+static int p_count __P((struct parse *p));
+static void p_bracket __P((struct parse *p));
+static void p_b_term __P((struct parse *p, cset *cs));
+static void p_b_cclass __P((struct parse *p, cset *cs));
+static void p_b_eclass __P((struct parse *p, cset *cs));
+static char p_b_symbol __P((struct parse *p));
+static char p_b_coll_elem __P((struct parse *p, int endc));
+static char othercase __P((int ch));
+static void bothcases __P((struct parse *p, int ch));
+static void ordinary __P((struct parse *p, int ch));
+static void nonnewline __P((struct parse *p));
+static void repeat __P((struct parse *p, sopno start, int from, int to));
+static int seterr __P((struct parse *p, int e));
+static cset *allocset __P((struct parse *p));
+static void freeset __P((struct parse *p, cset *cs));
+static int freezeset __P((struct parse *p, cset *cs));
+static int firstch __P((struct parse *p, cset *cs));
+static int nch __P((struct parse *p, cset *cs));
+static void mcadd __P((struct parse *p, cset *cs, const char *cp));
+#if 0
+static void mcsub __P((cset *cs, char *cp));
+static int mcin __P((cset *cs, char *cp));
+static char *mcfind __P((cset *cs, char *cp));
+#endif
+static void mcinvert __P((struct parse *p, cset *cs));
+static void mccase __P((struct parse *p, cset *cs));
+static int isinsets __P((struct re_guts *g, int c));
+static int samesets __P((struct re_guts *g, int c1, int c2));
+static void categorize __P((struct parse *p, struct re_guts *g));
+static sopno dupl __P((struct parse *p, sopno start, sopno finish));
+static void doemit __P((struct parse *p, sop op, sopno opnd));
+static void doinsert __P((struct parse *p, sop op, sopno opnd, sopno pos));
+static void dofwd __P((struct parse *p, sopno pos, sopno value));
+static void enlarge __P((struct parse *p, sopno size));
+static void stripsnug __P((struct parse *p, struct re_guts *g));
+static void findmust __P((struct parse *p, struct re_guts *g));
+static sopno pluscount __P((struct parse *p, struct re_guts *g));
+
+#ifdef __cplusplus
+}
+#endif
+/* ========= end header generated by ./mkh ========= */
+
+static char nuls[10]; /* place to point scanner in event of error */
+
+/*
+ * macros for use with parse structure
+ * BEWARE: these know that the parse structure is named `p' !!!
+ */
+#define PEEK() (*p->next)
+#define PEEK2() (*(p->next+1))
+#define MORE() (p->next < p->end)
+#define MORE2() (p->next+1 < p->end)
+#define SEE(c) (MORE() && PEEK() == (c))
+#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
+#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0)
+#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
+#define NEXT() (p->next++)
+#define NEXT2() (p->next += 2)
+#define NEXTn(n) (p->next += (n))
+#define GETNEXT() (*p->next++)
+#define SETERROR(e) seterr(p, (e))
+#define REQUIRE(co, e) (void) ((co) || SETERROR(e))
+#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e))
+#define MUSTEAT(c, e) (void) (REQUIRE(MORE() && GETNEXT() == (c), e))
+#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e))
+#define EMIT(op, sopnd) doemit(p, (sop)(op), sopnd)
+#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
+#define AHEAD(pos) dofwd(p, pos, HERE()-(pos))
+#define ASTERN(sop, pos) EMIT(sop, HERE()-pos)
+#define HERE() (p->slen)
+#define THERE() (p->slen - 1)
+#define THERETHERE() (p->slen - 2)
+#define DROP(n) (p->slen -= (n))
+
+#ifndef NDEBUG
+static int never = 0; /* for use in asserts; shuts lint up */
+#else
+#define never 0 /* some <assert.h>s have bugs too */
+#endif
+
+/*
+ - regcomp - interface for parser and compilation
+ = extern int regcomp(regex_t *, const char *, int);
+ = #define REG_BASIC 0000
+ = #define REG_EXTENDED 0001
+ = #define REG_ICASE 0002
+ = #define REG_NOSUB 0004
+ = #define REG_NEWLINE 0010
+ = #define REG_NOSPEC 0020
+ = #define REG_PEND 0040
+ = #define REG_DUMP 0200
+ */
+int /* 0 success, otherwise REG_something */
+regcomp(preg, pattern, cflags)
+regex_t *preg;
+const char *pattern;
+int cflags;
+{
+ struct parse pa;
+ struct re_guts *g;
+ struct parse *p = &pa;
+ int i;
+ size_t len;
+#ifdef REDEBUG
+# define GOODFLAGS(f) (f)
+#else
+# define GOODFLAGS(f) ((f)&~REG_DUMP)
+#endif
+
+ _DIAGASSERT(preg != NULL);
+ _DIAGASSERT(pattern != NULL);
+
+ cflags = GOODFLAGS(cflags);
+ if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC))
+ return(REG_INVARG);
+
+ if (cflags&REG_PEND) {
+ if (preg->re_endp < pattern)
+ return(REG_INVARG);
+ len = preg->re_endp - pattern;
+ } else
+ len = strlen(pattern);
+
+ /* do the mallocs early so failure handling is easy */
+ g = (struct re_guts *)malloc(sizeof(struct re_guts) +
+ (NC-1)*sizeof(cat_t));
+ if (g == NULL)
+ return(REG_ESPACE);
+ p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
+ p->strip = (sop *)malloc(p->ssize * sizeof(sop));
+ p->slen = 0;
+ if (p->strip == NULL) {
+ free(g);
+ return(REG_ESPACE);
+ }
+
+ /* set things up */
+ p->g = g;
+ /* LINTED convenience; we do not modify it */
+ p->next = (char *)pattern;
+ p->end = p->next + len;
+ p->error = 0;
+ p->ncsalloc = 0;
+ for (i = 0; i < NPAREN; i++) {
+ p->pbegin[i] = 0;
+ p->pend[i] = 0;
+ }
+ g->csetsize = NC;
+ g->sets = NULL;
+ g->setbits = NULL;
+ g->ncsets = 0;
+ g->cflags = cflags;
+ g->iflags = 0;
+ g->nbol = 0;
+ g->neol = 0;
+ g->must = NULL;
+ g->mlen = 0;
+ g->nsub = 0;
+ g->ncategories = 1; /* category 0 is "everything else" */
+ g->categories = &g->catspace[-(CHAR_MIN)];
+ (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t));
+ g->backrefs = 0;
+
+ /* do it */
+ EMIT(OEND, 0);
+ g->firststate = THERE();
+ if (cflags&REG_EXTENDED)
+ p_ere(p, OUT);
+ else if (cflags&REG_NOSPEC)
+ p_str(p);
+ else
+ p_bre(p, OUT, OUT);
+ EMIT(OEND, 0);
+ g->laststate = THERE();
+
+ /* tidy up loose ends and fill things in */
+ categorize(p, g);
+ stripsnug(p, g);
+ findmust(p, g);
+ g->nplus = pluscount(p, g);
+ g->magic = MAGIC2;
+ preg->re_nsub = g->nsub;
+ preg->re_g = g;
+ preg->re_magic = MAGIC1;
+#ifndef REDEBUG
+ /* not debugging, so can't rely on the assert() in regexec() */
+ if (g->iflags&BAD)
+ SETERROR(REG_ASSERT);
+#endif
+
+ /* win or lose, we're done */
+ if (p->error != 0) /* lose */
+ regfree(preg);
+ return(p->error);
+}
+
+/*
+ - p_ere - ERE parser top level, concatenation and alternation
+ == static void p_ere(struct parse *p, int stop);
+ */
+static void
+p_ere(p, stop)
+struct parse *p;
+int stop; /* character this ERE should end at */
+{
+ char c;
+ sopno prevback = 0; /* pacify gcc */
+ sopno prevfwd = 0; /* pacify gcc */
+ sopno conc;
+ int first = 1; /* is this the first alternative? */
+
+ _DIAGASSERT(p != NULL);
+
+ for (;;) {
+ /* do a bunch of concatenated expressions */
+ conc = HERE();
+ while (MORE() && (c = PEEK()) != '|' && c != stop)
+ p_ere_exp(p);
+ REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */
+
+ if (!EAT('|'))
+ break; /* NOTE BREAK OUT */
+
+ if (first) {
+ INSERT(OCH_, conc); /* offset is wrong */
+ prevfwd = conc;
+ prevback = conc;
+ first = 0;
+ }
+ ASTERN(OOR1, prevback);
+ prevback = THERE();
+ AHEAD(prevfwd); /* fix previous offset */
+ prevfwd = HERE();
+ EMIT(OOR2, 0); /* offset is very wrong */
+ }
+
+ if (!first) { /* tail-end fixups */
+ AHEAD(prevfwd);
+ ASTERN(O_CH, prevback);
+ }
+
+ assert(!MORE() || SEE(stop));
+}
+
+/*
+ - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
+ == static void p_ere_exp(struct parse *p);
+ */
+static void
+p_ere_exp(p)
+struct parse *p;
+{
+ char c;
+ sopno pos;
+ int count;
+ int count2;
+ sopno subno;
+ int wascaret = 0;
+
+ _DIAGASSERT(p != NULL);
+
+ assert(MORE()); /* caller should have ensured this */
+ c = GETNEXT();
+
+ pos = HERE();
+ switch (c) {
+ case '(':
+ REQUIRE(MORE(), REG_EPAREN);
+ p->g->nsub++;
+ subno = p->g->nsub;
+ if (subno < NPAREN)
+ p->pbegin[subno] = HERE();
+ EMIT(OLPAREN, subno);
+ if (!SEE(')'))
+ p_ere(p, ')');
+ if (subno < NPAREN) {
+ p->pend[subno] = HERE();
+ assert(p->pend[subno] != 0);
+ }
+ EMIT(ORPAREN, subno);
+ MUSTEAT(')', REG_EPAREN);
+ break;
+#ifndef POSIX_MISTAKE
+ case ')': /* happens only if no current unmatched ( */
+ /*
+ * You may ask, why the ifndef? Because I didn't notice
+ * this until slightly too late for 1003.2, and none of the
+ * other 1003.2 regular-expression reviewers noticed it at
+ * all. So an unmatched ) is legal POSIX, at least until
+ * we can get it fixed.
+ */
+ SETERROR(REG_EPAREN);
+ break;
+#endif
+ case '^':
+ EMIT(OBOL, 0);
+ p->g->iflags |= USEBOL;
+ p->g->nbol++;
+ wascaret = 1;
+ break;
+ case '$':
+ EMIT(OEOL, 0);
+ p->g->iflags |= USEEOL;
+ p->g->neol++;
+ break;
+ case '|':
+ SETERROR(REG_EMPTY);
+ break;
+ case '*':
+ case '+':
+ case '?':
+ SETERROR(REG_BADRPT);
+ break;
+ case '.':
+ if (p->g->cflags&REG_NEWLINE)
+ nonnewline(p);
+ else
+ EMIT(OANY, 0);
+ break;
+ case '[':
+ p_bracket(p);
+ break;
+ case '\\':
+ REQUIRE(MORE(), REG_EESCAPE);
+ c = GETNEXT();
+ ordinary(p, c);
+ break;
+ case '{': /* okay as ordinary except if digit follows */
+ REQUIRE(!MORE() || !isdigit((unsigned char)PEEK()), REG_BADRPT);
+ /* FALLTHROUGH */
+ default:
+ ordinary(p, c);
+ break;
+ }
+
+ if (!MORE())
+ return;
+ c = PEEK();
+ /* we call { a repetition if followed by a digit */
+ if (!( c == '*' || c == '+' || c == '?' ||
+ (c == '{' && MORE2() && isdigit((unsigned char)PEEK2())) ))
+ return; /* no repetition, we're done */
+ NEXT();
+
+ REQUIRE(!wascaret, REG_BADRPT);
+ switch (c) {
+ case '*': /* implemented as +? */
+ /* this case does not require the (y|) trick, noKLUDGE */
+ INSERT(OPLUS_, pos);
+ ASTERN(O_PLUS, pos);
+ INSERT(OQUEST_, pos);
+ ASTERN(O_QUEST, pos);
+ break;
+ case '+':
+ INSERT(OPLUS_, pos);
+ ASTERN(O_PLUS, pos);
+ break;
+ case '?':
+ /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
+ INSERT(OCH_, pos); /* offset slightly wrong */
+ ASTERN(OOR1, pos); /* this one's right */
+ AHEAD(pos); /* fix the OCH_ */
+ EMIT(OOR2, 0); /* offset very wrong... */
+ AHEAD(THERE()); /* ...so fix it */
+ ASTERN(O_CH, THERETHERE());
+ break;
+ case '{':
+ count = p_count(p);
+ if (EAT(',')) {
+ if (isdigit((unsigned char)PEEK())) {
+ count2 = p_count(p);
+ REQUIRE(count <= count2, REG_BADBR);
+ } else /* single number with comma */
+ count2 = INFINITY;
+ } else /* just a single number */
+ count2 = count;
+ repeat(p, pos, count, count2);
+ if (!EAT('}')) { /* error heuristics */
+ while (MORE() && PEEK() != '}')
+ NEXT();
+ REQUIRE(MORE(), REG_EBRACE);
+ SETERROR(REG_BADBR);
+ }
+ break;
+ }
+
+ if (!MORE())
+ return;
+ c = PEEK();
+ if (!( c == '*' || c == '+' || c == '?' ||
+ (c == '{' && MORE2() && isdigit((unsigned char)PEEK2())) ) )
+ return;
+ SETERROR(REG_BADRPT);
+}
+
+/*
+ - p_str - string (no metacharacters) "parser"
+ == static void p_str(struct parse *p);
+ */
+static void
+p_str(p)
+struct parse *p;
+{
+
+ _DIAGASSERT(p != NULL);
+
+ REQUIRE(MORE(), REG_EMPTY);
+ while (MORE())
+ ordinary(p, GETNEXT());
+}
+
+/*
+ - p_bre - BRE parser top level, anchoring and concatenation
+ == static void p_bre(struct parse *p, int end1, \
+ == int end2);
+ * Giving end1 as OUT essentially eliminates the end1/end2 check.
+ *
+ * This implementation is a bit of a kludge, in that a trailing $ is first
+ * taken as an ordinary character and then revised to be an anchor. The
+ * only undesirable side effect is that '$' gets included as a character
+ * category in such cases. This is fairly harmless; not worth fixing.
+ * The amount of lookahead needed to avoid this kludge is excessive.
+ */
+static void
+p_bre(p, end1, end2)
+struct parse *p;
+int end1; /* first terminating character */
+int end2; /* second terminating character */
+{
+ sopno start;
+ int first = 1; /* first subexpression? */
+ int wasdollar = 0;
+
+ _DIAGASSERT(p != NULL);
+
+ start = HERE();
+
+ if (EAT('^')) {
+ EMIT(OBOL, 0);
+ p->g->iflags |= USEBOL;
+ p->g->nbol++;
+ }
+ while (MORE() && !SEETWO(end1, end2)) {
+ wasdollar = p_simp_re(p, first);
+ first = 0;
+ }
+ if (wasdollar) { /* oops, that was a trailing anchor */
+ DROP(1);
+ EMIT(OEOL, 0);
+ p->g->iflags |= USEEOL;
+ p->g->neol++;
+ }
+
+ REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */
+}
+
+/*
+ - p_simp_re - parse a simple RE, an atom possibly followed by a repetition
+ == static int p_simp_re(struct parse *p, int starordinary);
+ */
+static int /* was the simple RE an unbackslashed $? */
+p_simp_re(p, starordinary)
+struct parse *p;
+int starordinary; /* is a leading * an ordinary character? */
+{
+ int c;
+ int count;
+ int count2;
+ sopno pos;
+ int i;
+ sopno subno;
+# define BACKSL (1<<CHAR_BIT)
+
+ _DIAGASSERT(p != NULL);
+
+ pos = HERE(); /* repetion op, if any, covers from here */
+
+ assert(MORE()); /* caller should have ensured this */
+ c = GETNEXT();
+ if (c == '\\') {
+ REQUIRE(MORE(), REG_EESCAPE);
+ c = BACKSL | (unsigned char)GETNEXT();
+ }
+ switch (c) {
+ case '.':
+ if (p->g->cflags&REG_NEWLINE)
+ nonnewline(p);
+ else
+ EMIT(OANY, 0);
+ break;
+ case '[':
+ p_bracket(p);
+ break;
+ case BACKSL|'{':
+ SETERROR(REG_BADRPT);
+ break;
+ case BACKSL|'(':
+ p->g->nsub++;
+ subno = p->g->nsub;
+ if (subno < NPAREN)
+ p->pbegin[subno] = HERE();
+ EMIT(OLPAREN, subno);
+ /* the MORE here is an error heuristic */
+ if (MORE() && !SEETWO('\\', ')'))
+ p_bre(p, '\\', ')');
+ if (subno < NPAREN) {
+ p->pend[subno] = HERE();
+ assert(p->pend[subno] != 0);
+ }
+ EMIT(ORPAREN, subno);
+ REQUIRE(EATTWO('\\', ')'), REG_EPAREN);
+ break;
+ case BACKSL|')': /* should not get here -- must be user */
+ case BACKSL|'}':
+ SETERROR(REG_EPAREN);
+ break;
+ case BACKSL|'1':
+ case BACKSL|'2':
+ case BACKSL|'3':
+ case BACKSL|'4':
+ case BACKSL|'5':
+ case BACKSL|'6':
+ case BACKSL|'7':
+ case BACKSL|'8':
+ case BACKSL|'9':
+ i = (c&~BACKSL) - '0';
+ assert(i < NPAREN);
+ if (p->pend[i] != 0) {
+ assert(i <= p->g->nsub);
+ EMIT(OBACK_, i);
+ assert(p->pbegin[i] != 0);
+ assert(OP(p->strip[p->pbegin[i]]) == OLPAREN);
+ assert(OP(p->strip[p->pend[i]]) == ORPAREN);
+ (void) dupl(p, p->pbegin[i]+1, p->pend[i]);
+ EMIT(O_BACK, i);
+ } else
+ SETERROR(REG_ESUBREG);
+ p->g->backrefs = 1;
+ break;
+ case '*':
+ REQUIRE(starordinary, REG_BADRPT);
+ /* FALLTHROUGH */
+ default:
+ ordinary(p, c &~ BACKSL);
+ break;
+ }
+
+ if (EAT('*')) { /* implemented as +? */
+ /* this case does not require the (y|) trick, noKLUDGE */
+ INSERT(OPLUS_, pos);
+ ASTERN(O_PLUS, pos);
+ INSERT(OQUEST_, pos);
+ ASTERN(O_QUEST, pos);
+ } else if (EATTWO('\\', '{')) {
+ count = p_count(p);
+ if (EAT(',')) {
+ if (MORE() && isdigit((unsigned char)PEEK())) {
+ count2 = p_count(p);
+ REQUIRE(count <= count2, REG_BADBR);
+ } else /* single number with comma */
+ count2 = INFINITY;
+ } else /* just a single number */
+ count2 = count;
+ repeat(p, pos, count, count2);
+ if (!EATTWO('\\', '}')) { /* error heuristics */
+ while (MORE() && !SEETWO('\\', '}'))
+ NEXT();
+ REQUIRE(MORE(), REG_EBRACE);
+ SETERROR(REG_BADBR);
+ }
+ } else if (c == (unsigned char)'$') /* $ (but not \$) ends it */
+ return(1);
+
+ return(0);
+}
+
+/*
+ - p_count - parse a repetition count
+ == static int p_count(struct parse *p);
+ */
+static int /* the value */
+p_count(p)
+struct parse *p;
+{
+ int count = 0;
+ int ndigits = 0;
+
+ _DIAGASSERT(p != NULL);
+
+ while (MORE() && isdigit((unsigned char)PEEK()) && count <= DUPMAX) {
+ count = count*10 + (GETNEXT() - '0');
+ ndigits++;
+ }
+
+ REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR);
+ return(count);
+}
+
+/*
+ - p_bracket - parse a bracketed character list
+ == static void p_bracket(struct parse *p);
+ *
+ * Note a significant property of this code: if the allocset() did SETERROR,
+ * no set operations are done.
+ */
+static void
+p_bracket(p)
+struct parse *p;
+{
+ cset *cs;
+ int invert = 0;
+
+ _DIAGASSERT(p != NULL);
+
+ cs = allocset(p);
+
+ /* Dept of Truly Sickening Special-Case Kludges */
+ if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]",
+ (size_t)6) == 0) {
+ EMIT(OBOW, 0);
+ NEXTn(6);
+ return;
+ }
+ if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]",
+ (size_t)6) == 0) {
+ EMIT(OEOW, 0);
+ NEXTn(6);
+ return;
+ }
+
+ if (EAT('^'))
+ invert++; /* make note to invert set at end */
+ if (EAT(']'))
+ CHadd(cs, ']');
+ else if (EAT('-'))
+ CHadd(cs, '-');
+ while (MORE() && PEEK() != ']' && !SEETWO('-', ']'))
+ p_b_term(p, cs);
+ if (EAT('-'))
+ CHadd(cs, '-');
+ MUSTEAT(']', REG_EBRACK);
+
+ if (p->error != 0) /* don't mess things up further */
+ return;
+
+ if (p->g->cflags&REG_ICASE) {
+ int i;
+ int ci;
+
+ for (i = p->g->csetsize - 1; i >= 0; i--)
+ if (CHIN(cs, i) && isalpha(i)) {
+ ci = othercase(i);
+ if (ci != i)
+ CHadd(cs, ci);
+ }
+ if (cs->multis != NULL)
+ mccase(p, cs);
+ }
+ if (invert) {
+ int i;
+
+ for (i = p->g->csetsize - 1; i >= 0; i--)
+ if (CHIN(cs, i))
+ CHsub(cs, i);
+ else
+ CHadd(cs, i);
+ if (p->g->cflags&REG_NEWLINE)
+ CHsub(cs, '\n');
+ if (cs->multis != NULL)
+ mcinvert(p, cs);
+ }
+
+ assert(cs->multis == NULL); /* xxx */
+
+ if (nch(p, cs) == 1) { /* optimize singleton sets */
+ ordinary(p, firstch(p, cs));
+ freeset(p, cs);
+ } else
+ EMIT(OANYOF, freezeset(p, cs));
+}
+
+/*
+ - p_b_term - parse one term of a bracketed character list
+ == static void p_b_term(struct parse *p, cset *cs);
+ */
+static void
+p_b_term(p, cs)
+struct parse *p;
+cset *cs;
+{
+ char c;
+ char start, finish;
+ int i;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ /* classify what we've got */
+ switch ((MORE()) ? PEEK() : '\0') {
+ case '[':
+ c = (MORE2()) ? PEEK2() : '\0';
+ break;
+
+ case '-':
+ SETERROR(REG_ERANGE);
+ return; /* NOTE RETURN */
+
+ default:
+ c = '\0';
+ break;
+ }
+
+ switch (c) {
+ case ':': /* character class */
+ NEXT2();
+ REQUIRE(MORE(), REG_EBRACK);
+ c = PEEK();
+ REQUIRE(c != '-' && c != ']', REG_ECTYPE);
+ p_b_cclass(p, cs);
+ REQUIRE(MORE(), REG_EBRACK);
+ REQUIRE(EATTWO(':', ']'), REG_ECTYPE);
+ break;
+ case '=': /* equivalence class */
+ NEXT2();
+ REQUIRE(MORE(), REG_EBRACK);
+ c = PEEK();
+ REQUIRE(c != '-' && c != ']', REG_ECOLLATE);
+ p_b_eclass(p, cs);
+ REQUIRE(MORE(), REG_EBRACK);
+ REQUIRE(EATTWO('=', ']'), REG_ECOLLATE);
+ break;
+ default: /* symbol, ordinary character, or range */
+/* xxx revision needed for multichar stuff */
+ start = p_b_symbol(p);
+ if (SEE('-') && MORE2() && PEEK2() != ']') {
+ /* range */
+ NEXT();
+ if (EAT('-'))
+ finish = '-';
+ else
+ finish = p_b_symbol(p);
+ } else
+ finish = start;
+/* xxx what about signed chars here... */
+ REQUIRE(start <= finish, REG_ERANGE);
+ for (i = start; i <= finish; i++)
+ CHadd(cs, i);
+ break;
+ }
+}
+
+/*
+ - p_b_cclass - parse a character-class name and deal with it
+ == static void p_b_cclass(struct parse *p, cset *cs);
+ */
+static void
+p_b_cclass(p, cs)
+struct parse *p;
+cset *cs;
+{
+ char *sp;
+ const struct cclass *cp;
+ size_t len;
+ const char *u;
+ char c;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ sp = p->next;
+
+ while (MORE() && isalpha((unsigned char)PEEK()))
+ NEXT();
+ len = p->next - sp;
+ for (cp = cclasses; cp->name != NULL; cp++)
+ if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
+ break;
+ if (cp->name == NULL) {
+ /* oops, didn't find it */
+ SETERROR(REG_ECTYPE);
+ return;
+ }
+
+ u = cp->chars;
+ while ((c = *u++) != '\0')
+ CHadd(cs, c);
+ for (u = cp->multis; *u != '\0'; u += strlen(u) + 1)
+ MCadd(p, cs, u);
+}
+
+/*
+ - p_b_eclass - parse an equivalence-class name and deal with it
+ == static void p_b_eclass(struct parse *p, cset *cs);
+ *
+ * This implementation is incomplete. xxx
+ */
+static void
+p_b_eclass(p, cs)
+struct parse *p;
+cset *cs;
+{
+ char c;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ c = p_b_coll_elem(p, '=');
+ CHadd(cs, c);
+}
+
+/*
+ - p_b_symbol - parse a character or [..]ed multicharacter collating symbol
+ == static char p_b_symbol(struct parse *p);
+ */
+static char /* value of symbol */
+p_b_symbol(p)
+struct parse *p;
+{
+ char value;
+
+ _DIAGASSERT(p != NULL);
+
+ REQUIRE(MORE(), REG_EBRACK);
+ if (!EATTWO('[', '.'))
+ return(GETNEXT());
+
+ /* collating symbol */
+ value = p_b_coll_elem(p, '.');
+ REQUIRE(EATTWO('.', ']'), REG_ECOLLATE);
+ return(value);
+}
+
+/*
+ - p_b_coll_elem - parse a collating-element name and look it up
+ == static char p_b_coll_elem(struct parse *p, int endc);
+ */
+static char /* value of collating element */
+p_b_coll_elem(p, endc)
+struct parse *p;
+int endc; /* name ended by endc,']' */
+{
+ char *sp;
+ const struct cname *cp;
+ size_t len;
+
+ _DIAGASSERT(p != NULL);
+
+ sp = p->next;
+
+ while (MORE() && !SEETWO(endc, ']'))
+ NEXT();
+ if (!MORE()) {
+ SETERROR(REG_EBRACK);
+ return(0);
+ }
+ len = p->next - sp;
+ for (cp = cnames; cp->name != NULL; cp++)
+ if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
+ return(cp->code); /* known name */
+ if (len == 1)
+ return(*sp); /* single character */
+ SETERROR(REG_ECOLLATE); /* neither */
+ return(0);
+}
+
+/*
+ - othercase - return the case counterpart of an alphabetic
+ == static char othercase(int ch);
+ */
+static char /* if no counterpart, return ch */
+othercase(ch)
+int ch;
+{
+ assert(isalpha(ch));
+ if (isupper(ch))
+ return(tolower(ch));
+ else if (islower(ch))
+ return(toupper(ch));
+ else /* peculiar, but could happen */
+ return(ch);
+}
+
+/*
+ - bothcases - emit a dualcase version of a two-case character
+ == static void bothcases(struct parse *p, int ch);
+ *
+ * Boy, is this implementation ever a kludge...
+ */
+static void
+bothcases(p, ch)
+struct parse *p;
+int ch;
+{
+ char *oldnext;
+ char *oldend;
+ char bracket[3];
+
+ _DIAGASSERT(p != NULL);
+
+ oldnext = p->next;
+ oldend = p->end;
+
+ assert(othercase(ch) != ch); /* p_bracket() would recurse */
+ p->next = bracket;
+ p->end = bracket+2;
+ bracket[0] = ch;
+ bracket[1] = ']';
+ bracket[2] = '\0';
+ p_bracket(p);
+ assert(p->next == bracket+2);
+ p->next = oldnext;
+ p->end = oldend;
+}
+
+/*
+ - ordinary - emit an ordinary character
+ == static void ordinary(struct parse *p, int ch);
+ */
+static void
+ordinary(p, ch)
+struct parse *p;
+int ch;
+{
+ cat_t *cap;
+
+ _DIAGASSERT(p != NULL);
+
+ cap = p->g->categories;
+ if ((p->g->cflags&REG_ICASE) && isalpha((unsigned char) ch)
+ && othercase((unsigned char) ch) != (unsigned char) ch)
+ bothcases(p, (unsigned char) ch);
+ else {
+ EMIT(OCHAR, (unsigned char)ch);
+ if (cap[ch] == 0)
+ cap[ch] = p->g->ncategories++;
+ }
+}
+
+/*
+ - nonnewline - emit REG_NEWLINE version of OANY
+ == static void nonnewline(struct parse *p);
+ *
+ * Boy, is this implementation ever a kludge...
+ */
+static void
+nonnewline(p)
+struct parse *p;
+{
+ char *oldnext;
+ char *oldend;
+ char bracket[4];
+
+ _DIAGASSERT(p != NULL);
+
+ oldnext = p->next;
+ oldend = p->end;
+
+ p->next = bracket;
+ p->end = bracket+3;
+ bracket[0] = '^';
+ bracket[1] = '\n';
+ bracket[2] = ']';
+ bracket[3] = '\0';
+ p_bracket(p);
+ assert(p->next == bracket+3);
+ p->next = oldnext;
+ p->end = oldend;
+}
+
+/*
+ - repeat - generate code for a bounded repetition, recursively if needed
+ == static void repeat(struct parse *p, sopno start, int from, int to);
+ */
+static void
+repeat(p, start, from, to)
+struct parse *p;
+sopno start; /* operand from here to end of strip */
+int from; /* repeated from this number */
+int to; /* to this number of times (maybe INFINITY) */
+{
+ sopno finish;
+# define N 2
+# define INF 3
+# define REP(f, t) ((f)*8 + (t))
+# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N)
+ sopno copy;
+
+ _DIAGASSERT(p != NULL);
+
+ finish = HERE();
+
+ if (p->error != 0) /* head off possible runaway recursion */
+ return;
+
+ assert(from <= to);
+
+ switch (REP(MAP(from), MAP(to))) {
+ case REP(0, 0): /* must be user doing this */
+ DROP(finish-start); /* drop the operand */
+ break;
+ case REP(0, 1): /* as x{1,1}? */
+ case REP(0, N): /* as x{1,n}? */
+ case REP(0, INF): /* as x{1,}? */
+ /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
+ INSERT(OCH_, start); /* offset is wrong... */
+ repeat(p, start+1, 1, to);
+ ASTERN(OOR1, start);
+ AHEAD(start); /* ... fix it */
+ EMIT(OOR2, 0);
+ AHEAD(THERE());
+ ASTERN(O_CH, THERETHERE());
+ break;
+ case REP(1, 1): /* trivial case */
+ /* done */
+ break;
+ case REP(1, N): /* as x?x{1,n-1} */
+ /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
+ INSERT(OCH_, start);
+ ASTERN(OOR1, start);
+ AHEAD(start);
+ EMIT(OOR2, 0); /* offset very wrong... */
+ AHEAD(THERE()); /* ...so fix it */
+ ASTERN(O_CH, THERETHERE());
+ copy = dupl(p, start+1, finish+1);
+ assert(copy == finish+4);
+ repeat(p, copy, 1, to-1);
+ break;
+ case REP(1, INF): /* as x+ */
+ INSERT(OPLUS_, start);
+ ASTERN(O_PLUS, start);
+ break;
+ case REP(N, N): /* as xx{m-1,n-1} */
+ copy = dupl(p, start, finish);
+ repeat(p, copy, from-1, to-1);
+ break;
+ case REP(N, INF): /* as xx{n-1,INF} */
+ copy = dupl(p, start, finish);
+ repeat(p, copy, from-1, to);
+ break;
+ default: /* "can't happen" */
+ SETERROR(REG_ASSERT); /* just in case */
+ break;
+ }
+}
+
+/*
+ - seterr - set an error condition
+ == static int seterr(struct parse *p, int e);
+ */
+static int /* useless but makes type checking happy */
+seterr(p, e)
+struct parse *p;
+int e;
+{
+
+ _DIAGASSERT(p != NULL);
+
+ if (p->error == 0) /* keep earliest error condition */
+ p->error = e;
+ p->next = nuls; /* try to bring things to a halt */
+ p->end = nuls;
+ return(0); /* make the return value well-defined */
+}
+
+/*
+ - allocset - allocate a set of characters for []
+ == static cset *allocset(struct parse *p);
+ */
+static cset *
+allocset(p)
+struct parse *p;
+{
+ int no;
+ size_t nc;
+ size_t nbytes;
+ cset *cs;
+ size_t css;
+ int i;
+
+ _DIAGASSERT(p != NULL);
+
+ no = p->g->ncsets++;
+ css = (size_t)p->g->csetsize;
+ if (no >= p->ncsalloc) { /* need another column of space */
+ p->ncsalloc += CHAR_BIT;
+ nc = p->ncsalloc;
+ assert(nc % CHAR_BIT == 0);
+ nbytes = nc / CHAR_BIT * css;
+ if (p->g->sets == NULL)
+ p->g->sets = malloc(nc * sizeof(cset));
+ else
+ p->g->sets = realloc(p->g->sets, nc * sizeof(cset));
+ if (p->g->setbits == NULL)
+ p->g->setbits = malloc(nbytes);
+ else {
+ p->g->setbits = realloc(p->g->setbits, nbytes);
+ /* xxx this isn't right if setbits is now NULL */
+ for (i = 0; i < no; i++)
+ p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT);
+ }
+ if (p->g->sets != NULL && p->g->setbits != NULL)
+ (void) memset((char *)p->g->setbits + (nbytes - css),
+ 0, css);
+ else {
+ no = 0;
+ SETERROR(REG_ESPACE);
+ /* caller's responsibility not to do set ops */
+ }
+ }
+
+ assert(p->g->sets != NULL); /* xxx */
+ cs = &p->g->sets[no];
+ cs->ptr = p->g->setbits + css*((no)/CHAR_BIT);
+ cs->mask = 1 << ((no) % CHAR_BIT);
+ cs->hash = 0;
+ cs->smultis = 0;
+ cs->multis = NULL;
+
+ return(cs);
+}
+
+/*
+ - freeset - free a now-unused set
+ == static void freeset(struct parse *p, cset *cs);
+ */
+static void
+freeset(p, cs)
+struct parse *p;
+cset *cs;
+{
+ int i;
+ cset *top;
+ size_t css;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ top = &p->g->sets[p->g->ncsets];
+ css = (size_t)p->g->csetsize;
+
+ for (i = 0; i < css; i++)
+ CHsub(cs, i);
+ if (cs == top-1) /* recover only the easy case */
+ p->g->ncsets--;
+}
+
+/*
+ - freezeset - final processing on a set of characters
+ == static int freezeset(struct parse *p, cset *cs);
+ *
+ * The main task here is merging identical sets. This is usually a waste
+ * of time (although the hash code minimizes the overhead), but can win
+ * big if REG_ICASE is being used. REG_ICASE, by the way, is why the hash
+ * is done using addition rather than xor -- all ASCII [aA] sets xor to
+ * the same value!
+ */
+static int /* set number */
+freezeset(p, cs)
+struct parse *p;
+cset *cs;
+{
+ uch h;
+ int i;
+ cset *top;
+ cset *cs2;
+ size_t css;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ h = cs->hash;
+ top = &p->g->sets[p->g->ncsets];
+ css = (size_t)p->g->csetsize;
+
+ /* look for an earlier one which is the same */
+ for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
+ if (cs2->hash == h && cs2 != cs) {
+ /* maybe */
+ for (i = 0; i < css; i++)
+ if (!!CHIN(cs2, i) != !!CHIN(cs, i))
+ break; /* no */
+ if (i == css)
+ break; /* yes */
+ }
+
+ if (cs2 < top) { /* found one */
+ freeset(p, cs);
+ cs = cs2;
+ }
+
+ return((int)(cs - p->g->sets));
+}
+
+/*
+ - firstch - return first character in a set (which must have at least one)
+ == static int firstch(struct parse *p, cset *cs);
+ */
+static int /* character; there is no "none" value */
+firstch(p, cs)
+struct parse *p;
+cset *cs;
+{
+ int i;
+ size_t css;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ css = (size_t)p->g->csetsize;
+
+ for (i = 0; i < css; i++)
+ if (CHIN(cs, i))
+ return((char)i);
+ assert(never);
+ return(0); /* arbitrary */
+}
+
+/*
+ - nch - number of characters in a set
+ == static int nch(struct parse *p, cset *cs);
+ */
+static int
+nch(p, cs)
+struct parse *p;
+cset *cs;
+{
+ int i;
+ size_t css;
+ int n = 0;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ css = (size_t)p->g->csetsize;
+
+ for (i = 0; i < css; i++)
+ if (CHIN(cs, i))
+ n++;
+ return(n);
+}
+
+/*
+ - mcadd - add a collating element to a cset
+ == static void mcadd(struct parse *p, cset *cs, \
+ == char *cp);
+ */
+static void
+mcadd(p, cs, cp)
+struct parse *p;
+cset *cs;
+const char *cp;
+{
+ size_t oldend;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+ _DIAGASSERT(cp != NULL);
+
+ oldend = cs->smultis;
+
+ cs->smultis += strlen(cp) + 1;
+ if (cs->multis == NULL)
+ cs->multis = malloc(cs->smultis);
+ else
+ cs->multis = realloc(cs->multis, cs->smultis);
+ if (cs->multis == NULL) {
+ SETERROR(REG_ESPACE);
+ return;
+ }
+
+ (void) strcpy(cs->multis + oldend - 1, cp);
+ cs->multis[cs->smultis - 1] = '\0';
+}
+
+#if 0
+/*
+ - mcsub - subtract a collating element from a cset
+ == static void mcsub(cset *cs, char *cp);
+ */
+static void
+mcsub(cs, cp)
+cset *cs;
+char *cp;
+{
+ char *fp;
+ size_t len;
+
+ _DIAGASSERT(cs != NULL);
+ _DIAGASSERT(cp != NULL);
+
+ fp = mcfind(cs, cp);
+ len = strlen(fp);
+
+ assert(fp != NULL);
+ (void) memmove(fp, fp + len + 1,
+ cs->smultis - (fp + len + 1 - cs->multis));
+ cs->smultis -= len;
+
+ if (cs->smultis == 0) {
+ free(cs->multis);
+ cs->multis = NULL;
+ return;
+ }
+
+ cs->multis = realloc(cs->multis, cs->smultis);
+ assert(cs->multis != NULL);
+}
+
+/*
+ - mcin - is a collating element in a cset?
+ == static int mcin(cset *cs, char *cp);
+ */
+static int
+mcin(cs, cp)
+cset *cs;
+char *cp;
+{
+
+ _DIAGASSERT(cs != NULL);
+ _DIAGASSERT(cp != NULL);
+
+ return(mcfind(cs, cp) != NULL);
+}
+
+/*
+ - mcfind - find a collating element in a cset
+ == static char *mcfind(cset *cs, char *cp);
+ */
+static char *
+mcfind(cs, cp)
+cset *cs;
+char *cp;
+{
+ char *p;
+
+ _DIAGASSERT(cs != NULL);
+ _DIAGASSERT(cp != NULL);
+
+ if (cs->multis == NULL)
+ return(NULL);
+ for (p = cs->multis; *p != '\0'; p += strlen(p) + 1)
+ if (strcmp(cp, p) == 0)
+ return(p);
+ return(NULL);
+}
+#endif
+
+/*
+ - mcinvert - invert the list of collating elements in a cset
+ == static void mcinvert(struct parse *p, cset *cs);
+ *
+ * This would have to know the set of possibilities. Implementation
+ * is deferred.
+ */
+/* ARGSUSED */
+static void
+mcinvert(p, cs)
+struct parse *p;
+cset *cs;
+{
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ assert(cs->multis == NULL); /* xxx */
+}
+
+/*
+ - mccase - add case counterparts of the list of collating elements in a cset
+ == static void mccase(struct parse *p, cset *cs);
+ *
+ * This would have to know the set of possibilities. Implementation
+ * is deferred.
+ */
+/* ARGSUSED */
+static void
+mccase(p, cs)
+struct parse *p;
+cset *cs;
+{
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(cs != NULL);
+
+ assert(cs->multis == NULL); /* xxx */
+}
+
+/*
+ - isinsets - is this character in any sets?
+ == static int isinsets(struct re_guts *g, int c);
+ */
+static int /* predicate */
+isinsets(g, c)
+struct re_guts *g;
+int c;
+{
+ uch *col;
+ int i;
+ int ncols;
+ unsigned uc = (unsigned char)c;
+
+ _DIAGASSERT(g != NULL);
+
+ ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
+
+ for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
+ if (col[uc] != 0)
+ return(1);
+ return(0);
+}
+
+/*
+ - samesets - are these two characters in exactly the same sets?
+ == static int samesets(struct re_guts *g, int c1, int c2);
+ */
+static int /* predicate */
+samesets(g, c1, c2)
+struct re_guts *g;
+int c1;
+int c2;
+{
+ uch *col;
+ int i;
+ int ncols;
+ unsigned uc1 = (unsigned char)c1;
+ unsigned uc2 = (unsigned char)c2;
+
+ _DIAGASSERT(g != NULL);
+
+ ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
+
+ for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
+ if (col[uc1] != col[uc2])
+ return(0);
+ return(1);
+}
+
+/*
+ - categorize - sort out character categories
+ == static void categorize(struct parse *p, struct re_guts *g);
+ */
+static void
+categorize(p, g)
+struct parse *p;
+struct re_guts *g;
+{
+ cat_t *cats;
+ int c;
+ int c2;
+ cat_t cat;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(g != NULL);
+
+ cats = g->categories;
+
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ for (c = CHAR_MIN; c <= CHAR_MAX; c++)
+ if (cats[c] == 0 && isinsets(g, c)) {
+ cat = g->ncategories++;
+ cats[c] = cat;
+ for (c2 = c+1; c2 <= CHAR_MAX; c2++)
+ if (cats[c2] == 0 && samesets(g, c, c2))
+ cats[c2] = cat;
+ }
+}
+
+/*
+ - dupl - emit a duplicate of a bunch of sops
+ == static sopno dupl(struct parse *p, sopno start, sopno finish);
+ */
+static sopno /* start of duplicate */
+dupl(p, start, finish)
+struct parse *p;
+sopno start; /* from here */
+sopno finish; /* to this less one */
+{
+ sopno ret;
+ sopno len = finish - start;
+
+ _DIAGASSERT(p != NULL);
+
+ ret = HERE();
+
+ assert(finish >= start);
+ if (len == 0)
+ return(ret);
+ enlarge(p, p->ssize + len); /* this many unexpected additions */
+ assert(p->ssize >= p->slen + len);
+ (void)memcpy(p->strip + p->slen, p->strip + start,
+ (size_t)len * sizeof(sop));
+ p->slen += len;
+ return(ret);
+}
+
+/*
+ - doemit - emit a strip operator
+ == static void doemit(struct parse *p, sop op, size_t opnd);
+ *
+ * It might seem better to implement this as a macro with a function as
+ * hard-case backup, but it's just too big and messy unless there are
+ * some changes to the data structures. Maybe later.
+ */
+static void
+doemit(p, op, opnd)
+struct parse *p;
+sop op;
+sopno opnd;
+{
+
+ _DIAGASSERT(p != NULL);
+
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ /* deal with oversize operands ("can't happen", more or less) */
+ assert(opnd < 1<<OPSHIFT);
+
+ /* deal with undersized strip */
+ if (p->slen >= p->ssize)
+ enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */
+ assert(p->slen < p->ssize);
+
+ /* finally, it's all reduced to the easy case */
+ p->strip[p->slen++] = SOP(op, opnd);
+}
+
+/*
+ - doinsert - insert a sop into the strip
+ == static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos);
+ */
+static void
+doinsert(p, op, opnd, pos)
+struct parse *p;
+sop op;
+sopno opnd;
+sopno pos;
+{
+ sopno sn;
+ sop s;
+ int i;
+
+ _DIAGASSERT(p != NULL);
+
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ sn = HERE();
+ EMIT(op, opnd); /* do checks, ensure space */
+ assert(HERE() == sn+1);
+ s = p->strip[sn];
+
+ /* adjust paren pointers */
+ assert(pos > 0);
+ for (i = 1; i < NPAREN; i++) {
+ if (p->pbegin[i] >= pos) {
+ p->pbegin[i]++;
+ }
+ if (p->pend[i] >= pos) {
+ p->pend[i]++;
+ }
+ }
+
+ memmove(&p->strip[pos+1], &p->strip[pos], (HERE()-pos-1)*sizeof(sop));
+ p->strip[pos] = s;
+}
+
+/*
+ - dofwd - complete a forward reference
+ == static void dofwd(struct parse *p, sopno pos, sop value);
+ */
+static void
+dofwd(p, pos, value)
+struct parse *p;
+sopno pos;
+sopno value;
+{
+
+ _DIAGASSERT(p != NULL);
+
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ assert(value < 1<<OPSHIFT);
+ p->strip[pos] = OP(p->strip[pos]) | value;
+}
+
+/*
+ - enlarge - enlarge the strip
+ == static void enlarge(struct parse *p, sopno size);
+ */
+static void
+enlarge(p, size)
+struct parse *p;
+sopno size;
+{
+ sop *sp;
+
+ _DIAGASSERT(p != NULL);
+
+ if (p->ssize >= size)
+ return;
+
+ sp = (sop *)realloc(p->strip, size*sizeof(sop));
+ if (sp == NULL) {
+ SETERROR(REG_ESPACE);
+ return;
+ }
+ p->strip = sp;
+ p->ssize = size;
+}
+
+/*
+ - stripsnug - compact the strip
+ == static void stripsnug(struct parse *p, struct re_guts *g);
+ */
+static void
+stripsnug(p, g)
+struct parse *p;
+struct re_guts *g;
+{
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(g != NULL);
+
+ g->nstates = p->slen;
+ g->strip = realloc(p->strip, p->slen * sizeof(sop));
+ if (g->strip == NULL) {
+ SETERROR(REG_ESPACE);
+ g->strip = p->strip;
+ }
+}
+
+/*
+ - findmust - fill in must and mlen with longest mandatory literal string
+ == static void findmust(struct parse *p, struct re_guts *g);
+ *
+ * This algorithm could do fancy things like analyzing the operands of |
+ * for common subsequences. Someday. This code is simple and finds most
+ * of the interesting cases.
+ *
+ * Note that must and mlen got initialized during setup.
+ */
+static void
+findmust(p, g)
+struct parse *p;
+struct re_guts *g;
+{
+ sop *scan;
+ sop *start = NULL;
+ sop *newstart = NULL;
+ sopno newlen;
+ sop s;
+ char *cp;
+ sopno i;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(g != NULL);
+
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ /* find the longest OCHAR sequence in strip */
+ newlen = 0;
+ scan = g->strip + 1;
+ do {
+ s = *scan++;
+ switch (OP(s)) {
+ case OCHAR: /* sequence member */
+ if (newlen == 0) /* new sequence */
+ newstart = scan - 1;
+ newlen++;
+ break;
+ case OPLUS_: /* things that don't break one */
+ case OLPAREN:
+ case ORPAREN:
+ break;
+ case OQUEST_: /* things that must be skipped */
+ case OCH_:
+ scan--;
+ do {
+ scan += OPND(s);
+ s = *scan;
+ /* assert() interferes w debug printouts */
+ if (OP(s) != O_QUEST && OP(s) != O_CH &&
+ OP(s) != OOR2) {
+ g->iflags |= BAD;
+ return;
+ }
+ } while (OP(s) != O_QUEST && OP(s) != O_CH);
+ /* FALLTHROUGH */
+ default: /* things that break a sequence */
+ if (newlen > g->mlen) { /* ends one */
+ start = newstart;
+ g->mlen = newlen;
+ }
+ newlen = 0;
+ break;
+ }
+ } while (OP(s) != OEND);
+
+ if (g->mlen == 0) /* there isn't one */
+ return;
+
+ /* turn it into a character string */
+ g->must = malloc((size_t)g->mlen + 1);
+ if (g->must == NULL) { /* argh; just forget it */
+ g->mlen = 0;
+ return;
+ }
+ cp = g->must;
+ scan = start;
+ for (i = g->mlen; i > 0; i--) {
+ while (OP(s = *scan++) != OCHAR)
+ continue;
+ assert(cp < g->must + g->mlen);
+ *cp++ = (char)OPND(s);
+ }
+ assert(cp == g->must + g->mlen);
+ *cp++ = '\0'; /* just on general principles */
+}
+
+/*
+ - pluscount - count + nesting
+ == static sopno pluscount(struct parse *p, struct re_guts *g);
+ */
+static sopno /* nesting depth */
+pluscount(p, g)
+struct parse *p;
+struct re_guts *g;
+{
+ sop *scan;
+ sop s;
+ sopno plusnest = 0;
+ sopno maxnest = 0;
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(g != NULL);
+
+ if (p->error != 0)
+ return(0); /* there may not be an OEND */
+
+ scan = g->strip + 1;
+ do {
+ s = *scan++;
+ switch (OP(s)) {
+ case OPLUS_:
+ plusnest++;
+ break;
+ case O_PLUS:
+ if (plusnest > maxnest)
+ maxnest = plusnest;
+ plusnest--;
+ break;
+ }
+ } while (OP(s) != OEND);
+ if (plusnest != 0)
+ g->iflags |= BAD;
+ return(maxnest);
+}
diff --git a/pkgtools/libnbcompat/files/regerror.c b/pkgtools/libnbcompat/files/regerror.c
new file mode 100644
index 00000000000..009bf91b474
--- /dev/null
+++ b/pkgtools/libnbcompat/files/regerror.c
@@ -0,0 +1,248 @@
+/* $NetBSD: regerror.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)regerror.c 8.4 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)regerror.c 8.4 (Berkeley) 3/20/94
+ */
+
+#include "nbcompat.h"
+
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94";
+#else
+__RCSID("$NetBSD: regerror.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* #include "namespace.h" */
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_ASSERT_H
+#include <assert.h>
+#endif
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#if HAVE_REGEX_H
+#include <regex.h>
+#endif
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(regerror,_regerror)
+#endif
+#endif
+
+#include "utils.h"
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* === regerror.c === */
+static char *regatoi __P((const regex_t *preg, char *localbuf, size_t buflen));
+
+#ifdef __cplusplus
+}
+#endif
+/* ========= end header generated by ./mkh ========= */
+/*
+ = #define REG_NOMATCH 1
+ = #define REG_BADPAT 2
+ = #define REG_ECOLLATE 3
+ = #define REG_ECTYPE 4
+ = #define REG_EESCAPE 5
+ = #define REG_ESUBREG 6
+ = #define REG_EBRACK 7
+ = #define REG_EPAREN 8
+ = #define REG_EBRACE 9
+ = #define REG_BADBR 10
+ = #define REG_ERANGE 11
+ = #define REG_ESPACE 12
+ = #define REG_BADRPT 13
+ = #define REG_EMPTY 14
+ = #define REG_ASSERT 15
+ = #define REG_INVARG 16
+ = #define REG_ATOI 255 // convert name to number (!)
+ = #define REG_ITOA 0400 // convert number to name (!)
+ */
+static const struct rerr {
+ int code;
+ const char *name;
+ const char *explain;
+} rerrs[] = {
+ { REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match" },
+ { REG_BADPAT, "REG_BADPAT", "invalid regular expression" },
+ { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" },
+ { REG_ECTYPE, "REG_ECTYPE", "invalid character class" },
+ { REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)" },
+ { REG_ESUBREG, "REG_ESUBREG", "invalid backreference number" },
+ { REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced" },
+ { REG_EPAREN, "REG_EPAREN", "parentheses not balanced" },
+ { REG_EBRACE, "REG_EBRACE", "braces not balanced" },
+ { REG_BADBR, "REG_BADBR", "invalid repetition count(s)" },
+ { REG_ERANGE, "REG_ERANGE", "invalid character range" },
+ { REG_ESPACE, "REG_ESPACE", "out of memory" },
+ { REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid" },
+ { REG_EMPTY, "REG_EMPTY", "empty (sub)expression" },
+ { REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug" },
+ { REG_INVARG, "REG_INVARG", "invalid argument to regex routine" },
+ { 0, "", "*** unknown regexp error code ***" }
+};
+
+/*
+ * regerror - the interface to error numbers
+ * extern size_t regerror(int, const regex_t *, char *, size_t);
+ */
+/* ARGSUSED */
+size_t
+regerror(errcode, preg, errbuf, errbuf_size)
+int errcode;
+const regex_t *preg;
+char *errbuf;
+size_t errbuf_size;
+{
+ const struct rerr *r;
+ size_t len;
+ int target = errcode &~ REG_ITOA;
+ const char *s;
+ char convbuf[50];
+
+ _DIAGASSERT(errcode != REG_ATOI || preg != NULL);
+ _DIAGASSERT(errbuf != NULL);
+
+ if (errcode == REG_ATOI)
+ s = regatoi(preg, convbuf, sizeof convbuf);
+ else {
+ for (r = rerrs; r->code != 0; r++)
+ if (r->code == target)
+ break;
+
+ if (errcode & REG_ITOA) {
+ if (r->code != 0) {
+ (void)strlcpy(convbuf, r->name, sizeof convbuf);
+ } else
+ (void)snprintf(convbuf, sizeof convbuf,
+ "REG_0x%x", target);
+ s = convbuf;
+ } else
+ s = r->explain;
+ }
+
+ len = strlen(s) + 1;
+ if (errbuf_size > 0)
+ (void)strlcpy(errbuf, s, errbuf_size);
+
+ return(len);
+}
+
+/*
+ * regatoi - internal routine to implement REG_ATOI
+ * static char *regatoi(const regex_t *preg, char *localbuf, size_t buflen);
+ */
+static char *
+regatoi(preg, localbuf, buflen)
+const regex_t *preg;
+char *localbuf;
+size_t buflen;
+{
+ const struct rerr *r;
+
+ for (r = rerrs; r->code != 0; r++)
+ if (strcmp(r->name, preg->re_endp) == 0)
+ break;
+ if (r->code == 0)
+ return("0");
+
+ (void)snprintf(localbuf, buflen, "%d", r->code);
+ return(localbuf);
+}
diff --git a/pkgtools/libnbcompat/files/regex2.h b/pkgtools/libnbcompat/files/regex2.h
new file mode 100644
index 00000000000..180c50cf3d7
--- /dev/null
+++ b/pkgtools/libnbcompat/files/regex2.h
@@ -0,0 +1,209 @@
+/* $NetBSD: regex2.h,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)regex2.h 8.4 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)regex2.h 8.4 (Berkeley) 3/20/94
+ */
+
+/*
+ * First, the stuff that ends up in the outside-world include file
+ = typedef off_t regoff_t;
+ = typedef struct {
+ = int re_magic;
+ = size_t re_nsub; // number of parenthesized subexpressions
+ = const char *re_endp; // end pointer for REG_PEND
+ = struct re_guts *re_g; // none of your business :-)
+ = } regex_t;
+ = typedef struct {
+ = regoff_t rm_so; // start of match
+ = regoff_t rm_eo; // end of match
+ = } regmatch_t;
+ */
+/*
+ * internals of regex_t
+ */
+#define MAGIC1 ((('r'^0200)<<8) | 'e')
+
+/*
+ * The internal representation is a *strip*, a sequence of
+ * operators ending with an endmarker. (Some terminology etc. is a
+ * historical relic of earlier versions which used multiple strips.)
+ * Certain oddities in the representation are there to permit running
+ * the machinery backwards; in particular, any deviation from sequential
+ * flow must be marked at both its source and its destination. Some
+ * fine points:
+ *
+ * - OPLUS_ and O_PLUS are *inside* the loop they create.
+ * - OQUEST_ and O_QUEST are *outside* the bypass they create.
+ * - OCH_ and O_CH are *outside* the multi-way branch they create, while
+ * OOR1 and OOR2 are respectively the end and the beginning of one of
+ * the branches. Note that there is an implicit OOR2 following OCH_
+ * and an implicit OOR1 preceding O_CH.
+ *
+ * In state representations, an operator's bit is on to signify a state
+ * immediately *preceding* "execution" of that operator.
+ */
+typedef u_int32_t sop; /* strip operator */
+typedef int sopno;
+#define OPRMASK ((u_int32_t)0xf8000000UL)
+#define OPDMASK ((u_int32_t)0x07ffffffUL)
+#define OPSHIFT ((unsigned)27)
+#define OP(n) ((n)&OPRMASK)
+#define OPND(n) ((int)((n)&OPDMASK))
+#define SOP(op, opnd) ((op)|(opnd))
+
+#define OPC(n) (((u_int32_t)(n))<<OPSHIFT)
+/* operators meaning operand */
+/* (back, fwd are offsets) */
+#define OEND OPC(1) /* endmarker - */
+#define OCHAR OPC(2) /* character unsigned char */
+#define OBOL OPC(3) /* left anchor - */
+#define OEOL OPC(4) /* right anchor - */
+#define OANY OPC(5) /* . - */
+#define OANYOF OPC(6) /* [...] set number */
+#define OBACK_ OPC(7) /* begin \d paren number */
+#define O_BACK OPC(8) /* end \d paren number */
+#define OPLUS_ OPC(9) /* + prefix fwd to suffix */
+#define O_PLUS OPC(10) /* + suffix back to prefix */
+#define OQUEST_ OPC(11) /* ? prefix fwd to suffix */
+#define O_QUEST OPC(12) /* ? suffix back to prefix */
+#define OLPAREN OPC(13) /* ( fwd to ) */
+#define ORPAREN OPC(14) /* ) back to ( */
+#define OCH_ OPC(15) /* begin choice fwd to OOR2 */
+#define OOR1 OPC(16) /* | pt. 1 back to OOR1 or OCH_ */
+#define OOR2 OPC(17) /* | pt. 2 fwd to OOR2 or O_CH */
+#define O_CH OPC(18) /* end choice back to OOR1 */
+#define OBOW OPC(19) /* begin word - */
+#define OEOW OPC(20) /* end word - */
+
+/*
+ * Structure for [] character-set representation. Character sets are
+ * done as bit vectors, grouped 8 to a byte vector for compactness.
+ * The individual set therefore has both a pointer to the byte vector
+ * and a mask to pick out the relevant bit of each byte. A hash code
+ * simplifies testing whether two sets could be identical.
+ *
+ * This will get trickier for multicharacter collating elements. As
+ * preliminary hooks for dealing with such things, we also carry along
+ * a string of multi-character elements, and decide the size of the
+ * vectors at run time.
+ */
+typedef struct {
+ uch *ptr; /* -> uch [csetsize] */
+ uch mask; /* bit within array */
+ uch hash; /* hash code */
+ size_t smultis;
+ char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */
+} cset;
+/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
+#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
+#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
+#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
+#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */
+#define MCsub(p, cs, cp) mcsub(p, cs, cp)
+#define MCin(p, cs, cp) mcin(p, cs, cp)
+
+/* stuff for character categories */
+typedef unsigned char cat_t;
+
+/*
+ * main compiled-expression structure
+ */
+struct re_guts {
+ int magic;
+# define MAGIC2 ((('R'^0200)<<8)|'E')
+ sop *strip; /* malloced area for strip */
+ int csetsize; /* number of bits in a cset vector */
+ int ncsets; /* number of csets in use */
+ cset *sets; /* -> cset [ncsets] */
+ uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */
+ int cflags; /* copy of regcomp() cflags argument */
+ sopno nstates; /* = number of sops */
+ sopno firststate; /* the initial OEND (normally 0) */
+ sopno laststate; /* the final OEND */
+ int iflags; /* internal flags */
+# define USEBOL 01 /* used ^ */
+# define USEEOL 02 /* used $ */
+# define BAD 04 /* something wrong */
+ int nbol; /* number of ^ used */
+ int neol; /* number of $ used */
+ int ncategories; /* how many character categories */
+ cat_t *categories; /* ->catspace[-CHAR_MIN] */
+ char *must; /* match must contain this string */
+ int mlen; /* length of must */
+ sopno nsub; /* copy of re_nsub */
+ int backrefs; /* does it use back references? */
+ sopno nplus; /* how deep does it nest +s? */
+ /* catspace must be last */
+ cat_t catspace[1]; /* actually [NC] */
+};
+
+/* misc utilities */
+#define OUT (CHAR_MAX+1) /* a non-character value */
+#define ISWORD(c) (isalnum((unsigned char)c) || (c) == '_')
diff --git a/pkgtools/libnbcompat/files/regexec.c b/pkgtools/libnbcompat/files/regexec.c
new file mode 100644
index 00000000000..625ff94f9e4
--- /dev/null
+++ b/pkgtools/libnbcompat/files/regexec.c
@@ -0,0 +1,261 @@
+/* $NetBSD: regexec.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)regexec.c 8.3 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)regexec.c 8.3 (Berkeley) 3/20/94
+ */
+
+#include "nbcompat.h"
+
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
+#else
+__RCSID("$NetBSD: regexec.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * the outer shell of regexec()
+ *
+ * This file includes engine.c *twice*, after muchos fiddling with the
+ * macros that code uses. This lets the same code operate on two different
+ * representations for state sets.
+ */
+/* #include "namespace.h" */
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_ASSERT_H
+#include <assert.h>
+#endif
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#if HAVE_REGEX_H
+#include <regex.h>
+#endif
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(regexec,_regexec)
+#endif
+#endif
+
+#include "utils.h"
+#include "regex2.h"
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+/* macros for manipulating states, small version */
+#define states unsigned long
+#define states1 unsigned long /* for later use in regexec() decision */
+#define CLEAR(v) ((v) = 0)
+#define SET0(v, n) ((v) &= ~((unsigned long)1 << (n)))
+#define SET1(v, n) ((v) |= (unsigned long)1 << (n))
+#define ISSET(v, n) (((v) & ((unsigned long)1 << (n))) != 0)
+#define ASSIGN(d, s) ((d) = (s))
+#define EQ(a, b) ((a) == (b))
+#define STATEVARS int dummy /* dummy version */
+#define STATESETUP(m, n) /* nothing */
+#define STATETEARDOWN(m) /* nothing */
+#define SETUP(v) ((v) = 0)
+#define onestate unsigned long
+#define INIT(o, n) ((o) = (unsigned long)1 << (n))
+#define INC(o) ((o) <<= 1)
+#define ISSTATEIN(v, o) (((v) & (o)) != 0)
+/* some abbreviations; note that some of these know variable names! */
+/* do "if I'm here, I can also be there" etc without branches */
+#define FWD(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) << (n))
+#define BACK(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) >> (n))
+#define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0)
+/* function names */
+#define SNAMES /* engine.c looks after details */
+
+#include "engine.c"
+
+/* now undo things */
+#undef states
+#undef CLEAR
+#undef SET0
+#undef SET1
+#undef ISSET
+#undef ASSIGN
+#undef EQ
+#undef STATEVARS
+#undef STATESETUP
+#undef STATETEARDOWN
+#undef SETUP
+#undef onestate
+#undef INIT
+#undef INC
+#undef ISSTATEIN
+#undef FWD
+#undef BACK
+#undef ISSETBACK
+#undef SNAMES
+
+/* macros for manipulating states, large version */
+#define states char *
+#define CLEAR(v) memset(v, 0, (size_t)m->g->nstates)
+#define SET0(v, n) ((v)[n] = 0)
+#define SET1(v, n) ((v)[n] = 1)
+#define ISSET(v, n) ((v)[n])
+#define ASSIGN(d, s) memcpy(d, s, (size_t)m->g->nstates)
+#define EQ(a, b) (memcmp(a, b, (size_t)m->g->nstates) == 0)
+#define STATEVARS int vn; char *space
+#define STATESETUP(m, nv) \
+ if (((m)->space = malloc((size_t)((nv)*(m)->g->nstates))) == NULL) \
+ return(REG_ESPACE); \
+ else \
+ (m)->vn = 0
+
+#define STATETEARDOWN(m) { free((m)->space); m->space = NULL; }
+#define SETUP(v) ((v) = &m->space[(size_t)(m->vn++ * m->g->nstates)])
+#define onestate int
+#define INIT(o, n) ((o) = (n))
+#define INC(o) ((o)++)
+#define ISSTATEIN(v, o) ((v)[o])
+/* some abbreviations; note that some of these know variable names! */
+/* do "if I'm here, I can also be there" etc without branches */
+#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
+#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
+#define ISSETBACK(v, n) ((v)[here - (n)])
+/* function names */
+#define LNAMES /* flag */
+
+#include "engine.c"
+
+/*
+ - regexec - interface for matching
+ = extern int regexec(const regex_t *, const char *, size_t, \
+ = regmatch_t [], int);
+ = #define REG_NOTBOL 00001
+ = #define REG_NOTEOL 00002
+ = #define REG_STARTEND 00004
+ = #define REG_TRACE 00400 // tracing of execution
+ = #define REG_LARGE 01000 // force large representation
+ = #define REG_BACKR 02000 // force use of backref code
+ *
+ * We put this here so we can exploit knowledge of the state representation
+ * when choosing which matcher to call. Also, by this point the matchers
+ * have been prototyped.
+ */
+int /* 0 success, REG_NOMATCH failure */
+regexec(preg, string, nmatch, pmatch, eflags)
+const regex_t *preg;
+const char *string;
+size_t nmatch;
+regmatch_t pmatch[];
+int eflags;
+{
+ struct re_guts *g = preg->re_g;
+ char *s;
+#ifdef REDEBUG
+# define GOODFLAGS(f) (f)
+#else
+# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
+#endif
+
+ _DIAGASSERT(preg != NULL);
+ _DIAGASSERT(string != NULL);
+
+ if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
+ return(REG_BADPAT);
+ assert(!(g->iflags&BAD));
+ if (g->iflags&BAD) /* backstop for no-debug case */
+ return(REG_BADPAT);
+ eflags = GOODFLAGS(eflags);
+
+ /* LINTED we believe that the regex routines do not change the string */
+ s = (char *)string;
+
+ if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
+ return(smatcher(g, s, nmatch, pmatch, eflags));
+ else
+ return(lmatcher(g, s, nmatch, pmatch, eflags));
+}
diff --git a/pkgtools/libnbcompat/files/regfree.c b/pkgtools/libnbcompat/files/regfree.c
new file mode 100644
index 00000000000..a6c2534a9d7
--- /dev/null
+++ b/pkgtools/libnbcompat/files/regfree.c
@@ -0,0 +1,149 @@
+/* $NetBSD: regfree.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)regfree.c 8.3 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)regfree.c 8.3 (Berkeley) 3/20/94
+ */
+
+#include "nbcompat.h"
+
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94";
+#else
+__RCSID("$NetBSD: regfree.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/* #include "namespace.h" */
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_ASSERT_H
+#include <assert.h>
+#endif
+#if HAVE_REGEX_H
+#include <regex.h>
+#endif
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(regfree,_regfree)
+#endif
+#endif
+
+#include "utils.h"
+#include "regex2.h"
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+/*
+ - regfree - free everything
+ = extern void regfree(regex_t *);
+ */
+void
+regfree(preg)
+regex_t *preg;
+{
+ struct re_guts *g;
+
+ _DIAGASSERT(preg != NULL);
+
+ _DIAGASSERT(preg->re_magic == MAGIC1);
+ if (preg->re_magic != MAGIC1) /* oops */
+ return; /* nice to complain, but hard */
+
+ g = preg->re_g;
+ if (g == NULL || g->magic != MAGIC2) /* oops again */
+ return;
+ preg->re_magic = 0; /* mark it invalid */
+ g->magic = 0; /* mark it invalid */
+
+ if (g->strip != NULL)
+ free(g->strip);
+ if (g->sets != NULL)
+ free(g->sets);
+ if (g->setbits != NULL)
+ free(g->setbits);
+ if (g->must != NULL)
+ free(g->must);
+ free(g);
+}
diff --git a/pkgtools/libnbcompat/files/rmd160.c b/pkgtools/libnbcompat/files/rmd160.c
index 1cee0aef08f..0cbae3a6550 100644
--- a/pkgtools/libnbcompat/files/rmd160.c
+++ b/pkgtools/libnbcompat/files/rmd160.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rmd160.c,v 1.4 2003/09/05 18:36:03 jlam Exp $ */
+/* $NetBSD: rmd160.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
/********************************************************************\
*
@@ -18,14 +18,11 @@
*
\********************************************************************/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
-
#include "nbcompat/nbtypes.h"
#ifndef lint
-__RCSID("$NetBSD: rmd160.c,v 1.4 2003/09/05 18:36:03 jlam Exp $");
+__RCSID("$NetBSD: rmd160.c,v 1.5 2004/08/16 17:24:56 jlam Exp $");
#endif /* not lint */
/* header files */
diff --git a/pkgtools/libnbcompat/files/rmd160hl.c b/pkgtools/libnbcompat/files/rmd160hl.c
index 72dd0c0d99c..919acf78b75 100644
--- a/pkgtools/libnbcompat/files/rmd160hl.c
+++ b/pkgtools/libnbcompat/files/rmd160hl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rmd160hl.c,v 1.4 2003/09/05 18:36:04 jlam Exp $ */
+/* $NetBSD: rmd160hl.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
/* rmd160hl.c
* ----------------------------------------------------------------------------
@@ -11,14 +11,11 @@
* from OpenBSD: rmd160hl.c,v 1.2 1999/08/17 09:13:12 millert Exp $
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
-
#include "nbcompat/nbtypes.h"
#ifndef lint
-__RCSID("$NetBSD: rmd160hl.c,v 1.4 2003/09/05 18:36:04 jlam Exp $");
+__RCSID("$NetBSD: rmd160hl.c,v 1.5 2004/08/16 17:24:56 jlam Exp $");
#endif /* not lint */
diff --git a/pkgtools/libnbcompat/files/setenv.c b/pkgtools/libnbcompat/files/setenv.c
index 84598ab6314..3fb64f8b6c7 100644
--- a/pkgtools/libnbcompat/files/setenv.c
+++ b/pkgtools/libnbcompat/files/setenv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: setenv.c,v 1.8 2003/12/05 15:43:10 erh Exp $ */
+/* $NetBSD: setenv.c,v 1.9 2004/08/16 17:24:56 jlam Exp $ */
/*
* Copyright (c) 1987 Regents of the University of California.
@@ -31,12 +31,10 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)setenv.c 5.6 (Berkeley) 6/4/91";*/
-static char *rcsid = "$Id: setenv.c,v 1.8 2003/12/05 15:43:10 erh Exp $";
+static char *rcsid = "$Id: setenv.c,v 1.9 2004/08/16 17:24:56 jlam Exp $";
#endif /* LIBC_SCCS and not lint */
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
#if HAVE_STRINGS_H
#include <strings.h>
diff --git a/pkgtools/libnbcompat/files/setmode.c b/pkgtools/libnbcompat/files/setmode.c
index c211f4d267e..318da248b58 100644
--- a/pkgtools/libnbcompat/files/setmode.c
+++ b/pkgtools/libnbcompat/files/setmode.c
@@ -1,4 +1,4 @@
-/* $NetBSD: setmode.c,v 1.7 2004/03/12 15:21:13 grant Exp $ */
+/* $NetBSD: setmode.c,v 1.8 2004/08/16 17:24:56 jlam Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -32,9 +32,7 @@
* SUCH DAMAGE.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
@@ -44,11 +42,11 @@
#if 0
static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94";
#else
-__RCSID("$NetBSD: setmode.c,v 1.7 2004/03/12 15:21:13 grant Exp $");
+__RCSID("$NetBSD: setmode.c,v 1.8 2004/08/16 17:24:56 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-#include "namespace.h"
+/* #include "namespace.h" */
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/pkgtools/libnbcompat/files/sha1.c b/pkgtools/libnbcompat/files/sha1.c
index b81f292e13c..1762ee46e96 100644
--- a/pkgtools/libnbcompat/files/sha1.c
+++ b/pkgtools/libnbcompat/files/sha1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sha1.c,v 1.4 2003/09/05 18:36:04 jlam Exp $ */
+/* $NetBSD: sha1.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
/* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
/*
@@ -15,10 +15,7 @@
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
-
#include "nbcompat/nbtypes.h"
#define SHA1HANDSOFF /* Copies data before messing with it. */
diff --git a/pkgtools/libnbcompat/files/sha1hl.c b/pkgtools/libnbcompat/files/sha1hl.c
index bed1d77eb9a..e8f50dedccc 100644
--- a/pkgtools/libnbcompat/files/sha1hl.c
+++ b/pkgtools/libnbcompat/files/sha1hl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sha1hl.c,v 1.4 2003/09/05 18:36:05 jlam Exp $ */
+/* $NetBSD: sha1hl.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
/* sha1hl.c
* ----------------------------------------------------------------------------
@@ -9,14 +9,11 @@
* ----------------------------------------------------------------------------
*/
-/* #include "namespace.h" */
-
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
-
#include "nbcompat/nbtypes.h"
+/* #include "namespace.h" */
+
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
@@ -35,7 +32,7 @@
#endif
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sha1hl.c,v 1.4 2003/09/05 18:36:05 jlam Exp $");
+__RCSID("$NetBSD: sha1hl.c,v 1.5 2004/08/16 17:24:56 jlam Exp $");
#endif /* LIBC_SCCS and not lint */
#ifndef _DIAGASSERT
diff --git a/pkgtools/libnbcompat/files/statvfs.c b/pkgtools/libnbcompat/files/statvfs.c
index 7dcca106825..76fdb9833a0 100644
--- a/pkgtools/libnbcompat/files/statvfs.c
+++ b/pkgtools/libnbcompat/files/statvfs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: statvfs.c,v 1.1 2004/08/06 16:55:09 jlam Exp $ */
+/* $NetBSD: statvfs.c,v 1.2 2004/08/16 17:24:56 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -36,9 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
#if HAVE_STRING_H
#include <string.h> /* memcpy() */
diff --git a/pkgtools/libnbcompat/files/strmode.c b/pkgtools/libnbcompat/files/strmode.c
index 44052464182..f187e5e48a7 100644
--- a/pkgtools/libnbcompat/files/strmode.c
+++ b/pkgtools/libnbcompat/files/strmode.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strmode.c,v 1.3 2003/09/01 15:31:21 jlam Exp $ */
+/* $NetBSD: strmode.c,v 1.4 2004/08/16 17:24:56 jlam Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -39,11 +39,11 @@
#if 0
static char sccsid[] = "@(#)strmode.c 8.3 (Berkeley) 8/15/94";
#else
-__RCSID("$NetBSD: strmode.c,v 1.3 2003/09/01 15:31:21 jlam Exp $");
+__RCSID("$NetBSD: strmode.c,v 1.4 2004/08/16 17:24:56 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-#include "namespace.h"
+/* #include "namespace.h" */
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/pkgtools/libnbcompat/files/unvis.c b/pkgtools/libnbcompat/files/unvis.c
index d6498aad32e..3a9f8d9314e 100644
--- a/pkgtools/libnbcompat/files/unvis.c
+++ b/pkgtools/libnbcompat/files/unvis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.5 2003/09/03 13:11:16 jlam Exp $ */
+/* $NetBSD: unvis.c,v 1.6 2004/08/16 17:24:56 jlam Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -29,9 +29,7 @@
* SUCH DAMAGE.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
@@ -41,13 +39,13 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.5 2003/09/03 13:11:16 jlam Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.6 2004/08/16 17:24:56 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#define __LIBC12_SOURCE__
-#include "namespace.h"
+/* #include "namespace.h" */
#include <sys/types.h>
#include <assert.h>
diff --git a/pkgtools/libnbcompat/files/utils.h b/pkgtools/libnbcompat/files/utils.h
new file mode 100644
index 00000000000..13c1d269b3c
--- /dev/null
+++ b/pkgtools/libnbcompat/files/utils.h
@@ -0,0 +1,100 @@
+/* $NetBSD: utils.h,v 1.1 2004/08/16 17:24:57 jlam Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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.
+ *
+ * @(#)utils.h 8.3 (Berkeley) 3/20/94
+ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. 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.
+ *
+ * @(#)utils.h 8.3 (Berkeley) 3/20/94
+ */
+
+/* utility definitions */
+#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
+#define INFINITY (DUPMAX + 1)
+#define NC (CHAR_MAX - CHAR_MIN + 1)
+typedef unsigned char uch;
+
+/* switch off assertions (if not already off) if no REDEBUG */
+#ifndef REDEBUG
+#ifndef NDEBUG
+#define NDEBUG /* no assertions please */
+#endif
+#endif
+#if HAVE_ASSERT_H
+#include <assert.h>
+#endif
+
+/*
+ * Workaround bug in some assert.h. This is okay since we really don't
+ * want assertions in the regex code.
+ */
+#undef assert
+#define assert(cond) ((void) 0)
+
+/* for old systems with bcopy() but no memmove() */
+#ifdef USEBCOPY
+#define memmove(d, s, c) bcopy(s, d, c)
+#endif
diff --git a/pkgtools/libnbcompat/files/vis.c b/pkgtools/libnbcompat/files/vis.c
index 8dd02909c97..91cbc065ff7 100644
--- a/pkgtools/libnbcompat/files/vis.c
+++ b/pkgtools/libnbcompat/files/vis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.5 2004/03/21 00:31:54 bouyer Exp $ */
+/* $NetBSD: vis.c,v 1.6 2004/08/16 17:24:57 jlam Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -34,10 +34,7 @@
* SUCH DAMAGE.
*/
-#if HAVE_CONFIG_H
#include "nbcompat/nbconfig.h"
-#endif
-
#include "nbcompat/nbtypes.h"
#if HAVE_SYS_CDEFS_H
@@ -45,10 +42,10 @@
#endif
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.5 2004/03/21 00:31:54 bouyer Exp $");
+__RCSID("$NetBSD: vis.c,v 1.6 2004/08/16 17:24:57 jlam Exp $");
#endif /* LIBC_SCCS and not lint */
-#include "namespace.h"
+/* #include "namespace.h" */
#include <sys/types.h>
#if HAVE_ASSERT_H