Index: /vendor/FreeBSD-libc/5.3/db/README
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/README	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/README	(revision 2404)
@@ -0,0 +1,40 @@
+#	@(#)README	8.27 (Berkeley) 9/1/94
+
+This is version 1.85 of the Berkeley DB code.
+
+For information on compiling and installing this software, see the file
+PORT/README.
+
+Newer versions of this software will periodically be made available by
+anonymous ftp from ftp.cs.berkeley.edu.  An archive in compressed format
+is in ucb/4bsd/db.tar.Z, or in gzip format in ucb/4bsd/db.tar.gz.  If
+you'd like to receive announcements of future releases of this software,
+send email to the contact address below.
+
+Email questions may be addressed to Keith Bostic at bostic@cs.berkeley.edu.
+
+============================================
+Distribution contents:
+
+Makefile.inc	Ignore this, it's the 4.4BSD subsystem Makefile.
+PORT		The per OS/architecture directories to use to build
+		libdb.a, if you're not running 4.4BSD.  See the file
+		PORT/README for more information.
+README		This file.
+btree		The B+tree routines.
+changelog	List of changes, per version.
+db		The dbopen(3) interface routine.
+docs		Various USENIX papers, and the formatted manual pages.
+hash		The extended linear hashing routines.
+man		The unformatted manual pages.
+mpool		The memory pool routines.
+recno		The fixed/variable length record routines.
+test		Test package.
+
+============================================
+Debugging:
+
+If you're running a memory checker (e.g. Purify) on DB, make sure that
+you recompile it with "-DPURIFY" in the CFLAGS, first.  By default,
+allocated pages are not initialized by the DB code, and they will show
+up as reads of uninitialized memory in the buffer write routines.
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_close.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_close.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_close.c	(revision 2404)
@@ -0,0 +1,186 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_close.c	8.7 (Berkeley) 8/17/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_close.c,v 1.8 2002/03/22 21:52:00 obrien Exp $");
+
+#include "namespace.h"
+#include <sys/param.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+#include <db.h>
+#include "btree.h"
+
+static int bt_meta(BTREE *);
+
+/*
+ * BT_CLOSE -- Close a btree.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__bt_close(dbp)
+	DB *dbp;
+{
+	BTREE *t;
+	int fd;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/* Sync the tree. */
+	if (__bt_sync(dbp, 0) == RET_ERROR)
+		return (RET_ERROR);
+
+	/* Close the memory pool. */
+	if (mpool_close(t->bt_mp) == RET_ERROR)
+		return (RET_ERROR);
+
+	/* Free random memory. */
+	if (t->bt_cursor.key.data != NULL) {
+		free(t->bt_cursor.key.data);
+		t->bt_cursor.key.size = 0;
+		t->bt_cursor.key.data = NULL;
+	}
+	if (t->bt_rkey.data) {
+		free(t->bt_rkey.data);
+		t->bt_rkey.size = 0;
+		t->bt_rkey.data = NULL;
+	}
+	if (t->bt_rdata.data) {
+		free(t->bt_rdata.data);
+		t->bt_rdata.size = 0;
+		t->bt_rdata.data = NULL;
+	}
+
+	fd = t->bt_fd;
+	free(t);
+	free(dbp);
+	return (_close(fd) ? RET_ERROR : RET_SUCCESS);
+}
+
+/*
+ * BT_SYNC -- sync the btree to disk.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ */
+int
+__bt_sync(dbp, flags)
+	const DB *dbp;
+	u_int flags;
+{
+	BTREE *t;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/* Sync doesn't currently take any flags. */
+	if (flags != 0) {
+		errno = EINVAL;
+		return (RET_ERROR);
+	}
+
+	if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED))
+		return (RET_SUCCESS);
+
+	if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR)
+		return (RET_ERROR);
+
+	if ((status = mpool_sync(t->bt_mp)) == RET_SUCCESS)
+		F_CLR(t, B_MODIFIED);
+
+	return (status);
+}
+
+/*
+ * BT_META -- write the tree meta data to disk.
+ *
+ * Parameters:
+ *	t:	tree
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+static int
+bt_meta(t)
+	BTREE *t;
+{
+	BTMETA m;
+	void *p;
+
+	if ((p = mpool_get(t->bt_mp, P_META, 0)) == NULL)
+		return (RET_ERROR);
+
+	/* Fill in metadata. */
+	m.magic = BTREEMAGIC;
+	m.version = BTREEVERSION;
+	m.psize = t->bt_psize;
+	m.free = t->bt_free;
+	m.nrecs = t->bt_nrecs;
+	m.flags = F_ISSET(t, SAVEMETA);
+
+	memmove(p, &m, sizeof(BTMETA));
+	mpool_put(t->bt_mp, p, MPOOL_DIRTY);
+	return (RET_SUCCESS);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_conv.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_conv.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_conv.c	(revision 2404)
@@ -0,0 +1,223 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_conv.c	8.5 (Berkeley) 8/17/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_conv.c,v 1.2 2002/03/21 22:46:25 obrien Exp $");
+
+#include <sys/param.h>
+
+#include <stdio.h>
+
+#include <db.h>
+#include "btree.h"
+
+static void mswap(PAGE *);
+
+/*
+ * __BT_BPGIN, __BT_BPGOUT --
+ *	Convert host-specific number layout to/from the host-independent
+ *	format stored on disk.
+ *
+ * Parameters:
+ *	t:	tree
+ *	pg:	page number
+ *	h:	page to convert
+ */
+void
+__bt_pgin(t, pg, pp)
+	void *t;
+	pgno_t pg;
+	void *pp;
+{
+	PAGE *h;
+	indx_t i, top;
+	u_char flags;
+	char *p;
+
+	if (!F_ISSET(((BTREE *)t), B_NEEDSWAP))
+		return;
+	if (pg == P_META) {
+		mswap(pp);
+		return;
+	}
+
+	h = pp;
+	M_32_SWAP(h->pgno);
+	M_32_SWAP(h->prevpg);
+	M_32_SWAP(h->nextpg);
+	M_32_SWAP(h->flags);
+	M_16_SWAP(h->lower);
+	M_16_SWAP(h->upper);
+
+	top = NEXTINDEX(h);
+	if ((h->flags & P_TYPE) == P_BINTERNAL)
+		for (i = 0; i < top; i++) {
+			M_16_SWAP(h->linp[i]);
+			p = (char *)GETBINTERNAL(h, i);
+			P_32_SWAP(p);
+			p += sizeof(u_int32_t);
+			P_32_SWAP(p);
+			p += sizeof(pgno_t);
+			if (*(u_char *)p & P_BIGKEY) {
+				p += sizeof(u_char);
+				P_32_SWAP(p);
+				p += sizeof(pgno_t);
+				P_32_SWAP(p);
+			}
+		}
+	else if ((h->flags & P_TYPE) == P_BLEAF)
+		for (i = 0; i < top; i++) {
+			M_16_SWAP(h->linp[i]);
+			p = (char *)GETBLEAF(h, i);
+			P_32_SWAP(p);
+			p += sizeof(u_int32_t);
+			P_32_SWAP(p);
+			p += sizeof(u_int32_t);
+			flags = *(u_char *)p;
+			if (flags & (P_BIGKEY | P_BIGDATA)) {
+				p += sizeof(u_char);
+				if (flags & P_BIGKEY) {
+					P_32_SWAP(p);
+					p += sizeof(pgno_t);
+					P_32_SWAP(p);
+				}
+				if (flags & P_BIGDATA) {
+					p += sizeof(u_int32_t);
+					P_32_SWAP(p);
+					p += sizeof(pgno_t);
+					P_32_SWAP(p);
+				}
+			}
+		}
+}
+
+void
+__bt_pgout(t, pg, pp)
+	void *t;
+	pgno_t pg;
+	void *pp;
+{
+	PAGE *h;
+	indx_t i, top;
+	u_char flags;
+	char *p;
+
+	if (!F_ISSET(((BTREE *)t), B_NEEDSWAP))
+		return;
+	if (pg == P_META) {
+		mswap(pp);
+		return;
+	}
+
+	h = pp;
+	top = NEXTINDEX(h);
+	if ((h->flags & P_TYPE) == P_BINTERNAL)
+		for (i = 0; i < top; i++) {
+			p = (char *)GETBINTERNAL(h, i);
+			P_32_SWAP(p);
+			p += sizeof(u_int32_t);
+			P_32_SWAP(p);
+			p += sizeof(pgno_t);
+			if (*(u_char *)p & P_BIGKEY) {
+				p += sizeof(u_char);
+				P_32_SWAP(p);
+				p += sizeof(pgno_t);
+				P_32_SWAP(p);
+			}
+			M_16_SWAP(h->linp[i]);
+		}
+	else if ((h->flags & P_TYPE) == P_BLEAF)
+		for (i = 0; i < top; i++) {
+			p = (char *)GETBLEAF(h, i);
+			P_32_SWAP(p);
+			p += sizeof(u_int32_t);
+			P_32_SWAP(p);
+			p += sizeof(u_int32_t);
+			flags = *(u_char *)p;
+			if (flags & (P_BIGKEY | P_BIGDATA)) {
+				p += sizeof(u_char);
+				if (flags & P_BIGKEY) {
+					P_32_SWAP(p);
+					p += sizeof(pgno_t);
+					P_32_SWAP(p);
+				}
+				if (flags & P_BIGDATA) {
+					p += sizeof(u_int32_t);
+					P_32_SWAP(p);
+					p += sizeof(pgno_t);
+					P_32_SWAP(p);
+				}
+			}
+			M_16_SWAP(h->linp[i]);
+		}
+
+	M_32_SWAP(h->pgno);
+	M_32_SWAP(h->prevpg);
+	M_32_SWAP(h->nextpg);
+	M_32_SWAP(h->flags);
+	M_16_SWAP(h->lower);
+	M_16_SWAP(h->upper);
+}
+
+/*
+ * MSWAP -- Actually swap the bytes on the meta page.
+ *
+ * Parameters:
+ *	p:	page to convert
+ */
+static void
+mswap(pg)
+	PAGE *pg;
+{
+	char *p;
+
+	p = (char *)pg;
+	P_32_SWAP(p);		/* magic */
+	p += sizeof(u_int32_t);
+	P_32_SWAP(p);		/* version */
+	p += sizeof(u_int32_t);
+	P_32_SWAP(p);		/* psize */
+	p += sizeof(u_int32_t);
+	P_32_SWAP(p);		/* free */
+	p += sizeof(u_int32_t);
+	P_32_SWAP(p);		/* nrecs */
+	p += sizeof(u_int32_t);
+	P_32_SWAP(p);		/* flags */
+	p += sizeof(u_int32_t);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_debug.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_debug.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_debug.c	(revision 2404)
@@ -0,0 +1,331 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_debug.c	8.5 (Berkeley) 8/17/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_debug.c,v 1.2 2002/03/22 21:52:01 obrien Exp $");
+
+#include <sys/param.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <db.h>
+#include "btree.h"
+
+#ifdef DEBUG
+/*
+ * BT_DUMP -- Dump the tree
+ *
+ * Parameters:
+ *	dbp:	pointer to the DB
+ */
+void
+__bt_dump(dbp)
+	DB *dbp;
+{
+	BTREE *t;
+	PAGE *h;
+	pgno_t i;
+	char *sep;
+
+	t = dbp->internal;
+	(void)fprintf(stderr, "%s: pgsz %d",
+	    F_ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize);
+	if (F_ISSET(t, R_RECNO))
+		(void)fprintf(stderr, " keys %lu", t->bt_nrecs);
+#undef X
+#define	X(flag, name) \
+	if (F_ISSET(t, flag)) { \
+		(void)fprintf(stderr, "%s%s", sep, name); \
+		sep = ", "; \
+	}
+	if (t->flags != 0) {
+		sep = " flags (";
+		X(R_FIXLEN,	"FIXLEN");
+		X(B_INMEM,	"INMEM");
+		X(B_NODUPS,	"NODUPS");
+		X(B_RDONLY,	"RDONLY");
+		X(R_RECNO,	"RECNO");
+		X(B_METADIRTY,"METADIRTY");
+		(void)fprintf(stderr, ")\n");
+	}
+#undef X
+
+	for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
+		__bt_dpage(h);
+		(void)mpool_put(t->bt_mp, h, 0);
+	}
+}
+
+/*
+ * BT_DMPAGE -- Dump the meta page
+ *
+ * Parameters:
+ *	h:	pointer to the PAGE
+ */
+void
+__bt_dmpage(h)
+	PAGE *h;
+{
+	BTMETA *m;
+	char *sep;
+
+	m = (BTMETA *)h;
+	(void)fprintf(stderr, "magic %lx\n", m->magic);
+	(void)fprintf(stderr, "version %lu\n", m->version);
+	(void)fprintf(stderr, "psize %lu\n", m->psize);
+	(void)fprintf(stderr, "free %lu\n", m->free);
+	(void)fprintf(stderr, "nrecs %lu\n", m->nrecs);
+	(void)fprintf(stderr, "flags %lu", m->flags);
+#undef X
+#define	X(flag, name) \
+	if (m->flags & flag) { \
+		(void)fprintf(stderr, "%s%s", sep, name); \
+		sep = ", "; \
+	}
+	if (m->flags) {
+		sep = " (";
+		X(B_NODUPS,	"NODUPS");
+		X(R_RECNO,	"RECNO");
+		(void)fprintf(stderr, ")");
+	}
+}
+
+/*
+ * BT_DNPAGE -- Dump the page
+ *
+ * Parameters:
+ *	n:	page number to dump.
+ */
+void
+__bt_dnpage(dbp, pgno)
+	DB *dbp;
+	pgno_t pgno;
+{
+	BTREE *t;
+	PAGE *h;
+
+	t = dbp->internal;
+	if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) {
+		__bt_dpage(h);
+		(void)mpool_put(t->bt_mp, h, 0);
+	}
+}
+
+/*
+ * BT_DPAGE -- Dump the page
+ *
+ * Parameters:
+ *	h:	pointer to the PAGE
+ */
+void
+__bt_dpage(h)
+	PAGE *h;
+{
+	BINTERNAL *bi;
+	BLEAF *bl;
+	RINTERNAL *ri;
+	RLEAF *rl;
+	indx_t cur, top;
+	char *sep;
+
+	(void)fprintf(stderr, "    page %d: (", h->pgno);
+#undef X
+#define	X(flag, name) \
+	if (h->flags & flag) { \
+		(void)fprintf(stderr, "%s%s", sep, name); \
+		sep = ", "; \
+	}
+	sep = "";
+	X(P_BINTERNAL,	"BINTERNAL")		/* types */
+	X(P_BLEAF,	"BLEAF")
+	X(P_RINTERNAL,	"RINTERNAL")		/* types */
+	X(P_RLEAF,	"RLEAF")
+	X(P_OVERFLOW,	"OVERFLOW")
+	X(P_PRESERVE,	"PRESERVE");
+	(void)fprintf(stderr, ")\n");
+#undef X
+
+	(void)fprintf(stderr, "\tprev %2d next %2d", h->prevpg, h->nextpg);
+	if (h->flags & P_OVERFLOW)
+		return;
+
+	top = NEXTINDEX(h);
+	(void)fprintf(stderr, " lower %3d upper %3d nextind %d\n",
+	    h->lower, h->upper, top);
+	for (cur = 0; cur < top; cur++) {
+		(void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]);
+		switch (h->flags & P_TYPE) {
+		case P_BINTERNAL:
+			bi = GETBINTERNAL(h, cur);
+			(void)fprintf(stderr,
+			    "size %03d pgno %03d", bi->ksize, bi->pgno);
+			if (bi->flags & P_BIGKEY)
+				(void)fprintf(stderr, " (indirect)");
+			else if (bi->ksize)
+				(void)fprintf(stderr,
+				    " {%.*s}", (int)bi->ksize, bi->bytes);
+			break;
+		case P_RINTERNAL:
+			ri = GETRINTERNAL(h, cur);
+			(void)fprintf(stderr, "entries %03d pgno %03d",
+				ri->nrecs, ri->pgno);
+			break;
+		case P_BLEAF:
+			bl = GETBLEAF(h, cur);
+			if (bl->flags & P_BIGKEY)
+				(void)fprintf(stderr,
+				    "big key page %lu size %u/",
+				    *(pgno_t *)bl->bytes,
+				    *(u_int32_t *)(bl->bytes + sizeof(pgno_t)));
+			else if (bl->ksize)
+				(void)fprintf(stderr, "%s/", bl->bytes);
+			if (bl->flags & P_BIGDATA)
+				(void)fprintf(stderr,
+				    "big data page %lu size %u",
+				    *(pgno_t *)(bl->bytes + bl->ksize),
+				    *(u_int32_t *)(bl->bytes + bl->ksize +
+				    sizeof(pgno_t)));
+			else if (bl->dsize)
+				(void)fprintf(stderr, "%.*s",
+				    (int)bl->dsize, bl->bytes + bl->ksize);
+			break;
+		case P_RLEAF:
+			rl = GETRLEAF(h, cur);
+			if (rl->flags & P_BIGDATA)
+				(void)fprintf(stderr,
+				    "big data page %lu size %u",
+				    *(pgno_t *)rl->bytes,
+				    *(u_int32_t *)(rl->bytes + sizeof(pgno_t)));
+			else if (rl->dsize)
+				(void)fprintf(stderr,
+				    "%.*s", (int)rl->dsize, rl->bytes);
+			break;
+		}
+		(void)fprintf(stderr, "\n");
+	}
+}
+#endif
+
+#ifdef STATISTICS
+/*
+ * BT_STAT -- Gather/print the tree statistics
+ *
+ * Parameters:
+ *	dbp:	pointer to the DB
+ */
+void
+__bt_stat(dbp)
+	DB *dbp;
+{
+	extern u_long bt_cache_hit, bt_cache_miss, bt_pfxsaved, bt_rootsplit;
+	extern u_long bt_sortsplit, bt_split;
+	BTREE *t;
+	PAGE *h;
+	pgno_t i, pcont, pinternal, pleaf;
+	u_long ifree, lfree, nkeys;
+	int levels;
+
+	t = dbp->internal;
+	pcont = pinternal = pleaf = 0;
+	nkeys = ifree = lfree = 0;
+	for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
+		switch (h->flags & P_TYPE) {
+		case P_BINTERNAL:
+		case P_RINTERNAL:
+			++pinternal;
+			ifree += h->upper - h->lower;
+			break;
+		case P_BLEAF:
+		case P_RLEAF:
+			++pleaf;
+			lfree += h->upper - h->lower;
+			nkeys += NEXTINDEX(h);
+			break;
+		case P_OVERFLOW:
+			++pcont;
+			break;
+		}
+		(void)mpool_put(t->bt_mp, h, 0);
+	}
+
+	/* Count the levels of the tree. */
+	for (i = P_ROOT, levels = 0 ;; ++levels) {
+		h = mpool_get(t->bt_mp, i, 0);
+		if (h->flags & (P_BLEAF|P_RLEAF)) {
+			if (levels == 0)
+				levels = 1;
+			(void)mpool_put(t->bt_mp, h, 0);
+			break;
+		}
+		i = F_ISSET(t, R_RECNO) ?
+		    GETRINTERNAL(h, 0)->pgno :
+		    GETBINTERNAL(h, 0)->pgno;
+		(void)mpool_put(t->bt_mp, h, 0);
+	}
+
+	(void)fprintf(stderr, "%d level%s with %ld keys",
+	    levels, levels == 1 ? "" : "s", nkeys);
+	if (F_ISSET(t, R_RECNO))
+		(void)fprintf(stderr, " (%ld header count)", t->bt_nrecs);
+	(void)fprintf(stderr,
+	    "\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n",
+	    pinternal + pleaf + pcont, pleaf, pinternal, pcont);
+	(void)fprintf(stderr, "%ld cache hits, %ld cache misses\n",
+	    bt_cache_hit, bt_cache_miss);
+	(void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n",
+	    bt_split, bt_rootsplit, bt_sortsplit);
+	pleaf *= t->bt_psize - BTDATAOFF;
+	if (pleaf)
+		(void)fprintf(stderr,
+		    "%.0f%% leaf fill (%ld bytes used, %ld bytes free)\n",
+		    ((double)(pleaf - lfree) / pleaf) * 100,
+		    pleaf - lfree, lfree);
+	pinternal *= t->bt_psize - BTDATAOFF;
+	if (pinternal)
+		(void)fprintf(stderr,
+		    "%.0f%% internal fill (%ld bytes used, %ld bytes free\n",
+		    ((double)(pinternal - ifree) / pinternal) * 100,
+		    pinternal - ifree, ifree);
+	if (bt_pfxsaved)
+		(void)fprintf(stderr, "prefix checking removed %lu bytes.\n",
+		    bt_pfxsaved);
+}
+#endif
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_delete.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_delete.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_delete.c	(revision 2404)
@@ -0,0 +1,659 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_delete.c	8.13 (Berkeley) 7/28/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_delete.c,v 1.2 2002/03/21 22:46:25 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <db.h>
+#include "btree.h"
+
+static int __bt_bdelete(BTREE *, const DBT *);
+static int __bt_curdel(BTREE *, const DBT *, PAGE *, u_int);
+static int __bt_pdelete(BTREE *, PAGE *);
+static int __bt_relink(BTREE *, PAGE *);
+static int __bt_stkacq(BTREE *, PAGE **, CURSOR *);
+
+/*
+ * __bt_delete
+ *	Delete the item(s) referenced by a key.
+ *
+ * Return RET_SPECIAL if the key is not found.
+ */
+int
+__bt_delete(dbp, key, flags)
+	const DB *dbp;
+	const DBT *key;
+	u_int flags;
+{
+	BTREE *t;
+	CURSOR *c;
+	PAGE *h;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/* Check for change to a read-only tree. */
+	if (F_ISSET(t, B_RDONLY)) {
+		errno = EPERM;
+		return (RET_ERROR);
+	}
+
+	switch (flags) {
+	case 0:
+		status = __bt_bdelete(t, key);
+		break;
+	case R_CURSOR:
+		/*
+		 * If flags is R_CURSOR, delete the cursor.  Must already
+		 * have started a scan and not have already deleted it.
+		 */
+		c = &t->bt_cursor;
+		if (F_ISSET(c, CURS_INIT)) {
+			if (F_ISSET(c, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE))
+				return (RET_SPECIAL);
+			if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL)
+				return (RET_ERROR);
+
+			/*
+			 * If the page is about to be emptied, we'll need to
+			 * delete it, which means we have to acquire a stack.
+			 */
+			if (NEXTINDEX(h) == 1)
+				if (__bt_stkacq(t, &h, &t->bt_cursor))
+					return (RET_ERROR);
+
+			status = __bt_dleaf(t, NULL, h, c->pg.index);
+
+			if (NEXTINDEX(h) == 0 && status == RET_SUCCESS) {
+				if (__bt_pdelete(t, h))
+					return (RET_ERROR);
+			} else
+				mpool_put(t->bt_mp,
+				    h, status == RET_SUCCESS ? MPOOL_DIRTY : 0);
+			break;
+		}
+		/* FALLTHROUGH */
+	default:
+		errno = EINVAL;
+		return (RET_ERROR);
+	}
+	if (status == RET_SUCCESS)
+		F_SET(t, B_MODIFIED);
+	return (status);
+}
+
+/*
+ * __bt_stkacq --
+ *	Acquire a stack so we can delete a cursor entry.
+ *
+ * Parameters:
+ *	  t:	tree
+ *	 hp:	pointer to current, pinned PAGE pointer
+ *	  c:	pointer to the cursor
+ *
+ * Returns:
+ *	0 on success, 1 on failure
+ */
+static int
+__bt_stkacq(t, hp, c)
+	BTREE *t;
+	PAGE **hp;
+	CURSOR *c;
+{
+	BINTERNAL *bi;
+	EPG *e;
+	EPGNO *parent;
+	PAGE *h;
+	indx_t index;
+	pgno_t pgno;
+	recno_t nextpg, prevpg;
+	int exact, level;
+	
+	/*
+	 * Find the first occurrence of the key in the tree.  Toss the
+	 * currently locked page so we don't hit an already-locked page.
+	 */
+	h = *hp;
+	mpool_put(t->bt_mp, h, 0);
+	if ((e = __bt_search(t, &c->key, &exact)) == NULL)
+		return (1);
+	h = e->page;
+
+	/* See if we got it in one shot. */
+	if (h->pgno == c->pg.pgno)
+		goto ret;
+
+	/*
+	 * Move right, looking for the page.  At each move we have to move
+	 * up the stack until we don't have to move to the next page.  If
+	 * we have to change pages at an internal level, we have to fix the
+	 * stack back up.
+	 */
+	while (h->pgno != c->pg.pgno) {
+		if ((nextpg = h->nextpg) == P_INVALID)
+			break;
+		mpool_put(t->bt_mp, h, 0);
+
+		/* Move up the stack. */
+		for (level = 0; (parent = BT_POP(t)) != NULL; ++level) {
+			/* Get the parent page. */
+			if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
+				return (1);
+
+			/* Move to the next index. */
+			if (parent->index != NEXTINDEX(h) - 1) {
+				index = parent->index + 1;
+				BT_PUSH(t, h->pgno, index);
+				break;
+			}
+			mpool_put(t->bt_mp, h, 0);
+		}
+
+		/* Restore the stack. */
+		while (level--) {
+			/* Push the next level down onto the stack. */
+			bi = GETBINTERNAL(h, index);
+			pgno = bi->pgno;
+			BT_PUSH(t, pgno, 0);
+
+			/* Lose the currently pinned page. */
+			mpool_put(t->bt_mp, h, 0);
+
+			/* Get the next level down. */
+			if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL)
+				return (1);
+			index = 0;
+		}
+		mpool_put(t->bt_mp, h, 0);
+		if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL)
+			return (1);
+	}
+
+	if (h->pgno == c->pg.pgno)
+		goto ret;
+
+	/* Reacquire the original stack. */
+	mpool_put(t->bt_mp, h, 0);
+	if ((e = __bt_search(t, &c->key, &exact)) == NULL)
+		return (1);
+	h = e->page;
+
+	/*
+	 * Move left, looking for the page.  At each move we have to move
+	 * up the stack until we don't have to change pages to move to the
+	 * next page.  If we have to change pages at an internal level, we
+	 * have to fix the stack back up.
+	 */
+	while (h->pgno != c->pg.pgno) {
+		if ((prevpg = h->prevpg) == P_INVALID)
+			break;
+		mpool_put(t->bt_mp, h, 0);
+
+		/* Move up the stack. */
+		for (level = 0; (parent = BT_POP(t)) != NULL; ++level) {
+			/* Get the parent page. */
+			if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
+				return (1);
+
+			/* Move to the next index. */
+			if (parent->index != 0) {
+				index = parent->index - 1;
+				BT_PUSH(t, h->pgno, index);
+				break;
+			}
+			mpool_put(t->bt_mp, h, 0);
+		}
+
+		/* Restore the stack. */
+		while (level--) {
+			/* Push the next level down onto the stack. */
+			bi = GETBINTERNAL(h, index);
+			pgno = bi->pgno;
+
+			/* Lose the currently pinned page. */
+			mpool_put(t->bt_mp, h, 0);
+
+			/* Get the next level down. */
+			if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL)
+				return (1);
+
+			index = NEXTINDEX(h) - 1;
+			BT_PUSH(t, pgno, index);
+		}
+		mpool_put(t->bt_mp, h, 0);
+		if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL)
+			return (1);
+	}
+	
+
+ret:	mpool_put(t->bt_mp, h, 0);
+	return ((*hp = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL);
+}
+
+/*
+ * __bt_bdelete --
+ *	Delete all key/data pairs matching the specified key.
+ *
+ * Parameters:
+ *	  t:	tree
+ *	key:	key to delete
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found.
+ */
+static int
+__bt_bdelete(t, key)
+	BTREE *t;
+	const DBT *key;
+{
+	EPG *e;
+	PAGE *h;
+	int deleted, exact, redo;
+
+	deleted = 0;
+
+	/* Find any matching record; __bt_search pins the page. */
+loop:	if ((e = __bt_search(t, key, &exact)) == NULL)
+		return (deleted ? RET_SUCCESS : RET_ERROR);
+	if (!exact) {
+		mpool_put(t->bt_mp, e->page, 0);
+		return (deleted ? RET_SUCCESS : RET_SPECIAL);
+	}
+
+	/*
+	 * Delete forward, then delete backward, from the found key.  If
+	 * there are duplicates and we reach either side of the page, do
+	 * the key search again, so that we get them all.
+	 */
+	redo = 0;
+	h = e->page;
+	do {
+		if (__bt_dleaf(t, key, h, e->index)) {
+			mpool_put(t->bt_mp, h, 0);
+			return (RET_ERROR);
+		}
+		if (F_ISSET(t, B_NODUPS)) {
+			if (NEXTINDEX(h) == 0) {
+				if (__bt_pdelete(t, h))
+					return (RET_ERROR);
+			} else
+				mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+			return (RET_SUCCESS);
+		}
+		deleted = 1;
+	} while (e->index < NEXTINDEX(h) && __bt_cmp(t, key, e) == 0);
+
+	/* Check for right-hand edge of the page. */
+	if (e->index == NEXTINDEX(h))
+		redo = 1;
+
+	/* Delete from the key to the beginning of the page. */
+	while (e->index-- > 0) {
+		if (__bt_cmp(t, key, e) != 0)
+			break;
+		if (__bt_dleaf(t, key, h, e->index) == RET_ERROR) {
+			mpool_put(t->bt_mp, h, 0);
+			return (RET_ERROR);
+		}
+		if (e->index == 0)
+			redo = 1;
+	}
+
+	/* Check for an empty page. */
+	if (NEXTINDEX(h) == 0) {
+		if (__bt_pdelete(t, h))
+			return (RET_ERROR);
+		goto loop;
+	}
+
+	/* Put the page. */
+	mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+
+	if (redo)
+		goto loop;
+	return (RET_SUCCESS);
+}
+
+/*
+ * __bt_pdelete --
+ *	Delete a single page from the tree.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	leaf page
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ *
+ * Side-effects:
+ *	mpool_put's the page
+ */
+static int
+__bt_pdelete(t, h)
+	BTREE *t;
+	PAGE *h;
+{
+	BINTERNAL *bi;
+	PAGE *pg;
+	EPGNO *parent;
+	indx_t cnt, index, *ip, offset;
+	u_int32_t nksize;
+	char *from;
+
+	/*
+	 * Walk the parent page stack -- a LIFO stack of the pages that were
+	 * traversed when we searched for the page where the delete occurred.
+	 * Each stack entry is a page number and a page index offset.  The
+	 * offset is for the page traversed on the search.  We've just deleted
+	 * a page, so we have to delete the key from the parent page.
+	 *
+	 * If the delete from the parent page makes it empty, this process may
+	 * continue all the way up the tree.  We stop if we reach the root page
+	 * (which is never deleted, it's just not worth the effort) or if the
+	 * delete does not empty the page.
+	 */
+	while ((parent = BT_POP(t)) != NULL) {
+		/* Get the parent page. */
+		if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
+			return (RET_ERROR);
+		
+		index = parent->index;
+		bi = GETBINTERNAL(pg, index);
+
+		/* Free any overflow pages. */
+		if (bi->flags & P_BIGKEY &&
+		    __ovfl_delete(t, bi->bytes) == RET_ERROR) {
+			mpool_put(t->bt_mp, pg, 0);
+			return (RET_ERROR);
+		}
+
+		/*
+		 * Free the parent if it has only the one key and it's not the
+		 * root page. If it's the rootpage, turn it back into an empty
+		 * leaf page.
+		 */
+		if (NEXTINDEX(pg) == 1)
+			if (pg->pgno == P_ROOT) {
+				pg->lower = BTDATAOFF;
+				pg->upper = t->bt_psize;
+				pg->flags = P_BLEAF;
+			} else {
+				if (__bt_relink(t, pg) || __bt_free(t, pg))
+					return (RET_ERROR);
+				continue;
+			}
+		else {
+			/* Pack remaining key items at the end of the page. */
+			nksize = NBINTERNAL(bi->ksize);
+			from = (char *)pg + pg->upper;
+			memmove(from + nksize, from, (char *)bi - from);
+			pg->upper += nksize;
+
+			/* Adjust indices' offsets, shift the indices down. */
+			offset = pg->linp[index];
+			for (cnt = index, ip = &pg->linp[0]; cnt--; ++ip)
+				if (ip[0] < offset)
+					ip[0] += nksize;
+			for (cnt = NEXTINDEX(pg) - index; --cnt; ++ip)
+				ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1];
+			pg->lower -= sizeof(indx_t);
+		}
+
+		mpool_put(t->bt_mp, pg, MPOOL_DIRTY);
+		break;
+	}
+
+	/* Free the leaf page, as long as it wasn't the root. */
+	if (h->pgno == P_ROOT) {
+		mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+		return (RET_SUCCESS);
+	}
+	return (__bt_relink(t, h) || __bt_free(t, h));
+}
+
+/*
+ * __bt_dleaf --
+ *	Delete a single record from a leaf page.
+ *
+ * Parameters:
+ *	t:	tree
+ *    key:	referenced key
+ *	h:	page
+ *	index:	index on page to delete
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ */
+int
+__bt_dleaf(t, key, h, index)
+	BTREE *t;
+	const DBT *key;
+	PAGE *h;
+	u_int index;
+{
+	BLEAF *bl;
+	indx_t cnt, *ip, offset;
+	u_int32_t nbytes;
+	void *to;
+	char *from;
+
+	/* If this record is referenced by the cursor, delete the cursor. */
+	if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
+	    !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
+	    t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == index &&
+	    __bt_curdel(t, key, h, index))
+		return (RET_ERROR);
+
+	/* If the entry uses overflow pages, make them available for reuse. */
+	to = bl = GETBLEAF(h, index);
+	if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR)
+		return (RET_ERROR);
+	if (bl->flags & P_BIGDATA &&
+	    __ovfl_delete(t, bl->bytes + bl->ksize) == RET_ERROR)
+		return (RET_ERROR);
+
+	/* Pack the remaining key/data items at the end of the page. */
+	nbytes = NBLEAF(bl);
+	from = (char *)h + h->upper;
+	memmove(from + nbytes, from, (char *)to - from);
+	h->upper += nbytes;
+
+	/* Adjust the indices' offsets, shift the indices down. */
+	offset = h->linp[index];
+	for (cnt = index, ip = &h->linp[0]; cnt--; ++ip)
+		if (ip[0] < offset)
+			ip[0] += nbytes;
+	for (cnt = NEXTINDEX(h) - index; --cnt; ++ip)
+		ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1];
+	h->lower -= sizeof(indx_t);
+
+	/* If the cursor is on this page, adjust it as necessary. */
+	if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
+	    !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
+	    t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > index)
+		--t->bt_cursor.pg.index;
+
+	return (RET_SUCCESS);
+}
+
+/*
+ * __bt_curdel --
+ *	Delete the cursor.
+ *
+ * Parameters:
+ *	t:	tree
+ *    key:	referenced key (or NULL)
+ *	h:	page
+ *  index:	index on page to delete
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ */
+static int
+__bt_curdel(t, key, h, index)
+	BTREE *t;
+	const DBT *key;
+	PAGE *h;
+	u_int index;
+{
+	CURSOR *c;
+	EPG e;
+	PAGE *pg;
+	int curcopy, status;
+
+	/*
+	 * If there are duplicates, move forward or backward to one.
+	 * Otherwise, copy the key into the cursor area.
+	 */
+	c = &t->bt_cursor;
+	F_CLR(c, CURS_AFTER | CURS_BEFORE | CURS_ACQUIRE);
+
+	curcopy = 0;
+	if (!F_ISSET(t, B_NODUPS)) {
+		/*
+		 * We're going to have to do comparisons.  If we weren't
+		 * provided a copy of the key, i.e. the user is deleting
+		 * the current cursor position, get one.
+		 */
+		if (key == NULL) {
+			e.page = h;
+			e.index = index;
+			if ((status = __bt_ret(t, &e,
+			    &c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS)
+				return (status);
+			curcopy = 1;
+			key = &c->key;
+		}
+		/* Check previous key, if not at the beginning of the page. */
+		if (index > 0) { 
+			e.page = h;
+			e.index = index - 1;
+			if (__bt_cmp(t, key, &e) == 0) {
+				F_SET(c, CURS_BEFORE);
+				goto dup2;
+			}
+		}
+		/* Check next key, if not at the end of the page. */
+		if (index < NEXTINDEX(h) - 1) {
+			e.page = h;
+			e.index = index + 1;
+			if (__bt_cmp(t, key, &e) == 0) {
+				F_SET(c, CURS_AFTER);
+				goto dup2;
+			}
+		}
+		/* Check previous key if at the beginning of the page. */
+		if (index == 0 && h->prevpg != P_INVALID) {
+			if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL)
+				return (RET_ERROR);
+			e.page = pg;
+			e.index = NEXTINDEX(pg) - 1;
+			if (__bt_cmp(t, key, &e) == 0) {
+				F_SET(c, CURS_BEFORE);
+				goto dup1;
+			}
+			mpool_put(t->bt_mp, pg, 0);
+		}
+		/* Check next key if at the end of the page. */
+		if (index == NEXTINDEX(h) - 1 && h->nextpg != P_INVALID) {
+			if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL)
+				return (RET_ERROR);
+			e.page = pg;
+			e.index = 0;
+			if (__bt_cmp(t, key, &e) == 0) {
+				F_SET(c, CURS_AFTER);
+dup1:				mpool_put(t->bt_mp, pg, 0);
+dup2:				c->pg.pgno = e.page->pgno;
+				c->pg.index = e.index;
+				return (RET_SUCCESS);
+			}
+			mpool_put(t->bt_mp, pg, 0);
+		}
+	}
+	e.page = h;
+	e.index = index;
+	if (curcopy || (status =
+	    __bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) {
+		F_SET(c, CURS_ACQUIRE);
+		return (RET_SUCCESS);
+	}
+	return (status);
+}
+
+/*
+ * __bt_relink --
+ *	Link around a deleted page.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	page to be deleted
+ */
+static int
+__bt_relink(t, h)
+	BTREE *t;
+	PAGE *h;
+{
+	PAGE *pg;
+
+	if (h->nextpg != P_INVALID) {
+		if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL)
+			return (RET_ERROR);
+		pg->prevpg = h->prevpg;
+		mpool_put(t->bt_mp, pg, MPOOL_DIRTY);
+	}
+	if (h->prevpg != P_INVALID) {
+		if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL)
+			return (RET_ERROR);
+		pg->nextpg = h->nextpg;
+		mpool_put(t->bt_mp, pg, MPOOL_DIRTY);
+	}
+	return (0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_get.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_get.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_get.c	(revision 2404)
@@ -0,0 +1,107 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_get.c	8.6 (Berkeley) 7/20/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_get.c,v 1.2 2002/03/22 21:52:01 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include <db.h>
+#include "btree.h"
+
+/*
+ * __BT_GET -- Get a record from the btree.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *	key:	key to find
+ *	data:	data to return
+ *	flag:	currently unused
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found.
+ */
+int
+__bt_get(dbp, key, data, flags)
+	const DB *dbp;
+	const DBT *key;
+	DBT *data;
+	u_int flags;
+{
+	BTREE *t;
+	EPG *e;
+	int exact, status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/* Get currently doesn't take any flags. */
+	if (flags) {
+		errno = EINVAL;
+		return (RET_ERROR);
+	}
+
+	if ((e = __bt_search(t, key, &exact)) == NULL)
+		return (RET_ERROR);
+	if (!exact) {
+		mpool_put(t->bt_mp, e->page, 0);
+		return (RET_SPECIAL);
+	}
+
+	status = __bt_ret(t, e, NULL, NULL, data, &t->bt_rdata, 0);
+
+	/*
+	 * If the user is doing concurrent access, we copied the
+	 * key/data, toss the page.
+	 */
+	if (F_ISSET(t, B_DB_LOCK))
+		mpool_put(t->bt_mp, e->page, 0);
+	else
+		t->bt_pinned = e->page;
+	return (status);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_open.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_open.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_open.c	(revision 2404)
@@ -0,0 +1,449 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_open.c	8.10 (Berkeley) 8/17/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_open.c,v 1.11 2002/03/22 21:52:01 obrien Exp $");
+
+/*
+ * Implementation of btree access method for 4.4BSD.
+ *
+ * The design here was originally based on that of the btree access method
+ * used in the Postgres database system at UC Berkeley.  This implementation
+ * is wholly independent of the Postgres code.
+ */
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+#include <db.h>
+#include "btree.h"
+
+#ifdef DEBUG
+#undef	MINPSIZE
+#define	MINPSIZE	128
+#endif
+
+static int byteorder(void);
+static int nroot(BTREE *);
+static int tmp(void);
+
+/*
+ * __BT_OPEN -- Open a btree.
+ *
+ * Creates and fills a DB struct, and calls the routine that actually
+ * opens the btree.
+ *
+ * Parameters:
+ *	fname:	filename (NULL for in-memory trees)
+ *	flags:	open flag bits
+ *	mode:	open permission bits
+ *	b:	BTREEINFO pointer
+ *
+ * Returns:
+ *	NULL on failure, pointer to DB on success.
+ *
+ */
+DB *
+__bt_open(fname, flags, mode, openinfo, dflags)
+	const char *fname;
+	int flags, mode, dflags;
+	const BTREEINFO *openinfo;
+{
+	struct stat sb;
+	BTMETA m;
+	BTREE *t;
+	BTREEINFO b;
+	DB *dbp;
+	pgno_t ncache;
+	ssize_t nr;
+	int machine_lorder;
+
+	t = NULL;
+
+	/*
+	 * Intention is to make sure all of the user's selections are okay
+	 * here and then use them without checking.  Can't be complete, since
+	 * we don't know the right page size, lorder or flags until the backing
+	 * file is opened.  Also, the file's page size can cause the cachesize
+	 * to change.
+	 */
+	machine_lorder = byteorder();
+	if (openinfo) {
+		b = *openinfo;
+
+		/* Flags: R_DUP. */
+		if (b.flags & ~(R_DUP))
+			goto einval;
+
+		/*
+		 * Page size must be indx_t aligned and >= MINPSIZE.  Default
+		 * page size is set farther on, based on the underlying file
+		 * transfer size.
+		 */
+		if (b.psize &&
+		    (b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 ||
+		    b.psize & (sizeof(indx_t) - 1) ))
+			goto einval;
+
+		/* Minimum number of keys per page; absolute minimum is 2. */
+		if (b.minkeypage) {
+			if (b.minkeypage < 2)
+				goto einval;
+		} else
+			b.minkeypage = DEFMINKEYPAGE;
+
+		/* If no comparison, use default comparison and prefix. */
+		if (b.compare == NULL) {
+			b.compare = __bt_defcmp;
+			if (b.prefix == NULL)
+				b.prefix = __bt_defpfx;
+		}
+
+		if (b.lorder == 0)
+			b.lorder = machine_lorder;
+	} else {
+		b.compare = __bt_defcmp;
+		b.cachesize = 0;
+		b.flags = 0;
+		b.lorder = machine_lorder;
+		b.minkeypage = DEFMINKEYPAGE;
+		b.prefix = __bt_defpfx;
+		b.psize = 0;
+	}
+
+	/* Check for the ubiquitous PDP-11. */
+	if (b.lorder != BIG_ENDIAN && b.lorder != LITTLE_ENDIAN)
+		goto einval;
+
+	/* Allocate and initialize DB and BTREE structures. */
+	if ((t = (BTREE *)malloc(sizeof(BTREE))) == NULL)
+		goto err;
+	memset(t, 0, sizeof(BTREE));
+	t->bt_fd = -1;			/* Don't close unopened fd on error. */
+	t->bt_lorder = b.lorder;
+	t->bt_order = NOT;
+	t->bt_cmp = b.compare;
+	t->bt_pfx = b.prefix;
+	t->bt_rfd = -1;
+
+	if ((t->bt_dbp = dbp = (DB *)malloc(sizeof(DB))) == NULL)
+		goto err;
+	memset(t->bt_dbp, 0, sizeof(DB));
+	if (t->bt_lorder != machine_lorder)
+		F_SET(t, B_NEEDSWAP);
+
+	dbp->type = DB_BTREE;
+	dbp->internal = t;
+	dbp->close = __bt_close;
+	dbp->del = __bt_delete;
+	dbp->fd = __bt_fd;
+	dbp->get = __bt_get;
+	dbp->put = __bt_put;
+	dbp->seq = __bt_seq;
+	dbp->sync = __bt_sync;
+
+	/*
+	 * If no file name was supplied, this is an in-memory btree and we
+	 * open a backing temporary file.  Otherwise, it's a disk-based tree.
+	 */
+	if (fname) {
+		switch (flags & O_ACCMODE) {
+		case O_RDONLY:
+			F_SET(t, B_RDONLY);
+			break;
+		case O_RDWR:
+			break;
+		case O_WRONLY:
+		default:
+			goto einval;
+		}
+		
+		if ((t->bt_fd = _open(fname, flags, mode)) < 0)
+			goto err;
+
+	} else {
+		if ((flags & O_ACCMODE) != O_RDWR)
+			goto einval;
+		if ((t->bt_fd = tmp()) == -1)
+			goto err;
+		F_SET(t, B_INMEM);
+	}
+
+	if (_fcntl(t->bt_fd, F_SETFD, 1) == -1)
+		goto err;
+
+	if (_fstat(t->bt_fd, &sb))
+		goto err;
+	if (sb.st_size) {
+		if ((nr = _read(t->bt_fd, &m, sizeof(BTMETA))) < 0)
+			goto err;
+		if (nr != sizeof(BTMETA))
+			goto eftype;
+
+		/*
+		 * Read in the meta-data.  This can change the notion of what
+		 * the lorder, page size and flags are, and, when the page size
+		 * changes, the cachesize value can change too.  If the user
+		 * specified the wrong byte order for an existing database, we
+		 * don't bother to return an error, we just clear the NEEDSWAP
+		 * bit.
+		 */
+		if (m.magic == BTREEMAGIC)
+			F_CLR(t, B_NEEDSWAP);
+		else {
+			F_SET(t, B_NEEDSWAP);
+			M_32_SWAP(m.magic);
+			M_32_SWAP(m.version);
+			M_32_SWAP(m.psize);
+			M_32_SWAP(m.free);
+			M_32_SWAP(m.nrecs);
+			M_32_SWAP(m.flags);
+		}
+		if (m.magic != BTREEMAGIC || m.version != BTREEVERSION)
+			goto eftype;
+		if (m.psize < MINPSIZE || m.psize > MAX_PAGE_OFFSET + 1 ||
+		    m.psize & (sizeof(indx_t) - 1) )
+			goto eftype;
+		if (m.flags & ~SAVEMETA)
+			goto eftype;
+		b.psize = m.psize;
+		F_SET(t, m.flags);
+		t->bt_free = m.free;
+		t->bt_nrecs = m.nrecs;
+	} else {
+		/*
+		 * Set the page size to the best value for I/O to this file.
+		 * Don't overflow the page offset type.
+		 */
+		if (b.psize == 0) {
+			b.psize = sb.st_blksize;
+			if (b.psize < MINPSIZE)
+				b.psize = MINPSIZE;
+			if (b.psize > MAX_PAGE_OFFSET + 1)
+				b.psize = MAX_PAGE_OFFSET + 1;
+		}
+
+		/* Set flag if duplicates permitted. */
+		if (!(b.flags & R_DUP))
+			F_SET(t, B_NODUPS);
+
+		t->bt_free = P_INVALID;
+		t->bt_nrecs = 0;
+		F_SET(t, B_METADIRTY);
+	}
+
+	t->bt_psize = b.psize;
+
+	/* Set the cache size; must be a multiple of the page size. */
+	if (b.cachesize && b.cachesize & (b.psize - 1) )
+		b.cachesize += (~b.cachesize & (b.psize - 1) ) + 1;
+	if (b.cachesize < b.psize * MINCACHE)
+		b.cachesize = b.psize * MINCACHE;
+
+	/* Calculate number of pages to cache. */
+	ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize;
+
+	/*
+	 * The btree data structure requires that at least two keys can fit on
+	 * a page, but other than that there's no fixed requirement.  The user
+	 * specified a minimum number per page, and we translated that into the
+	 * number of bytes a key/data pair can use before being placed on an
+	 * overflow page.  This calculation includes the page header, the size
+	 * of the index referencing the leaf item and the size of the leaf item
+	 * structure.  Also, don't let the user specify a minkeypage such that
+	 * a key/data pair won't fit even if both key and data are on overflow
+	 * pages.
+	 */
+	t->bt_ovflsize = (t->bt_psize - BTDATAOFF) / b.minkeypage -
+	    (sizeof(indx_t) + NBLEAFDBT(0, 0));
+	if (t->bt_ovflsize < NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t))
+		t->bt_ovflsize =
+		    NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t);
+
+	/* Initialize the buffer pool. */
+	if ((t->bt_mp =
+	    mpool_open(NULL, t->bt_fd, t->bt_psize, ncache)) == NULL)
+		goto err;
+	if (!F_ISSET(t, B_INMEM))
+		mpool_filter(t->bt_mp, __bt_pgin, __bt_pgout, t);
+
+	/* Create a root page if new tree. */
+	if (nroot(t) == RET_ERROR)
+		goto err;
+
+	/* Global flags. */
+	if (dflags & DB_LOCK)
+		F_SET(t, B_DB_LOCK);
+	if (dflags & DB_SHMEM)
+		F_SET(t, B_DB_SHMEM);
+	if (dflags & DB_TXN)
+		F_SET(t, B_DB_TXN);
+
+	return (dbp);
+
+einval:	errno = EINVAL;
+	goto err;
+
+eftype:	errno = EFTYPE;
+	goto err;
+
+err:	if (t) {
+		if (t->bt_dbp)
+			free(t->bt_dbp);
+		if (t->bt_fd != -1)
+			(void)_close(t->bt_fd);
+		free(t);
+	}
+	return (NULL);
+}
+
+/*
+ * NROOT -- Create the root of a new tree.
+ *
+ * Parameters:
+ *	t:	tree
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+static int
+nroot(t)
+	BTREE *t;
+{
+	PAGE *meta, *root;
+	pgno_t npg;
+
+	if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) {
+		mpool_put(t->bt_mp, meta, 0);
+		return (RET_SUCCESS);
+	}
+	if (errno != EINVAL)		/* It's OK to not exist. */
+		return (RET_ERROR);
+	errno = 0;
+
+	if ((meta = mpool_new(t->bt_mp, &npg)) == NULL)
+		return (RET_ERROR);
+
+	if ((root = mpool_new(t->bt_mp, &npg)) == NULL)
+		return (RET_ERROR);
+
+	if (npg != P_ROOT)
+		return (RET_ERROR);
+	root->pgno = npg;
+	root->prevpg = root->nextpg = P_INVALID;
+	root->lower = BTDATAOFF;
+	root->upper = t->bt_psize;
+	root->flags = P_BLEAF;
+	memset(meta, 0, t->bt_psize);
+	mpool_put(t->bt_mp, meta, MPOOL_DIRTY);
+	mpool_put(t->bt_mp, root, MPOOL_DIRTY);
+	return (RET_SUCCESS);
+}
+
+static int
+tmp()
+{
+	sigset_t set, oset;
+	int fd;
+	char *envtmp = NULL;
+	char path[MAXPATHLEN];
+
+	if (issetugid() == 0)
+		envtmp = getenv("TMPDIR");
+	(void)snprintf(path,
+	    sizeof(path), "%s/bt.XXXXXXXXXX", envtmp ? envtmp : "/tmp");
+
+	(void)sigfillset(&set);
+	(void)_sigprocmask(SIG_BLOCK, &set, &oset);
+	if ((fd = mkstemp(path)) != -1)
+		(void)unlink(path);
+	(void)_sigprocmask(SIG_SETMASK, &oset, NULL);
+	return(fd);
+}
+
+static int
+byteorder()
+{
+	u_int32_t x;
+	u_char *p;
+
+	x = 0x01020304;
+	p = (u_char *)&x;
+	switch (*p) {
+	case 1:
+		return (BIG_ENDIAN);
+	case 4:
+		return (LITTLE_ENDIAN);
+	default:
+		return (0);
+	}
+}
+
+int
+__bt_fd(dbp)
+        const DB *dbp;
+{
+	BTREE *t;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/* In-memory database can't have a file descriptor. */
+	if (F_ISSET(t, B_INMEM)) {
+		errno = ENOENT;
+		return (-1);
+	}
+	return (t->bt_fd);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_overflow.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_overflow.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_overflow.c	(revision 2404)
@@ -0,0 +1,230 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_overflow.c	8.5 (Berkeley) 7/16/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_overflow.c,v 1.3 2002/03/22 21:52:01 obrien Exp $");
+
+#include <sys/param.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <db.h>
+#include "btree.h"
+
+/*
+ * Big key/data code.
+ *
+ * Big key and data entries are stored on linked lists of pages.  The initial
+ * reference is byte string stored with the key or data and is the page number
+ * and size.  The actual record is stored in a chain of pages linked by the
+ * nextpg field of the PAGE header.
+ *
+ * The first page of the chain has a special property.  If the record is used
+ * by an internal page, it cannot be deleted and the P_PRESERVE bit will be set
+ * in the header.
+ *
+ * XXX
+ * A single DBT is written to each chain, so a lot of space on the last page
+ * is wasted.  This is a fairly major bug for some data sets.
+ */
+
+/*
+ * __OVFL_GET -- Get an overflow key/data item.
+ *
+ * Parameters:
+ *	t:	tree
+ *	p:	pointer to { pgno_t, u_int32_t }
+ *	buf:	storage address
+ *	bufsz:	storage size
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__ovfl_get(t, p, ssz, buf, bufsz)
+	BTREE *t;
+	void *p;
+	size_t *ssz;
+	void **buf;
+	size_t *bufsz;
+{
+	PAGE *h;
+	pgno_t pg;
+	size_t nb, plen;
+	u_int32_t sz;
+
+	memmove(&pg, p, sizeof(pgno_t));
+	memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t));
+	*ssz = sz;
+
+#ifdef DEBUG
+	if (pg == P_INVALID || sz == 0)
+		abort();
+#endif
+	/* Make the buffer bigger as necessary. */
+	if (*bufsz < sz) {
+		*buf = (char *)(*buf == NULL ? malloc(sz) : reallocf(*buf, sz));
+		if (*buf == NULL)
+			return (RET_ERROR);
+		*bufsz = sz;
+	}
+
+	/*
+	 * Step through the linked list of pages, copying the data on each one
+	 * into the buffer.  Never copy more than the data's length.
+	 */
+	plen = t->bt_psize - BTDATAOFF;
+	for (p = *buf;; p = (char *)p + nb, pg = h->nextpg) {
+		if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+			return (RET_ERROR);
+
+		nb = MIN(sz, plen);
+		memmove(p, (char *)h + BTDATAOFF, nb);
+		mpool_put(t->bt_mp, h, 0);
+
+		if ((sz -= nb) == 0)
+			break;
+	}
+	return (RET_SUCCESS);
+}
+
+/*
+ * __OVFL_PUT -- Store an overflow key/data item.
+ *
+ * Parameters:
+ *	t:	tree
+ *	data:	DBT to store
+ *	pgno:	storage page number
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__ovfl_put(t, dbt, pg)
+	BTREE *t;
+	const DBT *dbt;
+	pgno_t *pg;
+{
+	PAGE *h, *last;
+	void *p;
+	pgno_t npg;
+	size_t nb, plen;
+	u_int32_t sz;
+
+	/*
+	 * Allocate pages and copy the key/data record into them.  Store the
+	 * number of the first page in the chain.
+	 */
+	plen = t->bt_psize - BTDATAOFF;
+	for (last = NULL, p = dbt->data, sz = dbt->size;;
+	    p = (char *)p + plen, last = h) {
+		if ((h = __bt_new(t, &npg)) == NULL)
+			return (RET_ERROR);
+
+		h->pgno = npg;
+		h->nextpg = h->prevpg = P_INVALID;
+		h->flags = P_OVERFLOW;
+		h->lower = h->upper = 0;
+
+		nb = MIN(sz, plen);
+		memmove((char *)h + BTDATAOFF, p, nb);
+
+		if (last) {
+			last->nextpg = h->pgno;
+			mpool_put(t->bt_mp, last, MPOOL_DIRTY);
+		} else
+			*pg = h->pgno;
+
+		if ((sz -= nb) == 0) {
+			mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+			break;
+		}
+	}
+	return (RET_SUCCESS);
+}
+
+/*
+ * __OVFL_DELETE -- Delete an overflow chain.
+ *
+ * Parameters:
+ *	t:	tree
+ *	p:	pointer to { pgno_t, u_int32_t }
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__ovfl_delete(t, p)
+	BTREE *t;
+	void *p;
+{
+	PAGE *h;
+	pgno_t pg;
+	size_t plen;
+	u_int32_t sz;
+
+	memmove(&pg, p, sizeof(pgno_t));
+	memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(u_int32_t));
+
+#ifdef DEBUG
+	if (pg == P_INVALID || sz == 0)
+		abort();
+#endif
+	if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+		return (RET_ERROR);
+
+	/* Don't delete chains used by internal pages. */
+	if (h->flags & P_PRESERVE) {
+		mpool_put(t->bt_mp, h, 0);
+		return (RET_SUCCESS);
+	}
+
+	/* Step through the chain, calling the free routine for each page. */
+	for (plen = t->bt_psize - BTDATAOFF;; sz -= plen) {
+		pg = h->nextpg;
+		__bt_free(t, h);
+		if (sz <= plen)
+			break;
+		if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+			return (RET_ERROR);
+	}
+	return (RET_SUCCESS);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_page.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_page.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_page.c	(revision 2404)
@@ -0,0 +1,102 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_page.c	8.3 (Berkeley) 7/14/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_page.c,v 1.3 2002/03/22 21:52:01 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <stdio.h>
+
+#include <db.h>
+#include "btree.h"
+
+/*
+ * __bt_free --
+ *	Put a page on the freelist.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	page to free
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ *
+ * Side-effect:
+ *	mpool_put's the page.
+ */
+int
+__bt_free(t, h)
+	BTREE *t;
+	PAGE *h;
+{
+	/* Insert the page at the head of the free list. */
+	h->prevpg = P_INVALID;
+	h->nextpg = t->bt_free;
+	t->bt_free = h->pgno;
+	F_SET(t, B_METADIRTY);
+
+	/* Make sure the page gets written back. */
+	return (mpool_put(t->bt_mp, h, MPOOL_DIRTY));
+}
+
+/*
+ * __bt_new --
+ *	Get a new page, preferably from the freelist.
+ *
+ * Parameters:
+ *	t:	tree
+ *	npg:	storage for page number.
+ *
+ * Returns:
+ *	Pointer to a page, NULL on error.
+ */
+PAGE *
+__bt_new(t, npg)
+	BTREE *t;
+	pgno_t *npg;
+{
+	PAGE *h;
+
+	if (t->bt_free != P_INVALID &&
+	    (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) {
+		*npg = t->bt_free;
+		t->bt_free = h->nextpg;
+		F_SET(t, B_METADIRTY);
+		return (h);
+	}
+	return (mpool_new(t->bt_mp, npg));
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_put.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_put.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_put.c	(revision 2404)
@@ -0,0 +1,325 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_put.c	8.8 (Berkeley) 7/26/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_put.c,v 1.4 2003/05/30 11:05:08 tmm Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <db.h>
+#include "btree.h"
+
+static EPG *bt_fast(BTREE *, const DBT *, const DBT *, int *);
+
+/*
+ * __BT_PUT -- Add a btree item to the tree.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *	key:	key
+ *	data:	data
+ *	flag:	R_NOOVERWRITE
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the
+ *	tree and R_NOOVERWRITE specified.
+ */
+int
+__bt_put(dbp, key, data, flags)
+	const DB *dbp;
+	DBT *key;
+	const DBT *data;
+	u_int flags;
+{
+	BTREE *t;
+	DBT tkey, tdata;
+	EPG *e;
+	PAGE *h;
+	indx_t index, nxtindex;
+	pgno_t pg;
+	u_int32_t nbytes, tmp;
+	int dflags, exact, status;
+	char *dest, db[NOVFLSIZE], kb[NOVFLSIZE];
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/* Check for change to a read-only tree. */
+	if (F_ISSET(t, B_RDONLY)) {
+		errno = EPERM;
+		return (RET_ERROR);
+	}
+
+	switch (flags) {
+	case 0:
+	case R_NOOVERWRITE:
+		break;
+	case R_CURSOR:
+		/*
+		 * If flags is R_CURSOR, put the cursor.  Must already
+		 * have started a scan and not have already deleted it.
+		 */
+		if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
+		    !F_ISSET(&t->bt_cursor,
+		        CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE))
+			break;
+		/* FALLTHROUGH */
+	default:
+		errno = EINVAL;
+		return (RET_ERROR);
+	}
+
+	/*
+	 * If the key/data pair won't fit on a page, store it on overflow
+	 * pages.  Only put the key on the overflow page if the pair are
+	 * still too big after moving the data to an overflow page.
+	 *
+	 * XXX
+	 * If the insert fails later on, the overflow pages aren't recovered.
+	 */
+	dflags = 0;
+	if (key->size + data->size > t->bt_ovflsize) {
+		if (key->size > t->bt_ovflsize) {
+storekey:		if (__ovfl_put(t, key, &pg) == RET_ERROR)
+				return (RET_ERROR);
+			tkey.data = kb;
+			tkey.size = NOVFLSIZE;
+			memmove(kb, &pg, sizeof(pgno_t));
+			tmp = key->size;
+			memmove(kb + sizeof(pgno_t),
+			    &tmp, sizeof(u_int32_t));
+			dflags |= P_BIGKEY;
+			key = &tkey;
+		}
+		if (key->size + data->size > t->bt_ovflsize) {
+			if (__ovfl_put(t, data, &pg) == RET_ERROR)
+				return (RET_ERROR);
+			tdata.data = db;
+			tdata.size = NOVFLSIZE;
+			memmove(db, &pg, sizeof(pgno_t));
+			tmp = data->size;
+			memmove(db + sizeof(pgno_t),
+			    &tmp, sizeof(u_int32_t));
+			dflags |= P_BIGDATA;
+			data = &tdata;
+		}
+		if (key->size + data->size > t->bt_ovflsize)
+			goto storekey;
+	}
+
+	/* Replace the cursor. */
+	if (flags == R_CURSOR) {
+		if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL)
+			return (RET_ERROR);
+		index = t->bt_cursor.pg.index;
+		goto delete;
+	}
+
+	/*
+	 * Find the key to delete, or, the location at which to insert.
+	 * Bt_fast and __bt_search both pin the returned page.
+	 */
+	if (t->bt_order == NOT || (e = bt_fast(t, key, data, &exact)) == NULL)
+		if ((e = __bt_search(t, key, &exact)) == NULL)
+			return (RET_ERROR);
+	h = e->page;
+	index = e->index;
+
+	/*
+	 * Add the key/data pair to the tree.  If an identical key is already
+	 * in the tree, and R_NOOVERWRITE is set, an error is returned.  If
+	 * R_NOOVERWRITE is not set, the key is either added (if duplicates are
+	 * permitted) or an error is returned.
+	 */
+	switch (flags) {
+	case R_NOOVERWRITE:
+		if (!exact)
+			break;
+		mpool_put(t->bt_mp, h, 0);
+		return (RET_SPECIAL);
+	default:
+		if (!exact || !F_ISSET(t, B_NODUPS))
+			break;
+		/*
+		 * !!!
+		 * Note, the delete may empty the page, so we need to put a
+		 * new entry into the page immediately.
+		 */
+delete:		if (__bt_dleaf(t, key, h, index) == RET_ERROR) {
+			mpool_put(t->bt_mp, h, 0);
+			return (RET_ERROR);
+		}
+		break;
+	}
+
+	/*
+	 * If not enough room, or the user has put a ceiling on the number of
+	 * keys permitted in the page, split the page.  The split code will
+	 * insert the key and data and unpin the current page.  If inserting
+	 * into the offset array, shift the pointers up.
+	 */
+	nbytes = NBLEAFDBT(key->size, data->size);
+	if (h->upper - h->lower < nbytes + sizeof(indx_t)) {
+		if ((status = __bt_split(t, h, key,
+		    data, dflags, nbytes, index)) != RET_SUCCESS)
+			return (status);
+		goto success;
+	}
+
+	if (index < (nxtindex = NEXTINDEX(h)))
+		memmove(h->linp + index + 1, h->linp + index,
+		    (nxtindex - index) * sizeof(indx_t));
+	h->lower += sizeof(indx_t);
+
+	h->linp[index] = h->upper -= nbytes;
+	dest = (char *)h + h->upper;
+	WR_BLEAF(dest, key, data, dflags);
+
+	/* If the cursor is on this page, adjust it as necessary. */
+	if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
+	    !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
+	    t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= index)
+		++t->bt_cursor.pg.index;
+
+	if (t->bt_order == NOT) {
+		if (h->nextpg == P_INVALID) {
+			if (index == NEXTINDEX(h) - 1) {
+				t->bt_order = FORWARD;
+				t->bt_last.index = index;
+				t->bt_last.pgno = h->pgno;
+			}
+		} else if (h->prevpg == P_INVALID) {
+			if (index == 0) {
+				t->bt_order = BACK;
+				t->bt_last.index = 0;
+				t->bt_last.pgno = h->pgno;
+			}
+		}
+	}
+
+	mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+
+success:
+	if (flags == R_SETCURSOR)
+		__bt_setcur(t, e->page->pgno, e->index);
+
+	F_SET(t, B_MODIFIED);
+	return (RET_SUCCESS);
+}
+
+#ifdef STATISTICS
+u_long bt_cache_hit, bt_cache_miss;
+#endif
+
+/*
+ * BT_FAST -- Do a quick check for sorted data.
+ *
+ * Parameters:
+ *	t:	tree
+ *	key:	key to insert
+ *
+ * Returns:
+ * 	EPG for new record or NULL if not found.
+ */
+static EPG *
+bt_fast(t, key, data, exactp)
+	BTREE *t;
+	const DBT *key, *data;
+	int *exactp;
+{
+	PAGE *h;
+	u_int32_t nbytes;
+	int cmp;
+
+	if ((h = mpool_get(t->bt_mp, t->bt_last.pgno, 0)) == NULL) {
+		t->bt_order = NOT;
+		return (NULL);
+	}
+	t->bt_cur.page = h;
+	t->bt_cur.index = t->bt_last.index;
+
+	/*
+	 * If won't fit in this page or have too many keys in this page,
+	 * have to search to get split stack.
+	 */
+	nbytes = NBLEAFDBT(key->size, data->size);
+	if (h->upper - h->lower < nbytes + sizeof(indx_t))
+		goto miss;
+
+	if (t->bt_order == FORWARD) {
+		if (t->bt_cur.page->nextpg != P_INVALID)
+			goto miss;
+		if (t->bt_cur.index != NEXTINDEX(h) - 1)
+			goto miss;
+		if ((cmp = __bt_cmp(t, key, &t->bt_cur)) < 0)
+			goto miss;
+		t->bt_last.index = cmp ? ++t->bt_cur.index : t->bt_cur.index;
+	} else {
+		if (t->bt_cur.page->prevpg != P_INVALID)
+			goto miss;
+		if (t->bt_cur.index != 0)
+			goto miss;
+		if ((cmp = __bt_cmp(t, key, &t->bt_cur)) > 0)
+			goto miss;
+		t->bt_last.index = 0;
+	}
+	*exactp = cmp == 0;
+#ifdef STATISTICS
+	++bt_cache_hit;
+#endif
+	return (&t->bt_cur);
+
+miss:
+#ifdef STATISTICS
+	++bt_cache_miss;
+#endif
+	t->bt_order = NOT;
+	mpool_put(t->bt_mp, h, 0);
+	return (NULL);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_search.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_search.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_search.c	(revision 2404)
@@ -0,0 +1,215 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_search.c	8.8 (Berkeley) 7/31/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_search.c,v 1.2 2002/03/21 22:46:25 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <stdio.h>
+
+#include <db.h>
+#include "btree.h"
+
+static int __bt_snext(BTREE *, PAGE *, const DBT *, int *);
+static int __bt_sprev(BTREE *, PAGE *, const DBT *, int *);
+
+/*
+ * __bt_search --
+ *	Search a btree for a key.
+ *
+ * Parameters:
+ *	t:	tree to search
+ *	key:	key to find
+ *	exactp:	pointer to exact match flag
+ *
+ * Returns:
+ *	The EPG for matching record, if any, or the EPG for the location
+ *	of the key, if it were inserted into the tree, is entered into
+ *	the bt_cur field of the tree.  A pointer to the field is returned.
+ */
+EPG *
+__bt_search(t, key, exactp)
+	BTREE *t;
+	const DBT *key;
+	int *exactp;
+{
+	PAGE *h;
+	indx_t base, index, lim;
+	pgno_t pg;
+	int cmp;
+
+	BT_CLR(t);
+	for (pg = P_ROOT;;) {
+		if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+			return (NULL);
+
+		/* Do a binary search on the current page. */
+		t->bt_cur.page = h;
+		for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) {
+			t->bt_cur.index = index = base + (lim >> 1);
+			if ((cmp = __bt_cmp(t, key, &t->bt_cur)) == 0) {
+				if (h->flags & P_BLEAF) {
+					*exactp = 1;
+					return (&t->bt_cur);
+				}
+				goto next;
+			}
+			if (cmp > 0) {
+				base = index + 1;
+				--lim;
+			}
+		}
+
+		/*
+		 * If it's a leaf page, we're almost done.  If no duplicates
+		 * are allowed, or we have an exact match, we're done.  Else,
+		 * it's possible that there were matching keys on this page,
+		 * which later deleted, and we're on a page with no matches
+		 * while there are matches on other pages.  If at the start or
+		 * end of a page, check the adjacent page.
+		 */
+		if (h->flags & P_BLEAF) {
+			if (!F_ISSET(t, B_NODUPS)) {
+				if (base == 0 &&
+				    h->prevpg != P_INVALID &&
+				    __bt_sprev(t, h, key, exactp))
+					return (&t->bt_cur);
+				if (base == NEXTINDEX(h) &&
+				    h->nextpg != P_INVALID &&
+				    __bt_snext(t, h, key, exactp))
+					return (&t->bt_cur);
+			}
+			*exactp = 0;
+			t->bt_cur.index = base;
+			return (&t->bt_cur);
+		}
+
+		/*
+		 * No match found.  Base is the smallest index greater than
+		 * key and may be zero or a last + 1 index.  If it's non-zero,
+		 * decrement by one, and record the internal page which should
+		 * be a parent page for the key.  If a split later occurs, the
+		 * inserted page will be to the right of the saved page.
+		 */
+		index = base ? base - 1 : base;
+
+next:		BT_PUSH(t, h->pgno, index);
+		pg = GETBINTERNAL(h, index)->pgno;
+		mpool_put(t->bt_mp, h, 0);
+	}
+}
+
+/*
+ * __bt_snext --
+ *	Check for an exact match after the key.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	current page
+ *	key:	key
+ *	exactp:	pointer to exact match flag
+ *
+ * Returns:
+ *	If an exact match found.
+ */
+static int
+__bt_snext(t, h, key, exactp)
+	BTREE *t;
+	PAGE *h;
+	const DBT *key;
+	int *exactp;
+{
+	EPG e;
+
+	/*
+	 * Get the next page.  The key is either an exact
+	 * match, or not as good as the one we already have.
+	 */
+	if ((e.page = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL)
+		return (0);
+	e.index = 0;
+	if (__bt_cmp(t, key, &e) == 0) {
+		mpool_put(t->bt_mp, h, 0);
+		t->bt_cur = e;
+		*exactp = 1;
+		return (1);
+	}
+	mpool_put(t->bt_mp, e.page, 0);
+	return (0);
+}
+
+/*
+ * __bt_sprev --
+ *	Check for an exact match before the key.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	current page
+ *	key:	key
+ *	exactp:	pointer to exact match flag
+ *
+ * Returns:
+ *	If an exact match found.
+ */
+static int
+__bt_sprev(t, h, key, exactp)
+	BTREE *t;
+	PAGE *h;
+	const DBT *key;
+	int *exactp;
+{
+	EPG e;
+
+	/*
+	 * Get the previous page.  The key is either an exact
+	 * match, or not as good as the one we already have.
+	 */
+	if ((e.page = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL)
+		return (0);
+	e.index = NEXTINDEX(e.page) - 1;
+	if (__bt_cmp(t, key, &e) == 0) {
+		mpool_put(t->bt_mp, h, 0);
+		t->bt_cur = e;
+		*exactp = 1;
+		return (1);
+	}
+	mpool_put(t->bt_mp, e.page, 0);
+	return (0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_seq.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_seq.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_seq.c	(revision 2404)
@@ -0,0 +1,462 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_seq.c	8.7 (Berkeley) 7/20/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_seq.c,v 1.3 2002/03/21 22:46:25 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <db.h>
+#include "btree.h"
+
+static int __bt_first(BTREE *, const DBT *, EPG *, int *);
+static int __bt_seqadv(BTREE *, EPG *, int);
+static int __bt_seqset(BTREE *, EPG *, DBT *, int);
+
+/*
+ * Sequential scan support.
+ *
+ * The tree can be scanned sequentially, starting from either end of the
+ * tree or from any specific key.  A scan request before any scanning is
+ * done is initialized as starting from the least node.
+ */
+
+/*
+ * __bt_seq --
+ *	Btree sequential scan interface.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *	key:	key for positioning and return value
+ *	data:	data return value
+ *	flags:	R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV.
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key.
+ */
+int
+__bt_seq(dbp, key, data, flags)
+	const DB *dbp;
+	DBT *key, *data;
+	u_int flags;
+{
+	BTREE *t;
+	EPG e;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/*
+	 * If scan unitialized as yet, or starting at a specific record, set
+	 * the scan to a specific key.  Both __bt_seqset and __bt_seqadv pin
+	 * the page the cursor references if they're successful.
+	 */
+	switch (flags) {
+	case R_NEXT:
+	case R_PREV:
+		if (F_ISSET(&t->bt_cursor, CURS_INIT)) {
+			status = __bt_seqadv(t, &e, flags);
+			break;
+		}
+		/* FALLTHROUGH */
+	case R_FIRST:
+	case R_LAST:
+	case R_CURSOR:
+		status = __bt_seqset(t, &e, key, flags);
+		break;
+	default:
+		errno = EINVAL;
+		return (RET_ERROR);
+	}
+
+	if (status == RET_SUCCESS) {
+		__bt_setcur(t, e.page->pgno, e.index);
+
+		status =
+		    __bt_ret(t, &e, key, &t->bt_rkey, data, &t->bt_rdata, 0);
+
+		/*
+		 * If the user is doing concurrent access, we copied the
+		 * key/data, toss the page.
+		 */
+		if (F_ISSET(t, B_DB_LOCK))
+			mpool_put(t->bt_mp, e.page, 0);
+		else
+			t->bt_pinned = e.page;
+	}
+	return (status);
+}
+
+/*
+ * __bt_seqset --
+ *	Set the sequential scan to a specific key.
+ *
+ * Parameters:
+ *	t:	tree
+ *	ep:	storage for returned key
+ *	key:	key for initial scan position
+ *	flags:	R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV
+ *
+ * Side effects:
+ *	Pins the page the cursor references.
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key.
+ */
+static int
+__bt_seqset(t, ep, key, flags)
+	BTREE *t;
+	EPG *ep;
+	DBT *key;
+	int flags;
+{
+	PAGE *h;
+	pgno_t pg;
+	int exact;
+
+	/*
+	 * Find the first, last or specific key in the tree and point the
+	 * cursor at it.  The cursor may not be moved until a new key has
+	 * been found.
+	 */
+	switch (flags) {
+	case R_CURSOR:				/* Keyed scan. */
+		/*
+		 * Find the first instance of the key or the smallest key
+		 * which is greater than or equal to the specified key.
+		 */
+		if (key->data == NULL || key->size == 0) {
+			errno = EINVAL;
+			return (RET_ERROR);
+		}
+		return (__bt_first(t, key, ep, &exact));
+	case R_FIRST:				/* First record. */
+	case R_NEXT:
+		/* Walk down the left-hand side of the tree. */
+		for (pg = P_ROOT;;) {
+			if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+				return (RET_ERROR);
+
+			/* Check for an empty tree. */
+			if (NEXTINDEX(h) == 0) {
+				mpool_put(t->bt_mp, h, 0);
+				return (RET_SPECIAL);
+			}
+
+			if (h->flags & (P_BLEAF | P_RLEAF))
+				break;
+			pg = GETBINTERNAL(h, 0)->pgno;
+			mpool_put(t->bt_mp, h, 0);
+		}
+		ep->page = h;
+		ep->index = 0;
+		break;
+	case R_LAST:				/* Last record. */
+	case R_PREV:
+		/* Walk down the right-hand side of the tree. */
+		for (pg = P_ROOT;;) {
+			if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+				return (RET_ERROR);
+
+			/* Check for an empty tree. */
+			if (NEXTINDEX(h) == 0) {
+				mpool_put(t->bt_mp, h, 0);
+				return (RET_SPECIAL);
+			}
+
+			if (h->flags & (P_BLEAF | P_RLEAF))
+				break;
+			pg = GETBINTERNAL(h, NEXTINDEX(h) - 1)->pgno;
+			mpool_put(t->bt_mp, h, 0);
+		}
+
+		ep->page = h;
+		ep->index = NEXTINDEX(h) - 1;
+		break;
+	}
+	return (RET_SUCCESS);
+}
+
+/*
+ * __bt_seqadvance --
+ *	Advance the sequential scan.
+ *
+ * Parameters:
+ *	t:	tree
+ *	flags:	R_NEXT, R_PREV
+ *
+ * Side effects:
+ *	Pins the page the new key/data record is on.
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key.
+ */
+static int
+__bt_seqadv(t, ep, flags)
+	BTREE *t;
+	EPG *ep;
+	int flags;
+{
+	CURSOR *c;
+	PAGE *h;
+	indx_t index;
+	pgno_t pg;
+	int exact;
+
+	/*
+	 * There are a couple of states that we can be in.  The cursor has
+	 * been initialized by the time we get here, but that's all we know.
+	 */
+	c = &t->bt_cursor;
+
+	/*
+	 * The cursor was deleted where there weren't any duplicate records,
+	 * so the key was saved.  Find out where that key would go in the
+	 * current tree.  It doesn't matter if the returned key is an exact
+	 * match or not -- if it's an exact match, the record was added after
+	 * the delete so we can just return it.  If not, as long as there's
+	 * a record there, return it.
+	 */
+	if (F_ISSET(c, CURS_ACQUIRE))
+		return (__bt_first(t, &c->key, ep, &exact));
+
+	/* Get the page referenced by the cursor. */
+	if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL)
+		return (RET_ERROR);
+
+	/*
+ 	 * Find the next/previous record in the tree and point the cursor at
+	 * it.  The cursor may not be moved until a new key has been found.
+	 */
+	switch (flags) {
+	case R_NEXT:			/* Next record. */
+		/*
+		 * The cursor was deleted in duplicate records, and moved
+		 * forward to a record that has yet to be returned.  Clear
+		 * that flag, and return the record.
+		 */
+		if (F_ISSET(c, CURS_AFTER))
+			goto usecurrent;
+		index = c->pg.index;
+		if (++index == NEXTINDEX(h)) {
+			pg = h->nextpg;
+			mpool_put(t->bt_mp, h, 0);
+			if (pg == P_INVALID)
+				return (RET_SPECIAL);
+			if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+				return (RET_ERROR);
+			index = 0;
+		}
+		break;
+	case R_PREV:			/* Previous record. */
+		/*
+		 * The cursor was deleted in duplicate records, and moved
+		 * backward to a record that has yet to be returned.  Clear
+		 * that flag, and return the record.
+		 */
+		if (F_ISSET(c, CURS_BEFORE)) {
+usecurrent:		F_CLR(c, CURS_AFTER | CURS_BEFORE);
+			ep->page = h;
+			ep->index = c->pg.index;
+			return (RET_SUCCESS);
+		}
+		index = c->pg.index;
+		if (index == 0) {
+			pg = h->prevpg;
+			mpool_put(t->bt_mp, h, 0);
+			if (pg == P_INVALID)
+				return (RET_SPECIAL);
+			if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+				return (RET_ERROR);
+			index = NEXTINDEX(h) - 1;
+		} else
+			--index;
+		break;
+	}
+
+	ep->page = h;
+	ep->index = index;
+	return (RET_SUCCESS);
+}
+
+/*
+ * __bt_first --
+ *	Find the first entry.
+ *
+ * Parameters:
+ *	t:	the tree
+ *    key:	the key
+ *  erval:	return EPG
+ * exactp:	pointer to exact match flag
+ *
+ * Returns:
+ *	The first entry in the tree greater than or equal to key,
+ *	or RET_SPECIAL if no such key exists.
+ */
+static int
+__bt_first(t, key, erval, exactp)
+	BTREE *t;
+	const DBT *key;
+	EPG *erval;
+	int *exactp;
+{
+	PAGE *h;
+	EPG *ep, save;
+	pgno_t pg;
+
+	/*
+	 * Find any matching record; __bt_search pins the page.
+	 *
+	 * If it's an exact match and duplicates are possible, walk backwards
+	 * in the tree until we find the first one.  Otherwise, make sure it's
+	 * a valid key (__bt_search may return an index just past the end of a
+	 * page) and return it.
+	 */
+	if ((ep = __bt_search(t, key, exactp)) == NULL)
+		return (0);
+	if (*exactp) {
+		if (F_ISSET(t, B_NODUPS)) {
+			*erval = *ep;
+			return (RET_SUCCESS);
+		}
+			
+		/*
+		 * Walk backwards, as long as the entry matches and there are
+		 * keys left in the tree.  Save a copy of each match in case
+		 * we go too far.
+		 */
+		save = *ep;
+		h = ep->page;
+		do {
+			if (save.page->pgno != ep->page->pgno) {
+				mpool_put(t->bt_mp, save.page, 0);
+				save = *ep;
+			} else
+				save.index = ep->index;
+
+			/*
+			 * Don't unpin the page the last (or original) match
+			 * was on, but make sure it's unpinned if an error
+			 * occurs.
+			 */
+			if (ep->index == 0) {
+				if (h->prevpg == P_INVALID)
+					break;
+				if (h->pgno != save.page->pgno)
+					mpool_put(t->bt_mp, h, 0);
+				if ((h = mpool_get(t->bt_mp,
+				    h->prevpg, 0)) == NULL) {
+					if (h->pgno == save.page->pgno)
+						mpool_put(t->bt_mp,
+						    save.page, 0);
+					return (RET_ERROR);
+				}
+				ep->page = h;
+				ep->index = NEXTINDEX(h);
+			}
+			--ep->index;
+		} while (__bt_cmp(t, key, ep) == 0);
+
+		/*
+		 * Reach here with the last page that was looked at pinned,
+		 * which may or may not be the same as the last (or original)
+		 * match page.  If it's not useful, release it.
+		 */
+		if (h->pgno != save.page->pgno)
+			mpool_put(t->bt_mp, h, 0);
+
+		*erval = save;
+		return (RET_SUCCESS);
+	}
+
+	/* If at the end of a page, find the next entry. */
+	if (ep->index == NEXTINDEX(ep->page)) {
+		h = ep->page;
+		pg = h->nextpg;
+		mpool_put(t->bt_mp, h, 0);
+		if (pg == P_INVALID)
+			return (RET_SPECIAL);
+		if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+			return (RET_ERROR);
+		ep->index = 0;
+		ep->page = h;
+	}
+	*erval = *ep;
+	return (RET_SUCCESS);
+}
+
+/*
+ * __bt_setcur --
+ *	Set the cursor to an entry in the tree.
+ *
+ * Parameters:
+ *	t:	the tree
+ *   pgno:	page number
+ *  index:	page index
+ */
+void
+__bt_setcur(t, pgno, index)
+	BTREE *t;
+	pgno_t pgno;
+	u_int index;
+{
+	/* Lose any already deleted key. */
+	if (t->bt_cursor.key.data != NULL) {
+		free(t->bt_cursor.key.data);
+		t->bt_cursor.key.size = 0;
+		t->bt_cursor.key.data = NULL;
+	}
+	F_CLR(&t->bt_cursor, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE);
+
+	/* Update the cursor. */
+	t->bt_cursor.pg.pgno = pgno;
+	t->bt_cursor.pg.index = index;
+	F_SET(&t->bt_cursor, CURS_INIT);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_split.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_split.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_split.c	(revision 2404)
@@ -0,0 +1,827 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_split.c	8.9 (Berkeley) 7/26/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_split.c,v 1.5.6.1 2004/09/18 03:57:38 kuriyama Exp $");
+
+#include <sys/types.h>
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <db.h>
+#include "btree.h"
+
+static int	 bt_broot(BTREE *, PAGE *, PAGE *, PAGE *);
+static PAGE	*bt_page (BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t);
+static int	 bt_preserve(BTREE *, pgno_t);
+static PAGE	*bt_psplit (BTREE *, PAGE *, PAGE *, PAGE *, indx_t *, size_t);
+static PAGE	*bt_root (BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t);
+static int	 bt_rroot(BTREE *, PAGE *, PAGE *, PAGE *);
+static recno_t	 rec_total(PAGE *);
+
+#ifdef STATISTICS
+u_long	bt_rootsplit, bt_split, bt_sortsplit, bt_pfxsaved;
+#endif
+
+/*
+ * __BT_SPLIT -- Split the tree.
+ *
+ * Parameters:
+ *	t:	tree
+ *	sp:	page to split
+ *	key:	key to insert
+ *	data:	data to insert
+ *	flags:	BIGKEY/BIGDATA flags
+ *	ilen:	insert length
+ *	skip:	index to leave open
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__bt_split(t, sp, key, data, flags, ilen, argskip)
+	BTREE *t;
+	PAGE *sp;
+	const DBT *key, *data;
+	int flags;
+	size_t ilen;
+	u_int32_t argskip;
+{
+	BINTERNAL *bi;
+	BLEAF *bl, *tbl;
+	DBT a, b;
+	EPGNO *parent;
+	PAGE *h, *l, *r, *lchild, *rchild;
+	indx_t nxtindex;
+	u_int16_t skip;
+	u_int32_t n, nbytes, nksize;
+	int parentsplit;
+	char *dest;
+
+	/*
+	 * Split the page into two pages, l and r.  The split routines return
+	 * a pointer to the page into which the key should be inserted and with
+	 * skip set to the offset which should be used.  Additionally, l and r
+	 * are pinned.
+	 */
+	skip = argskip;
+	h = sp->pgno == P_ROOT ?
+	    bt_root(t, sp, &l, &r, &skip, ilen) :
+	    bt_page(t, sp, &l, &r, &skip, ilen);
+	if (h == NULL)
+		return (RET_ERROR);
+
+	/*
+	 * Insert the new key/data pair into the leaf page.  (Key inserts
+	 * always cause a leaf page to split first.)
+	 */
+	h->linp[skip] = h->upper -= ilen;
+	dest = (char *)h + h->upper;
+	if (F_ISSET(t, R_RECNO))
+		WR_RLEAF(dest, data, flags)
+	else
+		WR_BLEAF(dest, key, data, flags)
+
+	/* If the root page was split, make it look right. */
+	if (sp->pgno == P_ROOT &&
+	    (F_ISSET(t, R_RECNO) ?
+	    bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR)
+		goto err2;
+
+	/*
+	 * Now we walk the parent page stack -- a LIFO stack of the pages that
+	 * were traversed when we searched for the page that split.  Each stack
+	 * entry is a page number and a page index offset.  The offset is for
+	 * the page traversed on the search.  We've just split a page, so we
+	 * have to insert a new key into the parent page.
+	 *
+	 * If the insert into the parent page causes it to split, may have to
+	 * continue splitting all the way up the tree.  We stop if the root
+	 * splits or the page inserted into didn't have to split to hold the
+	 * new key.  Some algorithms replace the key for the old page as well
+	 * as the new page.  We don't, as there's no reason to believe that the
+	 * first key on the old page is any better than the key we have, and,
+	 * in the case of a key being placed at index 0 causing the split, the
+	 * key is unavailable.
+	 *
+	 * There are a maximum of 5 pages pinned at any time.  We keep the left
+	 * and right pages pinned while working on the parent.   The 5 are the
+	 * two children, left parent and right parent (when the parent splits)
+	 * and the root page or the overflow key page when calling bt_preserve.
+	 * This code must make sure that all pins are released other than the
+	 * root page or overflow page which is unlocked elsewhere.
+	 */
+	while ((parent = BT_POP(t)) != NULL) {
+		lchild = l;
+		rchild = r;
+
+		/* Get the parent page. */
+		if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
+			goto err2;
+
+	 	/*
+		 * The new key goes ONE AFTER the index, because the split
+		 * was to the right.
+		 */
+		skip = parent->index + 1;
+
+		/*
+		 * Calculate the space needed on the parent page.
+		 *
+		 * Prefix trees: space hack when inserting into BINTERNAL
+		 * pages.  Retain only what's needed to distinguish between
+		 * the new entry and the LAST entry on the page to its left.
+		 * If the keys compare equal, retain the entire key.  Note,
+		 * we don't touch overflow keys, and the entire key must be
+		 * retained for the next-to-left most key on the leftmost
+		 * page of each level, or the search will fail.  Applicable
+		 * ONLY to internal pages that have leaf pages as children.
+		 * Further reduction of the key between pairs of internal
+		 * pages loses too much information.
+		 */
+		switch (rchild->flags & P_TYPE) {
+		case P_BINTERNAL:
+			bi = GETBINTERNAL(rchild, 0);
+			nbytes = NBINTERNAL(bi->ksize);
+			break;
+		case P_BLEAF:
+			bl = GETBLEAF(rchild, 0);
+			nbytes = NBINTERNAL(bl->ksize);
+			if (t->bt_pfx && !(bl->flags & P_BIGKEY) &&
+			    (h->prevpg != P_INVALID || skip > 1)) {
+				tbl = GETBLEAF(lchild, NEXTINDEX(lchild) - 1);
+				a.size = tbl->ksize;
+				a.data = tbl->bytes;
+				b.size = bl->ksize;
+				b.data = bl->bytes;
+				nksize = t->bt_pfx(&a, &b);
+				n = NBINTERNAL(nksize);
+				if (n < nbytes) {
+#ifdef STATISTICS
+					bt_pfxsaved += nbytes - n;
+#endif
+					nbytes = n;
+				} else
+					nksize = 0;
+			} else
+				nksize = 0;
+			break;
+		case P_RINTERNAL:
+		case P_RLEAF:
+			nbytes = NRINTERNAL;
+			break;
+		default:
+			abort();
+		}
+
+		/* Split the parent page if necessary or shift the indices. */
+		if (h->upper - h->lower < nbytes + sizeof(indx_t)) {
+			sp = h;
+			h = h->pgno == P_ROOT ?
+			    bt_root(t, h, &l, &r, &skip, nbytes) :
+			    bt_page(t, h, &l, &r, &skip, nbytes);
+			if (h == NULL)
+				goto err1;
+			parentsplit = 1;
+		} else {
+			if (skip < (nxtindex = NEXTINDEX(h)))
+				memmove(h->linp + skip + 1, h->linp + skip,
+				    (nxtindex - skip) * sizeof(indx_t));
+			h->lower += sizeof(indx_t);
+			parentsplit = 0;
+		}
+
+		/* Insert the key into the parent page. */
+		switch (rchild->flags & P_TYPE) {
+		case P_BINTERNAL:
+			h->linp[skip] = h->upper -= nbytes;
+			dest = (char *)h + h->linp[skip];
+			memmove(dest, bi, nbytes);
+			((BINTERNAL *)dest)->pgno = rchild->pgno;
+			break;
+		case P_BLEAF:
+			h->linp[skip] = h->upper -= nbytes;
+			dest = (char *)h + h->linp[skip];
+			WR_BINTERNAL(dest, nksize ? nksize : bl->ksize,
+			    rchild->pgno, bl->flags & P_BIGKEY);
+			memmove(dest, bl->bytes, nksize ? nksize : bl->ksize);
+			if (bl->flags & P_BIGKEY &&
+			    bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR)
+				goto err1;
+			break;
+		case P_RINTERNAL:
+			/*
+			 * Update the left page count.  If split
+			 * added at index 0, fix the correct page.
+			 */
+			if (skip > 0)
+				dest = (char *)h + h->linp[skip - 1];
+			else
+				dest = (char *)l + l->linp[NEXTINDEX(l) - 1];
+			((RINTERNAL *)dest)->nrecs = rec_total(lchild);
+			((RINTERNAL *)dest)->pgno = lchild->pgno;
+
+			/* Update the right page count. */
+			h->linp[skip] = h->upper -= nbytes;
+			dest = (char *)h + h->linp[skip];
+			((RINTERNAL *)dest)->nrecs = rec_total(rchild);
+			((RINTERNAL *)dest)->pgno = rchild->pgno;
+			break;
+		case P_RLEAF:
+			/*
+			 * Update the left page count.  If split
+			 * added at index 0, fix the correct page.
+			 */
+			if (skip > 0)
+				dest = (char *)h + h->linp[skip - 1];
+			else
+				dest = (char *)l + l->linp[NEXTINDEX(l) - 1];
+			((RINTERNAL *)dest)->nrecs = NEXTINDEX(lchild);
+			((RINTERNAL *)dest)->pgno = lchild->pgno;
+
+			/* Update the right page count. */
+			h->linp[skip] = h->upper -= nbytes;
+			dest = (char *)h + h->linp[skip];
+			((RINTERNAL *)dest)->nrecs = NEXTINDEX(rchild);
+			((RINTERNAL *)dest)->pgno = rchild->pgno;
+			break;
+		default:
+			abort();
+		}
+
+		/* Unpin the held pages. */
+		if (!parentsplit) {
+			mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+			break;
+		}
+
+		/* If the root page was split, make it look right. */
+		if (sp->pgno == P_ROOT &&
+		    (F_ISSET(t, R_RECNO) ?
+		    bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR)
+			goto err1;
+
+		mpool_put(t->bt_mp, lchild, MPOOL_DIRTY);
+		mpool_put(t->bt_mp, rchild, MPOOL_DIRTY);
+	}
+
+	/* Unpin the held pages. */
+	mpool_put(t->bt_mp, l, MPOOL_DIRTY);
+	mpool_put(t->bt_mp, r, MPOOL_DIRTY);
+
+	/* Clear any pages left on the stack. */
+	return (RET_SUCCESS);
+
+	/*
+	 * If something fails in the above loop we were already walking back
+	 * up the tree and the tree is now inconsistent.  Nothing much we can
+	 * do about it but release any memory we're holding.
+	 */
+err1:	mpool_put(t->bt_mp, lchild, MPOOL_DIRTY);
+	mpool_put(t->bt_mp, rchild, MPOOL_DIRTY);
+
+err2:	mpool_put(t->bt_mp, l, 0);
+	mpool_put(t->bt_mp, r, 0);
+	__dbpanic(t->bt_dbp);
+	return (RET_ERROR);
+}
+
+/*
+ * BT_PAGE -- Split a non-root page of a btree.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	root page
+ *	lp:	pointer to left page pointer
+ *	rp:	pointer to right page pointer
+ *	skip:	pointer to index to leave open
+ *	ilen:	insert length
+ *
+ * Returns:
+ *	Pointer to page in which to insert or NULL on error.
+ */
+static PAGE *
+bt_page(t, h, lp, rp, skip, ilen)
+	BTREE *t;
+	PAGE *h, **lp, **rp;
+	indx_t *skip;
+	size_t ilen;
+{
+	PAGE *l, *r, *tp;
+	pgno_t npg;
+
+#ifdef STATISTICS
+	++bt_split;
+#endif
+	/* Put the new right page for the split into place. */
+	if ((r = __bt_new(t, &npg)) == NULL)
+		return (NULL);
+	r->pgno = npg;
+	r->lower = BTDATAOFF;
+	r->upper = t->bt_psize;
+	r->nextpg = h->nextpg;
+	r->prevpg = h->pgno;
+	r->flags = h->flags & P_TYPE;
+
+	/*
+	 * If we're splitting the last page on a level because we're appending
+	 * a key to it (skip is NEXTINDEX()), it's likely that the data is
+	 * sorted.  Adding an empty page on the side of the level is less work
+	 * and can push the fill factor much higher than normal.  If we're
+	 * wrong it's no big deal, we'll just do the split the right way next
+	 * time.  It may look like it's equally easy to do a similar hack for
+	 * reverse sorted data, that is, split the tree left, but it's not.
+	 * Don't even try.
+	 */
+	if (h->nextpg == P_INVALID && *skip == NEXTINDEX(h)) {
+#ifdef STATISTICS
+		++bt_sortsplit;
+#endif
+		h->nextpg = r->pgno;
+		r->lower = BTDATAOFF + sizeof(indx_t);
+		*skip = 0;
+		*lp = h;
+		*rp = r;
+		return (r);
+	}
+
+	/* Put the new left page for the split into place. */
+	if ((l = (PAGE *)malloc(t->bt_psize)) == NULL) {
+		mpool_put(t->bt_mp, r, 0);
+		return (NULL);
+	}
+#ifdef PURIFY
+	memset(l, 0xff, t->bt_psize);
+#endif
+	l->pgno = h->pgno;
+	l->nextpg = r->pgno;
+	l->prevpg = h->prevpg;
+	l->lower = BTDATAOFF;
+	l->upper = t->bt_psize;
+	l->flags = h->flags & P_TYPE;
+
+	/* Fix up the previous pointer of the page after the split page. */
+	if (h->nextpg != P_INVALID) {
+		if ((tp = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) {
+			free(l);
+			/* XXX mpool_free(t->bt_mp, r->pgno); */
+			return (NULL);
+		}
+		tp->prevpg = r->pgno;
+		mpool_put(t->bt_mp, tp, MPOOL_DIRTY);
+	}
+
+	/*
+	 * Split right.  The key/data pairs aren't sorted in the btree page so
+	 * it's simpler to copy the data from the split page onto two new pages
+	 * instead of copying half the data to the right page and compacting
+	 * the left page in place.  Since the left page can't change, we have
+	 * to swap the original and the allocated left page after the split.
+	 */
+	tp = bt_psplit(t, h, l, r, skip, ilen);
+
+	/* Move the new left page onto the old left page. */
+	memmove(h, l, t->bt_psize);
+	if (tp == l)
+		tp = h;
+	free(l);
+
+	*lp = h;
+	*rp = r;
+	return (tp);
+}
+
+/*
+ * BT_ROOT -- Split the root page of a btree.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	root page
+ *	lp:	pointer to left page pointer
+ *	rp:	pointer to right page pointer
+ *	skip:	pointer to index to leave open
+ *	ilen:	insert length
+ *
+ * Returns:
+ *	Pointer to page in which to insert or NULL on error.
+ */
+static PAGE *
+bt_root(t, h, lp, rp, skip, ilen)
+	BTREE *t;
+	PAGE *h, **lp, **rp;
+	indx_t *skip;
+	size_t ilen;
+{
+	PAGE *l, *r, *tp;
+	pgno_t lnpg, rnpg;
+
+#ifdef STATISTICS
+	++bt_split;
+	++bt_rootsplit;
+#endif
+	/* Put the new left and right pages for the split into place. */
+	if ((l = __bt_new(t, &lnpg)) == NULL ||
+	    (r = __bt_new(t, &rnpg)) == NULL)
+		return (NULL);
+	l->pgno = lnpg;
+	r->pgno = rnpg;
+	l->nextpg = r->pgno;
+	r->prevpg = l->pgno;
+	l->prevpg = r->nextpg = P_INVALID;
+	l->lower = r->lower = BTDATAOFF;
+	l->upper = r->upper = t->bt_psize;
+	l->flags = r->flags = h->flags & P_TYPE;
+
+	/* Split the root page. */
+	tp = bt_psplit(t, h, l, r, skip, ilen);
+
+	*lp = l;
+	*rp = r;
+	return (tp);
+}
+
+/*
+ * BT_RROOT -- Fix up the recno root page after it has been split.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	root page
+ *	l:	left page
+ *	r:	right page
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+static int
+bt_rroot(t, h, l, r)
+	BTREE *t;
+	PAGE *h, *l, *r;
+{
+	char *dest;
+
+	/* Insert the left and right keys, set the header information. */
+	h->linp[0] = h->upper = t->bt_psize - NRINTERNAL;
+	dest = (char *)h + h->upper;
+	WR_RINTERNAL(dest,
+	    l->flags & P_RLEAF ? NEXTINDEX(l) : rec_total(l), l->pgno);
+
+	h->linp[1] = h->upper -= NRINTERNAL;
+	dest = (char *)h + h->upper;
+	WR_RINTERNAL(dest,
+	    r->flags & P_RLEAF ? NEXTINDEX(r) : rec_total(r), r->pgno);
+
+	h->lower = BTDATAOFF + 2 * sizeof(indx_t);
+
+	/* Unpin the root page, set to recno internal page. */
+	h->flags &= ~P_TYPE;
+	h->flags |= P_RINTERNAL;
+	mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+
+	return (RET_SUCCESS);
+}
+
+/*
+ * BT_BROOT -- Fix up the btree root page after it has been split.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	root page
+ *	l:	left page
+ *	r:	right page
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+static int
+bt_broot(t, h, l, r)
+	BTREE *t;
+	PAGE *h, *l, *r;
+{
+	BINTERNAL *bi;
+	BLEAF *bl;
+	u_int32_t nbytes;
+	char *dest;
+
+	/*
+	 * If the root page was a leaf page, change it into an internal page.
+	 * We copy the key we split on (but not the key's data, in the case of
+	 * a leaf page) to the new root page.
+	 *
+	 * The btree comparison code guarantees that the left-most key on any
+	 * level of the tree is never used, so it doesn't need to be filled in.
+	 */
+	nbytes = NBINTERNAL(0);
+	h->linp[0] = h->upper = t->bt_psize - nbytes;
+	dest = (char *)h + h->upper;
+	WR_BINTERNAL(dest, 0, l->pgno, 0);
+
+	switch (h->flags & P_TYPE) {
+	case P_BLEAF:
+		bl = GETBLEAF(r, 0);
+		nbytes = NBINTERNAL(bl->ksize);
+		h->linp[1] = h->upper -= nbytes;
+		dest = (char *)h + h->upper;
+		WR_BINTERNAL(dest, bl->ksize, r->pgno, 0);
+		memmove(dest, bl->bytes, bl->ksize);
+
+		/*
+		 * If the key is on an overflow page, mark the overflow chain
+		 * so it isn't deleted when the leaf copy of the key is deleted.
+		 */
+		if (bl->flags & P_BIGKEY &&
+		    bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR)
+			return (RET_ERROR);
+		break;
+	case P_BINTERNAL:
+		bi = GETBINTERNAL(r, 0);
+		nbytes = NBINTERNAL(bi->ksize);
+		h->linp[1] = h->upper -= nbytes;
+		dest = (char *)h + h->upper;
+		memmove(dest, bi, nbytes);
+		((BINTERNAL *)dest)->pgno = r->pgno;
+		break;
+	default:
+		abort();
+	}
+
+	/* There are two keys on the page. */
+	h->lower = BTDATAOFF + 2 * sizeof(indx_t);
+
+	/* Unpin the root page, set to btree internal page. */
+	h->flags &= ~P_TYPE;
+	h->flags |= P_BINTERNAL;
+	mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+
+	return (RET_SUCCESS);
+}
+
+/*
+ * BT_PSPLIT -- Do the real work of splitting the page.
+ *
+ * Parameters:
+ *	t:	tree
+ *	h:	page to be split
+ *	l:	page to put lower half of data
+ *	r:	page to put upper half of data
+ *	pskip:	pointer to index to leave open
+ *	ilen:	insert length
+ *
+ * Returns:
+ *	Pointer to page in which to insert.
+ */
+static PAGE *
+bt_psplit(t, h, l, r, pskip, ilen)
+	BTREE *t;
+	PAGE *h, *l, *r;
+	indx_t *pskip;
+	size_t ilen;
+{
+	BINTERNAL *bi;
+	BLEAF *bl;
+	CURSOR *c;
+	RLEAF *rl;
+	PAGE *rval;
+	void *src;
+	indx_t full, half, nxt, off, skip, top, used;
+	u_int32_t nbytes;
+	int bigkeycnt, isbigkey;
+
+	/*
+	 * Split the data to the left and right pages.  Leave the skip index
+	 * open.  Additionally, make some effort not to split on an overflow
+	 * key.  This makes internal page processing faster and can save
+	 * space as overflow keys used by internal pages are never deleted.
+	 */
+	bigkeycnt = 0;
+	skip = *pskip;
+	full = t->bt_psize - BTDATAOFF;
+	half = full / 2;
+	used = 0;
+	for (nxt = off = 0, top = NEXTINDEX(h); nxt < top; ++off) {
+		if (skip == off) {
+			nbytes = ilen;
+			isbigkey = 0;		/* XXX: not really known. */
+		} else
+			switch (h->flags & P_TYPE) {
+			case P_BINTERNAL:
+				src = bi = GETBINTERNAL(h, nxt);
+				nbytes = NBINTERNAL(bi->ksize);
+				isbigkey = bi->flags & P_BIGKEY;
+				break;
+			case P_BLEAF:
+				src = bl = GETBLEAF(h, nxt);
+				nbytes = NBLEAF(bl);
+				isbigkey = bl->flags & P_BIGKEY;
+				break;
+			case P_RINTERNAL:
+				src = GETRINTERNAL(h, nxt);
+				nbytes = NRINTERNAL;
+				isbigkey = 0;
+				break;
+			case P_RLEAF:
+				src = rl = GETRLEAF(h, nxt);
+				nbytes = NRLEAF(rl);
+				isbigkey = 0;
+				break;
+			default:
+				abort();
+			}
+
+		/*
+		 * If the key/data pairs are substantial fractions of the max
+		 * possible size for the page, it's possible to get situations
+		 * where we decide to try and copy too much onto the left page.
+		 * Make sure that doesn't happen.
+		 */
+		if ((skip <= off && used + nbytes + sizeof(indx_t) >= full)
+		    || nxt == top - 1) {
+			--off;
+			break;
+		}
+
+		/* Copy the key/data pair, if not the skipped index. */
+		if (skip != off) {
+			++nxt;
+
+			l->linp[off] = l->upper -= nbytes;
+			memmove((char *)l + l->upper, src, nbytes);
+		}
+
+		used += nbytes + sizeof(indx_t);
+		if (used >= half) {
+			if (!isbigkey || bigkeycnt == 3)
+				break;
+			else
+				++bigkeycnt;
+		}
+	}
+
+	/*
+	 * Off is the last offset that's valid for the left page.
+	 * Nxt is the first offset to be placed on the right page.
+	 */
+	l->lower += (off + 1) * sizeof(indx_t);
+
+	/*
+	 * If splitting the page that the cursor was on, the cursor has to be
+	 * adjusted to point to the same record as before the split.  If the
+	 * cursor is at or past the skipped slot, the cursor is incremented by
+	 * one.  If the cursor is on the right page, it is decremented by the
+	 * number of records split to the left page.
+	 */
+	c = &t->bt_cursor;
+	if (F_ISSET(c, CURS_INIT) && c->pg.pgno == h->pgno) {
+		if (c->pg.index >= skip)
+			++c->pg.index;
+		if (c->pg.index < nxt)			/* Left page. */
+			c->pg.pgno = l->pgno;
+		else {					/* Right page. */
+			c->pg.pgno = r->pgno;
+			c->pg.index -= nxt;
+		}
+	}
+
+	/*
+	 * If the skipped index was on the left page, just return that page.
+	 * Otherwise, adjust the skip index to reflect the new position on
+	 * the right page.
+	 */
+	if (skip <= off) {
+		skip = MAX_PAGE_OFFSET;
+		rval = l;
+	} else {
+		rval = r;
+		*pskip -= nxt;
+	}
+
+	for (off = 0; nxt < top; ++off) {
+		if (skip == nxt) {
+			++off;
+			skip = MAX_PAGE_OFFSET;
+		}
+		switch (h->flags & P_TYPE) {
+		case P_BINTERNAL:
+			src = bi = GETBINTERNAL(h, nxt);
+			nbytes = NBINTERNAL(bi->ksize);
+			break;
+		case P_BLEAF:
+			src = bl = GETBLEAF(h, nxt);
+			nbytes = NBLEAF(bl);
+			break;
+		case P_RINTERNAL:
+			src = GETRINTERNAL(h, nxt);
+			nbytes = NRINTERNAL;
+			break;
+		case P_RLEAF:
+			src = rl = GETRLEAF(h, nxt);
+			nbytes = NRLEAF(rl);
+			break;
+		default:
+			abort();
+		}
+		++nxt;
+		r->linp[off] = r->upper -= nbytes;
+		memmove((char *)r + r->upper, src, nbytes);
+	}
+	r->lower += off * sizeof(indx_t);
+
+	/* If the key is being appended to the page, adjust the index. */
+	if (skip == top)
+		r->lower += sizeof(indx_t);
+
+	return (rval);
+}
+
+/*
+ * BT_PRESERVE -- Mark a chain of pages as used by an internal node.
+ *
+ * Chains of indirect blocks pointed to by leaf nodes get reclaimed when the
+ * record that references them gets deleted.  Chains pointed to by internal
+ * pages never get deleted.  This routine marks a chain as pointed to by an
+ * internal page.
+ *
+ * Parameters:
+ *	t:	tree
+ *	pg:	page number of first page in the chain.
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ */
+static int
+bt_preserve(t, pg)
+	BTREE *t;
+	pgno_t pg;
+{
+	PAGE *h;
+
+	if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+		return (RET_ERROR);
+	h->flags |= P_PRESERVE;
+	mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+	return (RET_SUCCESS);
+}
+
+/*
+ * REC_TOTAL -- Return the number of recno entries below a page.
+ *
+ * Parameters:
+ *	h:	page
+ *
+ * Returns:
+ *	The number of recno entries below a page.
+ *
+ * XXX
+ * These values could be set by the bt_psplit routine.  The problem is that the
+ * entry has to be popped off of the stack etc. or the values have to be passed
+ * all the way back to bt_split/bt_rroot and it's not very clean.
+ */
+static recno_t
+rec_total(h)
+	PAGE *h;
+{
+	recno_t recs;
+	indx_t nxt, top;
+
+	for (recs = 0, nxt = 0, top = NEXTINDEX(h); nxt < top; ++nxt)
+		recs += GETRINTERNAL(h, nxt)->nrecs;
+	return (recs);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/bt_utils.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/bt_utils.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/bt_utils.c	(revision 2404)
@@ -0,0 +1,262 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bt_utils.c	8.8 (Berkeley) 7/20/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/btree/bt_utils.c,v 1.3 2003/01/01 18:48:42 schweikh Exp $");
+
+#include <sys/param.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <db.h>
+#include "btree.h"
+
+/*
+ * __bt_ret --
+ *	Build return key/data pair.
+ *
+ * Parameters:
+ *	t:	tree
+ *	e:	key/data pair to be returned
+ *	key:	user's key structure (NULL if not to be filled in)
+ *	rkey:	memory area to hold key
+ *	data:	user's data structure (NULL if not to be filled in)
+ *	rdata:	memory area to hold data
+ *       copy:	always copy the key/data item
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ */
+int
+__bt_ret(t, e, key, rkey, data, rdata, copy)
+	BTREE *t;
+	EPG *e;
+	DBT *key, *rkey, *data, *rdata;
+	int copy;
+{
+	BLEAF *bl;
+	void *p;
+
+	bl = GETBLEAF(e->page, e->index);
+
+	/*
+	 * We must copy big keys/data to make them contigous.  Otherwise,
+	 * leave the page pinned and don't copy unless the user specified
+	 * concurrent access.
+	 */
+	if (key == NULL)
+		goto dataonly;
+
+	if (bl->flags & P_BIGKEY) {
+		if (__ovfl_get(t, bl->bytes,
+		    &key->size, &rkey->data, &rkey->size))
+			return (RET_ERROR);
+		key->data = rkey->data;
+	} else if (copy || F_ISSET(t, B_DB_LOCK)) {
+		if (bl->ksize > rkey->size) {
+			p = (void *)(rkey->data == NULL ?
+			    malloc(bl->ksize) : realloc(rkey->data, bl->ksize));
+			if (p == NULL)
+				return (RET_ERROR);
+			rkey->data = p;
+			rkey->size = bl->ksize;
+		}
+		memmove(rkey->data, bl->bytes, bl->ksize);
+		key->size = bl->ksize;
+		key->data = rkey->data;
+	} else {
+		key->size = bl->ksize;
+		key->data = bl->bytes;
+	}
+
+dataonly:
+	if (data == NULL)
+		return (RET_SUCCESS);
+
+	if (bl->flags & P_BIGDATA) {
+		if (__ovfl_get(t, bl->bytes + bl->ksize,
+		    &data->size, &rdata->data, &rdata->size))
+			return (RET_ERROR);
+		data->data = rdata->data;
+	} else if (copy || F_ISSET(t, B_DB_LOCK)) {
+		/* Use +1 in case the first record retrieved is 0 length. */
+		if (bl->dsize + 1 > rdata->size) {
+			p = (void *)(rdata->data == NULL ?
+			    malloc(bl->dsize + 1) :
+			    realloc(rdata->data, bl->dsize + 1));
+			if (p == NULL)
+				return (RET_ERROR);
+			rdata->data = p;
+			rdata->size = bl->dsize + 1;
+		}
+		memmove(rdata->data, bl->bytes + bl->ksize, bl->dsize);
+		data->size = bl->dsize;
+		data->data = rdata->data;
+	} else {
+		data->size = bl->dsize;
+		data->data = bl->bytes + bl->ksize;
+	}
+
+	return (RET_SUCCESS);
+}
+
+/*
+ * __BT_CMP -- Compare a key to a given record.
+ *
+ * Parameters:
+ *	t:	tree
+ *	k1:	DBT pointer of first arg to comparison
+ *	e:	pointer to EPG for comparison
+ *
+ * Returns:
+ *	< 0 if k1 is < record
+ *	= 0 if k1 is = record
+ *	> 0 if k1 is > record
+ */
+int
+__bt_cmp(t, k1, e)
+	BTREE *t;
+	const DBT *k1;
+	EPG *e;
+{
+	BINTERNAL *bi;
+	BLEAF *bl;
+	DBT k2;
+	PAGE *h;
+	void *bigkey;
+
+	/*
+	 * The left-most key on internal pages, at any level of the tree, is
+	 * guaranteed by the following code to be less than any user key.
+	 * This saves us from having to update the leftmost key on an internal
+	 * page when the user inserts a new key in the tree smaller than
+	 * anything we've yet seen.
+	 */
+	h = e->page;
+	if (e->index == 0 && h->prevpg == P_INVALID && !(h->flags & P_BLEAF))
+		return (1);
+
+	bigkey = NULL;
+	if (h->flags & P_BLEAF) {
+		bl = GETBLEAF(h, e->index);
+		if (bl->flags & P_BIGKEY)
+			bigkey = bl->bytes;
+		else {
+			k2.data = bl->bytes;
+			k2.size = bl->ksize;
+		}
+	} else {
+		bi = GETBINTERNAL(h, e->index);
+		if (bi->flags & P_BIGKEY)
+			bigkey = bi->bytes;
+		else {
+			k2.data = bi->bytes;
+			k2.size = bi->ksize;
+		}
+	}
+
+	if (bigkey) {
+		if (__ovfl_get(t, bigkey,
+		    &k2.size, &t->bt_rdata.data, &t->bt_rdata.size))
+			return (RET_ERROR);
+		k2.data = t->bt_rdata.data;
+	}
+	return ((*t->bt_cmp)(k1, &k2));
+}
+
+/*
+ * __BT_DEFCMP -- Default comparison routine.
+ *
+ * Parameters:
+ *	a:	DBT #1
+ *	b: 	DBT #2
+ *
+ * Returns:
+ *	< 0 if a is < b
+ *	= 0 if a is = b
+ *	> 0 if a is > b
+ */
+int
+__bt_defcmp(a, b)
+	const DBT *a, *b;
+{
+	size_t len;
+	u_char *p1, *p2;
+
+	/*
+	 * XXX
+	 * If a size_t doesn't fit in an int, this routine can lose.
+	 * What we need is an integral type which is guaranteed to be
+	 * larger than a size_t, and there is no such thing.
+	 */
+	len = MIN(a->size, b->size);
+	for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2)
+		if (*p1 != *p2)
+			return ((int)*p1 - (int)*p2);
+	return ((int)a->size - (int)b->size);
+}
+
+/*
+ * __BT_DEFPFX -- Default prefix routine.
+ *
+ * Parameters:
+ *	a:	DBT #1
+ *	b: 	DBT #2
+ *
+ * Returns:
+ *	Number of bytes needed to distinguish b from a.
+ */
+size_t
+__bt_defpfx(a, b)
+	const DBT *a, *b;
+{
+	u_char *p1, *p2;
+	size_t cnt, len;
+
+	cnt = 1;
+	len = MIN(a->size, b->size);
+	for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2, ++cnt)
+		if (*p1 != *p2)
+			return (cnt);
+
+	/* a->size must be <= b->size, or they wouldn't be in this order. */
+	return (a->size < b->size ? a->size + 1 : a->size);
+}
Index: /vendor/FreeBSD-libc/5.3/db/btree/btree.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/btree.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/btree.h	(revision 2404)
@@ -0,0 +1,384 @@
+/*-
+ * Copyright (c) 1991, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ *
+ *	@(#)btree.h	8.11 (Berkeley) 8/17/94
+ * $FreeBSD: src/lib/libc/db/btree/btree.h,v 1.3 2002/03/22 23:41:40 obrien Exp $
+ */
+
+/* Macros to set/clear/test flags. */
+#define	F_SET(p, f)	(p)->flags |= (f)
+#define	F_CLR(p, f)	(p)->flags &= ~(f)
+#define	F_ISSET(p, f)	((p)->flags & (f))
+
+#include <mpool.h>
+
+#define	DEFMINKEYPAGE	(2)		/* Minimum keys per page */
+#define	MINCACHE	(5)		/* Minimum cached pages */
+#define	MINPSIZE	(512)		/* Minimum page size */
+
+/*
+ * Page 0 of a btree file contains a copy of the meta-data.  This page is also
+ * used as an out-of-band page, i.e. page pointers that point to nowhere point
+ * to page 0.  Page 1 is the root of the btree.
+ */
+#define	P_INVALID	 0		/* Invalid tree page number. */
+#define	P_META		 0		/* Tree metadata page number. */
+#define	P_ROOT		 1		/* Tree root page number. */
+
+/*
+ * There are five page layouts in the btree: btree internal pages (BINTERNAL),
+ * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages
+ * (RLEAF) and overflow pages.  All five page types have a page header (PAGE).
+ * This implementation requires that values within structures NOT be padded.
+ * (ANSI C permits random padding.)  If your compiler pads randomly you'll have
+ * to do some work to get this package to run.
+ */
+typedef struct _page {
+	pgno_t	pgno;			/* this page's page number */
+	pgno_t	prevpg;			/* left sibling */
+	pgno_t	nextpg;			/* right sibling */
+
+#define	P_BINTERNAL	0x01		/* btree internal page */
+#define	P_BLEAF		0x02		/* leaf page */
+#define	P_OVERFLOW	0x04		/* overflow page */
+#define	P_RINTERNAL	0x08		/* recno internal page */
+#define	P_RLEAF		0x10		/* leaf page */
+#define P_TYPE		0x1f		/* type mask */
+#define	P_PRESERVE	0x20		/* never delete this chain of pages */
+	u_int32_t flags;
+
+	indx_t	lower;			/* lower bound of free space on page */
+	indx_t	upper;			/* upper bound of free space on page */
+	indx_t	linp[1];		/* indx_t-aligned VAR. LENGTH DATA */
+} PAGE;
+
+/* First and next index. */
+#define	BTDATAOFF							\
+	(sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) +		\
+	    sizeof(u_int32_t) + sizeof(indx_t) + sizeof(indx_t))
+#define	NEXTINDEX(p)	(((p)->lower - BTDATAOFF) / sizeof(indx_t))
+
+/*
+ * For pages other than overflow pages, there is an array of offsets into the
+ * rest of the page immediately following the page header.  Each offset is to
+ * an item which is unique to the type of page.  The h_lower offset is just
+ * past the last filled-in index.  The h_upper offset is the first item on the
+ * page.  Offsets are from the beginning of the page.
+ *
+ * If an item is too big to store on a single page, a flag is set and the item
+ * is a { page, size } pair such that the page is the first page of an overflow
+ * chain with size bytes of item.  Overflow pages are simply bytes without any
+ * external structure.
+ *
+ * The page number and size fields in the items are pgno_t-aligned so they can
+ * be manipulated without copying.  (This presumes that 32 bit items can be
+ * manipulated on this system.)
+ */
+#define	LALIGN(n)	(((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1))
+#define	NOVFLSIZE	(sizeof(pgno_t) + sizeof(u_int32_t))
+
+/*
+ * For the btree internal pages, the item is a key.  BINTERNALs are {key, pgno}
+ * pairs, such that the key compares less than or equal to all of the records
+ * on that page.  For a tree without duplicate keys, an internal page with two
+ * consecutive keys, a and b, will have all records greater than or equal to a
+ * and less than b stored on the page associated with a.  Duplicate keys are
+ * somewhat special and can cause duplicate internal and leaf page records and
+ * some minor modifications of the above rule.
+ */
+typedef struct _binternal {
+	u_int32_t ksize;		/* key size */
+	pgno_t	pgno;			/* page number stored on */
+#define	P_BIGDATA	0x01		/* overflow data */
+#define	P_BIGKEY	0x02		/* overflow key */
+	u_char	flags;
+	char	bytes[1];		/* data */
+} BINTERNAL;
+
+/* Get the page's BINTERNAL structure at index indx. */
+#define	GETBINTERNAL(pg, indx)						\
+	((BINTERNAL *)((char *)(pg) + (pg)->linp[indx]))
+
+/* Get the number of bytes in the entry. */
+#define NBINTERNAL(len)							\
+	LALIGN(sizeof(u_int32_t) + sizeof(pgno_t) + sizeof(u_char) + (len))
+
+/* Copy a BINTERNAL entry to the page. */
+#define	WR_BINTERNAL(p, size, pgno, flags) {				\
+	*(u_int32_t *)p = size;						\
+	p += sizeof(u_int32_t);						\
+	*(pgno_t *)p = pgno;						\
+	p += sizeof(pgno_t);						\
+	*(u_char *)p = flags;						\
+	p += sizeof(u_char);						\
+}
+
+/*
+ * For the recno internal pages, the item is a page number with the number of
+ * keys found on that page and below.
+ */
+typedef struct _rinternal {
+	recno_t	nrecs;			/* number of records */
+	pgno_t	pgno;			/* page number stored below */
+} RINTERNAL;
+
+/* Get the page's RINTERNAL structure at index indx. */
+#define	GETRINTERNAL(pg, indx)						\
+	((RINTERNAL *)((char *)(pg) + (pg)->linp[indx]))
+
+/* Get the number of bytes in the entry. */
+#define NRINTERNAL							\
+	LALIGN(sizeof(recno_t) + sizeof(pgno_t))
+
+/* Copy a RINTERAL entry to the page. */
+#define	WR_RINTERNAL(p, nrecs, pgno) {					\
+	*(recno_t *)p = nrecs;						\
+	p += sizeof(recno_t);						\
+	*(pgno_t *)p = pgno;						\
+}
+
+/* For the btree leaf pages, the item is a key and data pair. */
+typedef struct _bleaf {
+	u_int32_t	ksize;		/* size of key */
+	u_int32_t	dsize;		/* size of data */
+	u_char	flags;			/* P_BIGDATA, P_BIGKEY */
+	char	bytes[1];		/* data */
+} BLEAF;
+
+/* Get the page's BLEAF structure at index indx. */
+#define	GETBLEAF(pg, indx)						\
+	((BLEAF *)((char *)(pg) + (pg)->linp[indx]))
+
+/* Get the number of bytes in the entry. */
+#define NBLEAF(p)	NBLEAFDBT((p)->ksize, (p)->dsize)
+
+/* Get the number of bytes in the user's key/data pair. */
+#define NBLEAFDBT(ksize, dsize)						\
+	LALIGN(sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(u_char) +	\
+	    (ksize) + (dsize))
+
+/* Copy a BLEAF entry to the page. */
+#define	WR_BLEAF(p, key, data, flags) {					\
+	*(u_int32_t *)p = key->size;					\
+	p += sizeof(u_int32_t);						\
+	*(u_int32_t *)p = data->size;					\
+	p += sizeof(u_int32_t);						\
+	*(u_char *)p = flags;						\
+	p += sizeof(u_char);						\
+	memmove(p, key->data, key->size);				\
+	p += key->size;							\
+	memmove(p, data->data, data->size);				\
+}
+
+/* For the recno leaf pages, the item is a data entry. */
+typedef struct _rleaf {
+	u_int32_t	dsize;		/* size of data */
+	u_char	flags;			/* P_BIGDATA */
+	char	bytes[1];
+} RLEAF;
+
+/* Get the page's RLEAF structure at index indx. */
+#define	GETRLEAF(pg, indx)						\
+	((RLEAF *)((char *)(pg) + (pg)->linp[indx]))
+
+/* Get the number of bytes in the entry. */
+#define NRLEAF(p)	NRLEAFDBT((p)->dsize)
+
+/* Get the number of bytes from the user's data. */
+#define	NRLEAFDBT(dsize)						\
+	LALIGN(sizeof(u_int32_t) + sizeof(u_char) + (dsize))
+
+/* Copy a RLEAF entry to the page. */
+#define	WR_RLEAF(p, data, flags) {					\
+	*(u_int32_t *)p = data->size;					\
+	p += sizeof(u_int32_t);						\
+	*(u_char *)p = flags;						\
+	p += sizeof(u_char);						\
+	memmove(p, data->data, data->size);				\
+}
+
+/*
+ * A record in the tree is either a pointer to a page and an index in the page
+ * or a page number and an index.  These structures are used as a cursor, stack
+ * entry and search returns as well as to pass records to other routines.
+ *
+ * One comment about searches.  Internal page searches must find the largest
+ * record less than key in the tree so that descents work.  Leaf page searches
+ * must find the smallest record greater than key so that the returned index
+ * is the record's correct position for insertion.
+ */
+typedef struct _epgno {
+	pgno_t	pgno;			/* the page number */
+	indx_t	index;			/* the index on the page */
+} EPGNO;
+
+typedef struct _epg {
+	PAGE	*page;			/* the (pinned) page */
+	indx_t	 index;			/* the index on the page */
+} EPG;
+
+/*
+ * About cursors.  The cursor (and the page that contained the key/data pair
+ * that it referenced) can be deleted, which makes things a bit tricky.  If
+ * there are no duplicates of the cursor key in the tree (i.e. B_NODUPS is set
+ * or there simply aren't any duplicates of the key) we copy the key that it
+ * referenced when it's deleted, and reacquire a new cursor key if the cursor
+ * is used again.  If there are duplicates keys, we move to the next/previous
+ * key, and set a flag so that we know what happened.  NOTE: if duplicate (to
+ * the cursor) keys are added to the tree during this process, it is undefined
+ * if they will be returned or not in a cursor scan.
+ *
+ * The flags determine the possible states of the cursor:
+ *
+ * CURS_INIT	The cursor references *something*.
+ * CURS_ACQUIRE	The cursor was deleted, and a key has been saved so that
+ *		we can reacquire the right position in the tree.
+ * CURS_AFTER, CURS_BEFORE
+ *		The cursor was deleted, and now references a key/data pair
+ *		that has not yet been returned, either before or after the
+ *		deleted key/data pair.
+ * XXX
+ * This structure is broken out so that we can eventually offer multiple
+ * cursors as part of the DB interface.
+ */
+typedef struct _cursor {
+	EPGNO	 pg;			/* B: Saved tree reference. */
+	DBT	 key;			/* B: Saved key, or key.data == NULL. */
+	recno_t	 rcursor;		/* R: recno cursor (1-based) */
+
+#define	CURS_ACQUIRE	0x01		/*  B: Cursor needs to be reacquired. */
+#define	CURS_AFTER	0x02		/*  B: Unreturned cursor after key. */
+#define	CURS_BEFORE	0x04		/*  B: Unreturned cursor before key. */
+#define	CURS_INIT	0x08		/* RB: Cursor initialized. */
+	u_int8_t flags;
+} CURSOR;
+
+/*
+ * The metadata of the tree.  The nrecs field is used only by the RECNO code.
+ * This is because the btree doesn't really need it and it requires that every
+ * put or delete call modify the metadata.
+ */
+typedef struct _btmeta {
+	u_int32_t	magic;		/* magic number */
+	u_int32_t	version;	/* version */
+	u_int32_t	psize;		/* page size */
+	u_int32_t	free;		/* page number of first free page */
+	u_int32_t	nrecs;		/* R: number of records */
+
+#define	SAVEMETA	(B_NODUPS | R_RECNO)
+	u_int32_t	flags;		/* bt_flags & SAVEMETA */
+} BTMETA;
+
+/* The in-memory btree/recno data structure. */
+typedef struct _btree {
+	MPOOL	 *bt_mp;		/* memory pool cookie */
+
+	DB	 *bt_dbp;		/* pointer to enclosing DB */
+
+	EPG	  bt_cur;		/* current (pinned) page */
+	PAGE	 *bt_pinned;		/* page pinned across calls */
+
+	CURSOR	  bt_cursor;		/* cursor */
+
+#define	BT_PUSH(t, p, i) {						\
+	t->bt_sp->pgno = p; 						\
+	t->bt_sp->index = i; 						\
+	++t->bt_sp;							\
+}
+#define	BT_POP(t)	(t->bt_sp == t->bt_stack ? NULL : --t->bt_sp)
+#define	BT_CLR(t)	(t->bt_sp = t->bt_stack)
+	EPGNO	  bt_stack[50];		/* stack of parent pages */
+	EPGNO	 *bt_sp;		/* current stack pointer */
+
+	DBT	  bt_rkey;		/* returned key */
+	DBT	  bt_rdata;		/* returned data */
+
+	int	  bt_fd;		/* tree file descriptor */
+
+	pgno_t	  bt_free;		/* next free page */
+	u_int32_t bt_psize;		/* page size */
+	indx_t	  bt_ovflsize;		/* cut-off for key/data overflow */
+	int	  bt_lorder;		/* byte order */
+					/* sorted order */
+	enum { NOT, BACK, FORWARD } bt_order;
+	EPGNO	  bt_last;		/* last insert */
+
+					/* B: key comparison function */
+	int	(*bt_cmp)(const DBT *, const DBT *);
+					/* B: prefix comparison function */
+	size_t	(*bt_pfx)(const DBT *, const DBT *);
+					/* R: recno input function */
+	int	(*bt_irec)(struct _btree *, recno_t);
+
+	FILE	 *bt_rfp;		/* R: record FILE pointer */
+	int	  bt_rfd;		/* R: record file descriptor */
+
+	caddr_t	  bt_cmap;		/* R: current point in mapped space */
+	caddr_t	  bt_smap;		/* R: start of mapped space */
+	caddr_t   bt_emap;		/* R: end of mapped space */
+	size_t	  bt_msize;		/* R: size of mapped region. */
+
+	recno_t	  bt_nrecs;		/* R: number of records */
+	size_t	  bt_reclen;		/* R: fixed record length */
+	u_char	  bt_bval;		/* R: delimiting byte/pad character */
+
+/*
+ * NB:
+ * B_NODUPS and R_RECNO are stored on disk, and may not be changed.
+ */
+#define	B_INMEM		0x00001		/* in-memory tree */
+#define	B_METADIRTY	0x00002		/* need to write metadata */
+#define	B_MODIFIED	0x00004		/* tree modified */
+#define	B_NEEDSWAP	0x00008		/* if byte order requires swapping */
+#define	B_RDONLY	0x00010		/* read-only tree */
+
+#define	B_NODUPS	0x00020		/* no duplicate keys permitted */
+#define	R_RECNO		0x00080		/* record oriented tree */
+
+#define	R_CLOSEFP	0x00040		/* opened a file pointer */
+#define	R_EOF		0x00100		/* end of input file reached. */
+#define	R_FIXLEN	0x00200		/* fixed length records */
+#define	R_MEMMAPPED	0x00400		/* memory mapped file. */
+#define	R_INMEM		0x00800		/* in-memory file */
+#define	R_MODIFIED	0x01000		/* modified file */
+#define	R_RDONLY	0x02000		/* read-only file */
+
+#define	B_DB_LOCK	0x04000		/* DB_LOCK specified. */
+#define	B_DB_SHMEM	0x08000		/* DB_SHMEM specified. */
+#define	B_DB_TXN	0x10000		/* DB_TXN specified. */
+	u_int32_t flags;
+} BTREE;
+
+#include "extern.h"
Index: /vendor/FreeBSD-libc/5.3/db/btree/extern.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/btree/extern.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/btree/extern.h	(revision 2404)
@@ -0,0 +1,71 @@
+/*-
+ * Copyright (c) 1991, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ *
+ *	@(#)extern.h	8.10 (Berkeley) 7/20/94
+ * $FreeBSD: src/lib/libc/db/btree/extern.h,v 1.3 2002/03/22 09:18:22 obrien Exp $
+ */
+
+int	 __bt_close(DB *);
+int	 __bt_cmp(BTREE *, const DBT *, EPG *);
+int	 __bt_crsrdel(BTREE *, EPGNO *);
+int	 __bt_defcmp(const DBT *, const DBT *);
+size_t	 __bt_defpfx(const DBT *, const DBT *);
+int	 __bt_delete(const DB *, const DBT *, u_int);
+int	 __bt_dleaf(BTREE *, const DBT *, PAGE *, u_int);
+int	 __bt_fd(const DB *);
+int	 __bt_free(BTREE *, PAGE *);
+int	 __bt_get(const DB *, const DBT *, DBT *, u_int);
+PAGE	*__bt_new(BTREE *, pgno_t *);
+void	 __bt_pgin(void *, pgno_t, void *);
+void	 __bt_pgout(void *, pgno_t, void *);
+int	 __bt_push(BTREE *, pgno_t, int);
+int	 __bt_put(const DB *dbp, DBT *, const DBT *, u_int);
+int	 __bt_ret(BTREE *, EPG *, DBT *, DBT *, DBT *, DBT *, int);
+EPG	*__bt_search(BTREE *, const DBT *, int *);
+int	 __bt_seq(const DB *, DBT *, DBT *, u_int);
+void	 __bt_setcur(BTREE *, pgno_t, u_int);
+int	 __bt_split(BTREE *, PAGE *,
+	    const DBT *, const DBT *, int, size_t, u_int32_t);
+int	 __bt_sync(const DB *, u_int);
+
+int	 __ovfl_delete(BTREE *, void *);
+int	 __ovfl_get(BTREE *, void *, size_t *, void **, size_t *);
+int	 __ovfl_put(BTREE *, const DBT *, pgno_t *);
+
+#ifdef DEBUG
+void	 __bt_dnpage(DB *, pgno_t);
+void	 __bt_dpage(PAGE *);
+void	 __bt_dump(DB *);
+#endif
+#ifdef STATISTICS
+void	 __bt_stat(DB *);
+#endif
Index: /vendor/FreeBSD-libc/5.3/db/changelog
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/changelog	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/changelog	(revision 2404)
@@ -0,0 +1,103 @@
+1.84 -> 1.85
+	recno:	#ifdef out use of mmap, it's not portable enough.
+
+1.83 -> 1.84	Thu Aug 18 15:46:07 EDT 1994
+	recno:	Rework fixed-length records so that closing and reopening
+		the file now works.  Pad short records on input.  Never do
+		signed comparison in recno input reading functions.
+
+1.82 -> 1.83	Tue Jul 26 15:33:44 EDT 1994
+	btree:	Rework cursor deletion code yet again; bugs with
+		deleting empty pages that only contained the cursor
+		record.
+
+1.81 -> 1.82	Sat Jul 16 11:01:50 EDT 1994
+	btree:	Fix bugs introduced by new cursor/deletion code.
+		Replace return kbuf/dbuf with real DBT's.
+
+1.80 -> 1.81
+	btree:	Fix bugs introduced by new cursor/deletion code.
+	all:	Add #defines for Purify.
+
+1.79 -> 1.80	Wed Jul 13 22:41:54 EDT 1994
+	btree	Change deletion to coalesce empty pages.  This is a major
+		change, cursors and duplicate pages all had to be reworked.
+		Return to a fixed stack.
+	recno:	Affected by cursor changes.  New cursor structures should
+		permit multiple cursors in the future.
+
+1.78 -> 1.79	Mon Jun 20 17:36:47 EDT 1994
+	all:	Minor cleanups of 1.78 for porting reasons; only
+		major change was inlining check of NULL pointer
+		so that __fix_realloc goes away.
+
+1.77 -> 1.78	Thu Jun 16 19:06:43 EDT 1994
+	all:	Move "standard" size typedef's into db.h.
+
+1.76 -> 1.77	Thu Jun 16 16:48:38 EDT 1994
+	hash:	Delete __init_ routine, has special meaning to OSF 2.0.
+
+1.74 -> 1.76
+	all:	Finish up the port to the Alpha.
+
+1.73 -> 1.74
+	recno:	Don't put the record if rec_search fails, in rec_rdelete.
+		Create fixed-length intermediate records past "end" of DB
+		correctly.
+		Realloc bug when reading in fixed records.
+	all:	First cut at port to Alpha (64-bit architecture) using
+		4.4BSD basic integral types typedef's.
+		Cast allocation pointers to shut up old compilers.
+		Rework PORT directory into OS/machine directories.
+
+1.72 -> 1.73
+	btree:	If enough duplicate records were inserted and then deleted
+		that internal pages had references to empty pages of the
+		duplicate keys, the search function ended up on the wrong
+		page.
+
+1.7  -> 1.72	12 Oct 1993
+	hash:	Support NET/2 hash formats.
+
+1.7  -> 1.71	16 Sep 1993
+	btree/recno:
+		Fix bug in internal search routines that caused
+		return of invalid pointers.
+
+1.6  -> 1.7	07 Sep 1993
+	hash:	Fixed big key overflow bugs.
+	test:	Portability hacks, rewrite test script, Makefile.
+	btree/recno:
+		Stop copying non-overflow key/data pairs.
+	PORT:	Break PORT directory up into per architecture/OS
+		subdirectories.
+
+1.5  -> 1.6	06 Jun 1993
+	hash:	In PAIRFITS, the first comparison should look at (P)[2].
+		The hash_realloc function was walking off the end of memory.
+		The overflow page number was wrong when bumping splitpoint.
+
+1.4  -> 1.5	23 May 1993
+	hash:	Set hash default fill factor dynamically.
+	recno:	Fixed bug in sorted page splits.
+		Add page size parameter support.
+		Allow recno to specify the name of the underlying btree;
+			used for vi recovery.
+	btree/recno:
+		Support 64K pages.
+	btree/hash/recno:
+		Provide access to an underlying file descriptor.
+		Change sync routines to take a flag argument, recno
+			uses this to sync out the underlying btree.
+
+1.3  -> 1.4	10 May 1993
+	recno:	Delete the R_CURSORLOG flag from the recno interface.
+		Zero-length record fix for non-mmap reads.
+		Try and make SIZE_T_MAX test in open portable.
+
+1.2  -> 1.3	01 May 1993
+	btree:	Ignore user byte-order setting when reading already
+		existing database.  Fixes to byte-order conversions.
+
+1.1  -> 1.2	15 Apr 1993
+		No bug fixes, only compatibility hacks.
Index: /vendor/FreeBSD-libc/5.3/db/db/db.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/db/db.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/db/db.c	(revision 2404)
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)db.c	8.4 (Berkeley) 2/21/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/db/db.c,v 1.2 2002/03/22 21:52:01 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include <db.h>
+
+DB *
+dbopen(fname, flags, mode, type, openinfo)
+	const char *fname;
+	int flags, mode;
+	DBTYPE type;
+	const void *openinfo;
+{
+
+#define	DB_FLAGS	(DB_LOCK | DB_SHMEM | DB_TXN)
+#define	USE_OPEN_FLAGS							\
+	(O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY |		\
+	 O_RDWR | O_SHLOCK | O_TRUNC)
+
+	if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
+		switch (type) {
+		case DB_BTREE:
+			return (__bt_open(fname, flags & USE_OPEN_FLAGS,
+			    mode, openinfo, flags & DB_FLAGS));
+		case DB_HASH:
+			return (__hash_open(fname, flags & USE_OPEN_FLAGS,
+			    mode, openinfo, flags & DB_FLAGS));
+		case DB_RECNO:
+			return (__rec_open(fname, flags & USE_OPEN_FLAGS,
+			    mode, openinfo, flags & DB_FLAGS));
+		}
+	errno = EINVAL;
+	return (NULL);
+}
+
+static int
+__dberr()
+{
+	return (RET_ERROR);
+}
+
+/*
+ * __DBPANIC -- Stop.
+ *
+ * Parameters:
+ *	dbp:	pointer to the DB structure.
+ */
+void
+__dbpanic(dbp)
+	DB *dbp;
+{
+	/* The only thing that can succeed is a close. */
+	dbp->del = (int (*)())__dberr;
+	dbp->fd = (int (*)())__dberr;
+	dbp->get = (int (*)())__dberr;
+	dbp->put = (int (*)())__dberr;
+	dbp->seq = (int (*)())__dberr;
+	dbp->sync = (int (*)())__dberr;
+}
Index: /vendor/FreeBSD-libc/5.3/db/hash/README
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/README	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/README	(revision 2404)
@@ -0,0 +1,72 @@
+#	@(#)README	8.1 (Berkeley) 6/4/93
+
+This package implements a superset of the hsearch and dbm/ndbm libraries.
+
+Test Programs:
+	All test programs which need key/data pairs expect them entered
+	with key and data on separate lines
+
+	tcreat3.c	
+		Takes 
+			bucketsize (bsize), 
+			fill factor (ffactor), and
+			initial number of elements (nelem).  
+		Creates a hash table named hashtest containing the 
+		keys/data pairs entered from standard in.
+	thash4.c
+		Takes
+			bucketsize (bsize), 
+			fill factor (ffactor), 
+			initial number of elements (nelem)
+			bytes of cache (ncached), and
+			file from which to read data  (fname)
+		Creates a table from the key/data pairs on standard in and
+		then does a read of each key/data in fname
+	tdel.c
+		Takes
+			bucketsize (bsize), and
+			fill factor (ffactor).
+			file from which to read data (fname)
+		Reads each key/data pair from fname and deletes the
+		key from the hash table hashtest
+	tseq.c
+		Reads the key/data pairs in the file hashtest and writes them
+		to standard out.
+	tread2.c
+		Takes
+			butes of cache (ncached).
+		Reads key/data pairs from standard in and looks them up
+		in the file hashtest.
+	tverify.c
+		Reads key/data pairs from standard in, looks them up
+		in the file hashtest, and verifies that the data is
+		correct.
+
+NOTES:
+
+The file search.h is provided for using the hsearch compatible interface
+on BSD systems.  On System V derived systems, search.h should appear in 
+/usr/include.
+
+The man page ../man/db.3 explains the interface to the hashing system.
+The file hash.ps is a postscript copy of a paper explaining
+the history, implementation, and performance of the hash package.
+
+"bugs" or idiosyncracies
+
+If you have a lot of overflows, it is possible to run out of overflow
+pages.  Currently, this will cause a message to be printed on stderr.
+Eventually, this will be indicated by a return error code.
+
+If you are using the ndbm interface and exit without flushing or closing the
+file, you may lose updates since the package buffers all writes.  Also,
+the db interface only creates a single database file.  To avoid overwriting
+the user's original file, the suffix ".db" is appended to the file name
+passed to dbm_open.  Additionally, if your code "knows" about the historic
+.dir and .pag files, it will break.  
+
+There is a fundamental difference between this package and the old hsearch.
+Hsearch requires the user to maintain the keys and data in the application's
+allocated memory while hash takes care of all storage management.  The down
+side is that the byte strings passed in the ENTRY structure must be null
+terminated (both the keys and the data).
Index: /vendor/FreeBSD-libc/5.3/db/hash/extern.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/extern.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/extern.h	(revision 2404)
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 1991, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ *
+ *	@(#)extern.h	8.4 (Berkeley) 6/16/94
+ * $FreeBSD: src/lib/libc/db/hash/extern.h,v 1.3 2002/03/22 09:18:22 obrien Exp $
+ */
+
+BUFHEAD	*__add_ovflpage(HTAB *, BUFHEAD *);
+int	 __addel(HTAB *, BUFHEAD *, const DBT *, const DBT *);
+int	 __big_delete(HTAB *, BUFHEAD *);
+int	 __big_insert(HTAB *, BUFHEAD *, const DBT *, const DBT *);
+int	 __big_keydata(HTAB *, BUFHEAD *, DBT *, DBT *, int);
+int	 __big_return(HTAB *, BUFHEAD *, int, DBT *, int);
+int	 __big_split(HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *,
+		int, u_int32_t, SPLIT_RETURN *);
+int	 __buf_free(HTAB *, int, int);
+void	 __buf_init(HTAB *, int);
+u_int32_t	 __call_hash(HTAB *, char *, int);
+int	 __delpair(HTAB *, BUFHEAD *, int);
+int	 __expand_table(HTAB *);
+int	 __find_bigpair(HTAB *, BUFHEAD *, int, char *, int);
+u_int16_t	 __find_last_page(HTAB *, BUFHEAD **);
+void	 __free_ovflpage(HTAB *, BUFHEAD *);
+BUFHEAD	*__get_buf(HTAB *, u_int32_t, BUFHEAD *, int);
+int	 __get_page(HTAB *, char *, u_int32_t, int, int, int);
+int	 __ibitmap(HTAB *, int, int, int);
+u_int32_t	 __log2(u_int32_t);
+int	 __put_page(HTAB *, char *, u_int32_t, int, int);
+void	 __reclaim_buf(HTAB *, BUFHEAD *);
+int	 __split_page(HTAB *, u_int32_t, u_int32_t);
+
+/* Default hash routine. */
+extern u_int32_t (*__default_hash)(const void *, size_t);
+
+#ifdef HASH_STATISTICS
+extern int hash_accesses, hash_collisions, hash_expansions, hash_overflows;
+#endif
Index: /vendor/FreeBSD-libc/5.3/db/hash/hash.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/hash.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/hash.c	(revision 2404)
@@ -0,0 +1,1006 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)hash.c	8.9 (Berkeley) 6/16/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/hash/hash.c,v 1.11 2002/03/21 22:46:26 obrien Exp $");
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#ifdef DEBUG
+#include <assert.h>
+#endif
+#include "un-namespace.h"
+
+#include <db.h>
+#include "hash.h"
+#include "page.h"
+#include "extern.h"
+
+static int   alloc_segs(HTAB *, int);
+static int   flush_meta(HTAB *);
+static int   hash_access(HTAB *, ACTION, DBT *, DBT *);
+static int   hash_close(DB *);
+static int   hash_delete(const DB *, const DBT *, u_int32_t);
+static int   hash_fd(const DB *);
+static int   hash_get(const DB *, const DBT *, DBT *, u_int32_t);
+static int   hash_put(const DB *, DBT *, const DBT *, u_int32_t);
+static void *hash_realloc(SEGMENT **, int, int);
+static int   hash_seq(const DB *, DBT *, DBT *, u_int32_t);
+static int   hash_sync(const DB *, u_int32_t);
+static int   hdestroy(HTAB *);
+static HTAB *init_hash(HTAB *, const char *, HASHINFO *);
+static int   init_htab(HTAB *, int);
+#if BYTE_ORDER == LITTLE_ENDIAN
+static void  swap_header(HTAB *);
+static void  swap_header_copy(HASHHDR *, HASHHDR *);
+#endif
+
+/* Fast arithmetic, relying on powers of 2, */
+#define MOD(x, y)		((x) & ((y) - 1))
+
+#define RETURN_ERROR(ERR, LOC)	{ save_errno = ERR; goto LOC; }
+
+/* Return values */
+#define	SUCCESS	 (0)
+#define	ERROR	(-1)
+#define	ABNORMAL (1)
+
+#ifdef HASH_STATISTICS
+int hash_accesses, hash_collisions, hash_expansions, hash_overflows;
+#endif
+
+/************************** INTERFACE ROUTINES ***************************/
+/* OPEN/CLOSE */
+
+extern DB *
+__hash_open(file, flags, mode, info, dflags)
+	const char *file;
+	int flags, mode, dflags;
+	const HASHINFO *info;	/* Special directives for create */
+{
+	HTAB *hashp;
+	struct stat statbuf;
+	DB *dbp;
+	int bpages, hdrsize, new_table, nsegs, save_errno;
+
+	if ((flags & O_ACCMODE) == O_WRONLY) {
+		errno = EINVAL;
+		return (NULL);
+	}
+
+	if (!(hashp = (HTAB *)calloc(1, sizeof(HTAB))))
+		return (NULL);
+	hashp->fp = -1;
+
+	/*
+	 * Even if user wants write only, we need to be able to read
+	 * the actual file, so we need to open it read/write. But, the
+	 * field in the hashp structure needs to be accurate so that
+	 * we can check accesses.
+	 */
+	hashp->flags = flags;
+
+	new_table = 0;
+	if (!file || (flags & O_TRUNC) ||
+	    (stat(file, &statbuf) && (errno == ENOENT))) {
+		if (errno == ENOENT)
+			errno = 0; /* Just in case someone looks at errno */
+		new_table = 1;
+	}
+	if (file) {
+		if ((hashp->fp = _open(file, flags, mode)) == -1)
+			RETURN_ERROR(errno, error0);
+
+		/* if the .db file is empty, and we had permission to create
+		   a new .db file, then reinitialize the database */
+		if ((flags & O_CREAT) &&
+		     _fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
+			new_table = 1;
+
+		(void)_fcntl(hashp->fp, F_SETFD, 1);
+	}
+	if (new_table) {
+		if (!(hashp = init_hash(hashp, file, (HASHINFO *)info)))
+			RETURN_ERROR(errno, error1);
+	} else {
+		/* Table already exists */
+		if (info && info->hash)
+			hashp->hash = info->hash;
+		else
+			hashp->hash = __default_hash;
+
+		hdrsize = _read(hashp->fp, &hashp->hdr, sizeof(HASHHDR));
+#if BYTE_ORDER == LITTLE_ENDIAN
+		swap_header(hashp);
+#endif
+		if (hdrsize == -1)
+			RETURN_ERROR(errno, error1);
+		if (hdrsize != sizeof(HASHHDR))
+			RETURN_ERROR(EFTYPE, error1);
+		/* Verify file type, versions and hash function */
+		if (hashp->MAGIC != HASHMAGIC)
+			RETURN_ERROR(EFTYPE, error1);
+#define	OLDHASHVERSION	1
+		if (hashp->VERSION != HASHVERSION &&
+		    hashp->VERSION != OLDHASHVERSION)
+			RETURN_ERROR(EFTYPE, error1);
+		if (hashp->hash(CHARKEY, sizeof(CHARKEY)) != hashp->H_CHARKEY)
+			RETURN_ERROR(EFTYPE, error1);
+		/*
+		 * Figure out how many segments we need.  Max_Bucket is the
+		 * maximum bucket number, so the number of buckets is
+		 * max_bucket + 1.
+		 */
+		nsegs = (hashp->MAX_BUCKET + 1 + hashp->SGSIZE - 1) /
+			 hashp->SGSIZE;
+		hashp->nsegs = 0;
+		if (alloc_segs(hashp, nsegs))
+			/*
+			 * If alloc_segs fails, table will have been destroyed
+			 * and errno will have been set.
+			 */
+			return (NULL);
+		/* Read in bitmaps */
+		bpages = (hashp->SPARES[hashp->OVFL_POINT] +
+		    (hashp->BSIZE << BYTE_SHIFT) - 1) >>
+		    (hashp->BSHIFT + BYTE_SHIFT);
+
+		hashp->nmaps = bpages;
+		(void)memset(&hashp->mapp[0], 0, bpages * sizeof(u_int32_t *));
+	}
+
+	/* Initialize Buffer Manager */
+	if (info && info->cachesize)
+		__buf_init(hashp, info->cachesize);
+	else
+		__buf_init(hashp, DEF_BUFSIZE);
+
+	hashp->new_file = new_table;
+	hashp->save_file = file && (hashp->flags & O_RDWR);
+	hashp->cbucket = -1;
+	if (!(dbp = (DB *)malloc(sizeof(DB)))) {
+		save_errno = errno;
+		hdestroy(hashp);
+		errno = save_errno;
+		return (NULL);
+	}
+	dbp->internal = hashp;
+	dbp->close = hash_close;
+	dbp->del = hash_delete;
+	dbp->fd = hash_fd;
+	dbp->get = hash_get;
+	dbp->put = hash_put;
+	dbp->seq = hash_seq;
+	dbp->sync = hash_sync;
+	dbp->type = DB_HASH;
+
+#ifdef DEBUG
+	(void)fprintf(stderr,
+"%s\n%s%x\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%x\n%s%x\n%s%d\n%s%d\n",
+	    "init_htab:",
+	    "TABLE POINTER   ", hashp,
+	    "BUCKET SIZE     ", hashp->BSIZE,
+	    "BUCKET SHIFT    ", hashp->BSHIFT,
+	    "DIRECTORY SIZE  ", hashp->DSIZE,
+	    "SEGMENT SIZE    ", hashp->SGSIZE,
+	    "SEGMENT SHIFT   ", hashp->SSHIFT,
+	    "FILL FACTOR     ", hashp->FFACTOR,
+	    "MAX BUCKET      ", hashp->MAX_BUCKET,
+	    "OVFL POINT	     ", hashp->OVFL_POINT,
+	    "LAST FREED      ", hashp->LAST_FREED,
+	    "HIGH MASK       ", hashp->HIGH_MASK,
+	    "LOW  MASK       ", hashp->LOW_MASK,
+	    "NSEGS           ", hashp->nsegs,
+	    "NKEYS           ", hashp->NKEYS);
+#endif
+#ifdef HASH_STATISTICS
+	hash_overflows = hash_accesses = hash_collisions = hash_expansions = 0;
+#endif
+	return (dbp);
+
+error1:
+	if (hashp != NULL)
+		(void)_close(hashp->fp);
+
+error0:
+	free(hashp);
+	errno = save_errno;
+	return (NULL);
+}
+
+static int
+hash_close(dbp)
+	DB *dbp;
+{
+	HTAB *hashp;
+	int retval;
+
+	if (!dbp)
+		return (ERROR);
+
+	hashp = (HTAB *)dbp->internal;
+	retval = hdestroy(hashp);
+	free(dbp);
+	return (retval);
+}
+
+static int
+hash_fd(dbp)
+	const DB *dbp;
+{
+	HTAB *hashp;
+
+	if (!dbp)
+		return (ERROR);
+
+	hashp = (HTAB *)dbp->internal;
+	if (hashp->fp == -1) {
+		errno = ENOENT;
+		return (-1);
+	}
+	return (hashp->fp);
+}
+
+/************************** LOCAL CREATION ROUTINES **********************/
+static HTAB *
+init_hash(hashp, file, info)
+	HTAB *hashp;
+	const char *file;
+	HASHINFO *info;
+{
+	struct stat statbuf;
+	int nelem;
+
+	nelem = 1;
+	hashp->NKEYS = 0;
+	hashp->LORDER = BYTE_ORDER;
+	hashp->BSIZE = DEF_BUCKET_SIZE;
+	hashp->BSHIFT = DEF_BUCKET_SHIFT;
+	hashp->SGSIZE = DEF_SEGSIZE;
+	hashp->SSHIFT = DEF_SEGSIZE_SHIFT;
+	hashp->DSIZE = DEF_DIRSIZE;
+	hashp->FFACTOR = DEF_FFACTOR;
+	hashp->hash = __default_hash;
+	memset(hashp->SPARES, 0, sizeof(hashp->SPARES));
+	memset(hashp->BITMAPS, 0, sizeof (hashp->BITMAPS));
+
+	/* Fix bucket size to be optimal for file system */
+	if (file != NULL) {
+		if (stat(file, &statbuf))
+			return (NULL);
+		hashp->BSIZE = statbuf.st_blksize;
+		hashp->BSHIFT = __log2(hashp->BSIZE);
+	}
+
+	if (info) {
+		if (info->bsize) {
+			/* Round pagesize up to power of 2 */
+			hashp->BSHIFT = __log2(info->bsize);
+			hashp->BSIZE = 1 << hashp->BSHIFT;
+			if (hashp->BSIZE > MAX_BSIZE) {
+				errno = EINVAL;
+				return (NULL);
+			}
+		}
+		if (info->ffactor)
+			hashp->FFACTOR = info->ffactor;
+		if (info->hash)
+			hashp->hash = info->hash;
+		if (info->nelem)
+			nelem = info->nelem;
+		if (info->lorder) {
+			if (info->lorder != BIG_ENDIAN &&
+			    info->lorder != LITTLE_ENDIAN) {
+				errno = EINVAL;
+				return (NULL);
+			}
+			hashp->LORDER = info->lorder;
+		}
+	}
+	/* init_htab should destroy the table and set errno if it fails */
+	if (init_htab(hashp, nelem))
+		return (NULL);
+	else
+		return (hashp);
+}
+/*
+ * This calls alloc_segs which may run out of memory.  Alloc_segs will destroy
+ * the table and set errno, so we just pass the error information along.
+ *
+ * Returns 0 on No Error
+ */
+static int
+init_htab(hashp, nelem)
+	HTAB *hashp;
+	int nelem;
+{
+	int nbuckets, nsegs;
+	int l2;
+
+	/*
+	 * Divide number of elements by the fill factor and determine a
+	 * desired number of buckets.  Allocate space for the next greater
+	 * power of two number of buckets.
+	 */
+	nelem = (nelem - 1) / hashp->FFACTOR + 1;
+
+	l2 = __log2(MAX(nelem, 2));
+	nbuckets = 1 << l2;
+
+	hashp->SPARES[l2] = l2 + 1;
+	hashp->SPARES[l2 + 1] = l2 + 1;
+	hashp->OVFL_POINT = l2;
+	hashp->LAST_FREED = 2;
+
+	/* First bitmap page is at: splitpoint l2 page offset 1 */
+	if (__ibitmap(hashp, OADDR_OF(l2, 1), l2 + 1, 0))
+		return (-1);
+
+	hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1;
+	hashp->HIGH_MASK = (nbuckets << 1) - 1;
+	hashp->HDRPAGES = ((MAX(sizeof(HASHHDR), MINHDRSIZE) - 1) >>
+	    hashp->BSHIFT) + 1;
+
+	nsegs = (nbuckets - 1) / hashp->SGSIZE + 1;
+	nsegs = 1 << __log2(nsegs);
+
+	if (nsegs > hashp->DSIZE)
+		hashp->DSIZE = nsegs;
+	return (alloc_segs(hashp, nsegs));
+}
+
+/********************** DESTROY/CLOSE ROUTINES ************************/
+
+/*
+ * Flushes any changes to the file if necessary and destroys the hashp
+ * structure, freeing all allocated space.
+ */
+static int
+hdestroy(hashp)
+	HTAB *hashp;
+{
+	int i, save_errno;
+
+	save_errno = 0;
+
+#ifdef HASH_STATISTICS
+	(void)fprintf(stderr, "hdestroy: accesses %ld collisions %ld\n",
+	    hash_accesses, hash_collisions);
+	(void)fprintf(stderr, "hdestroy: expansions %ld\n",
+	    hash_expansions);
+	(void)fprintf(stderr, "hdestroy: overflows %ld\n",
+	    hash_overflows);
+	(void)fprintf(stderr, "keys %ld maxp %d segmentcount %d\n",
+	    hashp->NKEYS, hashp->MAX_BUCKET, hashp->nsegs);
+
+	for (i = 0; i < NCACHED; i++)
+		(void)fprintf(stderr,
+		    "spares[%d] = %d\n", i, hashp->SPARES[i]);
+#endif
+	/*
+	 * Call on buffer manager to free buffers, and if required,
+	 * write them to disk.
+	 */
+	if (__buf_free(hashp, 1, hashp->save_file))
+		save_errno = errno;
+	if (hashp->dir) {
+		free(*hashp->dir);	/* Free initial segments */
+		/* Free extra segments */
+		while (hashp->exsegs--)
+			free(hashp->dir[--hashp->nsegs]);
+		free(hashp->dir);
+	}
+	if (flush_meta(hashp) && !save_errno)
+		save_errno = errno;
+	/* Free Bigmaps */
+	for (i = 0; i < hashp->nmaps; i++)
+		if (hashp->mapp[i])
+			free(hashp->mapp[i]);
+
+	if (hashp->fp != -1)
+		(void)_close(hashp->fp);
+
+	free(hashp);
+
+	if (save_errno) {
+		errno = save_errno;
+		return (ERROR);
+	}
+	return (SUCCESS);
+}
+/*
+ * Write modified pages to disk
+ *
+ * Returns:
+ *	 0 == OK
+ *	-1 ERROR
+ */
+static int
+hash_sync(dbp, flags)
+	const DB *dbp;
+	u_int32_t flags;
+{
+	HTAB *hashp;
+
+	if (flags != 0) {
+		errno = EINVAL;
+		return (ERROR);
+	}
+
+	if (!dbp)
+		return (ERROR);
+
+	hashp = (HTAB *)dbp->internal;
+	if (!hashp->save_file)
+		return (0);
+	if (__buf_free(hashp, 0, 1) || flush_meta(hashp))
+		return (ERROR);
+	hashp->new_file = 0;
+	return (0);
+}
+
+/*
+ * Returns:
+ *	 0 == OK
+ *	-1 indicates that errno should be set
+ */
+static int
+flush_meta(hashp)
+	HTAB *hashp;
+{
+	HASHHDR *whdrp;
+#if BYTE_ORDER == LITTLE_ENDIAN
+	HASHHDR whdr;
+#endif
+	int fp, i, wsize;
+
+	if (!hashp->save_file)
+		return (0);
+	hashp->MAGIC = HASHMAGIC;
+	hashp->VERSION = HASHVERSION;
+	hashp->H_CHARKEY = hashp->hash(CHARKEY, sizeof(CHARKEY));
+
+	fp = hashp->fp;
+	whdrp = &hashp->hdr;
+#if BYTE_ORDER == LITTLE_ENDIAN
+	whdrp = &whdr;
+	swap_header_copy(&hashp->hdr, whdrp);
+#endif
+	if ((lseek(fp, (off_t)0, SEEK_SET) == -1) ||
+	    ((wsize = _write(fp, whdrp, sizeof(HASHHDR))) == -1))
+		return (-1);
+	else
+		if (wsize != sizeof(HASHHDR)) {
+			errno = EFTYPE;
+			hashp->error = errno;
+			return (-1);
+		}
+	for (i = 0; i < NCACHED; i++)
+		if (hashp->mapp[i])
+			if (__put_page(hashp, (char *)hashp->mapp[i],
+				hashp->BITMAPS[i], 0, 1))
+				return (-1);
+	return (0);
+}
+
+/*******************************SEARCH ROUTINES *****************************/
+/*
+ * All the access routines return
+ *
+ * Returns:
+ *	 0 on SUCCESS
+ *	 1 to indicate an external ERROR (i.e. key not found, etc)
+ *	-1 to indicate an internal ERROR (i.e. out of memory, etc)
+ */
+static int
+hash_get(dbp, key, data, flag)
+	const DB *dbp;
+	const DBT *key;
+	DBT *data;
+	u_int32_t flag;
+{
+	HTAB *hashp;
+
+	hashp = (HTAB *)dbp->internal;
+	if (flag) {
+		hashp->error = errno = EINVAL;
+		return (ERROR);
+	}
+	return (hash_access(hashp, HASH_GET, (DBT *)key, data));
+}
+
+static int
+hash_put(dbp, key, data, flag)
+	const DB *dbp;
+	DBT *key;
+	const DBT *data;
+	u_int32_t flag;
+{
+	HTAB *hashp;
+
+	hashp = (HTAB *)dbp->internal;
+	if (flag && flag != R_NOOVERWRITE) {
+		hashp->error = EINVAL;
+		errno = EINVAL;
+		return (ERROR);
+	}
+	if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
+		hashp->error = errno = EPERM;
+		return (ERROR);
+	}
+	return (hash_access(hashp, flag == R_NOOVERWRITE ?
+	    HASH_PUTNEW : HASH_PUT, (DBT *)key, (DBT *)data));
+}
+
+static int
+hash_delete(dbp, key, flag)
+	const DB *dbp;
+	const DBT *key;
+	u_int32_t flag;		/* Ignored */
+{
+	HTAB *hashp;
+
+	hashp = (HTAB *)dbp->internal;
+	if (flag && flag != R_CURSOR) {
+		hashp->error = errno = EINVAL;
+		return (ERROR);
+	}
+	if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
+		hashp->error = errno = EPERM;
+		return (ERROR);
+	}
+	return (hash_access(hashp, HASH_DELETE, (DBT *)key, NULL));
+}
+
+/*
+ * Assume that hashp has been set in wrapper routine.
+ */
+static int
+hash_access(hashp, action, key, val)
+	HTAB *hashp;
+	ACTION action;
+	DBT *key, *val;
+{
+	BUFHEAD *rbufp;
+	BUFHEAD *bufp, *save_bufp;
+	u_int16_t *bp;
+	int n, ndx, off, size;
+	char *kp;
+	u_int16_t pageno;
+
+#ifdef HASH_STATISTICS
+	hash_accesses++;
+#endif
+
+	off = hashp->BSIZE;
+	size = key->size;
+	kp = (char *)key->data;
+	rbufp = __get_buf(hashp, __call_hash(hashp, kp, size), NULL, 0);
+	if (!rbufp)
+		return (ERROR);
+	save_bufp = rbufp;
+
+	/* Pin the bucket chain */
+	rbufp->flags |= BUF_PIN;
+	for (bp = (u_int16_t *)rbufp->page, n = *bp++, ndx = 1; ndx < n;)
+		if (bp[1] >= REAL_KEY) {
+			/* Real key/data pair */
+			if (size == off - *bp &&
+			    memcmp(kp, rbufp->page + *bp, size) == 0)
+				goto found;
+			off = bp[1];
+#ifdef HASH_STATISTICS
+			hash_collisions++;
+#endif
+			bp += 2;
+			ndx += 2;
+		} else if (bp[1] == OVFLPAGE) {
+			rbufp = __get_buf(hashp, *bp, rbufp, 0);
+			if (!rbufp) {
+				save_bufp->flags &= ~BUF_PIN;
+				return (ERROR);
+			}
+			/* FOR LOOP INIT */
+			bp = (u_int16_t *)rbufp->page;
+			n = *bp++;
+			ndx = 1;
+			off = hashp->BSIZE;
+		} else if (bp[1] < REAL_KEY) {
+			if ((ndx =
+			    __find_bigpair(hashp, rbufp, ndx, kp, size)) > 0)
+				goto found;
+			if (ndx == -2) {
+				bufp = rbufp;
+				if (!(pageno =
+				    __find_last_page(hashp, &bufp))) {
+					ndx = 0;
+					rbufp = bufp;
+					break;	/* FOR */
+				}
+				rbufp = __get_buf(hashp, pageno, bufp, 0);
+				if (!rbufp) {
+					save_bufp->flags &= ~BUF_PIN;
+					return (ERROR);
+				}
+				/* FOR LOOP INIT */
+				bp = (u_int16_t *)rbufp->page;
+				n = *bp++;
+				ndx = 1;
+				off = hashp->BSIZE;
+			} else {
+				save_bufp->flags &= ~BUF_PIN;
+				return (ERROR);
+			}
+		}
+
+	/* Not found */
+	switch (action) {
+	case HASH_PUT:
+	case HASH_PUTNEW:
+		if (__addel(hashp, rbufp, key, val)) {
+			save_bufp->flags &= ~BUF_PIN;
+			return (ERROR);
+		} else {
+			save_bufp->flags &= ~BUF_PIN;
+			return (SUCCESS);
+		}
+	case HASH_GET:
+	case HASH_DELETE:
+	default:
+		save_bufp->flags &= ~BUF_PIN;
+		return (ABNORMAL);
+	}
+
+found:
+	switch (action) {
+	case HASH_PUTNEW:
+		save_bufp->flags &= ~BUF_PIN;
+		return (ABNORMAL);
+	case HASH_GET:
+		bp = (u_int16_t *)rbufp->page;
+		if (bp[ndx + 1] < REAL_KEY) {
+			if (__big_return(hashp, rbufp, ndx, val, 0))
+				return (ERROR);
+		} else {
+			val->data = (u_char *)rbufp->page + (int)bp[ndx + 1];
+			val->size = bp[ndx] - bp[ndx + 1];
+		}
+		break;
+	case HASH_PUT:
+		if ((__delpair(hashp, rbufp, ndx)) ||
+		    (__addel(hashp, rbufp, key, val))) {
+			save_bufp->flags &= ~BUF_PIN;
+			return (ERROR);
+		}
+		break;
+	case HASH_DELETE:
+		if (__delpair(hashp, rbufp, ndx))
+			return (ERROR);
+		break;
+	default:
+		abort();
+	}
+	save_bufp->flags &= ~BUF_PIN;
+	return (SUCCESS);
+}
+
+static int
+hash_seq(dbp, key, data, flag)
+	const DB *dbp;
+	DBT *key, *data;
+	u_int32_t flag;
+{
+	u_int32_t bucket;
+	BUFHEAD *bufp;
+	HTAB *hashp;
+	u_int16_t *bp, ndx;
+
+	hashp = (HTAB *)dbp->internal;
+	if (flag && flag != R_FIRST && flag != R_NEXT) {
+		hashp->error = errno = EINVAL;
+		return (ERROR);
+	}
+#ifdef HASH_STATISTICS
+	hash_accesses++;
+#endif
+	if ((hashp->cbucket < 0) || (flag == R_FIRST)) {
+		hashp->cbucket = 0;
+		hashp->cndx = 1;
+		hashp->cpage = NULL;
+	}
+
+	for (bp = NULL; !bp || !bp[0]; ) {
+		if (!(bufp = hashp->cpage)) {
+			for (bucket = hashp->cbucket;
+			    bucket <= hashp->MAX_BUCKET;
+			    bucket++, hashp->cndx = 1) {
+				bufp = __get_buf(hashp, bucket, NULL, 0);
+				if (!bufp)
+					return (ERROR);
+				hashp->cpage = bufp;
+				bp = (u_int16_t *)bufp->page;
+				if (bp[0])
+					break;
+			}
+			hashp->cbucket = bucket;
+			if (hashp->cbucket > hashp->MAX_BUCKET) {
+				hashp->cbucket = -1;
+				return (ABNORMAL);
+			}
+		} else
+			bp = (u_int16_t *)hashp->cpage->page;
+
+#ifdef DEBUG
+		assert(bp);
+		assert(bufp);
+#endif
+		while (bp[hashp->cndx + 1] == OVFLPAGE) {
+			bufp = hashp->cpage =
+			    __get_buf(hashp, bp[hashp->cndx], bufp, 0);
+			if (!bufp)
+				return (ERROR);
+			bp = (u_int16_t *)(bufp->page);
+			hashp->cndx = 1;
+		}
+		if (!bp[0]) {
+			hashp->cpage = NULL;
+			++hashp->cbucket;
+		}
+	}
+	ndx = hashp->cndx;
+	if (bp[ndx + 1] < REAL_KEY) {
+		if (__big_keydata(hashp, bufp, key, data, 1))
+			return (ERROR);
+	} else {
+		key->data = (u_char *)hashp->cpage->page + bp[ndx];
+		key->size = (ndx > 1 ? bp[ndx - 1] : hashp->BSIZE) - bp[ndx];
+		data->data = (u_char *)hashp->cpage->page + bp[ndx + 1];
+		data->size = bp[ndx] - bp[ndx + 1];
+		ndx += 2;
+		if (ndx > bp[0]) {
+			hashp->cpage = NULL;
+			hashp->cbucket++;
+			hashp->cndx = 1;
+		} else
+			hashp->cndx = ndx;
+	}
+	return (SUCCESS);
+}
+
+/********************************* UTILITIES ************************/
+
+/*
+ * Returns:
+ *	 0 ==> OK
+ *	-1 ==> Error
+ */
+extern int
+__expand_table(hashp)
+	HTAB *hashp;
+{
+	u_int32_t old_bucket, new_bucket;
+	int dirsize, new_segnum, spare_ndx;
+
+#ifdef HASH_STATISTICS
+	hash_expansions++;
+#endif
+	new_bucket = ++hashp->MAX_BUCKET;
+	old_bucket = (hashp->MAX_BUCKET & hashp->LOW_MASK);
+
+	new_segnum = new_bucket >> hashp->SSHIFT;
+
+	/* Check if we need a new segment */
+	if (new_segnum >= hashp->nsegs) {
+		/* Check if we need to expand directory */
+		if (new_segnum >= hashp->DSIZE) {
+			/* Reallocate directory */
+			dirsize = hashp->DSIZE * sizeof(SEGMENT *);
+			if (!hash_realloc(&hashp->dir, dirsize, dirsize << 1))
+				return (-1);
+			hashp->DSIZE = dirsize << 1;
+		}
+		if ((hashp->dir[new_segnum] =
+		    (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL)
+			return (-1);
+		hashp->exsegs++;
+		hashp->nsegs++;
+	}
+	/*
+	 * If the split point is increasing (MAX_BUCKET's log base 2
+	 * * increases), we need to copy the current contents of the spare
+	 * split bucket to the next bucket.
+	 */
+	spare_ndx = __log2(hashp->MAX_BUCKET + 1);
+	if (spare_ndx > hashp->OVFL_POINT) {
+		hashp->SPARES[spare_ndx] = hashp->SPARES[hashp->OVFL_POINT];
+		hashp->OVFL_POINT = spare_ndx;
+	}
+
+	if (new_bucket > hashp->HIGH_MASK) {
+		/* Starting a new doubling */
+		hashp->LOW_MASK = hashp->HIGH_MASK;
+		hashp->HIGH_MASK = new_bucket | hashp->LOW_MASK;
+	}
+	/* Relocate records to the new bucket */
+	return (__split_page(hashp, old_bucket, new_bucket));
+}
+
+/*
+ * If realloc guarantees that the pointer is not destroyed if the realloc
+ * fails, then this routine can go away.
+ */
+static void *
+hash_realloc(p_ptr, oldsize, newsize)
+	SEGMENT **p_ptr;
+	int oldsize, newsize;
+{
+	void *p;
+
+	if ( (p = malloc(newsize)) ) {
+		memmove(p, *p_ptr, oldsize);
+		memset((char *)p + oldsize, 0, newsize - oldsize);
+		free(*p_ptr);
+		*p_ptr = p;
+	}
+	return (p);
+}
+
+extern u_int32_t
+__call_hash(hashp, k, len)
+	HTAB *hashp;
+	char *k;
+	int len;
+{
+	int n, bucket;
+
+	n = hashp->hash(k, len);
+	bucket = n & hashp->HIGH_MASK;
+	if (bucket > hashp->MAX_BUCKET)
+		bucket = bucket & hashp->LOW_MASK;
+	return (bucket);
+}
+
+/*
+ * Allocate segment table.  On error, destroy the table and set errno.
+ *
+ * Returns 0 on success
+ */
+static int
+alloc_segs(hashp, nsegs)
+	HTAB *hashp;
+	int nsegs;
+{
+	int i;
+	SEGMENT store;
+
+	int save_errno;
+
+	if ((hashp->dir =
+	    (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) {
+		save_errno = errno;
+		(void)hdestroy(hashp);
+		errno = save_errno;
+		return (-1);
+	}
+	/* Allocate segments */
+	if ((store =
+	    (SEGMENT)calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) {
+		save_errno = errno;
+		(void)hdestroy(hashp);
+		errno = save_errno;
+		return (-1);
+	}
+	for (i = 0; i < nsegs; i++, hashp->nsegs++)
+		hashp->dir[i] = &store[i << hashp->SSHIFT];
+	return (0);
+}
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+/*
+ * Hashp->hdr needs to be byteswapped.
+ */
+static void
+swap_header_copy(srcp, destp)
+	HASHHDR *srcp, *destp;
+{
+	int i;
+
+	P_32_COPY(srcp->magic, destp->magic);
+	P_32_COPY(srcp->version, destp->version);
+	P_32_COPY(srcp->lorder, destp->lorder);
+	P_32_COPY(srcp->bsize, destp->bsize);
+	P_32_COPY(srcp->bshift, destp->bshift);
+	P_32_COPY(srcp->dsize, destp->dsize);
+	P_32_COPY(srcp->ssize, destp->ssize);
+	P_32_COPY(srcp->sshift, destp->sshift);
+	P_32_COPY(srcp->ovfl_point, destp->ovfl_point);
+	P_32_COPY(srcp->last_freed, destp->last_freed);
+	P_32_COPY(srcp->max_bucket, destp->max_bucket);
+	P_32_COPY(srcp->high_mask, destp->high_mask);
+	P_32_COPY(srcp->low_mask, destp->low_mask);
+	P_32_COPY(srcp->ffactor, destp->ffactor);
+	P_32_COPY(srcp->nkeys, destp->nkeys);
+	P_32_COPY(srcp->hdrpages, destp->hdrpages);
+	P_32_COPY(srcp->h_charkey, destp->h_charkey);
+	for (i = 0; i < NCACHED; i++) {
+		P_32_COPY(srcp->spares[i], destp->spares[i]);
+		P_16_COPY(srcp->bitmaps[i], destp->bitmaps[i]);
+	}
+}
+
+static void
+swap_header(hashp)
+	HTAB *hashp;
+{
+	HASHHDR *hdrp;
+	int i;
+
+	hdrp = &hashp->hdr;
+
+	M_32_SWAP(hdrp->magic);
+	M_32_SWAP(hdrp->version);
+	M_32_SWAP(hdrp->lorder);
+	M_32_SWAP(hdrp->bsize);
+	M_32_SWAP(hdrp->bshift);
+	M_32_SWAP(hdrp->dsize);
+	M_32_SWAP(hdrp->ssize);
+	M_32_SWAP(hdrp->sshift);
+	M_32_SWAP(hdrp->ovfl_point);
+	M_32_SWAP(hdrp->last_freed);
+	M_32_SWAP(hdrp->max_bucket);
+	M_32_SWAP(hdrp->high_mask);
+	M_32_SWAP(hdrp->low_mask);
+	M_32_SWAP(hdrp->ffactor);
+	M_32_SWAP(hdrp->nkeys);
+	M_32_SWAP(hdrp->hdrpages);
+	M_32_SWAP(hdrp->h_charkey);
+	for (i = 0; i < NCACHED; i++) {
+		M_32_SWAP(hdrp->spares[i]);
+		M_16_SWAP(hdrp->bitmaps[i]);
+	}
+}
+#endif
Index: /vendor/FreeBSD-libc/5.3/db/hash/hash.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/hash.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/hash.h	(revision 2404)
@@ -0,0 +1,294 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ *
+ *	@(#)hash.h	8.3 (Berkeley) 5/31/94
+ * $FreeBSD: src/lib/libc/db/hash/hash.h,v 1.6 2002/03/21 22:46:26 obrien Exp $
+ */
+
+/* Operations */
+typedef enum {
+	HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE, HASH_FIRST, HASH_NEXT
+} ACTION;
+
+/* Buffer Management structures */
+typedef struct _bufhead BUFHEAD;
+
+struct _bufhead {
+	BUFHEAD		*prev;		/* LRU links */
+	BUFHEAD		*next;		/* LRU links */
+	BUFHEAD		*ovfl;		/* Overflow page buffer header */
+	u_int32_t	 addr;		/* Address of this page */
+	char		*page;		/* Actual page data */
+	char	 	flags;
+#define	BUF_MOD		0x0001
+#define BUF_DISK	0x0002
+#define	BUF_BUCKET	0x0004
+#define	BUF_PIN		0x0008
+};
+
+#define IS_BUCKET(X)	((X) & BUF_BUCKET)
+
+typedef BUFHEAD **SEGMENT;
+
+/* Hash Table Information */
+typedef struct hashhdr {		/* Disk resident portion */
+	int		magic;		/* Magic NO for hash tables */
+	int		version;	/* Version ID */
+	u_int32_t	lorder;		/* Byte Order */
+	int		bsize;		/* Bucket/Page Size */
+	int		bshift;		/* Bucket shift */
+	int		dsize;		/* Directory Size */
+	int		ssize;		/* Segment Size */
+	int		sshift;		/* Segment shift */
+	int		ovfl_point;	/* Where overflow pages are being 
+					 * allocated */
+	int		last_freed;	/* Last overflow page freed */
+	int		max_bucket;	/* ID of Maximum bucket in use */
+	int		high_mask;	/* Mask to modulo into entire table */
+	int		low_mask;	/* Mask to modulo into lower half of 
+					 * table */
+	int		ffactor;	/* Fill factor */
+	int		nkeys;		/* Number of keys in hash table */
+	int		hdrpages;	/* Size of table header */
+	int		h_charkey;	/* value of hash(CHARKEY) */
+#define NCACHED	32			/* number of bit maps and spare 
+					 * points */
+	int		spares[NCACHED];/* spare pages for overflow */
+	u_int16_t	bitmaps[NCACHED];	/* address of overflow page 
+						 * bitmaps */
+} HASHHDR;
+
+typedef struct htab	 {		/* Memory resident data structure */
+	HASHHDR 	hdr;		/* Header */
+	int		nsegs;		/* Number of allocated segments */
+	int		exsegs;		/* Number of extra allocated 
+					 * segments */
+	u_int32_t			/* Hash function */
+	    (*hash)(const void *, size_t);
+	int		flags;		/* Flag values */
+	int		fp;		/* File pointer */
+	char		*tmp_buf;	/* Temporary Buffer for BIG data */
+	char		*tmp_key;	/* Temporary Buffer for BIG keys */
+	BUFHEAD 	*cpage;		/* Current page */
+	int		cbucket;	/* Current bucket */
+	int		cndx;		/* Index of next item on cpage */
+	int		error;		/* Error Number -- for DBM 
+					 * compatibility */
+	int		new_file;	/* Indicates if fd is backing store 
+					 * or no */
+	int		save_file;	/* Indicates whether we need to flush 
+					 * file at
+					 * exit */
+	u_int32_t	*mapp[NCACHED];	/* Pointers to page maps */
+	int		nmaps;		/* Initial number of bitmaps */
+	int		nbufs;		/* Number of buffers left to 
+					 * allocate */
+	BUFHEAD 	bufhead;	/* Header of buffer lru list */
+	SEGMENT 	*dir;		/* Hash Bucket directory */
+} HTAB;
+
+/*
+ * Constants
+ */
+#define	MAX_BSIZE		65536		/* 2^16 */
+#define MIN_BUFFERS		6
+#define MINHDRSIZE		512
+#define DEF_BUFSIZE		65536		/* 64 K */
+#define DEF_BUCKET_SIZE		4096
+#define DEF_BUCKET_SHIFT	12		/* log2(BUCKET) */
+#define DEF_SEGSIZE		256
+#define DEF_SEGSIZE_SHIFT	8		/* log2(SEGSIZE)	 */
+#define DEF_DIRSIZE		256
+#define DEF_FFACTOR		65536
+#define MIN_FFACTOR		4
+#define SPLTMAX			8
+#define CHARKEY			"%$sniglet^&"
+#define NUMKEY			1038583
+#define BYTE_SHIFT		3
+#define INT_TO_BYTE		2
+#define INT_BYTE_SHIFT		5
+#define ALL_SET			((u_int32_t)0xFFFFFFFF)
+#define ALL_CLEAR		0
+
+#define PTROF(X)	((BUFHEAD *)((ptrdiff_t)(X)&~0x3))
+#define ISMOD(X)	((u_int32_t)(ptrdiff_t)(X)&0x1)
+#define DOMOD(X)	((X) = (char *)((ptrdiff_t)(X)|0x1))
+#define ISDISK(X)	((u_int32_t)(ptrdiff_t)(X)&0x2)
+#define DODISK(X)	((X) = (char *)((ptrdiff_t)(X)|0x2))
+
+#define BITS_PER_MAP	32
+
+/* Given the address of the beginning of a big map, clear/set the nth bit */
+#define CLRBIT(A, N)	((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP)))
+#define SETBIT(A, N)	((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP)))
+#define ISSET(A, N)	((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP)))
+
+/* Overflow management */
+/*
+ * Overflow page numbers are allocated per split point.  At each doubling of
+ * the table, we can allocate extra pages.  So, an overflow page number has
+ * the top 5 bits indicate which split point and the lower 11 bits indicate
+ * which page at that split point is indicated (pages within split points are
+ * numberered starting with 1).
+ */
+
+#define SPLITSHIFT	11
+#define SPLITMASK	0x7FF
+#define SPLITNUM(N)	(((u_int32_t)(N)) >> SPLITSHIFT)
+#define OPAGENUM(N)	((N) & SPLITMASK)
+#define	OADDR_OF(S,O)	((u_int32_t)((u_int32_t)(S) << SPLITSHIFT) + (O))
+
+#define BUCKET_TO_PAGE(B) \
+	(B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((B)+1)-1] : 0)
+#define OADDR_TO_PAGE(B) 	\
+	BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B));
+
+/*
+ * page.h contains a detailed description of the page format.
+ *
+ * Normally, keys and data are accessed from offset tables in the top of
+ * each page which point to the beginning of the key and data.  There are
+ * four flag values which may be stored in these offset tables which indicate
+ * the following:
+ *
+ *
+ * OVFLPAGE	Rather than a key data pair, this pair contains
+ *		the address of an overflow page.  The format of
+ *		the pair is:
+ *		    OVERFLOW_PAGE_NUMBER OVFLPAGE
+ *
+ * PARTIAL_KEY	This must be the first key/data pair on a page
+ *		and implies that page contains only a partial key.
+ *		That is, the key is too big to fit on a single page
+ *		so it starts on this page and continues on the next.
+ *		The format of the page is:
+ *		    KEY_OFF PARTIAL_KEY OVFL_PAGENO OVFLPAGE
+ *
+ *		    KEY_OFF -- offset of the beginning of the key
+ *		    PARTIAL_KEY -- 1
+ *		    OVFL_PAGENO - page number of the next overflow page
+ *		    OVFLPAGE -- 0
+ *
+ * FULL_KEY	This must be the first key/data pair on the page.  It
+ *		is used in two cases.
+ *
+ *		Case 1:
+ *		    There is a complete key on the page but no data
+ *		    (because it wouldn't fit).  The next page contains
+ *		    the data.
+ *
+ *		    Page format it:
+ *		    KEY_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE
+ *
+ *		    KEY_OFF -- offset of the beginning of the key
+ *		    FULL_KEY -- 2
+ *		    OVFL_PAGENO - page number of the next overflow page
+ *		    OVFLPAGE -- 0
+ *
+ *		Case 2:
+ *		    This page contains no key, but part of a large
+ *		    data field, which is continued on the next page.
+ *
+ *		    Page format it:
+ *		    DATA_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE
+ *
+ *		    KEY_OFF -- offset of the beginning of the data on
+ *				this page
+ *		    FULL_KEY -- 2
+ *		    OVFL_PAGENO - page number of the next overflow page
+ *		    OVFLPAGE -- 0
+ *
+ * FULL_KEY_DATA
+ *		This must be the first key/data pair on the page.
+ *		There are two cases:
+ *
+ *		Case 1:
+ *		    This page contains a key and the beginning of the
+ *		    data field, but the data field is continued on the
+ *		    next page.
+ *
+ *		    Page format is:
+ *		    KEY_OFF FULL_KEY_DATA OVFL_PAGENO DATA_OFF
+ *
+ *		    KEY_OFF -- offset of the beginning of the key
+ *		    FULL_KEY_DATA -- 3
+ *		    OVFL_PAGENO - page number of the next overflow page
+ *		    DATA_OFF -- offset of the beginning of the data
+ *
+ *		Case 2:
+ *		    This page contains the last page of a big data pair.
+ *		    There is no key, only the  tail end of the data
+ *		    on this page.
+ *
+ *		    Page format is:
+ *		    DATA_OFF FULL_KEY_DATA <OVFL_PAGENO> <OVFLPAGE>
+ *
+ *		    DATA_OFF -- offset of the beginning of the data on
+ *				this page
+ *		    FULL_KEY_DATA -- 3
+ *		    OVFL_PAGENO - page number of the next overflow page
+ *		    OVFLPAGE -- 0
+ *
+ *		    OVFL_PAGENO and OVFLPAGE are optional (they are
+ *		    not present if there is no next page).
+ */
+
+#define OVFLPAGE	0
+#define PARTIAL_KEY	1
+#define FULL_KEY	2
+#define FULL_KEY_DATA	3
+#define	REAL_KEY	4
+
+/* Short hands for accessing structure */
+#define BSIZE		hdr.bsize
+#define BSHIFT		hdr.bshift
+#define DSIZE		hdr.dsize
+#define SGSIZE		hdr.ssize
+#define SSHIFT		hdr.sshift
+#define LORDER		hdr.lorder
+#define OVFL_POINT	hdr.ovfl_point
+#define	LAST_FREED	hdr.last_freed
+#define MAX_BUCKET	hdr.max_bucket
+#define FFACTOR		hdr.ffactor
+#define HIGH_MASK	hdr.high_mask
+#define LOW_MASK	hdr.low_mask
+#define NKEYS		hdr.nkeys
+#define HDRPAGES	hdr.hdrpages
+#define SPARES		hdr.spares
+#define BITMAPS		hdr.bitmaps
+#define VERSION		hdr.version
+#define MAGIC		hdr.magic
+#define NEXT_FREE	hdr.next_free
+#define H_CHARKEY	hdr.h_charkey
Index: /vendor/FreeBSD-libc/5.3/db/hash/hash_bigkey.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/hash_bigkey.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/hash_bigkey.c	(revision 2404)
@@ -0,0 +1,670 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)hash_bigkey.c	8.3 (Berkeley) 5/31/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/hash/hash_bigkey.c,v 1.5 2003/02/16 17:29:09 nectar Exp $");
+
+/*
+ * PACKAGE: hash
+ * DESCRIPTION:
+ *	Big key/data handling for the hashing package.
+ *
+ * ROUTINES:
+ * External
+ *	__big_keydata
+ *	__big_split
+ *	__big_insert
+ *	__big_return
+ *	__big_delete
+ *	__find_last_page
+ * Internal
+ *	collect_key
+ *	collect_data
+ */
+
+#include <sys/param.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef DEBUG
+#include <assert.h>
+#endif
+
+#include <db.h>
+#include "hash.h"
+#include "page.h"
+#include "extern.h"
+
+static int collect_key(HTAB *, BUFHEAD *, int, DBT *, int);
+static int collect_data(HTAB *, BUFHEAD *, int, int);
+
+/*
+ * Big_insert
+ *
+ * You need to do an insert and the key/data pair is too big
+ *
+ * Returns:
+ * 0 ==> OK
+ *-1 ==> ERROR
+ */
+extern int
+__big_insert(hashp, bufp, key, val)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+	const DBT *key, *val;
+{
+	u_int16_t *p;
+	int key_size, n, val_size;
+	u_int16_t space, move_bytes, off;
+	char *cp, *key_data, *val_data;
+
+	cp = bufp->page;		/* Character pointer of p. */
+	p = (u_int16_t *)cp;
+
+	key_data = (char *)key->data;
+	key_size = key->size;
+	val_data = (char *)val->data;
+	val_size = val->size;
+
+	/* First move the Key */
+	for (space = FREESPACE(p) - BIGOVERHEAD; key_size;
+	    space = FREESPACE(p) - BIGOVERHEAD) {
+		move_bytes = MIN(space, key_size);
+		off = OFFSET(p) - move_bytes;
+		memmove(cp + off, key_data, move_bytes);
+		key_size -= move_bytes;
+		key_data += move_bytes;
+		n = p[0];
+		p[++n] = off;
+		p[0] = ++n;
+		FREESPACE(p) = off - PAGE_META(n);
+		OFFSET(p) = off;
+		p[n] = PARTIAL_KEY;
+		bufp = __add_ovflpage(hashp, bufp);
+		if (!bufp)
+			return (-1);
+		n = p[0];
+		if (!key_size) {
+			if (FREESPACE(p)) {
+				move_bytes = MIN(FREESPACE(p), val_size);
+				off = OFFSET(p) - move_bytes;
+				p[n] = off;
+				memmove(cp + off, val_data, move_bytes);
+				val_data += move_bytes;
+				val_size -= move_bytes;
+				p[n - 2] = FULL_KEY_DATA;
+				FREESPACE(p) = FREESPACE(p) - move_bytes;
+				OFFSET(p) = off;
+			} else
+				p[n - 2] = FULL_KEY;
+		}
+		p = (u_int16_t *)bufp->page;
+		cp = bufp->page;
+		bufp->flags |= BUF_MOD;
+	}
+
+	/* Now move the data */
+	for (space = FREESPACE(p) - BIGOVERHEAD; val_size;
+	    space = FREESPACE(p) - BIGOVERHEAD) {
+		move_bytes = MIN(space, val_size);
+		/*
+		 * Here's the hack to make sure that if the data ends on the
+		 * same page as the key ends, FREESPACE is at least one.
+		 */
+		if (space == val_size && val_size == val->size)
+			move_bytes--;
+		off = OFFSET(p) - move_bytes;
+		memmove(cp + off, val_data, move_bytes);
+		val_size -= move_bytes;
+		val_data += move_bytes;
+		n = p[0];
+		p[++n] = off;
+		p[0] = ++n;
+		FREESPACE(p) = off - PAGE_META(n);
+		OFFSET(p) = off;
+		if (val_size) {
+			p[n] = FULL_KEY;
+			bufp = __add_ovflpage(hashp, bufp);
+			if (!bufp)
+				return (-1);
+			cp = bufp->page;
+			p = (u_int16_t *)cp;
+		} else
+			p[n] = FULL_KEY_DATA;
+		bufp->flags |= BUF_MOD;
+	}
+	return (0);
+}
+
+/*
+ * Called when bufp's page  contains a partial key (index should be 1)
+ *
+ * All pages in the big key/data pair except bufp are freed.  We cannot
+ * free bufp because the page pointing to it is lost and we can't get rid
+ * of its pointer.
+ *
+ * Returns:
+ * 0 => OK
+ *-1 => ERROR
+ */
+extern int
+__big_delete(hashp, bufp)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+{
+	BUFHEAD *last_bfp, *rbufp;
+	u_int16_t *bp, pageno;
+	int key_done, n;
+
+	rbufp = bufp;
+	last_bfp = NULL;
+	bp = (u_int16_t *)bufp->page;
+	pageno = 0;
+	key_done = 0;
+
+	while (!key_done || (bp[2] != FULL_KEY_DATA)) {
+		if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA)
+			key_done = 1;
+
+		/*
+		 * If there is freespace left on a FULL_KEY_DATA page, then
+		 * the data is short and fits entirely on this page, and this
+		 * is the last page.
+		 */
+		if (bp[2] == FULL_KEY_DATA && FREESPACE(bp))
+			break;
+		pageno = bp[bp[0] - 1];
+		rbufp->flags |= BUF_MOD;
+		rbufp = __get_buf(hashp, pageno, rbufp, 0);
+		if (last_bfp)
+			__free_ovflpage(hashp, last_bfp);
+		last_bfp = rbufp;
+		if (!rbufp)
+			return (-1);		/* Error. */
+		bp = (u_int16_t *)rbufp->page;
+	}
+
+	/*
+	 * If we get here then rbufp points to the last page of the big
+	 * key/data pair.  Bufp points to the first one -- it should now be
+	 * empty pointing to the next page after this pair.  Can't free it
+	 * because we don't have the page pointing to it.
+	 */
+
+	/* This is information from the last page of the pair. */
+	n = bp[0];
+	pageno = bp[n - 1];
+
+	/* Now, bp is the first page of the pair. */
+	bp = (u_int16_t *)bufp->page;
+	if (n > 2) {
+		/* There is an overflow page. */
+		bp[1] = pageno;
+		bp[2] = OVFLPAGE;
+		bufp->ovfl = rbufp->ovfl;
+	} else
+		/* This is the last page. */
+		bufp->ovfl = NULL;
+	n -= 2;
+	bp[0] = n;
+	FREESPACE(bp) = hashp->BSIZE - PAGE_META(n);
+	OFFSET(bp) = hashp->BSIZE - 1;
+
+	bufp->flags |= BUF_MOD;
+	if (rbufp)
+		__free_ovflpage(hashp, rbufp);
+	if (last_bfp != rbufp)
+		__free_ovflpage(hashp, last_bfp);
+
+	hashp->NKEYS--;
+	return (0);
+}
+/*
+ * Returns:
+ *  0 = key not found
+ * -1 = get next overflow page
+ * -2 means key not found and this is big key/data
+ * -3 error
+ */
+extern int
+__find_bigpair(hashp, bufp, ndx, key, size)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+	int ndx;
+	char *key;
+	int size;
+{
+	u_int16_t *bp;
+	char *p;
+	int ksize;
+	u_int16_t bytes;
+	char *kkey;
+
+	bp = (u_int16_t *)bufp->page;
+	p = bufp->page;
+	ksize = size;
+	kkey = key;
+
+	for (bytes = hashp->BSIZE - bp[ndx];
+	    bytes <= size && bp[ndx + 1] == PARTIAL_KEY;
+	    bytes = hashp->BSIZE - bp[ndx]) {
+		if (memcmp(p + bp[ndx], kkey, bytes))
+			return (-2);
+		kkey += bytes;
+		ksize -= bytes;
+		bufp = __get_buf(hashp, bp[ndx + 2], bufp, 0);
+		if (!bufp)
+			return (-3);
+		p = bufp->page;
+		bp = (u_int16_t *)p;
+		ndx = 1;
+	}
+
+	if (bytes != ksize || memcmp(p + bp[ndx], kkey, bytes)) {
+#ifdef HASH_STATISTICS
+		++hash_collisions;
+#endif
+		return (-2);
+	} else
+		return (ndx);
+}
+
+/*
+ * Given the buffer pointer of the first overflow page of a big pair,
+ * find the end of the big pair
+ *
+ * This will set bpp to the buffer header of the last page of the big pair.
+ * It will return the pageno of the overflow page following the last page
+ * of the pair; 0 if there isn't any (i.e. big pair is the last key in the
+ * bucket)
+ */
+extern u_int16_t
+__find_last_page(hashp, bpp)
+	HTAB *hashp;
+	BUFHEAD **bpp;
+{
+	BUFHEAD *bufp;
+	u_int16_t *bp, pageno;
+	int n;
+
+	bufp = *bpp;
+	bp = (u_int16_t *)bufp->page;
+	for (;;) {
+		n = bp[0];
+
+		/*
+		 * This is the last page if: the tag is FULL_KEY_DATA and
+		 * either only 2 entries OVFLPAGE marker is explicit there
+		 * is freespace on the page.
+		 */
+		if (bp[2] == FULL_KEY_DATA &&
+		    ((n == 2) || (bp[n] == OVFLPAGE) || (FREESPACE(bp))))
+			break;
+
+		pageno = bp[n - 1];
+		bufp = __get_buf(hashp, pageno, bufp, 0);
+		if (!bufp)
+			return (0);	/* Need to indicate an error! */
+		bp = (u_int16_t *)bufp->page;
+	}
+
+	*bpp = bufp;
+	if (bp[0] > 2)
+		return (bp[3]);
+	else
+		return (0);
+}
+
+/*
+ * Return the data for the key/data pair that begins on this page at this
+ * index (index should always be 1).
+ */
+extern int
+__big_return(hashp, bufp, ndx, val, set_current)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+	int ndx;
+	DBT *val;
+	int set_current;
+{
+	BUFHEAD *save_p;
+	u_int16_t *bp, len, off, save_addr;
+	char *tp;
+
+	bp = (u_int16_t *)bufp->page;
+	while (bp[ndx + 1] == PARTIAL_KEY) {
+		bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
+		if (!bufp)
+			return (-1);
+		bp = (u_int16_t *)bufp->page;
+		ndx = 1;
+	}
+
+	if (bp[ndx + 1] == FULL_KEY) {
+		bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
+		if (!bufp)
+			return (-1);
+		bp = (u_int16_t *)bufp->page;
+		save_p = bufp;
+		save_addr = save_p->addr;
+		off = bp[1];
+		len = 0;
+	} else
+		if (!FREESPACE(bp)) {
+			/*
+			 * This is a hack.  We can't distinguish between
+			 * FULL_KEY_DATA that contains complete data or
+			 * incomplete data, so we require that if the data
+			 * is complete, there is at least 1 byte of free
+			 * space left.
+			 */
+			off = bp[bp[0]];
+			len = bp[1] - off;
+			save_p = bufp;
+			save_addr = bufp->addr;
+			bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
+			if (!bufp)
+				return (-1);
+			bp = (u_int16_t *)bufp->page;
+		} else {
+			/* The data is all on one page. */
+			tp = (char *)bp;
+			off = bp[bp[0]];
+			val->data = (u_char *)tp + off;
+			val->size = bp[1] - off;
+			if (set_current) {
+				if (bp[0] == 2) {	/* No more buckets in
+							 * chain */
+					hashp->cpage = NULL;
+					hashp->cbucket++;
+					hashp->cndx = 1;
+				} else {
+					hashp->cpage = __get_buf(hashp,
+					    bp[bp[0] - 1], bufp, 0);
+					if (!hashp->cpage)
+						return (-1);
+					hashp->cndx = 1;
+					if (!((u_int16_t *)
+					    hashp->cpage->page)[0]) {
+						hashp->cbucket++;
+						hashp->cpage = NULL;
+					}
+				}
+			}
+			return (0);
+		}
+
+	val->size = collect_data(hashp, bufp, (int)len, set_current);
+	if (val->size == -1)
+		return (-1);
+	if (save_p->addr != save_addr) {
+		/* We are pretty short on buffers. */
+		errno = EINVAL;			/* OUT OF BUFFERS */
+		return (-1);
+	}
+	memmove(hashp->tmp_buf, (save_p->page) + off, len);
+	val->data = (u_char *)hashp->tmp_buf;
+	return (0);
+}
+/*
+ * Count how big the total datasize is by recursing through the pages.  Then
+ * allocate a buffer and copy the data as you recurse up.
+ */
+static int
+collect_data(hashp, bufp, len, set)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+	int len, set;
+{
+	u_int16_t *bp;
+	char *p;
+	BUFHEAD *xbp;
+	u_int16_t save_addr;
+	int mylen, totlen;
+
+	p = bufp->page;
+	bp = (u_int16_t *)p;
+	mylen = hashp->BSIZE - bp[1];
+	save_addr = bufp->addr;
+
+	if (bp[2] == FULL_KEY_DATA) {		/* End of Data */
+		totlen = len + mylen;
+		if (hashp->tmp_buf)
+			free(hashp->tmp_buf);
+		if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL)
+			return (-1);
+		if (set) {
+			hashp->cndx = 1;
+			if (bp[0] == 2) {	/* No more buckets in chain */
+				hashp->cpage = NULL;
+				hashp->cbucket++;
+			} else {
+				hashp->cpage =
+				    __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
+				if (!hashp->cpage)
+					return (-1);
+				else if (!((u_int16_t *)hashp->cpage->page)[0]) {
+					hashp->cbucket++;
+					hashp->cpage = NULL;
+				}
+			}
+		}
+	} else {
+		xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
+		if (!xbp || ((totlen =
+		    collect_data(hashp, xbp, len + mylen, set)) < 1))
+			return (-1);
+	}
+	if (bufp->addr != save_addr) {
+		errno = EINVAL;			/* Out of buffers. */
+		return (-1);
+	}
+	memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], mylen);
+	return (totlen);
+}
+
+/*
+ * Fill in the key and data for this big pair.
+ */
+extern int
+__big_keydata(hashp, bufp, key, val, set)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+	DBT *key, *val;
+	int set;
+{
+	key->size = collect_key(hashp, bufp, 0, val, set);
+	if (key->size == -1)
+		return (-1);
+	key->data = (u_char *)hashp->tmp_key;
+	return (0);
+}
+
+/*
+ * Count how big the total key size is by recursing through the pages.  Then
+ * collect the data, allocate a buffer and copy the key as you recurse up.
+ */
+static int
+collect_key(hashp, bufp, len, val, set)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+	int len;
+	DBT *val;
+	int set;
+{
+	BUFHEAD *xbp;
+	char *p;
+	int mylen, totlen;
+	u_int16_t *bp, save_addr;
+
+	p = bufp->page;
+	bp = (u_int16_t *)p;
+	mylen = hashp->BSIZE - bp[1];
+
+	save_addr = bufp->addr;
+	totlen = len + mylen;
+	if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) {    /* End of Key. */
+		if (hashp->tmp_key != NULL)
+			free(hashp->tmp_key);
+		if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL)
+			return (-1);
+		if (__big_return(hashp, bufp, 1, val, set))
+			return (-1);
+	} else {
+		xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
+		if (!xbp || ((totlen =
+		    collect_key(hashp, xbp, totlen, val, set)) < 1))
+			return (-1);
+	}
+	if (bufp->addr != save_addr) {
+		errno = EINVAL;		/* MIS -- OUT OF BUFFERS */
+		return (-1);
+	}
+	memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], mylen);
+	return (totlen);
+}
+
+/*
+ * Returns:
+ *  0 => OK
+ * -1 => error
+ */
+extern int
+__big_split(hashp, op, np, big_keyp, addr, obucket, ret)
+	HTAB *hashp;
+	BUFHEAD *op;	/* Pointer to where to put keys that go in old bucket */
+	BUFHEAD *np;	/* Pointer to new bucket page */
+			/* Pointer to first page containing the big key/data */
+	BUFHEAD *big_keyp;
+	int addr;	/* Address of big_keyp */
+	u_int32_t   obucket;/* Old Bucket */
+	SPLIT_RETURN *ret;
+{
+	BUFHEAD *tmpp;
+	u_int16_t *tp;
+	BUFHEAD *bp;
+	DBT key, val;
+	u_int32_t change;
+	u_int16_t free_space, n, off;
+
+	bp = big_keyp;
+
+	/* Now figure out where the big key/data goes */
+	if (__big_keydata(hashp, big_keyp, &key, &val, 0))
+		return (-1);
+	change = (__call_hash(hashp, key.data, key.size) != obucket);
+
+	if ( (ret->next_addr = __find_last_page(hashp, &big_keyp)) ) {
+		if (!(ret->nextp =
+		    __get_buf(hashp, ret->next_addr, big_keyp, 0)))
+			return (-1);;
+	} else
+		ret->nextp = NULL;
+
+	/* Now make one of np/op point to the big key/data pair */
+#ifdef DEBUG
+	assert(np->ovfl == NULL);
+#endif
+	if (change)
+		tmpp = np;
+	else
+		tmpp = op;
+
+	tmpp->flags |= BUF_MOD;
+#ifdef DEBUG1
+	(void)fprintf(stderr,
+	    "BIG_SPLIT: %d->ovfl was %d is now %d\n", tmpp->addr,
+	    (tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0));
+#endif
+	tmpp->ovfl = bp;	/* one of op/np point to big_keyp */
+	tp = (u_int16_t *)tmpp->page;
+#ifdef DEBUG
+	assert(FREESPACE(tp) >= OVFLSIZE);
+#endif
+	n = tp[0];
+	off = OFFSET(tp);
+	free_space = FREESPACE(tp);
+	tp[++n] = (u_int16_t)addr;
+	tp[++n] = OVFLPAGE;
+	tp[0] = n;
+	OFFSET(tp) = off;
+	FREESPACE(tp) = free_space - OVFLSIZE;
+
+	/*
+	 * Finally, set the new and old return values. BIG_KEYP contains a
+	 * pointer to the last page of the big key_data pair. Make sure that
+	 * big_keyp has no following page (2 elements) or create an empty
+	 * following page.
+	 */
+
+	ret->newp = np;
+	ret->oldp = op;
+
+	tp = (u_int16_t *)big_keyp->page;
+	big_keyp->flags |= BUF_MOD;
+	if (tp[0] > 2) {
+		/*
+		 * There may be either one or two offsets on this page.  If
+		 * there is one, then the overflow page is linked on normally
+		 * and tp[4] is OVFLPAGE.  If there are two, tp[4] contains
+		 * the second offset and needs to get stuffed in after the
+		 * next overflow page is added.
+		 */
+		n = tp[4];
+		free_space = FREESPACE(tp);
+		off = OFFSET(tp);
+		tp[0] -= 2;
+		FREESPACE(tp) = free_space + OVFLSIZE;
+		OFFSET(tp) = off;
+		tmpp = __add_ovflpage(hashp, big_keyp);
+		if (!tmpp)
+			return (-1);
+		tp[4] = n;
+	} else
+		tmpp = big_keyp;
+
+	if (change)
+		ret->newp = tmpp;
+	else
+		ret->oldp = tmpp;
+	return (0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/hash/hash_buf.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/hash_buf.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/hash_buf.c	(revision 2404)
@@ -0,0 +1,356 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)hash_buf.c	8.5 (Berkeley) 7/15/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/hash/hash_buf.c,v 1.7 2002/03/21 22:46:26 obrien Exp $");
+
+/*
+ * PACKAGE: hash
+ *
+ * DESCRIPTION:
+ *	Contains buffer management
+ *
+ * ROUTINES:
+ * External
+ *	__buf_init
+ *	__get_buf
+ *	__buf_free
+ *	__reclaim_buf
+ * Internal
+ *	newbuf
+ */
+
+#include <sys/param.h>
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef DEBUG
+#include <assert.h>
+#endif
+
+#include <db.h>
+#include "hash.h"
+#include "page.h"
+#include "extern.h"
+
+static BUFHEAD *newbuf(HTAB *, u_int32_t, BUFHEAD *);
+
+/* Unlink B from its place in the lru */
+#define BUF_REMOVE(B) { \
+	(B)->prev->next = (B)->next; \
+	(B)->next->prev = (B)->prev; \
+}
+
+/* Insert B after P */
+#define BUF_INSERT(B, P) { \
+	(B)->next = (P)->next; \
+	(B)->prev = (P); \
+	(P)->next = (B); \
+	(B)->next->prev = (B); \
+}
+
+#define	MRU	hashp->bufhead.next
+#define	LRU	hashp->bufhead.prev
+
+#define MRU_INSERT(B)	BUF_INSERT((B), &hashp->bufhead)
+#define LRU_INSERT(B)	BUF_INSERT((B), LRU)
+
+/*
+ * We are looking for a buffer with address "addr".  If prev_bp is NULL, then
+ * address is a bucket index.  If prev_bp is not NULL, then it points to the
+ * page previous to an overflow page that we are trying to find.
+ *
+ * CAVEAT:  The buffer header accessed via prev_bp's ovfl field may no longer
+ * be valid.  Therefore, you must always verify that its address matches the
+ * address you are seeking.
+ */
+extern BUFHEAD *
+__get_buf(hashp, addr, prev_bp, newpage)
+	HTAB *hashp;
+	u_int32_t addr;
+	BUFHEAD *prev_bp;
+	int newpage;	/* If prev_bp set, indicates a new overflow page. */
+{
+	BUFHEAD *bp;
+	u_int32_t is_disk_mask;
+	int is_disk, segment_ndx;
+	SEGMENT segp;
+
+	is_disk = 0;
+	is_disk_mask = 0;
+	if (prev_bp) {
+		bp = prev_bp->ovfl;
+		if (!bp || (bp->addr != addr))
+			bp = NULL;
+		if (!newpage)
+			is_disk = BUF_DISK;
+	} else {
+		/* Grab buffer out of directory */
+		segment_ndx = addr & (hashp->SGSIZE - 1);
+
+		/* valid segment ensured by __call_hash() */
+		segp = hashp->dir[addr >> hashp->SSHIFT];
+#ifdef DEBUG
+		assert(segp != NULL);
+#endif
+		bp = PTROF(segp[segment_ndx]);
+		is_disk_mask = ISDISK(segp[segment_ndx]);
+		is_disk = is_disk_mask || !hashp->new_file;
+	}
+
+	if (!bp) {
+		bp = newbuf(hashp, addr, prev_bp);
+		if (!bp ||
+		    __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0))
+			return (NULL);
+		if (!prev_bp)
+			segp[segment_ndx] =
+			    (BUFHEAD *)((ptrdiff_t)bp | is_disk_mask);
+	} else {
+		BUF_REMOVE(bp);
+		MRU_INSERT(bp);
+	}
+	return (bp);
+}
+
+/*
+ * We need a buffer for this page. Either allocate one, or evict a resident
+ * one (if we have as many buffers as we're allowed) and put this one in.
+ *
+ * If newbuf finds an error (returning NULL), it also sets errno.
+ */
+static BUFHEAD *
+newbuf(hashp, addr, prev_bp)
+	HTAB *hashp;
+	u_int32_t addr;
+	BUFHEAD *prev_bp;
+{
+	BUFHEAD *bp;		/* The buffer we're going to use */
+	BUFHEAD *xbp;		/* Temp pointer */
+	BUFHEAD *next_xbp;
+	SEGMENT segp;
+	int segment_ndx;
+	u_int16_t oaddr, *shortp;
+
+	oaddr = 0;
+	bp = LRU;
+	/*
+	 * If LRU buffer is pinned, the buffer pool is too small. We need to
+	 * allocate more buffers.
+	 */
+	if (hashp->nbufs || (bp->flags & BUF_PIN)) {
+		/* Allocate a new one */
+		if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL)
+			return (NULL);
+#ifdef PURIFY
+		memset(bp, 0xff, sizeof(BUFHEAD));
+#endif
+		if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) {
+			free(bp);
+			return (NULL);
+		}
+#ifdef PURIFY
+		memset(bp->page, 0xff, hashp->BSIZE);
+#endif
+		if (hashp->nbufs)
+			hashp->nbufs--;
+	} else {
+		/* Kick someone out */
+		BUF_REMOVE(bp);
+		/*
+		 * If this is an overflow page with addr 0, it's already been
+		 * flushed back in an overflow chain and initialized.
+		 */
+		if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) {
+			/*
+			 * Set oaddr before __put_page so that you get it
+			 * before bytes are swapped.
+			 */
+			shortp = (u_int16_t *)bp->page;
+			if (shortp[0])
+				oaddr = shortp[shortp[0] - 1];
+			if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page,
+			    bp->addr, (int)IS_BUCKET(bp->flags), 0))
+				return (NULL);
+			/*
+			 * Update the pointer to this page (i.e. invalidate it).
+			 *
+			 * If this is a new file (i.e. we created it at open
+			 * time), make sure that we mark pages which have been
+			 * written to disk so we retrieve them from disk later,
+			 * rather than allocating new pages.
+			 */
+			if (IS_BUCKET(bp->flags)) {
+				segment_ndx = bp->addr & (hashp->SGSIZE - 1);
+				segp = hashp->dir[bp->addr >> hashp->SSHIFT];
+#ifdef DEBUG
+				assert(segp != NULL);
+#endif
+
+				if (hashp->new_file &&
+				    ((bp->flags & BUF_MOD) ||
+				    ISDISK(segp[segment_ndx])))
+					segp[segment_ndx] = (BUFHEAD *)BUF_DISK;
+				else
+					segp[segment_ndx] = NULL;
+			}
+			/*
+			 * Since overflow pages can only be access by means of
+			 * their bucket, free overflow pages associated with
+			 * this bucket.
+			 */
+			for (xbp = bp; xbp->ovfl;) {
+				next_xbp = xbp->ovfl;
+				xbp->ovfl = 0;
+				xbp = next_xbp;
+
+				/* Check that ovfl pointer is up date. */
+				if (IS_BUCKET(xbp->flags) ||
+				    (oaddr != xbp->addr))
+					break;
+
+				shortp = (u_int16_t *)xbp->page;
+				if (shortp[0])
+					/* set before __put_page */
+					oaddr = shortp[shortp[0] - 1];
+				if ((xbp->flags & BUF_MOD) && __put_page(hashp,
+				    xbp->page, xbp->addr, 0, 0))
+					return (NULL);
+				xbp->addr = 0;
+				xbp->flags = 0;
+				BUF_REMOVE(xbp);
+				LRU_INSERT(xbp);
+			}
+		}
+	}
+
+	/* Now assign this buffer */
+	bp->addr = addr;
+#ifdef DEBUG1
+	(void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n",
+	    bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0);
+#endif
+	bp->ovfl = NULL;
+	if (prev_bp) {
+		/*
+		 * If prev_bp is set, this is an overflow page, hook it in to
+		 * the buffer overflow links.
+		 */
+#ifdef DEBUG1
+		(void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n",
+		    prev_bp->addr, (prev_bp->ovfl ? bp->ovfl->addr : 0),
+		    (bp ? bp->addr : 0));
+#endif
+		prev_bp->ovfl = bp;
+		bp->flags = 0;
+	} else
+		bp->flags = BUF_BUCKET;
+	MRU_INSERT(bp);
+	return (bp);
+}
+
+extern void
+__buf_init(hashp, nbytes)
+	HTAB *hashp;
+	int nbytes;
+{
+	BUFHEAD *bfp;
+	int npages;
+
+	bfp = &(hashp->bufhead);
+	npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT;
+	npages = MAX(npages, MIN_BUFFERS);
+
+	hashp->nbufs = npages;
+	bfp->next = bfp;
+	bfp->prev = bfp;
+	/*
+	 * This space is calloc'd so these are already null.
+	 *
+	 * bfp->ovfl = NULL;
+	 * bfp->flags = 0;
+	 * bfp->page = NULL;
+	 * bfp->addr = 0;
+	 */
+}
+
+extern int
+__buf_free(hashp, do_free, to_disk)
+	HTAB *hashp;
+	int do_free, to_disk;
+{
+	BUFHEAD *bp;
+
+	/* Need to make sure that buffer manager has been initialized */
+	if (!LRU)
+		return (0);
+	for (bp = LRU; bp != &hashp->bufhead;) {
+		/* Check that the buffer is valid */
+		if (bp->addr || IS_BUCKET(bp->flags)) {
+			if (to_disk && (bp->flags & BUF_MOD) &&
+			    __put_page(hashp, bp->page,
+			    bp->addr, IS_BUCKET(bp->flags), 0))
+				return (-1);
+		}
+		/* Check if we are freeing stuff */
+		if (do_free) {
+			if (bp->page)
+				free(bp->page);
+			BUF_REMOVE(bp);
+			free(bp);
+			bp = LRU;
+		} else
+			bp = bp->prev;
+	}
+	return (0);
+}
+
+extern void
+__reclaim_buf(hashp, bp)
+	HTAB *hashp;
+	BUFHEAD *bp;
+{
+	bp->ovfl = 0;
+	bp->addr = 0;
+	bp->flags = 0;
+	BUF_REMOVE(bp);
+	LRU_INSERT(bp);
+}
Index: /vendor/FreeBSD-libc/5.3/db/hash/hash_func.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/hash_func.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/hash_func.c	(revision 2404)
@@ -0,0 +1,214 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)hash_func.c	8.2 (Berkeley) 2/21/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/hash/hash_func.c,v 1.5 2003/02/16 17:29:09 nectar Exp $");
+
+#include <sys/types.h>
+
+#include <db.h>
+#include "hash.h"
+#include "page.h"
+#include "extern.h"
+
+static u_int32_t hash1(const void *, size_t) __unused;
+static u_int32_t hash2(const void *, size_t) __unused;
+static u_int32_t hash3(const void *, size_t) __unused;
+static u_int32_t hash4(const void *, size_t);
+
+/* Global default hash function */
+u_int32_t (*__default_hash)(const void *, size_t) = hash4;
+
+/*
+ * HASH FUNCTIONS
+ *
+ * Assume that we've already split the bucket to which this key hashes,
+ * calculate that bucket, and check that in fact we did already split it.
+ *
+ * This came from ejb's hsearch.
+ */
+
+#define PRIME1		37
+#define PRIME2		1048583
+
+static u_int32_t
+hash1(keyarg, len)
+	const void *keyarg;
+	size_t len;
+{
+	const u_char *key;
+	u_int32_t h;
+
+	/* Convert string to integer */
+	for (key = keyarg, h = 0; len--;)
+		h = h * PRIME1 ^ (*key++ - ' ');
+	h %= PRIME2;
+	return (h);
+}
+
+/*
+ * Phong's linear congruential hash
+ */
+#define dcharhash(h, c)	((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c))
+
+static u_int32_t
+hash2(keyarg, len)
+	const void *keyarg;
+	size_t len;
+{
+	const u_char *e, *key;
+	u_int32_t h;
+	u_char c;
+
+	key = keyarg;
+	e = key + len;
+	for (h = 0; key != e;) {
+		c = *key++;
+		if (!c && key > e)
+			break;
+		dcharhash(h, c);
+	}
+	return (h);
+}
+
+/*
+ * This is INCREDIBLY ugly, but fast.  We break the string up into 8 byte
+ * units.  On the first time through the loop we get the "leftover bytes"
+ * (strlen % 8).  On every other iteration, we perform 8 HASHC's so we handle
+ * all 8 bytes.  Essentially, this saves us 7 cmp & branch instructions.  If
+ * this routine is heavily used enough, it's worth the ugly coding.
+ *
+ * OZ's original sdbm hash
+ */
+static u_int32_t
+hash3(keyarg, len)
+	const void *keyarg;
+	size_t len;
+{
+	const u_char *key;
+	size_t loop;
+	u_int32_t h;
+
+#define HASHC   h = *key++ + 65599 * h
+
+	h = 0;
+	key = keyarg;
+	if (len > 0) {
+		loop = (len + 8 - 1) >> 3;
+
+		switch (len & (8 - 1)) {
+		case 0:
+			do {
+				HASHC;
+				/* FALLTHROUGH */
+		case 7:
+				HASHC;
+				/* FALLTHROUGH */
+		case 6:
+				HASHC;
+				/* FALLTHROUGH */
+		case 5:
+				HASHC;
+				/* FALLTHROUGH */
+		case 4:
+				HASHC;
+				/* FALLTHROUGH */
+		case 3:
+				HASHC;
+				/* FALLTHROUGH */
+		case 2:
+				HASHC;
+				/* FALLTHROUGH */
+		case 1:
+				HASHC;
+			} while (--loop);
+		}
+	}
+	return (h);
+}
+
+/* Hash function from Chris Torek. */
+static u_int32_t
+hash4(keyarg, len)
+	const void *keyarg;
+	size_t len;
+{
+	const u_char *key;
+	size_t loop;
+	u_int32_t h;
+
+#define HASH4a   h = (h << 5) - h + *key++;
+#define HASH4b   h = (h << 5) + h + *key++;
+#define HASH4 HASH4b
+
+	h = 0;
+	key = keyarg;
+	if (len > 0) {
+		loop = (len + 8 - 1) >> 3;
+
+		switch (len & (8 - 1)) {
+		case 0:
+			do {
+				HASH4;
+				/* FALLTHROUGH */
+		case 7:
+				HASH4;
+				/* FALLTHROUGH */
+		case 6:
+				HASH4;
+				/* FALLTHROUGH */
+		case 5:
+				HASH4;
+				/* FALLTHROUGH */
+		case 4:
+				HASH4;
+				/* FALLTHROUGH */
+		case 3:
+				HASH4;
+				/* FALLTHROUGH */
+		case 2:
+				HASH4;
+				/* FALLTHROUGH */
+		case 1:
+				HASH4;
+			} while (--loop);
+		}
+	}
+	return (h);
+}
Index: /vendor/FreeBSD-libc/5.3/db/hash/hash_log2.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/hash_log2.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/hash_log2.c	(revision 2404)
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)hash_log2.c	8.2 (Berkeley) 5/31/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/hash/hash_log2.c,v 1.2 2002/03/21 18:47:38 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <db.h>
+
+u_int32_t
+__log2(num)
+	u_int32_t num;
+{
+	u_int32_t i, limit;
+
+	limit = 1;
+	for (i = 0; limit < num; limit = limit << 1, i++);
+	return (i);
+}
Index: /vendor/FreeBSD-libc/5.3/db/hash/hash_page.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/hash_page.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/hash_page.c	(revision 2404)
@@ -0,0 +1,948 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)hash_page.c	8.7 (Berkeley) 8/16/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/hash/hash_page.c,v 1.8 2002/03/21 22:46:26 obrien Exp $");
+
+/*
+ * PACKAGE:  hashing
+ *
+ * DESCRIPTION:
+ *	Page manipulation for hashing package.
+ *
+ * ROUTINES:
+ *
+ * External
+ *	__get_page
+ *	__add_ovflpage
+ * Internal
+ *	overflow_page
+ *	open_temp
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#ifdef DEBUG
+#include <assert.h>
+#endif
+#include "un-namespace.h"
+
+#include <db.h>
+#include "hash.h"
+#include "page.h"
+#include "extern.h"
+
+static u_int32_t	*fetch_bitmap(HTAB *, int);
+static u_int32_t	 first_free(u_int32_t);
+static int	 open_temp(HTAB *);
+static u_int16_t	 overflow_page(HTAB *);
+static void	 putpair(char *, const DBT *, const DBT *);
+static void	 squeeze_key(u_int16_t *, const DBT *, const DBT *);
+static int	 ugly_split
+(HTAB *, u_int32_t, BUFHEAD *, BUFHEAD *, int, int);
+
+#define	PAGE_INIT(P) { \
+	((u_int16_t *)(P))[0] = 0; \
+	((u_int16_t *)(P))[1] = hashp->BSIZE - 3 * sizeof(u_int16_t); \
+	((u_int16_t *)(P))[2] = hashp->BSIZE; \
+}
+
+/*
+ * This is called AFTER we have verified that there is room on the page for
+ * the pair (PAIRFITS has returned true) so we go right ahead and start moving
+ * stuff on.
+ */
+static void
+putpair(p, key, val)
+	char *p;
+	const DBT *key, *val;
+{
+	u_int16_t *bp, n, off;
+
+	bp = (u_int16_t *)p;
+
+	/* Enter the key first. */
+	n = bp[0];
+
+	off = OFFSET(bp) - key->size;
+	memmove(p + off, key->data, key->size);
+	bp[++n] = off;
+
+	/* Now the data. */
+	off -= val->size;
+	memmove(p + off, val->data, val->size);
+	bp[++n] = off;
+
+	/* Adjust page info. */
+	bp[0] = n;
+	bp[n + 1] = off - ((n + 3) * sizeof(u_int16_t));
+	bp[n + 2] = off;
+}
+
+/*
+ * Returns:
+ *	 0 OK
+ *	-1 error
+ */
+extern int
+__delpair(hashp, bufp, ndx)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+	int ndx;
+{
+	u_int16_t *bp, newoff;
+	int n;
+	u_int16_t pairlen;
+
+	bp = (u_int16_t *)bufp->page;
+	n = bp[0];
+
+	if (bp[ndx + 1] < REAL_KEY)
+		return (__big_delete(hashp, bufp));
+	if (ndx != 1)
+		newoff = bp[ndx - 1];
+	else
+		newoff = hashp->BSIZE;
+	pairlen = newoff - bp[ndx + 1];
+
+	if (ndx != (n - 1)) {
+		/* Hard Case -- need to shuffle keys */
+		int i;
+		char *src = bufp->page + (int)OFFSET(bp);
+		char *dst = src + (int)pairlen;
+		memmove(dst, src, bp[ndx + 1] - OFFSET(bp));
+
+		/* Now adjust the pointers */
+		for (i = ndx + 2; i <= n; i += 2) {
+			if (bp[i + 1] == OVFLPAGE) {
+				bp[i - 2] = bp[i];
+				bp[i - 1] = bp[i + 1];
+			} else {
+				bp[i - 2] = bp[i] + pairlen;
+				bp[i - 1] = bp[i + 1] + pairlen;
+			}
+		}
+	}
+	/* Finally adjust the page data */
+	bp[n] = OFFSET(bp) + pairlen;
+	bp[n - 1] = bp[n + 1] + pairlen + 2 * sizeof(u_int16_t);
+	bp[0] = n - 2;
+	hashp->NKEYS--;
+
+	bufp->flags |= BUF_MOD;
+	return (0);
+}
+/*
+ * Returns:
+ *	 0 ==> OK
+ *	-1 ==> Error
+ */
+extern int
+__split_page(hashp, obucket, nbucket)
+	HTAB *hashp;
+	u_int32_t obucket, nbucket;
+{
+	BUFHEAD *new_bufp, *old_bufp;
+	u_int16_t *ino;
+	char *np;
+	DBT key, val;
+	int n, ndx, retval;
+	u_int16_t copyto, diff, off, moved;
+	char *op;
+
+	copyto = (u_int16_t)hashp->BSIZE;
+	off = (u_int16_t)hashp->BSIZE;
+	old_bufp = __get_buf(hashp, obucket, NULL, 0);
+	if (old_bufp == NULL)
+		return (-1);
+	new_bufp = __get_buf(hashp, nbucket, NULL, 0);
+	if (new_bufp == NULL)
+		return (-1);
+
+	old_bufp->flags |= (BUF_MOD | BUF_PIN);
+	new_bufp->flags |= (BUF_MOD | BUF_PIN);
+
+	ino = (u_int16_t *)(op = old_bufp->page);
+	np = new_bufp->page;
+
+	moved = 0;
+
+	for (n = 1, ndx = 1; n < ino[0]; n += 2) {
+		if (ino[n + 1] < REAL_KEY) {
+			retval = ugly_split(hashp, obucket, old_bufp, new_bufp,
+			    (int)copyto, (int)moved);
+			old_bufp->flags &= ~BUF_PIN;
+			new_bufp->flags &= ~BUF_PIN;
+			return (retval);
+
+		}
+		key.data = (u_char *)op + ino[n];
+		key.size = off - ino[n];
+
+		if (__call_hash(hashp, key.data, key.size) == obucket) {
+			/* Don't switch page */
+			diff = copyto - off;
+			if (diff) {
+				copyto = ino[n + 1] + diff;
+				memmove(op + copyto, op + ino[n + 1],
+				    off - ino[n + 1]);
+				ino[ndx] = copyto + ino[n] - ino[n + 1];
+				ino[ndx + 1] = copyto;
+			} else
+				copyto = ino[n + 1];
+			ndx += 2;
+		} else {
+			/* Switch page */
+			val.data = (u_char *)op + ino[n + 1];
+			val.size = ino[n] - ino[n + 1];
+			putpair(np, &key, &val);
+			moved += 2;
+		}
+
+		off = ino[n + 1];
+	}
+
+	/* Now clean up the page */
+	ino[0] -= moved;
+	FREESPACE(ino) = copyto - sizeof(u_int16_t) * (ino[0] + 3);
+	OFFSET(ino) = copyto;
+
+#ifdef DEBUG3
+	(void)fprintf(stderr, "split %d/%d\n",
+	    ((u_int16_t *)np)[0] / 2,
+	    ((u_int16_t *)op)[0] / 2);
+#endif
+	/* unpin both pages */
+	old_bufp->flags &= ~BUF_PIN;
+	new_bufp->flags &= ~BUF_PIN;
+	return (0);
+}
+
+/*
+ * Called when we encounter an overflow or big key/data page during split
+ * handling.  This is special cased since we have to begin checking whether
+ * the key/data pairs fit on their respective pages and because we may need
+ * overflow pages for both the old and new pages.
+ *
+ * The first page might be a page with regular key/data pairs in which case
+ * we have a regular overflow condition and just need to go on to the next
+ * page or it might be a big key/data pair in which case we need to fix the
+ * big key/data pair.
+ *
+ * Returns:
+ *	 0 ==> success
+ *	-1 ==> failure
+ */
+static int
+ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved)
+	HTAB *hashp;
+	u_int32_t obucket;	/* Same as __split_page. */
+	BUFHEAD *old_bufp, *new_bufp;
+	int copyto;	/* First byte on page which contains key/data values. */
+	int moved;		/* Number of pairs moved to new page. */
+{
+	BUFHEAD *bufp;		/* Buffer header for ino */
+	u_int16_t *ino;		/* Page keys come off of */
+	u_int16_t *np;		/* New page */
+	u_int16_t *op;		/* Page keys go on to if they aren't moving */
+
+	BUFHEAD *last_bfp;	/* Last buf header OVFL needing to be freed */
+	DBT key, val;
+	SPLIT_RETURN ret;
+	u_int16_t n, off, ov_addr, scopyto;
+	char *cino;		/* Character value of ino */
+
+	bufp = old_bufp;
+	ino = (u_int16_t *)old_bufp->page;
+	np = (u_int16_t *)new_bufp->page;
+	op = (u_int16_t *)old_bufp->page;
+	last_bfp = NULL;
+	scopyto = (u_int16_t)copyto;	/* ANSI */
+
+	n = ino[0] - 1;
+	while (n < ino[0]) {
+		if (ino[2] < REAL_KEY && ino[2] != OVFLPAGE) {
+			if (__big_split(hashp, old_bufp,
+			    new_bufp, bufp, bufp->addr, obucket, &ret))
+				return (-1);
+			old_bufp = ret.oldp;
+			if (!old_bufp)
+				return (-1);
+			op = (u_int16_t *)old_bufp->page;
+			new_bufp = ret.newp;
+			if (!new_bufp)
+				return (-1);
+			np = (u_int16_t *)new_bufp->page;
+			bufp = ret.nextp;
+			if (!bufp)
+				return (0);
+			cino = (char *)bufp->page;
+			ino = (u_int16_t *)cino;
+			last_bfp = ret.nextp;
+		} else if (ino[n + 1] == OVFLPAGE) {
+			ov_addr = ino[n];
+			/*
+			 * Fix up the old page -- the extra 2 are the fields
+			 * which contained the overflow information.
+			 */
+			ino[0] -= (moved + 2);
+			FREESPACE(ino) =
+			    scopyto - sizeof(u_int16_t) * (ino[0] + 3);
+			OFFSET(ino) = scopyto;
+
+			bufp = __get_buf(hashp, ov_addr, bufp, 0);
+			if (!bufp)
+				return (-1);
+
+			ino = (u_int16_t *)bufp->page;
+			n = 1;
+			scopyto = hashp->BSIZE;
+			moved = 0;
+
+			if (last_bfp)
+				__free_ovflpage(hashp, last_bfp);
+			last_bfp = bufp;
+		}
+		/* Move regular sized pairs of there are any */
+		off = hashp->BSIZE;
+		for (n = 1; (n < ino[0]) && (ino[n + 1] >= REAL_KEY); n += 2) {
+			cino = (char *)ino;
+			key.data = (u_char *)cino + ino[n];
+			key.size = off - ino[n];
+			val.data = (u_char *)cino + ino[n + 1];
+			val.size = ino[n] - ino[n + 1];
+			off = ino[n + 1];
+
+			if (__call_hash(hashp, key.data, key.size) == obucket) {
+				/* Keep on old page */
+				if (PAIRFITS(op, (&key), (&val)))
+					putpair((char *)op, &key, &val);
+				else {
+					old_bufp =
+					    __add_ovflpage(hashp, old_bufp);
+					if (!old_bufp)
+						return (-1);
+					op = (u_int16_t *)old_bufp->page;
+					putpair((char *)op, &key, &val);
+				}
+				old_bufp->flags |= BUF_MOD;
+			} else {
+				/* Move to new page */
+				if (PAIRFITS(np, (&key), (&val)))
+					putpair((char *)np, &key, &val);
+				else {
+					new_bufp =
+					    __add_ovflpage(hashp, new_bufp);
+					if (!new_bufp)
+						return (-1);
+					np = (u_int16_t *)new_bufp->page;
+					putpair((char *)np, &key, &val);
+				}
+				new_bufp->flags |= BUF_MOD;
+			}
+		}
+	}
+	if (last_bfp)
+		__free_ovflpage(hashp, last_bfp);
+	return (0);
+}
+
+/*
+ * Add the given pair to the page
+ *
+ * Returns:
+ *	0 ==> OK
+ *	1 ==> failure
+ */
+extern int
+__addel(hashp, bufp, key, val)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+	const DBT *key, *val;
+{
+	u_int16_t *bp, *sop;
+	int do_expand;
+
+	bp = (u_int16_t *)bufp->page;
+	do_expand = 0;
+	while (bp[0] && (bp[2] < REAL_KEY || bp[bp[0]] < REAL_KEY))
+		/* Exception case */
+		if (bp[2] == FULL_KEY_DATA && bp[0] == 2)
+			/* This is the last page of a big key/data pair
+			   and we need to add another page */
+			break;
+		else if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) {
+			bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
+			if (!bufp)
+				return (-1);
+			bp = (u_int16_t *)bufp->page;
+		} else
+			/* Try to squeeze key on this page */
+			if (FREESPACE(bp) > PAIRSIZE(key, val)) {
+				squeeze_key(bp, key, val);
+				return (0);
+			} else {
+				bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
+				if (!bufp)
+					return (-1);
+				bp = (u_int16_t *)bufp->page;
+			}
+
+	if (PAIRFITS(bp, key, val))
+		putpair(bufp->page, key, val);
+	else {
+		do_expand = 1;
+		bufp = __add_ovflpage(hashp, bufp);
+		if (!bufp)
+			return (-1);
+		sop = (u_int16_t *)bufp->page;
+
+		if (PAIRFITS(sop, key, val))
+			putpair((char *)sop, key, val);
+		else
+			if (__big_insert(hashp, bufp, key, val))
+				return (-1);
+	}
+	bufp->flags |= BUF_MOD;
+	/*
+	 * If the average number of keys per bucket exceeds the fill factor,
+	 * expand the table.
+	 */
+	hashp->NKEYS++;
+	if (do_expand ||
+	    (hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR))
+		return (__expand_table(hashp));
+	return (0);
+}
+
+/*
+ *
+ * Returns:
+ *	pointer on success
+ *	NULL on error
+ */
+extern BUFHEAD *
+__add_ovflpage(hashp, bufp)
+	HTAB *hashp;
+	BUFHEAD *bufp;
+{
+	u_int16_t *sp;
+	u_int16_t ndx, ovfl_num;
+#ifdef DEBUG1
+	int tmp1, tmp2;
+#endif
+	sp = (u_int16_t *)bufp->page;
+
+	/* Check if we are dynamically determining the fill factor */
+	if (hashp->FFACTOR == DEF_FFACTOR) {
+		hashp->FFACTOR = sp[0] >> 1;
+		if (hashp->FFACTOR < MIN_FFACTOR)
+			hashp->FFACTOR = MIN_FFACTOR;
+	}
+	bufp->flags |= BUF_MOD;
+	ovfl_num = overflow_page(hashp);
+#ifdef DEBUG1
+	tmp1 = bufp->addr;
+	tmp2 = bufp->ovfl ? bufp->ovfl->addr : 0;
+#endif
+	if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, ovfl_num, bufp, 1)))
+		return (NULL);
+	bufp->ovfl->flags |= BUF_MOD;
+#ifdef DEBUG1
+	(void)fprintf(stderr, "ADDOVFLPAGE: %d->ovfl was %d is now %d\n",
+	    tmp1, tmp2, bufp->ovfl->addr);
+#endif
+	ndx = sp[0];
+	/*
+	 * Since a pair is allocated on a page only if there's room to add
+	 * an overflow page, we know that the OVFL information will fit on
+	 * the page.
+	 */
+	sp[ndx + 4] = OFFSET(sp);
+	sp[ndx + 3] = FREESPACE(sp) - OVFLSIZE;
+	sp[ndx + 1] = ovfl_num;
+	sp[ndx + 2] = OVFLPAGE;
+	sp[0] = ndx + 2;
+#ifdef HASH_STATISTICS
+	hash_overflows++;
+#endif
+	return (bufp->ovfl);
+}
+
+/*
+ * Returns:
+ *	 0 indicates SUCCESS
+ *	-1 indicates FAILURE
+ */
+extern int
+__get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap)
+	HTAB *hashp;
+	char *p;
+	u_int32_t bucket;
+	int is_bucket, is_disk, is_bitmap;
+{
+	int fd, page, size;
+	int rsize;
+	u_int16_t *bp;
+
+	fd = hashp->fp;
+	size = hashp->BSIZE;
+
+	if ((fd == -1) || !is_disk) {
+		PAGE_INIT(p);
+		return (0);
+	}
+	if (is_bucket)
+		page = BUCKET_TO_PAGE(bucket);
+	else
+		page = OADDR_TO_PAGE(bucket);
+	if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) ||
+	    ((rsize = _read(fd, p, size)) == -1))
+		return (-1);
+	bp = (u_int16_t *)p;
+	if (!rsize)
+		bp[0] = 0;	/* We hit the EOF, so initialize a new page */
+	else
+		if (rsize != size) {
+			errno = EFTYPE;
+			return (-1);
+		}
+	if (!is_bitmap && !bp[0]) {
+		PAGE_INIT(p);
+	} else
+		if (hashp->LORDER != BYTE_ORDER) {
+			int i, max;
+
+			if (is_bitmap) {
+				max = hashp->BSIZE >> 2; /* divide by 4 */
+				for (i = 0; i < max; i++)
+					M_32_SWAP(((int *)p)[i]);
+			} else {
+				M_16_SWAP(bp[0]);
+				max = bp[0] + 2;
+				for (i = 1; i <= max; i++)
+					M_16_SWAP(bp[i]);
+			}
+		}
+	return (0);
+}
+
+/*
+ * Write page p to disk
+ *
+ * Returns:
+ *	 0 ==> OK
+ *	-1 ==>failure
+ */
+extern int
+__put_page(hashp, p, bucket, is_bucket, is_bitmap)
+	HTAB *hashp;
+	char *p;
+	u_int32_t bucket;
+	int is_bucket, is_bitmap;
+{
+	int fd, page, size;
+	int wsize;
+
+	size = hashp->BSIZE;
+	if ((hashp->fp == -1) && open_temp(hashp))
+		return (-1);
+	fd = hashp->fp;
+
+	if (hashp->LORDER != BYTE_ORDER) {
+		int i;
+		int max;
+
+		if (is_bitmap) {
+			max = hashp->BSIZE >> 2;	/* divide by 4 */
+			for (i = 0; i < max; i++)
+				M_32_SWAP(((int *)p)[i]);
+		} else {
+			max = ((u_int16_t *)p)[0] + 2;
+			for (i = 0; i <= max; i++)
+				M_16_SWAP(((u_int16_t *)p)[i]);
+		}
+	}
+	if (is_bucket)
+		page = BUCKET_TO_PAGE(bucket);
+	else
+		page = OADDR_TO_PAGE(bucket);
+	if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) ||
+	    ((wsize = _write(fd, p, size)) == -1))
+		/* Errno is set */
+		return (-1);
+	if (wsize != size) {
+		errno = EFTYPE;
+		return (-1);
+	}
+	return (0);
+}
+
+#define BYTE_MASK	((1 << INT_BYTE_SHIFT) -1)
+/*
+ * Initialize a new bitmap page.  Bitmap pages are left in memory
+ * once they are read in.
+ */
+extern int
+__ibitmap(hashp, pnum, nbits, ndx)
+	HTAB *hashp;
+	int pnum, nbits, ndx;
+{
+	u_int32_t *ip;
+	int clearbytes, clearints;
+
+	if ((ip = (u_int32_t *)malloc(hashp->BSIZE)) == NULL)
+		return (1);
+	hashp->nmaps++;
+	clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1;
+	clearbytes = clearints << INT_TO_BYTE;
+	(void)memset((char *)ip, 0, clearbytes);
+	(void)memset(((char *)ip) + clearbytes, 0xFF,
+	    hashp->BSIZE - clearbytes);
+	ip[clearints - 1] = ALL_SET << (nbits & BYTE_MASK);
+	SETBIT(ip, 0);
+	hashp->BITMAPS[ndx] = (u_int16_t)pnum;
+	hashp->mapp[ndx] = ip;
+	return (0);
+}
+
+static u_int32_t
+first_free(map)
+	u_int32_t map;
+{
+	u_int32_t i, mask;
+
+	mask = 0x1;
+	for (i = 0; i < BITS_PER_MAP; i++) {
+		if (!(mask & map))
+			return (i);
+		mask = mask << 1;
+	}
+	return (i);
+}
+
+static u_int16_t
+overflow_page(hashp)
+	HTAB *hashp;
+{
+	u_int32_t *freep;
+	int max_free, offset, splitnum;
+	u_int16_t addr;
+	int bit, first_page, free_bit, free_page, i, in_use_bits, j;
+#ifdef DEBUG2
+	int tmp1, tmp2;
+#endif
+	splitnum = hashp->OVFL_POINT;
+	max_free = hashp->SPARES[splitnum];
+
+	free_page = (max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT);
+	free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1);
+
+	/* Look through all the free maps to find the first free block */
+	first_page = hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT);
+	for ( i = first_page; i <= free_page; i++ ) {
+		if (!(freep = (u_int32_t *)hashp->mapp[i]) &&
+		    !(freep = fetch_bitmap(hashp, i)))
+			return (0);
+		if (i == free_page)
+			in_use_bits = free_bit;
+		else
+			in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1;
+
+		if (i == first_page) {
+			bit = hashp->LAST_FREED &
+			    ((hashp->BSIZE << BYTE_SHIFT) - 1);
+			j = bit / BITS_PER_MAP;
+			bit = bit & ~(BITS_PER_MAP - 1);
+		} else {
+			bit = 0;
+			j = 0;
+		}
+		for (; bit <= in_use_bits; j++, bit += BITS_PER_MAP)
+			if (freep[j] != ALL_SET)
+				goto found;
+	}
+
+	/* No Free Page Found */
+	hashp->LAST_FREED = hashp->SPARES[splitnum];
+	hashp->SPARES[splitnum]++;
+	offset = hashp->SPARES[splitnum] -
+	    (splitnum ? hashp->SPARES[splitnum - 1] : 0);
+
+#define	OVMSG	"HASH: Out of overflow pages.  Increase page size\n"
+	if (offset > SPLITMASK) {
+		if (++splitnum >= NCACHED) {
+			(void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1);
+			return (0);
+		}
+		hashp->OVFL_POINT = splitnum;
+		hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1];
+		hashp->SPARES[splitnum-1]--;
+		offset = 1;
+	}
+
+	/* Check if we need to allocate a new bitmap page */
+	if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) {
+		free_page++;
+		if (free_page >= NCACHED) {
+			(void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1);
+			return (0);
+		}
+		/*
+		 * This is tricky.  The 1 indicates that you want the new page
+		 * allocated with 1 clear bit.  Actually, you are going to
+		 * allocate 2 pages from this map.  The first is going to be
+		 * the map page, the second is the overflow page we were
+		 * looking for.  The init_bitmap routine automatically, sets
+		 * the first bit of itself to indicate that the bitmap itself
+		 * is in use.  We would explicitly set the second bit, but
+		 * don't have to if we tell init_bitmap not to leave it clear
+		 * in the first place.
+		 */
+		if (__ibitmap(hashp,
+		    (int)OADDR_OF(splitnum, offset), 1, free_page))
+			return (0);
+		hashp->SPARES[splitnum]++;
+#ifdef DEBUG2
+		free_bit = 2;
+#endif
+		offset++;
+		if (offset > SPLITMASK) {
+			if (++splitnum >= NCACHED) {
+				(void)_write(STDERR_FILENO, OVMSG,
+				    sizeof(OVMSG) - 1);
+				return (0);
+			}
+			hashp->OVFL_POINT = splitnum;
+			hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1];
+			hashp->SPARES[splitnum-1]--;
+			offset = 0;
+		}
+	} else {
+		/*
+		 * Free_bit addresses the last used bit.  Bump it to address
+		 * the first available bit.
+		 */
+		free_bit++;
+		SETBIT(freep, free_bit);
+	}
+
+	/* Calculate address of the new overflow page */
+	addr = OADDR_OF(splitnum, offset);
+#ifdef DEBUG2
+	(void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n",
+	    addr, free_bit, free_page);
+#endif
+	return (addr);
+
+found:
+	bit = bit + first_free(freep[j]);
+	SETBIT(freep, bit);
+#ifdef DEBUG2
+	tmp1 = bit;
+	tmp2 = i;
+#endif
+	/*
+	 * Bits are addressed starting with 0, but overflow pages are addressed
+	 * beginning at 1. Bit is a bit addressnumber, so we need to increment
+	 * it to convert it to a page number.
+	 */
+	bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT));
+	if (bit >= hashp->LAST_FREED)
+		hashp->LAST_FREED = bit - 1;
+
+	/* Calculate the split number for this page */
+	for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++);
+	offset = (i ? bit - hashp->SPARES[i - 1] : bit);
+	if (offset >= SPLITMASK)
+		return (0);	/* Out of overflow pages */
+	addr = OADDR_OF(i, offset);
+#ifdef DEBUG2
+	(void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n",
+	    addr, tmp1, tmp2);
+#endif
+
+	/* Allocate and return the overflow page */
+	return (addr);
+}
+
+/*
+ * Mark this overflow page as free.
+ */
+extern void
+__free_ovflpage(hashp, obufp)
+	HTAB *hashp;
+	BUFHEAD *obufp;
+{
+	u_int16_t addr;
+	u_int32_t *freep;
+	int bit_address, free_page, free_bit;
+	u_int16_t ndx;
+
+	addr = obufp->addr;
+#ifdef DEBUG1
+	(void)fprintf(stderr, "Freeing %d\n", addr);
+#endif
+	ndx = (((u_int16_t)addr) >> SPLITSHIFT);
+	bit_address =
+	    (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1;
+	 if (bit_address < hashp->LAST_FREED)
+		hashp->LAST_FREED = bit_address;
+	free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT));
+	free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1);
+
+	if (!(freep = hashp->mapp[free_page]))
+		freep = fetch_bitmap(hashp, free_page);
+#ifdef DEBUG
+	/*
+	 * This had better never happen.  It means we tried to read a bitmap
+	 * that has already had overflow pages allocated off it, and we
+	 * failed to read it from the file.
+	 */
+	if (!freep)
+		assert(0);
+#endif
+	CLRBIT(freep, free_bit);
+#ifdef DEBUG2
+	(void)fprintf(stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n",
+	    obufp->addr, free_bit, free_page);
+#endif
+	__reclaim_buf(hashp, obufp);
+}
+
+/*
+ * Returns:
+ *	 0 success
+ *	-1 failure
+ */
+static int
+open_temp(hashp)
+	HTAB *hashp;
+{
+	sigset_t set, oset;
+	static char namestr[] = "_hashXXXXXX";
+
+	/* Block signals; make sure file goes away at process exit. */
+	(void)sigfillset(&set);
+	(void)_sigprocmask(SIG_BLOCK, &set, &oset);
+	if ((hashp->fp = mkstemp(namestr)) != -1) {
+		(void)unlink(namestr);
+		(void)_fcntl(hashp->fp, F_SETFD, 1);
+	}
+	(void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
+	return (hashp->fp != -1 ? 0 : -1);
+}
+
+/*
+ * We have to know that the key will fit, but the last entry on the page is
+ * an overflow pair, so we need to shift things.
+ */
+static void
+squeeze_key(sp, key, val)
+	u_int16_t *sp;
+	const DBT *key, *val;
+{
+	char *p;
+	u_int16_t free_space, n, off, pageno;
+
+	p = (char *)sp;
+	n = sp[0];
+	free_space = FREESPACE(sp);
+	off = OFFSET(sp);
+
+	pageno = sp[n - 1];
+	off -= key->size;
+	sp[n - 1] = off;
+	memmove(p + off, key->data, key->size);
+	off -= val->size;
+	sp[n] = off;
+	memmove(p + off, val->data, val->size);
+	sp[0] = n + 2;
+	sp[n + 1] = pageno;
+	sp[n + 2] = OVFLPAGE;
+	FREESPACE(sp) = free_space - PAIRSIZE(key, val);
+	OFFSET(sp) = off;
+}
+
+static u_int32_t *
+fetch_bitmap(hashp, ndx)
+	HTAB *hashp;
+	int ndx;
+{
+	if (ndx >= hashp->nmaps)
+		return (NULL);
+	if ((hashp->mapp[ndx] = (u_int32_t *)malloc(hashp->BSIZE)) == NULL)
+		return (NULL);
+	if (__get_page(hashp,
+	    (char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) {
+		free(hashp->mapp[ndx]);
+		return (NULL);
+	}
+	return (hashp->mapp[ndx]);
+}
+
+#ifdef DEBUG4
+int
+print_chain(addr)
+	int addr;
+{
+	BUFHEAD *bufp;
+	short *bp, oaddr;
+
+	(void)fprintf(stderr, "%d ", addr);
+	bufp = __get_buf(hashp, addr, NULL, 0);
+	bp = (short *)bufp->page;
+	while (bp[0] && ((bp[bp[0]] == OVFLPAGE) ||
+		((bp[0] > 2) && bp[2] < REAL_KEY))) {
+		oaddr = bp[bp[0] - 1];
+		(void)fprintf(stderr, "%d ", (int)oaddr);
+		bufp = __get_buf(hashp, (int)oaddr, bufp, 0);
+		bp = (short *)bufp->page;
+	}
+	(void)fprintf(stderr, "\n");
+}
+#endif
Index: /vendor/FreeBSD-libc/5.3/db/hash/ndbm.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/ndbm.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/ndbm.c	(revision 2404)
@@ -0,0 +1,231 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ndbm.c	8.4 (Berkeley) 7/21/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/hash/ndbm.c,v 1.6 2002/03/22 21:52:01 obrien Exp $");
+
+/*
+ * This package provides a dbm compatible interface to the new hashing
+ * package described in db(3).
+ */
+
+#include <sys/param.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <ndbm.h>
+#include "hash.h"
+
+/*
+ * Returns:
+ * 	*DBM on success
+ *	 NULL on failure
+ */
+extern DBM *
+dbm_open(file, flags, mode)
+	const char *file;
+	int flags, mode;
+{
+	HASHINFO info;
+	char path[MAXPATHLEN];
+
+	info.bsize = 4096;
+	info.ffactor = 40;
+	info.nelem = 1;
+	info.cachesize = 0;
+	info.hash = NULL;
+	info.lorder = 0;
+
+	if( strlen(file) >= sizeof(path) - strlen(DBM_SUFFIX)) {
+		errno = ENAMETOOLONG;
+		return(NULL);
+	}
+	(void)strcpy(path, file);
+	(void)strcat(path, DBM_SUFFIX);
+	return ((DBM *)__hash_open(path, flags, mode, &info, 0));
+}
+
+extern void
+dbm_close(db)
+	DBM *db;
+{
+	(void)(db->close)(db);
+}
+
+/*
+ * Returns:
+ *	DATUM on success
+ *	NULL on failure
+ */
+extern datum
+dbm_fetch(db, key)
+	DBM *db;
+	datum key;
+{
+	datum retdata;
+	int status;
+	DBT dbtkey, dbtretdata;
+
+	dbtkey.data = key.dptr;
+	dbtkey.size = key.dsize;
+	status = (db->get)(db, &dbtkey, &dbtretdata, 0);
+	if (status) {
+		dbtretdata.data = NULL;
+		dbtretdata.size = 0;
+	}
+	retdata.dptr = dbtretdata.data;
+	retdata.dsize = dbtretdata.size;
+	return (retdata);
+}
+
+/*
+ * Returns:
+ *	DATUM on success
+ *	NULL on failure
+ */
+extern datum
+dbm_firstkey(db)
+	DBM *db;
+{
+	int status;
+	datum retkey;
+	DBT dbtretkey, dbtretdata;
+
+	status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST);
+	if (status)
+		dbtretkey.data = NULL;
+	retkey.dptr = dbtretkey.data;
+	retkey.dsize = dbtretkey.size;
+	return (retkey);
+}
+
+/*
+ * Returns:
+ *	DATUM on success
+ *	NULL on failure
+ */
+extern datum
+dbm_nextkey(db)
+	DBM *db;
+{
+	int status;
+	datum retkey;
+	DBT dbtretkey, dbtretdata;
+
+	status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
+	if (status)
+		dbtretkey.data = NULL;
+	retkey.dptr = dbtretkey.data;
+	retkey.dsize = dbtretkey.size;
+	return (retkey);
+}
+
+/*
+ * Returns:
+ *	 0 on success
+ *	<0 failure
+ */
+extern int
+dbm_delete(db, key)
+	DBM *db;
+	datum key;
+{
+	int status;
+	DBT dbtkey;
+
+	dbtkey.data = key.dptr;
+	dbtkey.size = key.dsize;
+	status = (db->del)(db, &dbtkey, 0);
+	if (status)
+		return (-1);
+	else
+		return (0);
+}
+
+/*
+ * Returns:
+ *	 0 on success
+ *	<0 failure
+ *	 1 if DBM_INSERT and entry exists
+ */
+extern int
+dbm_store(db, key, data, flags)
+	DBM *db;
+	datum key, data;
+	int flags;
+{
+	DBT dbtkey, dbtdata;
+
+	dbtkey.data = key.dptr;
+	dbtkey.size = key.dsize;
+	dbtdata.data = data.dptr;
+	dbtdata.size = data.dsize;
+	return ((db->put)(db, &dbtkey, &dbtdata,
+	    (flags == DBM_INSERT) ? R_NOOVERWRITE : 0));
+}
+
+extern int
+dbm_error(db)
+	DBM *db;
+{
+	HTAB *hp;
+
+	hp = (HTAB *)db->internal;
+	return (hp->error);
+}
+
+extern int
+dbm_clearerr(db)
+	DBM *db;
+{
+	HTAB *hp;
+
+	hp = (HTAB *)db->internal;
+	hp->error = 0;
+	return (0);
+}
+
+extern int
+dbm_dirfno(db)
+	DBM *db;
+{
+	return(((HTAB *)db->internal)->fp);
+}
Index: /vendor/FreeBSD-libc/5.3/db/hash/page.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/hash/page.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/hash/page.h	(revision 2404)
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ *
+ *	@(#)page.h	8.2 (Berkeley) 5/31/94
+ * $FreeBSD: src/lib/libc/db/hash/page.h,v 1.2 2002/03/22 23:41:40 obrien Exp $
+ */
+
+/*
+ * Definitions for hashing page file format.
+ */
+
+/*
+ * routines dealing with a data page
+ *
+ * page format:
+ *	+------------------------------+
+ * p	| n | keyoff | datoff | keyoff |
+ * 	+------------+--------+--------+
+ *	| datoff | free  |  ptr  | --> |
+ *	+--------+---------------------+
+ *	|	 F R E E A R E A       |
+ *	+--------------+---------------+
+ *	|  <---- - - - | data          |
+ *	+--------+-----+----+----------+
+ *	|  key   | data     | key      |
+ *	+--------+----------+----------+
+ *
+ * Pointer to the free space is always:  p[p[0] + 2]
+ * Amount of free space on the page is:  p[p[0] + 1]
+ */
+
+/*
+ * How many bytes required for this pair?
+ *	2 shorts in the table at the top of the page + room for the
+ *	key and room for the data
+ *
+ * We prohibit entering a pair on a page unless there is also room to append
+ * an overflow page. The reason for this it that you can get in a situation
+ * where a single key/data pair fits on a page, but you can't append an
+ * overflow page and later you'd have to split the key/data and handle like
+ * a big pair.
+ * You might as well do this up front.
+ */
+
+#define	PAIRSIZE(K,D)	(2*sizeof(u_int16_t) + (K)->size + (D)->size)
+#define BIGOVERHEAD	(4*sizeof(u_int16_t))
+#define KEYSIZE(K)	(4*sizeof(u_int16_t) + (K)->size);
+#define OVFLSIZE	(2*sizeof(u_int16_t))
+#define FREESPACE(P)	((P)[(P)[0]+1])
+#define	OFFSET(P)	((P)[(P)[0]+2])
+#define PAIRFITS(P,K,D) \
+	(((P)[2] >= REAL_KEY) && \
+	    (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P)))
+#define PAGE_META(N)	(((N)+3) * sizeof(u_int16_t))
+
+typedef struct {
+	BUFHEAD *newp;
+	BUFHEAD *oldp;
+	BUFHEAD *nextp;
+	u_int16_t next_addr;
+}       SPLIT_RETURN;
Index: /vendor/FreeBSD-libc/5.3/db/mpool/README
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/mpool/README	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/mpool/README	(revision 2404)
@@ -0,0 +1,7 @@
+#	@(#)README	8.1 (Berkeley) 6/4/93
+
+These are the current memory pool routines.
+They aren't ready for prime time, yet, and
+the interface is expected to change.
+
+--keith
Index: /vendor/FreeBSD-libc/5.3/db/mpool/mpool.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/mpool/mpool.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/mpool/mpool.c	(revision 2404)
@@ -0,0 +1,462 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)mpool.c	8.5 (Berkeley) 7/26/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/mpool/mpool.c,v 1.11 2004/01/20 00:40:35 das Exp $");
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+#include <db.h>
+
+#define	__MPOOLINTERFACE_PRIVATE
+#include <mpool.h>
+
+static BKT *mpool_bkt(MPOOL *);
+static BKT *mpool_look(MPOOL *, pgno_t);
+static int  mpool_write(MPOOL *, BKT *);
+
+/*
+ * mpool_open --
+ *	Initialize a memory pool.
+ */
+MPOOL *
+mpool_open(key, fd, pagesize, maxcache)
+	void *key;
+	int fd;
+	pgno_t pagesize, maxcache;
+{
+	struct stat sb;
+	MPOOL *mp;
+	int entry;
+
+	/*
+	 * Get information about the file.
+	 *
+	 * XXX
+	 * We don't currently handle pipes, although we should.
+	 */
+	if (_fstat(fd, &sb))
+		return (NULL);
+	if (!S_ISREG(sb.st_mode)) {
+		errno = ESPIPE;
+		return (NULL);
+	}
+
+	/* Allocate and initialize the MPOOL cookie. */
+	if ((mp = (MPOOL *)calloc(1, sizeof(MPOOL))) == NULL)
+		return (NULL);
+	TAILQ_INIT(&mp->lqh);
+	for (entry = 0; entry < HASHSIZE; ++entry)
+		TAILQ_INIT(&mp->hqh[entry]);
+	mp->maxcache = maxcache;
+	mp->npages = sb.st_size / pagesize;
+	mp->pagesize = pagesize;
+	mp->fd = fd;
+	return (mp);
+}
+
+/*
+ * mpool_filter --
+ *	Initialize input/output filters.
+ */
+void
+mpool_filter(mp, pgin, pgout, pgcookie)
+	MPOOL *mp;
+	void (*pgin)(void *, pgno_t, void *);
+	void (*pgout)(void *, pgno_t, void *);
+	void *pgcookie;
+{
+	mp->pgin = pgin;
+	mp->pgout = pgout;
+	mp->pgcookie = pgcookie;
+}
+	
+/*
+ * mpool_new --
+ *	Get a new page of memory.
+ */
+void *
+mpool_new(mp, pgnoaddr)
+	MPOOL *mp;
+	pgno_t *pgnoaddr;
+{
+	struct _hqh *head;
+	BKT *bp;
+
+	if (mp->npages == MAX_PAGE_NUMBER) {
+		(void)fprintf(stderr, "mpool_new: page allocation overflow.\n");
+		abort();
+	}
+#ifdef STATISTICS
+	++mp->pagenew;
+#endif
+	/*
+	 * Get a BKT from the cache.  Assign a new page number, attach
+	 * it to the head of the hash chain, the tail of the lru chain,
+	 * and return.
+	 */
+	if ((bp = mpool_bkt(mp)) == NULL)
+		return (NULL);
+	*pgnoaddr = bp->pgno = mp->npages++;
+	bp->flags = MPOOL_PINNED;
+
+	head = &mp->hqh[HASHKEY(bp->pgno)];
+	TAILQ_INSERT_HEAD(head, bp, hq);
+	TAILQ_INSERT_TAIL(&mp->lqh, bp, q);
+	return (bp->page);
+}
+
+/*
+ * mpool_get
+ *	Get a page.
+ */
+void *
+mpool_get(mp, pgno, flags)
+	MPOOL *mp;
+	pgno_t pgno;
+	u_int flags;				/* XXX not used? */
+{
+	struct _hqh *head;
+	BKT *bp;
+	off_t off;
+	int nr;
+
+	/* Check for attempt to retrieve a non-existent page. */
+	if (pgno >= mp->npages) {
+		errno = EINVAL;
+		return (NULL);
+	}
+
+#ifdef STATISTICS
+	++mp->pageget;
+#endif
+
+	/* Check for a page that is cached. */
+	if ((bp = mpool_look(mp, pgno)) != NULL) {
+#ifdef DEBUG
+		if (bp->flags & MPOOL_PINNED) {
+			(void)fprintf(stderr,
+			    "mpool_get: page %d already pinned\n", bp->pgno);
+			abort();
+		}
+#endif
+		/*
+		 * Move the page to the head of the hash chain and the tail
+		 * of the lru chain.
+		 */
+		head = &mp->hqh[HASHKEY(bp->pgno)];
+		TAILQ_REMOVE(head, bp, hq);
+		TAILQ_INSERT_HEAD(head, bp, hq);
+		TAILQ_REMOVE(&mp->lqh, bp, q);
+		TAILQ_INSERT_TAIL(&mp->lqh, bp, q);
+
+		/* Return a pinned page. */
+		bp->flags |= MPOOL_PINNED;
+		return (bp->page);
+	}
+
+	/* Get a page from the cache. */
+	if ((bp = mpool_bkt(mp)) == NULL)
+		return (NULL);
+
+	/* Read in the contents. */
+#ifdef STATISTICS
+	++mp->pageread;
+#endif
+	off = mp->pagesize * pgno;
+	nr = pread(mp->fd, bp->page, mp->pagesize, off);
+	if (nr != mp->pagesize) {
+		if (nr >= 0)
+			errno = EFTYPE;
+		return (NULL);
+	}
+
+	/* Set the page number, pin the page. */
+	bp->pgno = pgno;
+	bp->flags = MPOOL_PINNED;
+
+	/*
+	 * Add the page to the head of the hash chain and the tail
+	 * of the lru chain.
+	 */
+	head = &mp->hqh[HASHKEY(bp->pgno)];
+	TAILQ_INSERT_HEAD(head, bp, hq);
+	TAILQ_INSERT_TAIL(&mp->lqh, bp, q);
+
+	/* Run through the user's filter. */
+	if (mp->pgin != NULL)
+		(mp->pgin)(mp->pgcookie, bp->pgno, bp->page);
+
+	return (bp->page);
+}
+
+/*
+ * mpool_put
+ *	Return a page.
+ */
+int
+mpool_put(mp, page, flags)
+	MPOOL *mp;
+	void *page;
+	u_int flags;
+{
+	BKT *bp;
+
+#ifdef STATISTICS
+	++mp->pageput;
+#endif
+	bp = (BKT *)((char *)page - sizeof(BKT));
+#ifdef DEBUG
+	if (!(bp->flags & MPOOL_PINNED)) {
+		(void)fprintf(stderr,
+		    "mpool_put: page %d not pinned\n", bp->pgno);
+		abort();
+	}
+#endif
+	bp->flags &= ~MPOOL_PINNED;
+	bp->flags |= flags & MPOOL_DIRTY;
+	return (RET_SUCCESS);
+}
+
+/*
+ * mpool_close
+ *	Close the buffer pool.
+ */
+int
+mpool_close(mp)
+	MPOOL *mp;
+{
+	BKT *bp;
+
+	/* Free up any space allocated to the lru pages. */
+	while (!TAILQ_EMPTY(&mp->lqh)) {
+		bp = TAILQ_FIRST(&mp->lqh);
+		TAILQ_REMOVE(&mp->lqh, bp, q);
+		free(bp);
+	}
+
+	/* Free the MPOOL cookie. */
+	free(mp);
+	return (RET_SUCCESS);
+}
+
+/*
+ * mpool_sync
+ *	Sync the pool to disk.
+ */
+int
+mpool_sync(mp)
+	MPOOL *mp;
+{
+	BKT *bp;
+
+	/* Walk the lru chain, flushing any dirty pages to disk. */
+	TAILQ_FOREACH(bp, &mp->lqh, q)
+		if (bp->flags & MPOOL_DIRTY &&
+		    mpool_write(mp, bp) == RET_ERROR)
+			return (RET_ERROR);
+
+	/* Sync the file descriptor. */
+	return (_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS);
+}
+
+/*
+ * mpool_bkt
+ *	Get a page from the cache (or create one).
+ */
+static BKT *
+mpool_bkt(mp)
+	MPOOL *mp;
+{
+	struct _hqh *head;
+	BKT *bp;
+
+	/* If under the max cached, always create a new page. */
+	if (mp->curcache < mp->maxcache)
+		goto new;
+
+	/*
+	 * If the cache is max'd out, walk the lru list for a buffer we
+	 * can flush.  If we find one, write it (if necessary) and take it
+	 * off any lists.  If we don't find anything we grow the cache anyway.
+	 * The cache never shrinks.
+	 */
+	TAILQ_FOREACH(bp, &mp->lqh, q)
+		if (!(bp->flags & MPOOL_PINNED)) {
+			/* Flush if dirty. */
+			if (bp->flags & MPOOL_DIRTY &&
+			    mpool_write(mp, bp) == RET_ERROR)
+				return (NULL);
+#ifdef STATISTICS
+			++mp->pageflush;
+#endif
+			/* Remove from the hash and lru queues. */
+			head = &mp->hqh[HASHKEY(bp->pgno)];
+			TAILQ_REMOVE(head, bp, hq);
+			TAILQ_REMOVE(&mp->lqh, bp, q);
+#ifdef DEBUG
+			{ void *spage;
+				spage = bp->page;
+				memset(bp, 0xff, sizeof(BKT) + mp->pagesize);
+				bp->page = spage;
+			}
+#endif
+			return (bp);
+		}
+
+new:	if ((bp = (BKT *)malloc(sizeof(BKT) + mp->pagesize)) == NULL)
+		return (NULL);
+#ifdef STATISTICS
+	++mp->pagealloc;
+#endif
+#if defined(DEBUG) || defined(PURIFY)
+	memset(bp, 0xff, sizeof(BKT) + mp->pagesize);
+#endif
+	bp->page = (char *)bp + sizeof(BKT);
+	++mp->curcache;
+	return (bp);
+}
+
+/*
+ * mpool_write
+ *	Write a page to disk.
+ */
+static int
+mpool_write(mp, bp)
+	MPOOL *mp;
+	BKT *bp;
+{
+	off_t off;
+
+#ifdef STATISTICS
+	++mp->pagewrite;
+#endif
+
+	/* Run through the user's filter. */
+	if (mp->pgout)
+		(mp->pgout)(mp->pgcookie, bp->pgno, bp->page);
+
+	off = mp->pagesize * bp->pgno;
+	if (pwrite(mp->fd, bp->page, mp->pagesize, off) != mp->pagesize)
+		return (RET_ERROR);
+
+	bp->flags &= ~MPOOL_DIRTY;
+	return (RET_SUCCESS);
+}
+
+/*
+ * mpool_look
+ *	Lookup a page in the cache.
+ */
+static BKT *
+mpool_look(mp, pgno)
+	MPOOL *mp;
+	pgno_t pgno;
+{
+	struct _hqh *head;
+	BKT *bp;
+
+	head = &mp->hqh[HASHKEY(pgno)];
+	TAILQ_FOREACH(bp, head, hq)
+		if (bp->pgno == pgno) {
+#ifdef STATISTICS
+			++mp->cachehit;
+#endif
+			return (bp);
+		}
+#ifdef STATISTICS
+	++mp->cachemiss;
+#endif
+	return (NULL);
+}
+
+#ifdef STATISTICS
+/*
+ * mpool_stat
+ *	Print out cache statistics.
+ */
+void
+mpool_stat(mp)
+	MPOOL *mp;
+{
+	BKT *bp;
+	int cnt;
+	char *sep;
+
+	(void)fprintf(stderr, "%lu pages in the file\n", mp->npages);
+	(void)fprintf(stderr,
+	    "page size %lu, cacheing %lu pages of %lu page max cache\n",
+	    mp->pagesize, mp->curcache, mp->maxcache);
+	(void)fprintf(stderr, "%lu page puts, %lu page gets, %lu page new\n",
+	    mp->pageput, mp->pageget, mp->pagenew);
+	(void)fprintf(stderr, "%lu page allocs, %lu page flushes\n",
+	    mp->pagealloc, mp->pageflush);
+	if (mp->cachehit + mp->cachemiss)
+		(void)fprintf(stderr,
+		    "%.0f%% cache hit rate (%lu hits, %lu misses)\n", 
+		    ((double)mp->cachehit / (mp->cachehit + mp->cachemiss))
+		    * 100, mp->cachehit, mp->cachemiss);
+	(void)fprintf(stderr, "%lu page reads, %lu page writes\n",
+	    mp->pageread, mp->pagewrite);
+
+	sep = "";
+	cnt = 0;
+	TAILQ_FOREACH(bp, &mp->lqh, q) {
+		(void)fprintf(stderr, "%s%d", sep, bp->pgno);
+		if (bp->flags & MPOOL_DIRTY)
+			(void)fprintf(stderr, "d");
+		if (bp->flags & MPOOL_PINNED)
+			(void)fprintf(stderr, "P");
+		if (++cnt == 10) {
+			sep = "\n";
+			cnt = 0;
+		} else
+			sep = ", ";
+			
+	}
+	(void)fprintf(stderr, "\n");
+}
+#endif
Index: /vendor/FreeBSD-libc/5.3/db/mpool/mpool.libtp
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/mpool/mpool.libtp	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/mpool/mpool.libtp	(revision 2404)
@@ -0,0 +1,746 @@
+/******************************************************************************
+
+VERSION $FreeBSD: src/lib/libc/db/mpool/mpool.libtp,v 1.4 1999/08/27 23:58:23 peter Exp $
+PACKAGE: 	User Level Shared Memory Manager
+
+DESCRIPTION: 	
+	This package provides a buffer pool interface implemented as
+	a collection of file pages mapped into shared memory.
+
+	Based on Mark's buffer manager
+
+ROUTINES: 
+    External
+	buf_alloc
+	buf_flags
+	buf_get
+	buf_init
+	buf_last
+	buf_open
+	buf_pin
+	buf_sync
+	buf_unpin
+    Internal
+	bf_assign_buf
+	bf_fid_to_fd
+	bf_newbuf
+	bf_put_page
+	
+
+******************************************************************************/
+#include	<sys/types.h>
+#include	<assert.h>
+#include	<sys/file.h>
+#include	<sys/stat.h>
+#include	<stdio.h>
+#include	<errno.h>
+#include	"list.h"
+#include	"user.h"
+#include	"txn_sys.h"
+#include	"buf.h"
+#include	"semkeys.h"
+#include	"error.h"
+
+/*
+    we need to translate between some type of file id that the user 
+    process passes and a file descriptor.  For now, it's a nop.
+*/
+#define GET_MASTER      get_sem ( buf_spinlock )
+#define RELEASE_MASTER  release_sem ( buf_spinlock )
+
+#define	LRUID	*buf_lru
+#define	LRUP	(bufhdr_table+*buf_lru)
+#define	MRU	bufhdr_table[*buf_lru].lru.prev
+
+/* Global indicator that you have started reusing buffers */
+int	do_statistics = 0;
+/*
+    Process Statics (pointers into shared memory)
+*/
+static	BUF_T	*buf_table = 0;
+static	BUFHDR_T	*bufhdr_table;
+static	int	*buf_hash_table;
+static	int	*buf_lru;		/* LRU is the free list */
+static	int	buf_spinlock;
+static	FINFO_T	*buf_fids;
+static	int	*buf_sp;		/* Pointer to string free space */
+static	char	*buf_strings;
+
+/* Process Local FID->FD table */
+static	int	fds[NUM_FILE_ENTRIES];
+
+/* Static routines */
+static	BUFHDR_T	*bf_assign_buf();
+static	int		bf_fid_to_fd();
+static	BUFHDR_T	*bf_newbuf();
+static	int		bf_put_page();
+
+/*
+    Return  0 on success
+	    1 on failure
+*/
+extern int
+buf_init ( )
+{
+    ADDR_T	buf_region;
+    BUFHDR_T	*bhp;
+    int		i;
+    int		ref_count;
+    int		*spinlockp;
+
+    /*
+	Initialize Process local structures
+    */
+    for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) {
+	fds[i] = -1;
+    }
+
+    buf_region = attach_region ( BUF_REGION_NAME, BUF_REGION_NUM,
+				 BUF_REGION_SIZE, &ref_count );
+    if ( !buf_region ) {
+	return (1);
+    }
+    error_log3 ( "Buf Region: ADDR: %d ID: %d SIZE: %d\n", buf_region,
+		    BUF_REGION_NUM, BUF_REGION_SIZE );
+
+    buf_table = (BUF_T *)buf_region;
+    bufhdr_table = (BUFHDR_T *)(buf_table + NUM_BUFS);
+    buf_hash_table = (int *)(bufhdr_table + NUM_BUFS);
+    buf_lru = buf_hash_table + NUMTABLE_ENTRIES;
+    spinlockp = buf_lru + 1;
+    buf_fids = (FINFO_T *)(spinlockp+1);
+    buf_sp = (int *)(buf_fids + NUM_FILE_ENTRIES);
+    buf_strings = (char *)(buf_sp + 1);
+
+    /* Create locking spinlock (gets creating holding the lock) */
+    buf_spinlock = create_sem ( BUF_SPIN_NAME, BUF_SPIN_NUM, ref_count <= 1 );
+    if ( buf_spinlock < 0 )  {
+	return(1);
+    }
+    if ( ref_count <= 1 ) {
+	*spinlockp = buf_spinlock;
+
+	/* Now initialize the buffer manager */
+
+	/* 1. Free list */
+	*buf_lru = 0;
+
+	/* 2. Buffer headers */
+	for ( i = 0, bhp = bufhdr_table; i < NUM_BUFS; bhp++, i++ ) {
+		bhp->lru.next = i+1;
+		bhp->lru.prev = i-1;
+		bhp->flags = 0;				/* All Flags off */
+		bhp->refcount = 0;
+		bhp->wait_proc = -1;			/* No sleepers */
+		LISTPE_INIT ( hash, bhp, i );		/* Hash chains */
+	}
+	bufhdr_table[0].lru.prev = NUM_BUFS-1;
+	bufhdr_table[NUM_BUFS-1].lru.next = 0;
+
+	/* 3. Hash Table */
+	for ( i = 0; i < NUMTABLE_ENTRIES; i++ ) {
+		buf_hash_table[i] = NUM_BUFS;
+	}
+
+	/* 4. File ID Table */
+	for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) {
+		buf_fids[i].offset = -1;
+		buf_fids[i].npages = -1;
+		buf_fids[i].refcount = 0;
+	}
+
+	/* 5. Free String Pointer */
+	*buf_sp = (FILE_NAME_LEN*NUM_FILE_ENTRIES);
+	if (RELEASE_MASTER) {
+		return(1);
+	}
+	error_log0 ( "Initialized buffer region\n" );
+    } 
+    return (0);
+}
+
+extern	void
+buf_exit()
+{
+    int	ref;
+    int	i;
+
+    /* Flush Buffer Pool on Exit */
+    for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) {
+	if ( fds[i] != -1 ) {
+		close ( fds[i] );
+	}
+    }
+    if ( buf_table ) {
+	detach_region ( buf_table, BUF_REGION_NUM, BUF_REGION_SIZE, &ref );
+    }
+    return;
+}
+
+/*
+	We need an empty buffer.  Find the LRU unpinned NON-Dirty page.
+*/
+static BUFHDR_T	*
+bf_newbuf()
+{
+    int		fd;
+    int		lruid;
+    int		nbytes;
+    int		ndx;
+    BUFHDR_T	*bhp;
+
+    lruid = LRUID;
+    for ( bhp = LRUP; 
+	  bhp->flags & (BUF_PINNED|BUF_IO_IN_PROGRESS); 
+	  bhp = LISTP_NEXTP (bufhdr_table, lru, bhp ) ) {
+
+	if ( bhp->lru.next == lruid ) {
+		/* OUT OF BUFFERS */
+		error_log1 ( "All buffers are pinned.  %s\n",
+				"Unable to grant buffer request" );
+		return(NULL);
+	}
+    }
+    /* BHP can be used */
+    if ( bhp->flags & BUF_DIRTY ) {
+	do_statistics = 1;
+	/* 
+	    MIS  Check for log flushed appropriately
+	*/
+	fd = bf_fid_to_fd(bhp->id.file_id);
+	if ( fd == -1 ) {
+	    error_log1 ("Invalid fid %d\n", bhp->id.file_id);
+	    return(NULL);
+	}
+	if ( bf_put_page(fd, bhp) < 0 ) {
+	    return(NULL);
+	}
+    }
+    /* Update Hash Pointers */
+    ndx = BUF_HASH ( bhp->id.file_id, bhp->id.obj_id );
+    LISTP_REMOVE(bufhdr_table, hash, bhp);
+    if ( buf_hash_table[ndx] == (bhp-bufhdr_table) ) {
+	if ( bhp->hash.next != (bhp-bufhdr_table) ) {
+		buf_hash_table[ndx] = bhp->hash.next;
+	} else {
+		buf_hash_table[ndx] = NUM_BUFS;
+	}
+    }
+    INIT_BUF(bhp); 
+
+    return(bhp);
+}
+/*
+    buf_alloc
+
+    Add a page to a file and return a buffer for it.
+
+*/
+ADDR_T
+buf_alloc ( fid, new_pageno )
+int	fid;
+int	*new_pageno;
+{
+	BUFHDR_T	*bhp;
+	int	fd;
+	int	len;
+	int	ndx;
+	OBJ_T	fobj;
+
+	if (GET_MASTER) {
+		return(NULL);
+	}
+	if ( buf_fids[fid].npages == -1 ) {
+	    /* initialize npages field */
+	    fd = bf_fid_to_fd ( fid );
+	}
+	assert (fid < NUM_FILE_ENTRIES);
+
+	*new_pageno = buf_fids[fid].npages;
+	if ( *new_pageno == -1 ) {
+	    RELEASE_MASTER;
+	    return ( NULL );
+	}
+	buf_fids[fid].npages++;
+	ndx = BUF_HASH ( fid, *new_pageno );
+	fobj.file_id = fid;
+	fobj.obj_id  = *new_pageno;
+	bhp = bf_assign_buf ( ndx, &fobj, BF_PIN|BF_DIRTY|BF_EMPTY, &len );
+	if ( RELEASE_MASTER ) {
+		/* Memory leak */
+		return(NULL);
+	}
+	if ( bhp ) {
+	    return ((ADDR_T)(buf_table+(bhp-bufhdr_table)));
+	} else {
+	    return ( NULL );
+	}
+}
+
+
+/*
+	Buffer Flags
+	BF_DIRTY		Mark page as dirty
+	BF_EMPTY		Don't initialize page, just get buffer
+	BF_PIN			Retrieve with pin 
+
+MIS
+Might want to add a flag that sets an LSN for this buffer is the
+DIRTY flag is set
+
+Eventually, you may want a flag that indicates the I/O and lock
+request should be shipped off together, but not for now.
+*/
+extern ADDR_T
+buf_get ( file_id, page_id, flags, len )
+int	file_id;
+int	page_id;
+u_long	flags;
+int	*len;		/* Number of bytes read into buffer */
+{
+	BUFHDR_T	*bhp;
+	int		bufid;
+	int		fd;
+	int		ndx;
+	int		next_bufid;
+	int		stat;
+	OBJ_T		fobj;	
+
+	ndx = BUF_HASH ( file_id, page_id );
+	fobj.file_id = (long) file_id;
+	fobj.obj_id = (long) page_id;
+	if ( GET_MASTER ) {
+		return(NULL);
+	}
+	/*
+		This could be a for loop, but we lose speed
+		by making all the cases general purpose so we
+		optimize for the no-collision case. 
+	*/
+	bufid = buf_hash_table[ndx]; 
+	if ( bufid < NUM_BUFS ) {
+	    for ( bhp = bufhdr_table+bufid; 
+		  !OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID);
+		  bhp = LISTP_NEXTP ( bufhdr_table, hash, bhp ) ) {
+
+		if ( bhp->hash.next == bufid ) {
+		    goto not_found;
+		}
+	    }
+/* found */
+	    if ( flags & BF_PIN ) {
+		    bhp->flags |= BUF_PINNED;
+		    bhp->refcount++;
+#ifdef PIN_DEBUG
+	fprintf(stderr, "buf_get: %X PINNED (%d)\n", 
+			buf_table + (bhp-bufhdr_table), bhp->refcount);
+#endif
+	    }
+	    if ( flags & BF_DIRTY ) {
+		    bhp->flags |= BUF_DIRTY;
+	    }
+
+	    while ( bhp->flags & BUF_IO_IN_PROGRESS ) {
+		/* MIS -- eventually err check here */
+#ifdef DEBUG
+		printf("About to sleep on %d (me: %d\n)\n", bhp->wait_proc,
+			my_txnp - txn_table);
+#endif
+#ifdef WAIT_STATS
+		buf_waits++;
+#endif
+		stat = proc_sleep_on ( &(bhp->wait_proc), buf_spinlock );
+		if ( stat ) {
+			/* Memory leak */
+			return(NULL);
+		}
+		if (!( bhp->flags & BUF_IO_IN_PROGRESS) &&
+		    (!OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID))) {
+			if (RELEASE_MASTER)
+				return(NULL);
+			return(buf_get ( file_id, page_id, flags, len ));
+		}
+	    }
+	    MAKE_MRU( bhp );
+	    *len = BUFSIZE;
+	} else {
+not_found:
+	    /* If you get here, the page isn't in the hash table */
+	    bhp = bf_assign_buf ( ndx, &fobj, flags, len );
+	}
+	/* Common code between found and not found */
+
+	if ( bhp && bhp->flags & BUF_NEWPAGE ) {
+	    *len = 0;
+	}
+	if (RELEASE_MASTER){
+		/* Memory leak */
+		return(NULL);
+	}
+	if ( bhp ) {
+	    return ((ADDR_T)(buf_table+(bhp-bufhdr_table)));
+	} else {
+	    return ( NULL );
+	}
+}
+
+/*
+	MIS - do I want to add file links to buffer pool?
+*/
+extern int
+buf_sync ( fid, close )
+int	fid;
+int	close;		/* should we dec refcount and possibly
+			   invalidate all the buffers */
+{
+    int	i;
+    int	fd;
+    int	invalidate;
+    BUFHDR_T	*bhp;
+
+    if ( (fd = bf_fid_to_fd ( fid )) < 0 ) {
+	return(1);
+    }
+    if (GET_MASTER) {
+	return(1);
+    }
+    invalidate = (buf_fids[fid].refcount == 1 && close);
+    if ( invalidate )
+	for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) {
+	    if (bhp->id.file_id == fid) {
+		if ((bhp->flags & BF_DIRTY) && (bf_put_page( fd, bhp ) < 0)) {
+			return(1);
+		}
+		bhp->id.file_id = -1;
+	    }
+	}
+    if (invalidate || close)
+	buf_fids[fid].refcount--;
+
+    if (RELEASE_MASTER) {
+	return(1);
+    }
+    return(0);
+
+
+}
+
+extern int
+buf_flags ( addr, set_flags, unset_flags )
+ADDR_T	addr;
+u_long	set_flags;
+u_long	unset_flags;
+{
+    int		bufid;
+    BUFHDR_T	*bhp;
+
+#ifdef PIN_DEBUG
+	fprintf(stderr, "buf_flags: %X setting %s%s%s%s%s releasing %s%s%s%s%s\n",
+	    addr, 
+	    set_flags&BUF_DIRTY ? "DIRTY " : "", 
+	    set_flags&BUF_VALID ? "VALID " : "", 
+	    set_flags&BUF_PINNED ? "PINNED " : "", 
+	    set_flags&BUF_IO_ERROR ? "IO_ERROR " : "", 
+	    set_flags&BUF_IO_IN_PROGRESS ? "IO_IN_PROG " : "", 
+	    set_flags&BUF_NEWPAGE ? "NEWPAGE " : "", 
+	    unset_flags&BUF_DIRTY ? "DIRTY " : "", 
+	    unset_flags&BUF_VALID ? "VALID " : "", 
+	    unset_flags&BUF_PINNED ? "PINNED " : "", 
+	    unset_flags&BUF_IO_ERROR ? "IO_ERROR " : "", 
+	    unset_flags&BUF_IO_IN_PROGRESS ? "IO_IN_PROG " : "", 
+	    unset_flags&BUF_NEWPAGE ? "NEWPAGE " : "" );
+#endif
+    if (!ADDR_OK(addr)) {
+	error_log1 ( "buf_pin: Invalid Buffer Address %x\n", addr );
+	return(1);
+    }
+    bufid = ((BUF_T *)addr) - buf_table;
+    assert ( bufid < NUM_BUFS);
+    bhp = &bufhdr_table[bufid];
+    if (GET_MASTER) {
+	return(1);
+    }
+    bhp->flags |= set_flags;
+    if ( set_flags & BUF_PINNED ) {
+	bhp->refcount++;
+    }
+    if ( set_flags & BUF_DIRTY ) {
+	unset_flags |= BUF_NEWPAGE;
+    }
+
+    if ( unset_flags & BUF_PINNED ) {
+	bhp->refcount--;
+	if ( bhp->refcount ) {
+		/* Turn off pin bit so it doesn't get unset */
+		unset_flags &= ~BUF_PINNED;
+	}
+    }
+    bhp->flags &= ~unset_flags;
+    MAKE_MRU(bhp);
+    if (RELEASE_MASTER) {
+	return(1);
+    }
+    return(0);
+}
+
+/*
+	Take a string name and produce an fid.
+
+	returns -1 on error
+
+	MIS -- this is a potential problem -- you keep actual names
+		here -- what if people run from different directories?
+*/
+extern	int
+buf_name_lookup ( fname )
+char	*fname;
+{
+    int	i;
+    int	fid;
+    int	ndx;
+
+    fid = -1;
+    if (GET_MASTER) {
+	    return(-1);
+    }
+    for ( i = 0; i < NUM_FILE_ENTRIES; i++ ) {
+	if ( buf_fids[i].offset == -1 ) {
+		fid = i;
+	} else {
+		if (!strcmp (fname, buf_strings+buf_fids[i].offset)) {
+			if (RELEASE_MASTER) {
+				return(-1);
+			}
+			buf_fids[i].refcount++;
+			return(i);
+		}
+	}
+    }
+    if ( fid == -1 ) {
+	error_log0 ( "No more file ID's\n" );
+    } else {
+	ndx = *buf_sp - strlen(fname) - 1;
+	if ( ndx < 0 ) {
+	    error_log0 ( "Out of string space\n" );
+	    fid = -1;
+	} else {
+	    *buf_sp = ndx;
+	    strcpy ( buf_strings+ndx, fname );
+	    buf_fids[fid].offset = ndx;
+	}
+	buf_fids[fid].refcount = 1;
+    }
+    if (RELEASE_MASTER) {
+	return(-1);
+    }
+    return(fid);
+}
+
+static	int
+bf_fid_to_fd ( fid ) 
+int	fid;
+{
+	struct stat sbuf;
+
+	assert ( (fid < NUM_FILE_ENTRIES) && (buf_fids[fid].offset != -1) );
+	if ( fds[fid] != -1 ) {
+	    return(fds[fid]);
+
+	}
+	fds[fid] = open ( buf_strings+buf_fids[fid].offset, O_RDWR|O_CREAT, 
+			  0666 );
+	if ( fds[fid] < 0 ) {
+	    error_log3 ( "Error Opening File %s FID: %d FD: %d.  Errno = %d\n", 
+			    buf_strings+buf_fids[fid].offset, fid, fds[fid], 
+			    errno );
+	    return(-1);
+	}
+	error_log3 ( "Opening File %s FID: %d FD: %d\n", 
+			buf_strings+buf_fids[fid].offset, fid, fds[fid] );
+	if ( buf_fids[fid].npages == -1 ) {
+		/* Initialize the npages field */
+		if ( fstat ( fds[fid], &sbuf ) ) {
+		    error_log3 ( "Error Fstating %s FID: %d.  Errno = %d\n", 
+				buf_strings+buf_fids[fid].offset, fid, errno );
+		} else {
+		    buf_fids[fid].npages = ( sbuf.st_size / BUFSIZE );
+		}
+	}
+
+	return ( fds[fid] );
+}
+
+static int
+bf_put_page ( fd, bhp ) 
+int	fd;
+BUFHDR_T	*bhp;
+{
+	int	nbytes;
+
+	assert ( (bhp-bufhdr_table) < NUM_BUFS );
+	if ( lseek ( fd, bhp->id.obj_id << BUFSHIFT, L_SET ) < 0 ) {
+	    return(-1);
+	}
+	bhp->flags |= BUF_IO_IN_PROGRESS;
+	if (RELEASE_MASTER) {
+	    return(-1);
+	}
+	nbytes = write(fd, buf_table[bhp-bufhdr_table], BUFSIZE);
+	if (GET_MASTER) {
+	    return(-2);
+	}
+	if ( nbytes < 0 ) {
+		error_log1 ("Write failed with error code %d\n", errno);
+		return(-1);
+	} else if ( nbytes != BUFSIZE ) {
+		error_log1 ("Short write: %d bytes of %d\n", nbytes, BUFSIZE );
+	}
+	bhp->flags &= ~(BUF_DIRTY|BUF_IO_IN_PROGRESS);
+	return (0);
+}
+
+static BUFHDR_T	*
+bf_assign_buf ( ndx, obj, flags, len )
+int	ndx;
+OBJ_T	*obj;
+u_long	flags;
+int	*len;		/* Number of bytes read */
+{
+    BUFHDR_T	*bhp;
+    int		fd;
+
+    assert ( obj->file_id < NUM_FILE_ENTRIES );
+    bhp = bf_newbuf();
+    if ( !bhp ) {
+	return(NULL);
+    }
+    OBJ_ASSIGN ( (*obj), bhp->id );
+    if ( buf_hash_table[ndx] >= NUM_BUFS ) {
+	buf_hash_table[ndx] = bhp-bufhdr_table;
+    } else {
+	LISTPE_INSERT ( bufhdr_table, hash, bhp, buf_hash_table[ndx] );
+    }
+
+    bhp->flags |= BUF_VALID;
+    if ( flags & BF_PIN ) {
+	bhp->flags |= BUF_PINNED;
+	bhp->refcount++;
+#ifdef PIN_DEBUG
+	fprintf(stderr, "bf_assign_buf: %X PINNED (%d)\n", 
+		buf_table + (bhp-bufhdr_table), bhp->refcount);
+#endif
+    }
+    fd = bf_fid_to_fd(obj->file_id);
+    if ( fd == -1 ) {
+	error_log1 ("Invalid fid %d\n", obj->file_id);
+	bhp->flags |= ~BUF_IO_ERROR;
+	return(NULL);
+    }
+    if ( obj->obj_id >= buf_fids[obj->file_id].npages) {
+	buf_fids[obj->file_id].npages = obj->obj_id+1;
+	*len = 0;
+    } else if ( flags & BF_EMPTY ) {
+	*len = 0;
+    } else {
+	bhp->flags |= BUF_IO_IN_PROGRESS;
+	if (RELEASE_MASTER) {
+		return(NULL);
+	}
+	if ( lseek ( fd, obj->obj_id << BUFSHIFT, L_SET ) < -1 ) {
+	    error_log2 ("Unable to perform seek on file: %d  to page %d",
+			obj->file_id, obj->obj_id );
+	    bhp->flags &= ~BUF_IO_IN_PROGRESS;
+	    bhp->flags |= ~BUF_IO_ERROR;
+	    return(NULL);
+	}
+	*len = read(fd, buf_table[bhp-bufhdr_table], BUFSIZE);
+	if ( *len < 0 ) {
+	    error_log2 ("Unable to perform read on file: %d  to page %d",
+			obj->file_id, obj->obj_id );
+	    bhp->flags &= ~BUF_IO_IN_PROGRESS;
+	    bhp->flags |= ~BUF_IO_ERROR;
+	    return(NULL);
+	} 
+	if (GET_MASTER) {
+		return(NULL);
+	}
+	bhp->flags &= ~BUF_IO_IN_PROGRESS;
+	if ( bhp->wait_proc != -1 ) {
+	    /* wake up waiter and anyone waiting on it */
+#ifdef DEBUG
+	    printf("Waking transaction %d due to completed I/O\n", 
+		bhp->wait_proc);
+#endif
+	    proc_wake_id ( bhp->wait_proc );
+	    bhp->wait_proc = -1;
+	}
+	MAKE_MRU(bhp);
+    }
+
+    if ( flags & BF_DIRTY ) {
+	bhp->flags |= BUF_DIRTY;
+    } else if ( *len < BUFSIZE ) {
+	bhp->flags |= BUF_NEWPAGE;
+    }
+    return ( bhp );
+}
+
+int
+buf_last ( fid )
+int	fid;
+{
+	int	val;
+
+	if (GET_MASTER) {
+		return(-1);
+	}
+	assert ( fid < NUM_FILE_ENTRIES );
+	if ( buf_fids[fid].npages == -1 ) {
+	    /* initialize npages field */
+	    (void) bf_fid_to_fd ( fid );
+	}
+	val = buf_fids[fid].npages;	
+	if ( val ) {
+		val--;			/* Convert to page number */
+	}
+	if (RELEASE_MASTER) {
+		return(-1);
+	}
+	return(val);
+}
+
+#ifdef DEBUG
+extern void
+buf_dump ( id, all )
+int	id;
+int	all;
+{
+	int i;
+	BUFHDR_T	*bhp;
+
+	printf ( "LRU + %d\n", *buf_lru );
+	if ( all ) {
+	    printf("ID\tFID\tPID\tLNEXT\tLPREV\tHNEXT\tHPREV\tSLEEP\tFLAG\tREFS\n");
+	    for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) {
+		    printf ( "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%x\t%d\n", i,
+			bhp->id.file_id, bhp->id.obj_id,
+			bhp->lru.next, bhp->lru.prev,
+			bhp->hash.next, bhp->hash.prev,
+			bhp->wait_proc, bhp->flags, bhp->refcount );
+	    }
+	} else {
+		if ( id >= NUM_BUFS ) {
+			printf ( "Buffer ID (%d) too high\n", id );
+			return;
+		}
+		bhp = bufhdr_table+id;
+		printf ( "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%x\t%d\n", i,
+		    bhp->id.file_id, bhp->id.obj_id,
+		    bhp->lru.next, bhp->lru.prev,
+		    bhp->hash.next, bhp->hash.prev,
+		    bhp->wait_proc, bhp->flags, bhp->refcount );
+	}
+	return;
+}
+#endif
+
Index: /vendor/FreeBSD-libc/5.3/db/recno/extern.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/extern.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/extern.h	(revision 2404)
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ *
+ *	@(#)extern.h	8.3 (Berkeley) 6/4/94
+ * $FreeBSD: src/lib/libc/db/recno/extern.h,v 1.2 2002/03/21 22:46:28 obrien Exp $
+ */
+
+#include "../btree/extern.h"
+
+int	 __rec_close(DB *);
+int	 __rec_delete(const DB *, const DBT *, u_int);
+int	 __rec_dleaf(BTREE *, PAGE *, u_int32_t);
+int	 __rec_fd(const DB *);
+int	 __rec_fmap(BTREE *, recno_t);
+int	 __rec_fout(BTREE *);
+int	 __rec_fpipe(BTREE *, recno_t);
+int	 __rec_get(const DB *, const DBT *, DBT *, u_int);
+int	 __rec_iput(BTREE *, recno_t, const DBT *, u_int);
+int	 __rec_put(const DB *dbp, DBT *, const DBT *, u_int);
+int	 __rec_ret(BTREE *, EPG *, recno_t, DBT *, DBT *);
+EPG	*__rec_search(BTREE *, recno_t, enum SRCHOP);
+int	 __rec_seq(const DB *, DBT *, DBT *, u_int);
+int	 __rec_sync(const DB *, u_int);
+int	 __rec_vmap(BTREE *, recno_t);
+int	 __rec_vout(BTREE *);
+int	 __rec_vpipe(BTREE *, recno_t);
Index: /vendor/FreeBSD-libc/5.3/db/recno/rec_close.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/rec_close.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/rec_close.c	(revision 2404)
@@ -0,0 +1,188 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rec_close.c	8.6 (Berkeley) 8/18/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_close.c,v 1.7 2003/02/16 17:29:09 nectar Exp $");
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <sys/mman.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+#include <db.h>
+#include "recno.h"
+
+/*
+ * __REC_CLOSE -- Close a recno tree.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__rec_close(dbp)
+	DB *dbp;
+{
+	BTREE *t;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	if (__rec_sync(dbp, 0) == RET_ERROR)
+		return (RET_ERROR);
+
+	/* Committed to closing. */
+	status = RET_SUCCESS;
+	if (F_ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize))
+		status = RET_ERROR;
+
+	if (!F_ISSET(t, R_INMEM)) {
+		if (F_ISSET(t, R_CLOSEFP)) {
+			if (fclose(t->bt_rfp))
+				status = RET_ERROR;
+		} else
+			if (_close(t->bt_rfd))
+				status = RET_ERROR;
+	}
+
+	if (__bt_close(dbp) == RET_ERROR)
+		status = RET_ERROR;
+
+	return (status);
+}
+
+/*
+ * __REC_SYNC -- sync the recno tree to disk.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ */
+int
+__rec_sync(dbp, flags)
+	const DB *dbp;
+	u_int flags;
+{
+	struct iovec iov[2];
+	BTREE *t;
+	DBT data, key;
+	off_t off;
+	recno_t scursor, trec;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	if (flags == R_RECNOSYNC)
+		return (__bt_sync(dbp, 0));
+
+	if (F_ISSET(t, R_RDONLY | R_INMEM) || !F_ISSET(t, R_MODIFIED))
+		return (RET_SUCCESS);
+
+	/* Read any remaining records into the tree. */
+	if (!F_ISSET(t, R_EOF) && t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR)
+		return (RET_ERROR);
+
+	/* Rewind the file descriptor. */
+	if (lseek(t->bt_rfd, (off_t)0, SEEK_SET) != 0)
+		return (RET_ERROR);
+
+	/* Save the cursor. */
+	scursor = t->bt_cursor.rcursor;
+
+	key.size = sizeof(recno_t);
+	key.data = &trec;
+
+	if (F_ISSET(t, R_FIXLEN)) {
+		/*
+		 * We assume that fixed length records are all fixed length.
+		 * Any that aren't are either EINVAL'd or corrected by the
+		 * record put code.
+		 */
+		status = (dbp->seq)(dbp, &key, &data, R_FIRST);
+		while (status == RET_SUCCESS) {
+			if (_write(t->bt_rfd, data.data, data.size) !=
+			    data.size)
+				return (RET_ERROR);
+			status = (dbp->seq)(dbp, &key, &data, R_NEXT);
+		}
+	} else {
+		iov[1].iov_base = (char *)&t->bt_bval;
+		iov[1].iov_len = 1;
+
+		status = (dbp->seq)(dbp, &key, &data, R_FIRST);
+		while (status == RET_SUCCESS) {
+			iov[0].iov_base = data.data;
+			iov[0].iov_len = data.size;
+			if (_writev(t->bt_rfd, iov, 2) != data.size + 1)
+				return (RET_ERROR);
+			status = (dbp->seq)(dbp, &key, &data, R_NEXT);
+		}
+	}
+
+	/* Restore the cursor. */
+	t->bt_cursor.rcursor = scursor;
+
+	if (status == RET_ERROR)
+		return (RET_ERROR);
+	if ((off = lseek(t->bt_rfd, (off_t)0, SEEK_CUR)) == -1)
+		return (RET_ERROR);
+	if (ftruncate(t->bt_rfd, off))
+		return (RET_ERROR);
+	F_CLR(t, R_MODIFIED);
+	return (RET_SUCCESS);
+}
Index: /vendor/FreeBSD-libc/5.3/db/recno/rec_delete.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/rec_delete.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/rec_delete.c	(revision 2404)
@@ -0,0 +1,199 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rec_delete.c	8.7 (Berkeley) 7/14/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_delete.c,v 1.2 2002/03/21 22:46:28 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <db.h>
+#include "recno.h"
+
+static int rec_rdelete(BTREE *, recno_t);
+
+/*
+ * __REC_DELETE -- Delete the item(s) referenced by a key.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *	key:	key to delete
+ *	flags:	R_CURSOR if deleting what the cursor references
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found.
+ */
+int
+__rec_delete(dbp, key, flags)
+	const DB *dbp;
+	const DBT *key;
+	u_int flags;
+{
+	BTREE *t;
+	recno_t nrec;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	switch(flags) {
+	case 0:
+		if ((nrec = *(recno_t *)key->data) == 0)
+			goto einval;
+		if (nrec > t->bt_nrecs)
+			return (RET_SPECIAL);
+		--nrec;
+		status = rec_rdelete(t, nrec);
+		break;
+	case R_CURSOR:
+		if (!F_ISSET(&t->bt_cursor, CURS_INIT))
+			goto einval;
+		if (t->bt_nrecs == 0)
+			return (RET_SPECIAL);
+		status = rec_rdelete(t, t->bt_cursor.rcursor - 1);
+		if (status == RET_SUCCESS)
+			--t->bt_cursor.rcursor;
+		break;
+	default:
+einval:		errno = EINVAL;
+		return (RET_ERROR);
+	}
+
+	if (status == RET_SUCCESS)
+		F_SET(t, B_MODIFIED | R_MODIFIED);
+	return (status);
+}
+
+/*
+ * REC_RDELETE -- Delete the data matching the specified key.
+ *
+ * Parameters:
+ *	tree:	tree
+ *	nrec:	record to delete
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found.
+ */
+static int
+rec_rdelete(t, nrec)
+	BTREE *t;
+	recno_t nrec;
+{
+	EPG *e;
+	PAGE *h;
+	int status;
+
+	/* Find the record; __rec_search pins the page. */
+	if ((e = __rec_search(t, nrec, SDELETE)) == NULL)
+		return (RET_ERROR);
+
+	/* Delete the record. */
+	h = e->page;
+	status = __rec_dleaf(t, h, e->index);
+	if (status != RET_SUCCESS) {
+		mpool_put(t->bt_mp, h, 0);
+		return (status);
+	}
+	mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+	return (RET_SUCCESS);
+}
+
+/*
+ * __REC_DLEAF -- Delete a single record from a recno leaf page.
+ *
+ * Parameters:
+ *	t:	tree
+ *	index:	index on current page to delete
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ */
+int
+__rec_dleaf(t, h, index)
+	BTREE *t;
+	PAGE *h;
+	u_int32_t index;
+{
+	RLEAF *rl;
+	indx_t *ip, cnt, offset;
+	u_int32_t nbytes;
+	char *from;
+	void *to;
+
+	/*
+	 * Delete a record from a recno leaf page.  Internal records are never
+	 * deleted from internal pages, regardless of the records that caused
+	 * them to be added being deleted.  Pages made empty by deletion are
+	 * not reclaimed.  They are, however, made available for reuse.
+	 *
+	 * Pack the remaining entries at the end of the page, shift the indices
+	 * down, overwriting the deleted record and its index.  If the record
+	 * uses overflow pages, make them available for reuse.
+	 */
+	to = rl = GETRLEAF(h, index);
+	if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR)
+		return (RET_ERROR);
+	nbytes = NRLEAF(rl);
+
+	/*
+	 * Compress the key/data pairs.  Compress and adjust the [BR]LEAF
+	 * offsets.  Reset the headers.
+	 */
+	from = (char *)h + h->upper;
+	memmove(from + nbytes, from, (char *)to - from);
+	h->upper += nbytes;
+
+	offset = h->linp[index];
+	for (cnt = &h->linp[index] - (ip = &h->linp[0]); cnt--; ++ip)
+		if (ip[0] < offset)
+			ip[0] += nbytes;
+	for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip)
+		ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1];
+	h->lower -= sizeof(indx_t);
+	--t->bt_nrecs;
+	return (RET_SUCCESS);
+}
Index: /vendor/FreeBSD-libc/5.3/db/recno/rec_get.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/rec_get.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/rec_get.c	(revision 2404)
@@ -0,0 +1,313 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rec_get.c	8.9 (Berkeley) 8/18/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_get.c,v 1.5 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <db.h>
+#include "recno.h"
+
+/*
+ * __REC_GET -- Get a record from the btree.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *	key:	key to find
+ *	data:	data to return
+ *	flag:	currently unused
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found.
+ */
+int
+__rec_get(dbp, key, data, flags)
+	const DB *dbp;
+	const DBT *key;
+	DBT *data;
+	u_int flags;
+{
+	BTREE *t;
+	EPG *e;
+	recno_t nrec;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/* Get currently doesn't take any flags, and keys of 0 are illegal. */
+	if (flags || (nrec = *(recno_t *)key->data) == 0) {
+		errno = EINVAL;
+		return (RET_ERROR);
+	}
+
+	/*
+	 * If we haven't seen this record yet, try to find it in the
+	 * original file.
+	 */
+	if (nrec > t->bt_nrecs) {
+		if (F_ISSET(t, R_EOF | R_INMEM))
+			return (RET_SPECIAL);
+		if ((status = t->bt_irec(t, nrec)) != RET_SUCCESS)
+			return (status);
+	}
+
+	--nrec;
+	if ((e = __rec_search(t, nrec, SEARCH)) == NULL)
+		return (RET_ERROR);
+
+	status = __rec_ret(t, e, 0, NULL, data);
+	if (F_ISSET(t, B_DB_LOCK))
+		mpool_put(t->bt_mp, e->page, 0);
+	else
+		t->bt_pinned = e->page;
+	return (status);
+}
+
+/*
+ * __REC_FPIPE -- Get fixed length records from a pipe.
+ *
+ * Parameters:
+ *	t:	tree
+ *	cnt:	records to read
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__rec_fpipe(t, top)
+	BTREE *t;
+	recno_t top;
+{
+	DBT data;
+	recno_t nrec;
+	size_t len;
+	int ch;
+	u_char *p;
+
+	if (t->bt_rdata.size < t->bt_reclen) {
+		t->bt_rdata.data = t->bt_rdata.data == NULL ?
+		    malloc(t->bt_reclen) :
+		    reallocf(t->bt_rdata.data, t->bt_reclen);
+		if (t->bt_rdata.data == NULL)
+			return (RET_ERROR);
+		t->bt_rdata.size = t->bt_reclen;
+	}
+	data.data = t->bt_rdata.data;
+	data.size = t->bt_reclen;
+
+	for (nrec = t->bt_nrecs; nrec < top;) {
+		len = t->bt_reclen;
+		for (p = t->bt_rdata.data;; *p++ = ch)
+			if ((ch = getc(t->bt_rfp)) == EOF || !--len) {
+				if (ch != EOF)
+					*p = ch;
+				if (len != 0)
+					memset(p, t->bt_bval, len);
+				if (__rec_iput(t,
+				    nrec, &data, 0) != RET_SUCCESS)
+					return (RET_ERROR);
+				++nrec;
+				break;
+			}
+		if (ch == EOF)
+			break;
+	}
+	if (nrec < top) {
+		F_SET(t, R_EOF);
+		return (RET_SPECIAL);
+	}
+	return (RET_SUCCESS);
+}
+
+/*
+ * __REC_VPIPE -- Get variable length records from a pipe.
+ *
+ * Parameters:
+ *	t:	tree
+ *	cnt:	records to read
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__rec_vpipe(t, top)
+	BTREE *t;
+	recno_t top;
+{
+	DBT data;
+	recno_t nrec;
+	size_t len;
+	size_t sz;
+	int bval, ch;
+	u_char *p;
+
+	bval = t->bt_bval;
+	for (nrec = t->bt_nrecs; nrec < top; ++nrec) {
+		for (p = t->bt_rdata.data,
+		    sz = t->bt_rdata.size;; *p++ = ch, --sz) {
+			if ((ch = getc(t->bt_rfp)) == EOF || ch == bval) {
+				data.data = t->bt_rdata.data;
+				data.size = p - (u_char *)t->bt_rdata.data;
+				if (ch == EOF && data.size == 0)
+					break;
+				if (__rec_iput(t, nrec, &data, 0)
+				    != RET_SUCCESS)
+					return (RET_ERROR);
+				break;
+			}
+			if (sz == 0) {
+				len = p - (u_char *)t->bt_rdata.data;
+				t->bt_rdata.size += (sz = 256);
+				t->bt_rdata.data = t->bt_rdata.data == NULL ?
+				    malloc(t->bt_rdata.size) :
+				    reallocf(t->bt_rdata.data, t->bt_rdata.size);
+				if (t->bt_rdata.data == NULL)
+					return (RET_ERROR);
+				p = (u_char *)t->bt_rdata.data + len;
+			}
+		}
+		if (ch == EOF)
+			break;
+	}
+	if (nrec < top) {
+		F_SET(t, R_EOF);
+		return (RET_SPECIAL);
+	}
+	return (RET_SUCCESS);
+}
+
+/*
+ * __REC_FMAP -- Get fixed length records from a file.
+ *
+ * Parameters:
+ *	t:	tree
+ *	cnt:	records to read
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__rec_fmap(t, top)
+	BTREE *t;
+	recno_t top;
+{
+	DBT data;
+	recno_t nrec;
+	u_char *sp, *ep, *p;
+	size_t len;
+
+	if (t->bt_rdata.size < t->bt_reclen) {
+		t->bt_rdata.data = t->bt_rdata.data == NULL ?
+		    malloc(t->bt_reclen) :
+		    reallocf(t->bt_rdata.data, t->bt_reclen);
+		if (t->bt_rdata.data == NULL)
+			return (RET_ERROR);
+		t->bt_rdata.size = t->bt_reclen;
+	}
+	data.data = t->bt_rdata.data;
+	data.size = t->bt_reclen;
+
+	sp = (u_char *)t->bt_cmap;
+	ep = (u_char *)t->bt_emap;
+	for (nrec = t->bt_nrecs; nrec < top; ++nrec) {
+		if (sp >= ep) {
+			F_SET(t, R_EOF);
+			return (RET_SPECIAL);
+		}
+		len = t->bt_reclen;
+		for (p = t->bt_rdata.data;
+		    sp < ep && len > 0; *p++ = *sp++, --len);
+		if (len != 0)
+			memset(p, t->bt_bval, len);
+		if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS)
+			return (RET_ERROR);
+	}
+	t->bt_cmap = (caddr_t)sp;
+	return (RET_SUCCESS);
+}
+
+/*
+ * __REC_VMAP -- Get variable length records from a file.
+ *
+ * Parameters:
+ *	t:	tree
+ *	cnt:	records to read
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__rec_vmap(t, top)
+	BTREE *t;
+	recno_t top;
+{
+	DBT data;
+	u_char *sp, *ep;
+	recno_t nrec;
+	int bval;
+
+	sp = (u_char *)t->bt_cmap;
+	ep = (u_char *)t->bt_emap;
+	bval = t->bt_bval;
+
+	for (nrec = t->bt_nrecs; nrec < top; ++nrec) {
+		if (sp >= ep) {
+			F_SET(t, R_EOF);
+			return (RET_SPECIAL);
+		}
+		for (data.data = sp; sp < ep && *sp != bval; ++sp);
+		data.size = sp - (u_char *)data.data;
+		if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS)
+			return (RET_ERROR);
+		++sp;
+	}
+	t->bt_cmap = (caddr_t)sp;
+	return (RET_SUCCESS);
+}
Index: /vendor/FreeBSD-libc/5.3/db/recno/rec_open.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/rec_open.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/rec_open.c	(revision 2404)
@@ -0,0 +1,245 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rec_open.c	8.10 (Berkeley) 9/1/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_open.c,v 1.6 2002/03/22 21:52:02 obrien Exp $");
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+#include <db.h>
+#include "recno.h"
+
+DB *
+__rec_open(fname, flags, mode, openinfo, dflags)
+	const char *fname;
+	int flags, mode, dflags;
+	const RECNOINFO *openinfo;
+{
+	BTREE *t;
+	BTREEINFO btopeninfo;
+	DB *dbp;
+	PAGE *h;
+	struct stat sb;
+	int rfd, sverrno;
+
+	/* Open the user's file -- if this fails, we're done. */
+	if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0)
+		return (NULL);
+
+	/* Create a btree in memory (backed by disk). */
+	dbp = NULL;
+	if (openinfo) {
+		if (openinfo->flags & ~(R_FIXEDLEN | R_NOKEY | R_SNAPSHOT))
+			goto einval;
+		btopeninfo.flags = 0;
+		btopeninfo.cachesize = openinfo->cachesize;
+		btopeninfo.maxkeypage = 0;
+		btopeninfo.minkeypage = 0;
+		btopeninfo.psize = openinfo->psize;
+		btopeninfo.compare = NULL;
+		btopeninfo.prefix = NULL;
+		btopeninfo.lorder = openinfo->lorder;
+		dbp = __bt_open(openinfo->bfname,
+		    O_RDWR, S_IRUSR | S_IWUSR, &btopeninfo, dflags);
+	} else
+		dbp = __bt_open(NULL, O_RDWR, S_IRUSR | S_IWUSR, NULL, dflags);
+	if (dbp == NULL)
+		goto err;
+
+	/*
+	 * Some fields in the tree structure are recno specific.  Fill them
+	 * in and make the btree structure look like a recno structure.  We
+	 * don't change the bt_ovflsize value, it's close enough and slightly
+	 * bigger.
+	 */
+	t = dbp->internal;
+	if (openinfo) {
+		if (openinfo->flags & R_FIXEDLEN) {
+			F_SET(t, R_FIXLEN);
+			t->bt_reclen = openinfo->reclen;
+			if (t->bt_reclen == 0)
+				goto einval;
+		}
+		t->bt_bval = openinfo->bval;
+	} else
+		t->bt_bval = '\n';
+
+	F_SET(t, R_RECNO);
+	if (fname == NULL)
+		F_SET(t, R_EOF | R_INMEM);
+	else
+		t->bt_rfd = rfd;
+
+	if (fname != NULL) {
+		/*
+		 * In 4.4BSD, stat(2) returns true for ISSOCK on pipes.
+		 * Unfortunately, that's not portable, so we use lseek
+		 * and check the errno values.
+		 */
+		errno = 0;
+		if (lseek(rfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) {
+			switch (flags & O_ACCMODE) {
+			case O_RDONLY:
+				F_SET(t, R_RDONLY);
+				break;
+			default:
+				goto einval;
+			}
+slow:			if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
+				goto err;
+			F_SET(t, R_CLOSEFP);
+			t->bt_irec =
+			    F_ISSET(t, R_FIXLEN) ? __rec_fpipe : __rec_vpipe;
+		} else {
+			switch (flags & O_ACCMODE) {
+			case O_RDONLY:
+				F_SET(t, R_RDONLY);
+				break;
+			case O_RDWR:
+				break;
+			default:
+				goto einval;
+			}
+
+			if (_fstat(rfd, &sb))
+				goto err;
+			/*
+			 * Kluge -- we'd like to test to see if the file is too
+			 * big to mmap.  Since, we don't know what size or type
+			 * off_t's or size_t's are, what the largest unsigned
+			 * integral type is, or what random insanity the local
+			 * C compiler will perpetrate, doing the comparison in
+			 * a portable way is flatly impossible.  Hope that mmap
+			 * fails if the file is too large.
+			 */
+			if (sb.st_size == 0)
+				F_SET(t, R_EOF);
+			else {
+#ifdef MMAP_NOT_AVAILABLE
+				/*
+				 * XXX
+				 * Mmap doesn't work correctly on many current
+				 * systems.  In particular, it can fail subtly,
+				 * with cache coherency problems.  Don't use it
+				 * for now.
+				 */
+				t->bt_msize = sb.st_size;
+				if ((t->bt_smap = mmap(NULL, t->bt_msize,
+				    PROT_READ, MAP_PRIVATE, rfd,
+				    (off_t)0)) == MAP_FAILED)
+					goto slow;
+				t->bt_cmap = t->bt_smap;
+				t->bt_emap = t->bt_smap + sb.st_size;
+				t->bt_irec = F_ISSET(t, R_FIXLEN) ?
+				    __rec_fmap : __rec_vmap;
+				F_SET(t, R_MEMMAPPED);
+#else
+				goto slow;
+#endif
+			}
+		}
+	}
+
+	/* Use the recno routines. */
+	dbp->close = __rec_close;
+	dbp->del = __rec_delete;
+	dbp->fd = __rec_fd;
+	dbp->get = __rec_get;
+	dbp->put = __rec_put;
+	dbp->seq = __rec_seq;
+	dbp->sync = __rec_sync;
+
+	/* If the root page was created, reset the flags. */
+	if ((h = mpool_get(t->bt_mp, P_ROOT, 0)) == NULL)
+		goto err;
+	if ((h->flags & P_TYPE) == P_BLEAF) {
+		F_CLR(h, P_TYPE);
+		F_SET(h, P_RLEAF);
+		mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+	} else
+		mpool_put(t->bt_mp, h, 0);
+
+	if (openinfo && openinfo->flags & R_SNAPSHOT &&
+	    !F_ISSET(t, R_EOF | R_INMEM) &&
+	    t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR)
+                goto err;
+	return (dbp);
+
+einval:	errno = EINVAL;
+err:	sverrno = errno;
+	if (dbp != NULL)
+		(void)__bt_close(dbp);
+	if (fname != NULL)
+		(void)_close(rfd);
+	errno = sverrno;
+	return (NULL);
+}
+
+int
+__rec_fd(dbp)
+	const DB *dbp;
+{
+	BTREE *t;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/* In-memory database can't have a file descriptor. */
+	if (F_ISSET(t, R_INMEM)) {
+		errno = ENOENT;
+		return (-1);
+	}
+	return (t->bt_rfd);
+}
Index: /vendor/FreeBSD-libc/5.3/db/recno/rec_put.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/rec_put.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/rec_put.c	(revision 2404)
@@ -0,0 +1,287 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rec_put.c	8.7 (Berkeley) 8/18/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_put.c,v 1.6 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <db.h>
+#include "recno.h"
+
+/*
+ * __REC_PUT -- Add a recno item to the tree.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *	key:	key
+ *	data:	data
+ *	flag:	R_CURSOR, R_IAFTER, R_IBEFORE, R_NOOVERWRITE
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is
+ *	already in the tree and R_NOOVERWRITE specified.
+ */
+int
+__rec_put(dbp, key, data, flags)
+	const DB *dbp;
+	DBT *key;
+	const DBT *data;
+	u_int flags;
+{
+	BTREE *t;
+	DBT fdata, tdata;
+	recno_t nrec;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	/*
+	 * If using fixed-length records, and the record is long, return
+	 * EINVAL.  If it's short, pad it out.  Use the record data return
+	 * memory, it's only short-term.
+	 */
+	if (F_ISSET(t, R_FIXLEN) && data->size != t->bt_reclen) {
+		if (data->size > t->bt_reclen)
+			goto einval;
+
+		if (t->bt_rdata.size < t->bt_reclen) {
+			t->bt_rdata.data = 
+			    reallocf(t->bt_rdata.data, t->bt_reclen);
+			if (t->bt_rdata.data == NULL)
+				return (RET_ERROR);
+			t->bt_rdata.size = t->bt_reclen;
+		}
+		memmove(t->bt_rdata.data, data->data, data->size);
+		memset((char *)t->bt_rdata.data + data->size,
+		    t->bt_bval, t->bt_reclen - data->size);
+		fdata.data = t->bt_rdata.data;
+		fdata.size = t->bt_reclen;
+	} else {
+		fdata.data = data->data;
+		fdata.size = data->size;
+	}
+
+	switch (flags) {
+	case R_CURSOR:
+		if (!F_ISSET(&t->bt_cursor, CURS_INIT))
+			goto einval;
+		nrec = t->bt_cursor.rcursor;
+		break;
+	case R_SETCURSOR:
+		if ((nrec = *(recno_t *)key->data) == 0)
+			goto einval;
+		break;
+	case R_IAFTER:
+		if ((nrec = *(recno_t *)key->data) == 0) {
+			nrec = 1;
+			flags = R_IBEFORE;
+		}
+		break;
+	case 0:
+	case R_IBEFORE:
+		if ((nrec = *(recno_t *)key->data) == 0)
+			goto einval;
+		break;
+	case R_NOOVERWRITE:
+		if ((nrec = *(recno_t *)key->data) == 0)
+			goto einval;
+		if (nrec <= t->bt_nrecs)
+			return (RET_SPECIAL);
+		break;
+	default:
+einval:		errno = EINVAL;
+		return (RET_ERROR);
+	}
+
+	/*
+	 * Make sure that records up to and including the put record are
+	 * already in the database.  If skipping records, create empty ones.
+	 */
+	if (nrec > t->bt_nrecs) {
+		if (!F_ISSET(t, R_EOF | R_INMEM) &&
+		    t->bt_irec(t, nrec) == RET_ERROR)
+			return (RET_ERROR);
+		if (nrec > t->bt_nrecs + 1) {
+			if (F_ISSET(t, R_FIXLEN)) {
+				if ((tdata.data =
+				    (void *)malloc(t->bt_reclen)) == NULL)
+					return (RET_ERROR);
+				tdata.size = t->bt_reclen;
+				memset(tdata.data, t->bt_bval, tdata.size);
+			} else {
+				tdata.data = NULL;
+				tdata.size = 0;
+			}
+			while (nrec > t->bt_nrecs + 1)
+				if (__rec_iput(t,
+				    t->bt_nrecs, &tdata, 0) != RET_SUCCESS)
+					return (RET_ERROR);
+			if (F_ISSET(t, R_FIXLEN))
+				free(tdata.data);
+		}
+	}
+
+	if ((status = __rec_iput(t, nrec - 1, &fdata, flags)) != RET_SUCCESS)
+		return (status);
+
+	switch (flags) {
+	case R_IAFTER:
+		nrec++;
+		break;
+	case R_SETCURSOR:
+		t->bt_cursor.rcursor = nrec;
+		break;
+	}
+	
+	F_SET(t, R_MODIFIED);
+	return (__rec_ret(t, NULL, nrec, key, NULL));
+}
+
+/*
+ * __REC_IPUT -- Add a recno item to the tree.
+ *
+ * Parameters:
+ *	t:	tree
+ *	nrec:	record number
+ *	data:	data
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS
+ */
+int
+__rec_iput(t, nrec, data, flags)
+	BTREE *t;
+	recno_t nrec;
+	const DBT *data;
+	u_int flags;
+{
+	DBT tdata;
+	EPG *e;
+	PAGE *h;
+	indx_t index, nxtindex;
+	pgno_t pg;
+	u_int32_t nbytes;
+	int dflags, status;
+	char *dest, db[NOVFLSIZE];
+
+	/*
+	 * If the data won't fit on a page, store it on indirect pages.
+	 *
+	 * XXX
+	 * If the insert fails later on, these pages aren't recovered.
+	 */
+	if (data->size > t->bt_ovflsize) {
+		if (__ovfl_put(t, data, &pg) == RET_ERROR)
+			return (RET_ERROR);
+		tdata.data = db;
+		tdata.size = NOVFLSIZE;
+		*(pgno_t *)db = pg;
+		*(u_int32_t *)(db + sizeof(pgno_t)) = data->size;
+		dflags = P_BIGDATA;
+		data = &tdata;
+	} else
+		dflags = 0;
+
+	/* __rec_search pins the returned page. */
+	if ((e = __rec_search(t, nrec,
+	    nrec > t->bt_nrecs || flags == R_IAFTER || flags == R_IBEFORE ?
+	    SINSERT : SEARCH)) == NULL)
+		return (RET_ERROR);
+
+	h = e->page;
+	index = e->index;
+
+	/*
+	 * Add the specified key/data pair to the tree.  The R_IAFTER and
+	 * R_IBEFORE flags insert the key after/before the specified key.
+	 *
+	 * Pages are split as required.
+	 */
+	switch (flags) {
+	case R_IAFTER:
+		++index;
+		break;
+	case R_IBEFORE:
+		break;
+	default:
+		if (nrec < t->bt_nrecs &&
+		    __rec_dleaf(t, h, index) == RET_ERROR) {
+			mpool_put(t->bt_mp, h, 0);
+			return (RET_ERROR);
+		}
+		break;
+	}
+
+	/*
+	 * If not enough room, split the page.  The split code will insert
+	 * the key and data and unpin the current page.  If inserting into
+	 * the offset array, shift the pointers up.
+	 */
+	nbytes = NRLEAFDBT(data->size);
+	if (h->upper - h->lower < nbytes + sizeof(indx_t)) {
+		status = __bt_split(t, h, NULL, data, dflags, nbytes, index);
+		if (status == RET_SUCCESS)
+			++t->bt_nrecs;
+		return (status);
+	}
+
+	if (index < (nxtindex = NEXTINDEX(h)))
+		memmove(h->linp + index + 1, h->linp + index,
+		    (nxtindex - index) * sizeof(indx_t));
+	h->lower += sizeof(indx_t);
+
+	h->linp[index] = h->upper -= nbytes;
+	dest = (char *)h + h->upper;
+	WR_RLEAF(dest, data, dflags);
+
+	++t->bt_nrecs;
+	F_SET(t, B_MODIFIED);
+	mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+
+	return (RET_SUCCESS);
+}
Index: /vendor/FreeBSD-libc/5.3/db/recno/rec_search.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/rec_search.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/rec_search.c	(revision 2404)
@@ -0,0 +1,128 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rec_search.c	8.4 (Berkeley) 7/14/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_search.c,v 1.4 2002/03/21 18:47:38 obrien Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <db.h>
+#include "recno.h"
+
+/*
+ * __REC_SEARCH -- Search a btree for a key.
+ *
+ * Parameters:
+ *	t:	tree to search
+ *	recno:	key to find
+ *	op: 	search operation
+ *
+ * Returns:
+ *	EPG for matching record, if any, or the EPG for the location of the
+ *	key, if it were inserted into the tree.
+ *
+ * Returns:
+ *	The EPG for matching record, if any, or the EPG for the location
+ *	of the key, if it were inserted into the tree, is entered into
+ *	the bt_cur field of the tree.  A pointer to the field is returned.
+ */
+EPG *
+__rec_search(t, recno, op)
+	BTREE *t;
+	recno_t recno;
+	enum SRCHOP op;
+{
+	indx_t index;
+	PAGE *h;
+	EPGNO *parent;
+	RINTERNAL *r;
+	pgno_t pg;
+	indx_t top;
+	recno_t total;
+	int sverrno;
+
+	BT_CLR(t);
+	for (pg = P_ROOT, total = 0;;) {
+		if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+			goto err;
+		if (h->flags & P_RLEAF) {
+			t->bt_cur.page = h;
+			t->bt_cur.index = recno - total;
+			return (&t->bt_cur);
+		}
+		for (index = 0, top = NEXTINDEX(h);;) {
+			r = GETRINTERNAL(h, index);
+			if (++index == top || total + r->nrecs > recno)
+				break;
+			total += r->nrecs;
+		}
+
+		BT_PUSH(t, pg, index - 1);
+		
+		pg = r->pgno;
+		switch (op) {
+		case SDELETE:
+			--GETRINTERNAL(h, (index - 1))->nrecs;
+			mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+			break;
+		case SINSERT:
+			++GETRINTERNAL(h, (index - 1))->nrecs;
+			mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+			break;
+		case SEARCH:
+			mpool_put(t->bt_mp, h, 0);
+			break;
+		}
+
+	}
+	/* Try and recover the tree. */
+err:	sverrno = errno;
+	if (op != SEARCH)
+		while  ((parent = BT_POP(t)) != NULL) {
+			if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
+				break;
+			if (op == SINSERT)
+				--GETRINTERNAL(h, parent->index)->nrecs;
+			else
+				++GETRINTERNAL(h, parent->index)->nrecs;
+                        mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+                }
+	errno = sverrno;
+	return (NULL);
+}
Index: /vendor/FreeBSD-libc/5.3/db/recno/rec_seq.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/rec_seq.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/rec_seq.c	(revision 2404)
@@ -0,0 +1,134 @@
+/*-
+ * Copyright (c) 1991, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+/* XXX use __SCCSID */
+static char sccsid[] __unused = "@(#)rec_seq.c	8.3 (Berkeley) 7/14/94";
+#endif /* not lint */
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_seq.c,v 1.5 2003/02/16 17:29:09 nectar Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <db.h>
+#include "recno.h"
+
+/*
+ * __REC_SEQ -- Recno sequential scan interface.
+ *
+ * Parameters:
+ *	dbp:	pointer to access method
+ *	key:	key for positioning and return value
+ *	data:	data return value
+ *	flags:	R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV.
+ *
+ * Returns:
+ *	RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key.
+ */
+int
+__rec_seq(dbp, key, data, flags)
+	const DB *dbp;
+	DBT *key, *data;
+	u_int flags;
+{
+	BTREE *t;
+	EPG *e;
+	recno_t nrec;
+	int status;
+
+	t = dbp->internal;
+
+	/* Toss any page pinned across calls. */
+	if (t->bt_pinned != NULL) {
+		mpool_put(t->bt_mp, t->bt_pinned, 0);
+		t->bt_pinned = NULL;
+	}
+
+	switch(flags) {
+	case R_CURSOR:
+		if ((nrec = *(recno_t *)key->data) == 0)
+			goto einval;
+		break;
+	case R_NEXT:
+		if (F_ISSET(&t->bt_cursor, CURS_INIT)) {
+			nrec = t->bt_cursor.rcursor + 1;
+			break;
+		}
+		/* FALLTHROUGH */
+	case R_FIRST:
+		nrec = 1;
+		break;
+	case R_PREV:
+		if (F_ISSET(&t->bt_cursor, CURS_INIT)) {
+			if ((nrec = t->bt_cursor.rcursor - 1) == 0)
+				return (RET_SPECIAL);
+			break;
+		}
+		/* FALLTHROUGH */
+	case R_LAST:
+		if (!F_ISSET(t, R_EOF | R_INMEM) &&
+		    t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR)
+			return (RET_ERROR);
+		nrec = t->bt_nrecs;
+		break;
+	default:
+einval:		errno = EINVAL;
+		return (RET_ERROR);
+	}
+	
+	if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) {
+		if (!F_ISSET(t, R_EOF | R_INMEM) &&
+		    (status = t->bt_irec(t, nrec)) != RET_SUCCESS)
+			return (status);
+		if (t->bt_nrecs == 0 || nrec > t->bt_nrecs)
+			return (RET_SPECIAL);
+	}
+
+	if ((e = __rec_search(t, nrec - 1, SEARCH)) == NULL)
+		return (RET_ERROR);
+
+	F_SET(&t->bt_cursor, CURS_INIT);
+	t->bt_cursor.rcursor = nrec;
+
+	status = __rec_ret(t, e, nrec, key, data);
+	if (F_ISSET(t, B_DB_LOCK))
+		mpool_put(t->bt_mp, e->page, 0);
+	else
+		t->bt_pinned = e->page;
+	return (status);
+}
Index: /vendor/FreeBSD-libc/5.3/db/recno/rec_utils.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/rec_utils.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/rec_utils.c	(revision 2404)
@@ -0,0 +1,124 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rec_utils.c	8.6 (Berkeley) 7/16/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_utils.c,v 1.2 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/param.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <db.h>
+#include "recno.h"
+
+/*
+ * __rec_ret --
+ *	Build return data.
+ *
+ * Parameters:
+ *	t:	tree
+ *	e:	key/data pair to be returned
+ *   nrec:	record number
+ *    key:	user's key structure
+ *	data:	user's data structure
+ *
+ * Returns:
+ *	RET_SUCCESS, RET_ERROR.
+ */
+int
+__rec_ret(t, e, nrec, key, data)
+	BTREE *t;
+	EPG *e;
+	recno_t nrec;
+	DBT *key, *data;
+{
+	RLEAF *rl;
+	void *p;
+
+	if (key == NULL)
+		goto dataonly;
+
+	/* We have to copy the key, it's not on the page. */
+	if (sizeof(recno_t) > t->bt_rkey.size) {
+		p = (void *)(t->bt_rkey.data == NULL ?
+		    malloc(sizeof(recno_t)) :
+		    realloc(t->bt_rkey.data, sizeof(recno_t)));
+		if (p == NULL)
+			return (RET_ERROR);
+		t->bt_rkey.data = p;
+		t->bt_rkey.size = sizeof(recno_t);
+	}
+	memmove(t->bt_rkey.data, &nrec, sizeof(recno_t));
+	key->size = sizeof(recno_t);
+	key->data = t->bt_rkey.data;
+
+dataonly:
+	if (data == NULL)
+		return (RET_SUCCESS);
+
+	/*
+	 * We must copy big keys/data to make them contigous.  Otherwise,
+	 * leave the page pinned and don't copy unless the user specified
+	 * concurrent access.
+	 */
+	rl = GETRLEAF(e->page, e->index);
+	if (rl->flags & P_BIGDATA) {
+		if (__ovfl_get(t, rl->bytes,
+		    &data->size, &t->bt_rdata.data, &t->bt_rdata.size))
+			return (RET_ERROR);
+		data->data = t->bt_rdata.data;
+	} else if (F_ISSET(t, B_DB_LOCK)) {
+		/* Use +1 in case the first record retrieved is 0 length. */
+		if (rl->dsize + 1 > t->bt_rdata.size) {
+			p = (void *)(t->bt_rdata.data == NULL ?
+			    malloc(rl->dsize + 1) :
+			    realloc(t->bt_rdata.data, rl->dsize + 1));
+			if (p == NULL)
+				return (RET_ERROR);
+			t->bt_rdata.data = p;
+			t->bt_rdata.size = rl->dsize + 1;
+		}
+		memmove(t->bt_rdata.data, rl->bytes, rl->dsize);
+		data->size = rl->dsize;
+		data->data = t->bt_rdata.data;
+	} else {
+		data->size = rl->dsize;
+		data->data = rl->bytes;
+	}
+	return (RET_SUCCESS);
+}
Index: /vendor/FreeBSD-libc/5.3/db/recno/recno.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/recno/recno.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/recno/recno.h	(revision 2404)
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ *
+ *	@(#)recno.h	8.1 (Berkeley) 6/4/93
+ * $FreeBSD: src/lib/libc/db/recno/recno.h,v 1.2 2002/03/22 23:41:40 obrien Exp $
+ */
+
+enum SRCHOP { SDELETE, SINSERT, SEARCH};	/* Rec_search operation. */
+
+#include "../btree/btree.h"
+#include "extern.h"
Index: /vendor/FreeBSD-libc/5.3/db/test/Makefile
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/Makefile	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/Makefile	(revision 2404)
@@ -0,0 +1,24 @@
+#	@(#)Makefile	8.15 (Berkeley) 7/28/94
+# $FreeBSD: src/lib/libc/db/test/Makefile,v 1.3 2001/08/03 21:43:26 bde Exp $
+
+PROG=	dbtest
+OBJS=	dbtest.o strerror.o
+
+# Uncomment the STAT line get hash and btree statistical use info.  This
+# also forces ld to load the btree debug functions for use by gdb, which
+# is useful.  The db library has to be compiled with -DSTATISTICS as well.
+INC=	-I${PORTDIR}/include -I${PORTDIR}
+OORG=	-g
+#STAT=	-DSTATISTICS
+CFLAGS+=-D__DBINTERFACE_PRIVATE -DDEBUG ${STAT} ${OORG} ${INC}
+
+dbtest: ${OBJS} ${PORTDIR}/libdb.a
+	${CC} -o ${.TARGET} ${OBJS} ${PORTDIR}/libdb.a
+
+strerror.o: ${PORTDIR}/clib/strerror.c
+	${CC} -c ${PORTDIR}/clib/strerror.c
+
+clean:
+	rm -f dbtest.core gmon.out ${OBJS} ${PROG} t1 t2 t3
+
+${OBJS}: Makefile
Index: /vendor/FreeBSD-libc/5.3/db/test/README
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/README	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/README	(revision 2404)
@@ -0,0 +1,74 @@
+#	@(#)README	8.8 (Berkeley) 7/31/94
+
+To build this portably, try something like:
+
+    make PORTDIR="../PORT/MACH"
+
+where MACH is the machine, i.e. "sunos.4.1.1".
+
+To run the tests, enter "sh run.test".  If your system dictionary isn't
+in /usr/share/dict/words, edit run.test to reflect the correct place.
+
+Fairly large files (the command files) are built in this directory during
+the test runs, and even larger files (the database files) are created in
+"/var/tmp".  If the latter directory doesn't exist, set the environmental
+variable TMPDIR to a directory where the files can be built.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+The script file consists of lines with an initial character which is
+the command for that line, or an initial character indicating a key
+or data entry for a previous command.
+
+Legal command characters are as follows:
+
+c: compare a record
+	+ must be followed by [kK][dD]; the data value in the database
+	  associated with the specified key is compared to the specified
+	  data value.
+e: echo a string
+	+ writes out the rest of the line into the output file; if the
+	  last character is not a carriage-return, a newline is appended.
+f: set the flags for the next command
+	+ no value zero's the flags
+g: do a get command
+	+ must be followed by [kK]
+	+ writes out the retrieved data DBT.
+o [r]: dump [reverse]
+	+ dump the database out, if 'r' is set, in reverse order.
+p: do a put command
+	+ must be followed by [kK][dD]
+r: do a del command
+	+ must be followed by [kK] unless R_CURSOR flag set.
+S: sync the database
+s: do a seq command
+	+ must be followed by [kK] if R_CURSOR flag set.
+	+ writes out the retrieved data DBT.
+
+Legal key/data characters are as follows:
+
+D [file]: data file
+	+ set the current data value to the contents of the file
+d [data]:
+	+ set the current key value to the contents of the line.
+K [file]: key file
+	+ set the current key value to the contents of the file
+k [data]:
+	+ set the current key value to the contents of the line.
+
+Blank lines, lines with leading white space, and lines with leading
+hash marks (#) are ignored.
+
+Options to dbtest are as follows:
+
+	-d: Set the DB_LOCK flag.
+	-f: Use the file argument as the database file.
+	-i: Use the rest of the argument to set elements in the info
+	    structure.  If the type is btree, then "-i cachesize=10240"
+	    will set BTREEINFO.cachesize to 10240.
+	-o: The rest of the argument is the output file instead of
+	    using stdout.
+	-s: Don't delete the database file before opening it, i.e.
+	    use the database file from a previous run.
+
+Dbtest requires two arguments, the type of access "hash", "recno"
+or "btree", and the script name or "-" to indicate stdin.
Index: /vendor/FreeBSD-libc/5.3/db/test/btree.tests/main.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/btree.tests/main.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/btree.tests/main.c	(revision 2404)
@@ -0,0 +1,767 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Olson.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)main.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/btree.tests/main.c,v 1.4 2002/03/21 22:46:29 obrien Exp $");
+
+#include <sys/param.h>
+#include <fcntl.h>
+#include <db.h>
+#include <errno.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include "btree.h"
+
+typedef struct cmd_table {
+	char *cmd;
+	int nargs;
+	int rconv;
+	void (*func)(DB *, char **);
+	char *usage, *descrip;
+} cmd_table;
+
+int stopstop;
+DB *globaldb;
+
+void append(DB *, char **);
+void bstat(DB *, char **);
+void cursor(DB *, char **);
+void delcur(DB *, char **);
+void delete(DB *, char **);
+void dump(DB *, char **);
+void first(DB *, char **);
+void get(DB *, char **);
+void help(DB *, char **);
+void iafter(DB *, char **);
+void ibefore(DB *, char **);
+void icursor(DB *, char **);
+void insert(DB *, char **);
+void keydata(DBT *, DBT *);
+void last(DB *, char **);
+void list(DB *, char **);
+void load(DB *, char **);
+void mstat(DB *, char **);
+void next(DB *, char **);
+int  parse(char *, char **, int);
+void previous(DB *, char **);
+void show(DB *, char **);
+void usage(void);
+void user(DB *);
+
+cmd_table commands[] = {
+	"?",	0, 0, help, "help", NULL,
+	"a",	2, 1, append, "append key def", "append key with data def",
+	"b",	0, 0, bstat, "bstat", "stat btree",
+	"c",	1, 1, cursor,  "cursor word", "move cursor to word",
+	"delc",	0, 0, delcur, "delcur", "delete key the cursor references",
+	"dele",	1, 1, delete, "delete word", "delete word",
+	"d",	0, 0, dump, "dump", "dump database",
+	"f",	0, 0, first, "first", "move cursor to first record",
+	"g",	1, 1, get, "get key", "locate key",
+	"h",	0, 0, help, "help", "print command summary",
+	"ia",	2, 1, iafter, "iafter key data", "insert data after key",
+	"ib",	2, 1, ibefore, "ibefore key data", "insert data before key",
+	"ic",	2, 1, icursor, "icursor key data", "replace cursor",
+	"in",	2, 1, insert, "insert key def", "insert key with data def",
+	"la",	0, 0, last, "last", "move cursor to last record",
+	"li",	1, 1, list, "list file", "list to a file",
+	"loa",	1, 0, load, "load file", NULL,
+	"loc",	1, 1, get, "get key", NULL,
+	"m",	0, 0, mstat, "mstat", "stat memory pool",
+	"n",	0, 0, next, "next", "move cursor forward one record",
+	"p",	0, 0, previous, "previous", "move cursor back one record",
+	"q",	0, 0, NULL, "quit", "quit",
+	"sh",	1, 0, show, "show page", "dump a page",
+	{ NULL },
+};
+
+int recno;					/* use record numbers */
+char *dict = "words";				/* default dictionary */
+char *progname;
+
+int
+main(argc, argv)
+	int argc;
+	char **argv;
+{
+	int c;
+	DB *db;
+	BTREEINFO b;
+
+	progname = *argv;
+
+	b.flags = 0;
+	b.cachesize = 0;
+	b.maxkeypage = 0;
+	b.minkeypage = 0;
+	b.psize = 0;
+	b.compare = NULL;
+	b.prefix = NULL;
+	b.lorder = 0;
+
+	while ((c = getopt(argc, argv, "bc:di:lp:ru")) != EOF) {
+		switch (c) {
+		case 'b':
+			b.lorder = BIG_ENDIAN;
+			break;
+		case 'c':
+			b.cachesize = atoi(optarg);
+			break;
+		case 'd':
+			b.flags |= R_DUP;
+			break;
+		case 'i':
+			dict = optarg;
+			break;
+		case 'l':
+			b.lorder = LITTLE_ENDIAN;
+			break;
+		case 'p':
+			b.psize = atoi(optarg);
+			break;
+		case 'r':
+			recno = 1;
+			break;
+		case 'u':
+			b.flags = 0;
+			break;
+		default:
+			usage();
+		}
+	}
+	argc -= optind;
+	argv += optind;
+
+	if (recno)
+		db = dbopen(*argv == NULL ? NULL : *argv, O_RDWR,
+		    0, DB_RECNO, NULL);
+	else
+		db = dbopen(*argv == NULL ? NULL : *argv, O_CREAT|O_RDWR,
+		    0600, DB_BTREE, &b);
+
+	if (db == NULL) {
+		(void)fprintf(stderr, "dbopen: %s\n", strerror(errno));
+		exit(1);
+	}
+	globaldb = db;
+	user(db);
+	exit(0);
+	/* NOTREACHED */
+}
+
+void
+user(db)
+	DB *db;
+{
+	FILE *ifp;
+	int argc, i, last;
+	char *lbuf, *argv[4], buf[512];
+
+	if ((ifp = fopen("/dev/tty", "r")) == NULL) {
+		(void)fprintf(stderr,
+		    "/dev/tty: %s\n", strerror(errno));
+		exit(1);
+	}
+	for (last = 0;;) {
+		(void)printf("> ");
+		(void)fflush(stdout);
+		if ((lbuf = fgets(&buf[0], 512, ifp)) == NULL)
+			break;
+		if (lbuf[0] == '\n') {
+			i = last;
+			goto uselast;
+		}
+		lbuf[strlen(lbuf) - 1] = '\0';
+
+		if (lbuf[0] == 'q')
+			break;
+
+		argc = parse(lbuf, &argv[0], 3);
+		if (argc == 0)
+			continue;
+
+		for (i = 0; commands[i].cmd != NULL; i++)
+			if (strncmp(commands[i].cmd, argv[0],
+			    strlen(commands[i].cmd)) == 0)
+				break;
+
+		if (commands[i].cmd == NULL) {
+			(void)fprintf(stderr,
+			    "%s: command unknown ('help' for help)\n", lbuf);
+			continue;
+		}
+
+		if (commands[i].nargs != argc - 1) {
+			(void)fprintf(stderr, "usage: %s\n", commands[i].usage);
+			continue;
+		}
+
+		if (recno && commands[i].rconv) {
+			static recno_t nlong;
+			nlong = atoi(argv[1]);
+			argv[1] = (char *)&nlong;
+		}
+uselast:	last = i;
+		(*commands[i].func)(db, argv);
+	}
+	if ((db->sync)(db) == RET_ERROR)
+		perror("dbsync");
+	else if ((db->close)(db) == RET_ERROR)
+		perror("dbclose");
+}
+
+int
+parse(lbuf, argv, maxargc)
+	char *lbuf, **argv;
+	int maxargc;
+{
+	int argc = 0;
+	char *c;
+
+	c = lbuf;
+	while (isspace(*c))
+		c++;
+	while (*c != '\0' && argc < maxargc) {
+		*argv++ = c;
+		argc++;
+		while (!isspace(*c) && *c != '\0') {
+			c++;
+		}
+		while (isspace(*c))
+			*c++ = '\0';
+	}
+	return (argc);
+}
+
+void
+append(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT key, data;
+	int status;
+
+	if (!recno) {
+		(void)fprintf(stderr,
+		    "append only available for recno db's.\n");
+		return;
+	}
+	key.data = argv[1];
+	key.size = sizeof(recno_t);
+	data.data = argv[2];
+	data.size = strlen(data.data);
+	status = (db->put)(db, &key, &data, R_APPEND);
+	switch (status) {
+	case RET_ERROR:
+		perror("append/put");
+		break;
+	case RET_SPECIAL:
+		(void)printf("%s (duplicate key)\n", argv[1]);
+		break;
+	case RET_SUCCESS:
+		break;
+	}
+}
+
+void
+cursor(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT data, key;
+	int status;
+
+	key.data = argv[1];
+	if (recno)
+		key.size = sizeof(recno_t);
+	else
+		key.size = strlen(argv[1]) + 1;
+	status = (*db->seq)(db, &key, &data, R_CURSOR);
+	switch (status) {
+	case RET_ERROR:
+		perror("cursor/seq");
+		break;
+	case RET_SPECIAL:
+		(void)printf("key not found\n");
+		break;
+	case RET_SUCCESS:
+		keydata(&key, &data);
+		break;
+	}
+}
+
+void
+delcur(db, argv)
+	DB *db;
+	char **argv;
+{
+	int status;
+
+	status = (*db->del)(db, NULL, R_CURSOR);
+
+	if (status == RET_ERROR)
+		perror("delcur/del");
+}
+
+void
+delete(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT key;
+	int status;
+
+	key.data = argv[1];
+	if (recno)
+		key.size = sizeof(recno_t);
+	else
+		key.size = strlen(argv[1]) + 1;
+
+	status = (*db->del)(db, &key, 0);
+	switch (status) {
+	case RET_ERROR:
+		perror("delete/del");
+		break;
+	case RET_SPECIAL:
+		(void)printf("key not found\n");
+		break;
+	case RET_SUCCESS:
+		break;
+	}
+}
+
+void
+dump(db, argv)
+	DB *db;
+	char **argv;
+{
+	__bt_dump(db);
+}
+
+void
+first(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT data, key;
+	int status;
+
+	status = (*db->seq)(db, &key, &data, R_FIRST);
+
+	switch (status) {
+	case RET_ERROR:
+		perror("first/seq");
+		break;
+	case RET_SPECIAL:
+		(void)printf("no more keys\n");
+		break;
+	case RET_SUCCESS:
+		keydata(&key, &data);
+		break;
+	}
+}
+
+void
+get(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT data, key;
+	int status;
+
+	key.data = argv[1];
+	if (recno)
+		key.size = sizeof(recno_t);
+	else
+		key.size = strlen(argv[1]) + 1;
+
+	status = (*db->get)(db, &key, &data, 0);
+
+	switch (status) {
+	case RET_ERROR:
+		perror("get/get");
+		break;
+	case RET_SPECIAL:
+		(void)printf("key not found\n");
+		break;
+	case RET_SUCCESS:
+		keydata(&key, &data);
+		break;
+	}
+}
+
+void
+help(db, argv)
+	DB *db;
+	char **argv;
+{
+	int i;
+
+	for (i = 0; commands[i].cmd; i++)
+		if (commands[i].descrip)
+			(void)printf("%s: %s\n",
+			    commands[i].usage, commands[i].descrip);
+}
+
+void
+iafter(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT key, data;
+	int status;
+
+	if (!recno) {
+		(void)fprintf(stderr,
+		    "iafter only available for recno db's.\n");
+		return;
+	}
+	key.data = argv[1];
+	key.size = sizeof(recno_t);
+	data.data = argv[2];
+	data.size = strlen(data.data);
+	status = (db->put)(db, &key, &data, R_IAFTER);
+	switch (status) {
+	case RET_ERROR:
+		perror("iafter/put");
+		break;
+	case RET_SPECIAL:
+		(void)printf("%s (duplicate key)\n", argv[1]);
+		break;
+	case RET_SUCCESS:
+		break;
+	}
+}
+
+void
+ibefore(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT key, data;
+	int status;
+
+	if (!recno) {
+		(void)fprintf(stderr,
+		    "ibefore only available for recno db's.\n");
+		return;
+	}
+	key.data = argv[1];
+	key.size = sizeof(recno_t);
+	data.data = argv[2];
+	data.size = strlen(data.data);
+	status = (db->put)(db, &key, &data, R_IBEFORE);
+	switch (status) {
+	case RET_ERROR:
+		perror("ibefore/put");
+		break;
+	case RET_SPECIAL:
+		(void)printf("%s (duplicate key)\n", argv[1]);
+		break;
+	case RET_SUCCESS:
+		break;
+	}
+}
+
+void
+icursor(db, argv)
+	DB *db;
+	char **argv;
+{
+	int status;
+	DBT data, key;
+
+	key.data = argv[1];
+	if (recno)
+		key.size = sizeof(recno_t);
+	else
+		key.size = strlen(argv[1]) + 1;
+	data.data = argv[2];
+	data.size = strlen(argv[2]) + 1;
+
+	status = (*db->put)(db, &key, &data, R_CURSOR);
+	switch (status) {
+	case RET_ERROR:
+		perror("icursor/put");
+		break;
+	case RET_SPECIAL:
+		(void)printf("%s (duplicate key)\n", argv[1]);
+		break;
+	case RET_SUCCESS:
+		break;
+	}
+}
+
+void
+insert(db, argv)
+	DB *db;
+	char **argv;
+{
+	int status;
+	DBT data, key;
+
+	key.data = argv[1];
+	if (recno)
+		key.size = sizeof(recno_t);
+	else
+		key.size = strlen(argv[1]) + 1;
+	data.data = argv[2];
+	data.size = strlen(argv[2]) + 1;
+
+	status = (*db->put)(db, &key, &data, R_NOOVERWRITE);
+	switch (status) {
+	case RET_ERROR:
+		perror("insert/put");
+		break;
+	case RET_SPECIAL:
+		(void)printf("%s (duplicate key)\n", argv[1]);
+		break;
+	case RET_SUCCESS:
+		break;
+	}
+}
+
+void
+last(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT data, key;
+	int status;
+
+	status = (*db->seq)(db, &key, &data, R_LAST);
+
+	switch (status) {
+	case RET_ERROR:
+		perror("last/seq");
+		break;
+	case RET_SPECIAL:
+		(void)printf("no more keys\n");
+		break;
+	case RET_SUCCESS:
+		keydata(&key, &data);
+		break;
+	}
+}
+
+void
+list(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT data, key;
+	FILE *fp;
+	int status;
+
+	if ((fp = fopen(argv[1], "w")) == NULL) {
+		(void)fprintf(stderr, "%s: %s\n", argv[1], strerror(errno));
+		return;
+	}
+	status = (*db->seq)(db, &key, &data, R_FIRST);
+	while (status == RET_SUCCESS) {
+		(void)fprintf(fp, "%s\n", key.data);
+		status = (*db->seq)(db, &key, &data, R_NEXT);
+	}
+	if (status == RET_ERROR)
+		perror("list/seq");
+}
+
+DB *BUGdb;
+void
+load(db, argv)
+	DB *db;
+	char **argv;
+{
+	char *p, *t;
+	FILE *fp;
+	DBT data, key;
+	recno_t cnt;
+	size_t len;
+	int status;
+	char *lp, buf[16 * 1024];
+
+	BUGdb = db;
+	if ((fp = fopen(argv[1], "r")) == NULL) {
+		(void)fprintf(stderr, "%s: %s\n", argv[1], strerror(errno));
+		return;
+	}
+	(void)printf("loading %s...\n", argv[1]);
+
+	for (cnt = 1; (lp = fgetline(fp, &len)) != NULL; ++cnt) {
+		if (recno) {
+			key.data = &cnt;
+			key.size = sizeof(recno_t);
+			data.data = lp;
+			data.size = len + 1;
+		} else {
+			key.data = lp;
+			key.size = len + 1;
+			for (p = lp + len - 1, t = buf; p >= lp; *t++ = *p--);
+			*t = '\0';
+			data.data = buf;
+			data.size = len + 1;
+		}
+
+		status = (*db->put)(db, &key, &data, R_NOOVERWRITE);
+		switch (status) {
+		case RET_ERROR:
+			perror("load/put");
+			exit(1);
+		case RET_SPECIAL:
+			if (recno)
+				(void)fprintf(stderr,
+				    "duplicate: %ld {%s}\n", cnt, data.data);
+			else
+				(void)fprintf(stderr,
+				    "duplicate: %ld {%s}\n", cnt, key.data);
+			exit(1);
+		case RET_SUCCESS:
+			break;
+		}
+	}
+	(void)fclose(fp);
+}
+
+void
+next(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT data, key;
+	int status;
+
+	status = (*db->seq)(db, &key, &data, R_NEXT);
+
+	switch (status) {
+	case RET_ERROR:
+		perror("next/seq");
+		break;
+	case RET_SPECIAL:
+		(void)printf("no more keys\n");
+		break;
+	case RET_SUCCESS:
+		keydata(&key, &data);
+		break;
+	}
+}
+
+void
+previous(db, argv)
+	DB *db;
+	char **argv;
+{
+	DBT data, key;
+	int status;
+
+	status = (*db->seq)(db, &key, &data, R_PREV);
+
+	switch (status) {
+	case RET_ERROR:
+		perror("previous/seq");
+		break;
+	case RET_SPECIAL:
+		(void)printf("no more keys\n");
+		break;
+	case RET_SUCCESS:
+		keydata(&key, &data);
+		break;
+	}
+}
+
+void
+show(db, argv)
+	DB *db;
+	char **argv;
+{
+	BTREE *t;
+	PAGE *h;
+	pgno_t pg;
+
+	pg = atoi(argv[1]);
+	t = db->internal;
+	if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) {
+		(void)printf("getpage of %ld failed\n", pg);
+		return;
+	}
+	if (pg == 0)
+		__bt_dmpage(h);
+	else
+		__bt_dpage(h);
+	mpool_put(t->bt_mp, h, 0);
+}
+
+void
+bstat(db, argv)
+	DB *db;
+	char **argv;
+{
+	(void)printf("BTREE\n");
+	__bt_stat(db);
+}
+
+void
+mstat(db, argv)
+	DB *db;
+	char **argv;
+{
+	(void)printf("MPOOL\n");
+	mpool_stat(((BTREE *)db->internal)->bt_mp);
+}
+
+void
+keydata(key, data)
+	DBT *key, *data;
+{
+	if (!recno && key->size > 0)
+		(void)printf("%s/", key->data);
+	if (data->size > 0)
+		(void)printf("%s", data->data);
+	(void)printf("\n");
+}
+
+void
+usage()
+{
+	(void)fprintf(stderr,
+	    "usage: %s [-bdlu] [-c cache] [-i file] [-p page] [file]\n",
+	    progname);
+	exit (1);
+}
Index: /vendor/FreeBSD-libc/5.3/db/test/dbtest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/dbtest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/dbtest.c	(revision 2404)
@@ -0,0 +1,742 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1992, 1993, 1994\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)dbtest.c	8.17 (Berkeley) 9/1/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/dbtest.c,v 1.10 2002/05/28 16:59:38 alfred Exp $");
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <db.h>
+
+enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA };
+
+void	 compare(DBT *, DBT *);
+DBTYPE	 dbtype(char *);
+void	 dump(DB *, int);
+void	 err(const char *, ...) __printflike(1, 2);
+void	 get(DB *, DBT *);
+void	 getdata(DB *, DBT *, DBT *);
+void	 put(DB *, DBT *, DBT *);
+void	 rem(DB *, DBT *);
+char	*sflags(int);
+void	 synk(DB *);
+void	*rfile(char *, size_t *);
+void	 seq(DB *, DBT *);
+u_int	 setflags(char *);
+void	*setinfo(DBTYPE, char *);
+void	 usage(void);
+void	*xmalloc(char *, size_t);
+
+DBTYPE type;				/* Database type. */
+void *infop;				/* Iflags. */
+u_long lineno;				/* Current line in test script. */
+u_int flags;				/* Current DB flags. */
+int ofd = STDOUT_FILENO;		/* Standard output fd. */
+
+DB *XXdbp;				/* Global for gdb. */
+int XXlineno;				/* Fast breakpoint for gdb. */
+
+int
+main(argc, argv)
+	int argc;
+	char *argv[];
+{
+	extern int optind;
+	extern char *optarg;
+	enum S command, state;
+	DB *dbp;
+	DBT data, key, keydata;
+	size_t len;
+	int ch, oflags, sflag;
+	char *fname, *infoarg, *p, *t, buf[8 * 1024];
+
+	infoarg = NULL;
+	fname = NULL;
+	oflags = O_CREAT | O_RDWR;
+	sflag = 0;
+	while ((ch = getopt(argc, argv, "f:i:lo:s")) != EOF)
+		switch (ch) {
+		case 'f':
+			fname = optarg;
+			break;
+		case 'i':
+			infoarg = optarg;
+			break;
+		case 'l':
+			oflags |= DB_LOCK;
+			break;
+		case 'o':
+			if ((ofd = open(optarg,
+			    O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
+				err("%s: %s", optarg, strerror(errno));
+			break;
+		case 's':
+			sflag = 1;
+			break;
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (argc != 2)
+		usage();
+
+	/* Set the type. */
+	type = dbtype(*argv++);
+
+	/* Open the descriptor file. */
+        if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL)
+	    err("%s: %s", *argv, strerror(errno));
+
+	/* Set up the db structure as necessary. */
+	if (infoarg == NULL)
+		infop = NULL;
+	else
+		for (p = strtok(infoarg, ",\t "); p != NULL;
+		    p = strtok(0, ",\t "))
+			if (*p != '\0')
+				infop = setinfo(type, p);
+
+	/*
+	 * Open the DB.  Delete any preexisting copy, you almost never
+	 * want it around, and it often screws up tests.
+	 */
+	if (fname == NULL) {
+		p = getenv("TMPDIR");
+		if (p == NULL)
+			p = "/var/tmp";
+		(void)snprintf(buf, sizeof(buf), "%s/__dbtest", p);
+		fname = buf;
+		(void)unlink(buf);
+	} else  if (!sflag)
+		(void)unlink(fname);
+
+	if ((dbp = dbopen(fname,
+	    oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL)
+		err("dbopen: %s", strerror(errno));
+	XXdbp = dbp;
+
+	state = COMMAND;
+	for (lineno = 1;
+	    (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) {
+		/* Delete the newline, displaying the key/data is easier. */
+		if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL)
+			*t = '\0';
+		if ((len = strlen(buf)) == 0 || isspace(*p) || *p == '#')
+			continue;
+
+		/* Convenient gdb break point. */
+		if (XXlineno == lineno)
+			XXlineno = 1;
+		switch (*p) {
+		case 'c':			/* compare */
+			if (state != COMMAND)
+				err("line %lu: not expecting command", lineno);
+			state = KEY;
+			command = COMPARE;
+			break;
+		case 'e':			/* echo */
+			if (state != COMMAND)
+				err("line %lu: not expecting command", lineno);
+			/* Don't display the newline, if CR at EOL. */
+			if (p[len - 2] == '\r')
+				--len;
+			if (write(ofd, p + 1, len - 1) != len - 1 ||
+			    write(ofd, "\n", 1) != 1)
+				err("write: %s", strerror(errno));
+			break;
+		case 'g':			/* get */
+			if (state != COMMAND)
+				err("line %lu: not expecting command", lineno);
+			state = KEY;
+			command = GET;
+			break;
+		case 'p':			/* put */
+			if (state != COMMAND)
+				err("line %lu: not expecting command", lineno);
+			state = KEY;
+			command = PUT;
+			break;
+		case 'r':			/* remove */
+			if (state != COMMAND)
+				err("line %lu: not expecting command", lineno);
+                        if (flags == R_CURSOR) {
+				rem(dbp, &key);
+				state = COMMAND;
+                        } else {
+				state = KEY;
+				command = REMOVE;
+			}
+			break;
+		case 'S':			/* sync */
+			if (state != COMMAND)
+				err("line %lu: not expecting command", lineno);
+			synk(dbp);
+			state = COMMAND;
+			break;
+		case 's':			/* seq */
+			if (state != COMMAND)
+				err("line %lu: not expecting command", lineno);
+			if (flags == R_CURSOR) {
+				state = KEY;
+				command = SEQ;
+			} else
+				seq(dbp, &key);
+			break;
+		case 'f':
+			flags = setflags(p + 1);
+			break;
+		case 'D':			/* data file */
+			if (state != DATA)
+				err("line %lu: not expecting data", lineno);
+			data.data = rfile(p + 1, &data.size);
+			goto ldata;
+		case 'd':			/* data */
+			if (state != DATA)
+				err("line %lu: not expecting data", lineno);
+			data.data = xmalloc(p + 1, len - 1);
+			data.size = len - 1;
+ldata:			switch (command) {
+			case COMPARE:
+				compare(&keydata, &data);
+				break;
+			case PUT:
+				put(dbp, &key, &data);
+				break;
+			default:
+				err("line %lu: command doesn't take data",
+				    lineno);
+			}
+			if (type != DB_RECNO)
+				free(key.data);
+			free(data.data);
+			state = COMMAND;
+			break;
+		case 'K':			/* key file */
+			if (state != KEY)
+				err("line %lu: not expecting a key", lineno);
+			if (type == DB_RECNO)
+				err("line %lu: 'K' not available for recno",
+				    lineno);
+			key.data = rfile(p + 1, &key.size);
+			goto lkey;
+		case 'k':			/* key */
+			if (state != KEY)
+				err("line %lu: not expecting a key", lineno);
+			if (type == DB_RECNO) {
+				static recno_t recno;
+				recno = atoi(p + 1);
+				key.data = &recno;
+				key.size = sizeof(recno);
+			} else {
+				key.data = xmalloc(p + 1, len - 1);
+				key.size = len - 1;
+			}
+lkey:			switch (command) {
+			case COMPARE:
+				getdata(dbp, &key, &keydata);
+				state = DATA;
+				break;
+			case GET:
+				get(dbp, &key);
+				if (type != DB_RECNO)
+					free(key.data);
+				state = COMMAND;
+				break;
+			case PUT:
+				state = DATA;
+				break;
+			case REMOVE:
+				rem(dbp, &key);
+				if ((type != DB_RECNO) && (flags != R_CURSOR))
+					free(key.data);
+				state = COMMAND;
+				break;
+			case SEQ:
+				seq(dbp, &key);
+				if ((type != DB_RECNO) && (flags != R_CURSOR))
+					free(key.data);
+				state = COMMAND;
+				break;
+			default:
+				err("line %lu: command doesn't take a key",
+				    lineno);
+			}
+			break;
+		case 'o':
+			dump(dbp, p[1] == 'r');
+			break;
+		default:
+			err("line %lu: %s: unknown command character",
+			    lineno, p);
+		}
+	}
+#ifdef STATISTICS
+	/*
+	 * -l must be used (DB_LOCK must be set) for this to be
+	 * used, otherwise a page will be locked and it will fail.
+	 */
+	if (type == DB_BTREE && oflags & DB_LOCK)
+		__bt_stat(dbp);
+#endif
+	if (dbp->close(dbp))
+		err("db->close: %s", strerror(errno));
+	(void)close(ofd);
+	exit(0);
+}
+
+#define	NOOVERWRITE	"put failed, would overwrite key\n"
+
+void
+compare(db1, db2)
+	DBT *db1, *db2;
+{
+	size_t len;
+	u_char *p1, *p2;
+
+	if (db1->size != db2->size)
+		printf("compare failed: key->data len %lu != data len %lu\n",
+		    db1->size, db2->size);
+
+	len = MIN(db1->size, db2->size);
+	for (p1 = db1->data, p2 = db2->data; len--;)
+		if (*p1++ != *p2++) {
+			printf("compare failed at offset %d\n",
+			    p1 - (u_char *)db1->data);
+			break;
+		}
+}
+
+void
+get(dbp, kp)
+	DB *dbp;
+	DBT *kp;
+{
+	DBT data;
+
+	switch (dbp->get(dbp, kp, &data, flags)) {
+	case 0:
+		(void)write(ofd, data.data, data.size);
+		if (ofd == STDOUT_FILENO)
+			(void)write(ofd, "\n", 1);
+		break;
+	case -1:
+		err("line %lu: get: %s", lineno, strerror(errno));
+		/* NOTREACHED */
+	case 1:
+#define	NOSUCHKEY	"get failed, no such key\n"
+		if (ofd != STDOUT_FILENO)
+			(void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
+		else
+			(void)fprintf(stderr, "%d: %.*s: %s",
+			    lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
+#undef	NOSUCHKEY
+		break;
+	}
+}
+
+void
+getdata(dbp, kp, dp)
+	DB *dbp;
+	DBT *kp, *dp;
+{
+	switch (dbp->get(dbp, kp, dp, flags)) {
+	case 0:
+		return;
+	case -1:
+		err("line %lu: getdata: %s", lineno, strerror(errno));
+		/* NOTREACHED */
+	case 1:
+		err("line %lu: getdata failed, no such key", lineno);
+		/* NOTREACHED */
+	}
+}
+
+void
+put(dbp, kp, dp)
+	DB *dbp;
+	DBT *kp, *dp;
+{
+	switch (dbp->put(dbp, kp, dp, flags)) {
+	case 0:
+		break;
+	case -1:
+		err("line %lu: put: %s", lineno, strerror(errno));
+		/* NOTREACHED */
+	case 1:
+		(void)write(ofd, NOOVERWRITE, sizeof(NOOVERWRITE) - 1);
+		break;
+	}
+}
+
+void
+rem(dbp, kp)
+	DB *dbp;
+	DBT *kp;
+{
+	switch (dbp->del(dbp, kp, flags)) {
+	case 0:
+		break;
+	case -1:
+		err("line %lu: rem: %s", lineno, strerror(errno));
+		/* NOTREACHED */
+	case 1:
+#define	NOSUCHKEY	"rem failed, no such key\n"
+		if (ofd != STDOUT_FILENO)
+			(void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
+		else if (flags != R_CURSOR)
+			(void)fprintf(stderr, "%d: %.*s: %s", 
+			    lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
+		else
+			(void)fprintf(stderr,
+			    "%d: rem of cursor failed\n", lineno);
+#undef	NOSUCHKEY
+		break;
+	}
+}
+
+void
+synk(dbp)
+	DB *dbp;
+{
+	switch (dbp->sync(dbp, flags)) {
+	case 0:
+		break;
+	case -1:
+		err("line %lu: synk: %s", lineno, strerror(errno));
+		/* NOTREACHED */
+	}
+}
+
+void
+seq(dbp, kp)
+	DB *dbp;
+	DBT *kp;
+{
+	DBT data;
+
+	switch (dbp->seq(dbp, kp, &data, flags)) {
+	case 0:
+		(void)write(ofd, data.data, data.size);
+		if (ofd == STDOUT_FILENO)
+			(void)write(ofd, "\n", 1);
+		break;
+	case -1:
+		err("line %lu: seq: %s", lineno, strerror(errno));
+		/* NOTREACHED */
+	case 1:
+#define	NOSUCHKEY	"seq failed, no such key\n"
+		if (ofd != STDOUT_FILENO)
+			(void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
+		else if (flags == R_CURSOR)
+			(void)fprintf(stderr, "%d: %.*s: %s", 
+			    lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
+		else
+			(void)fprintf(stderr,
+			    "%d: seq (%s) failed\n", lineno, sflags(flags));
+#undef	NOSUCHKEY
+		break;
+	}
+}
+
+void
+dump(dbp, rev)
+	DB *dbp;
+	int rev;
+{
+	DBT key, data;
+	int flags, nflags;
+
+	if (rev) {
+		flags = R_LAST;
+		nflags = R_PREV;
+	} else {
+		flags = R_FIRST;
+		nflags = R_NEXT;
+	}
+	for (;; flags = nflags)
+		switch (dbp->seq(dbp, &key, &data, flags)) {
+		case 0:
+			(void)write(ofd, data.data, data.size);
+			if (ofd == STDOUT_FILENO)
+				(void)write(ofd, "\n", 1);
+			break;
+		case 1:
+			goto done;
+		case -1:
+			err("line %lu: (dump) seq: %s",
+			    lineno, strerror(errno));
+			/* NOTREACHED */
+		}
+done:	return;
+}
+	
+u_int
+setflags(s)
+	char *s;
+{
+	char *p, *index();
+
+	for (; isspace(*s); ++s);
+	if (*s == '\n' || *s == '\0')
+		return (0);
+	if ((p = index(s, '\n')) != NULL)
+		*p = '\0';
+	if (!strcmp(s, "R_CURSOR"))		return (R_CURSOR);
+	if (!strcmp(s, "R_FIRST"))		return (R_FIRST);
+	if (!strcmp(s, "R_IAFTER")) 		return (R_IAFTER);
+	if (!strcmp(s, "R_IBEFORE")) 		return (R_IBEFORE);
+	if (!strcmp(s, "R_LAST")) 		return (R_LAST);
+	if (!strcmp(s, "R_NEXT")) 		return (R_NEXT);
+	if (!strcmp(s, "R_NOOVERWRITE"))	return (R_NOOVERWRITE);
+	if (!strcmp(s, "R_PREV"))		return (R_PREV);
+	if (!strcmp(s, "R_SETCURSOR"))		return (R_SETCURSOR);
+
+	err("line %lu: %s: unknown flag", lineno, s);
+	/* NOTREACHED */
+}
+
+char *
+sflags(flags)
+	int flags;
+{
+	switch (flags) {
+	case R_CURSOR:		return ("R_CURSOR");
+	case R_FIRST:		return ("R_FIRST");
+	case R_IAFTER:		return ("R_IAFTER");
+	case R_IBEFORE:		return ("R_IBEFORE");
+	case R_LAST:		return ("R_LAST");
+	case R_NEXT:		return ("R_NEXT");
+	case R_NOOVERWRITE:	return ("R_NOOVERWRITE");
+	case R_PREV:		return ("R_PREV");
+	case R_SETCURSOR:	return ("R_SETCURSOR");
+	}
+
+	return ("UNKNOWN!");
+}
+	
+DBTYPE
+dbtype(s)
+	char *s;
+{
+	if (!strcmp(s, "btree"))
+		return (DB_BTREE);
+	if (!strcmp(s, "hash"))
+		return (DB_HASH);
+	if (!strcmp(s, "recno"))
+		return (DB_RECNO);
+	err("%s: unknown type (use btree, hash or recno)", s);
+	/* NOTREACHED */
+}
+
+void *
+setinfo(type, s)
+	DBTYPE type;
+	char *s;
+{
+	static BTREEINFO ib;
+	static HASHINFO ih;
+	static RECNOINFO rh;
+	char *eq, *index();
+
+	if ((eq = index(s, '=')) == NULL)
+		err("%s: illegal structure set statement", s);
+	*eq++ = '\0';
+	if (!isdigit(*eq))
+		err("%s: structure set statement must be a number", s);
+		
+	switch (type) {
+	case DB_BTREE:
+		if (!strcmp("flags", s)) {
+			ib.flags = atoi(eq);
+			return (&ib);
+		}
+		if (!strcmp("cachesize", s)) {
+			ib.cachesize = atoi(eq);
+			return (&ib);
+		}
+		if (!strcmp("maxkeypage", s)) {
+			ib.maxkeypage = atoi(eq);
+			return (&ib);
+		}
+		if (!strcmp("minkeypage", s)) {
+			ib.minkeypage = atoi(eq);
+			return (&ib);
+		}
+		if (!strcmp("lorder", s)) {
+			ib.lorder = atoi(eq);
+			return (&ib);
+		}
+		if (!strcmp("psize", s)) {
+			ib.psize = atoi(eq);
+			return (&ib);
+		}
+		break;
+	case DB_HASH:
+		if (!strcmp("bsize", s)) {
+			ih.bsize = atoi(eq);
+			return (&ih);
+		}
+		if (!strcmp("ffactor", s)) {
+			ih.ffactor = atoi(eq);
+			return (&ih);
+		}
+		if (!strcmp("nelem", s)) {
+			ih.nelem = atoi(eq);
+			return (&ih);
+		}
+		if (!strcmp("cachesize", s)) {
+			ih.cachesize = atoi(eq);
+			return (&ih);
+		}
+		if (!strcmp("lorder", s)) {
+			ih.lorder = atoi(eq);
+			return (&ih);
+		}
+		break;
+	case DB_RECNO:
+		if (!strcmp("flags", s)) {
+			rh.flags = atoi(eq);
+			return (&rh);
+		}
+		if (!strcmp("cachesize", s)) {
+			rh.cachesize = atoi(eq);
+			return (&rh);
+		}
+		if (!strcmp("lorder", s)) {
+			rh.lorder = atoi(eq);
+			return (&rh);
+		}
+		if (!strcmp("reclen", s)) {
+			rh.reclen = atoi(eq);
+			return (&rh);
+		}
+		if (!strcmp("bval", s)) {
+			rh.bval = atoi(eq);
+			return (&rh);
+		}
+		if (!strcmp("psize", s)) {
+			rh.psize = atoi(eq);
+			return (&rh);
+		}
+		break;
+	}
+	err("%s: unknown structure value", s);
+	/* NOTREACHED */
+}
+
+void *
+rfile(name, lenp)
+	char *name;
+	size_t *lenp;
+{
+	struct stat sb;
+	void *p;
+	int fd;
+	char *np, *index();
+
+	for (; isspace(*name); ++name);
+	if ((np = index(name, '\n')) != NULL)
+		*np = '\0';
+	if ((fd = open(name, O_RDONLY, 0)) < 0 ||
+	    fstat(fd, &sb))
+		err("%s: %s\n", name, strerror(errno));
+#ifdef NOT_PORTABLE
+	if (sb.st_size > (off_t)SIZE_T_MAX)
+		err("%s: %s\n", name, strerror(E2BIG));
+#endif
+	if ((p = (void *)malloc((u_int)sb.st_size)) == NULL)
+		err("%s", strerror(errno));
+	(void)read(fd, p, (int)sb.st_size);
+	*lenp = sb.st_size;
+	(void)close(fd);
+	return (p);
+}
+
+void *
+xmalloc(text, len)
+	char *text;
+	size_t len;
+{
+	void *p;
+
+	if ((p = (void *)malloc(len)) == NULL)
+		err("%s", strerror(errno));
+	memmove(p, text, len);
+	return (p);
+}
+
+void
+usage()
+{
+	(void)fprintf(stderr,
+	    "usage: dbtest [-l] [-f file] [-i info] [-o file] type script\n");
+	exit(1);
+}
+
+#include <stdarg.h>
+
+void
+err(const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	(void)fprintf(stderr, "dbtest: ");
+	(void)vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	(void)fprintf(stderr, "\n");
+	exit(1);
+	/* NOTREACHED */
+}
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/driver2.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/driver2.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/driver2.c	(revision 2404)
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)driver2.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/hash.tests/driver2.c,v 1.3 2002/03/22 21:52:02 obrien Exp $");
+
+/*
+ * Test driver, to try to tackle the large ugly-split problem.
+ */
+
+#include <sys/file.h>
+#include <stdio.h>
+#include "ndbm.h"
+
+int my_hash(key, len)
+	char	*key;
+	int	len;
+{
+	return(17);		/* So I'm cruel... */
+}
+
+main(argc, argv)
+	int	argc;
+{
+	DB	*db;
+	DBT	key, content;
+	char	keybuf[2049];
+	char	contentbuf[2049];
+	char	buf[256];
+	int	i;
+	HASHINFO	info;
+
+	info.bsize = 1024;
+	info.ffactor = 5;
+	info.nelem = 1;
+	info.cachesize = NULL;
+#ifdef HASH_ID_PROGRAM_SPECIFIED
+	info.hash_id = HASH_ID_PROGRAM_SPECIFIED;
+	info.hash_func = my_hash;
+#else
+	info.hash = my_hash;
+#endif
+	info.lorder = 0;
+	if (!(db = dbopen("bigtest", O_RDWR | O_CREAT, 0644, DB_HASH, &info))) {
+		sprintf(buf, "dbopen: failed on file bigtest");
+		perror(buf);
+		exit(1);
+	}
+	srandom(17);
+	key.data = keybuf;
+	content.data = contentbuf;
+	bzero(keybuf, sizeof(keybuf));
+	bzero(contentbuf, sizeof(contentbuf));
+	for (i=1; i <= 500; i++) {
+		key.size = 128 + (random()&1023);
+		content.size = 128 + (random()&1023);
+/*		printf("%d: Key size %d, data size %d\n", i, key.size,
+		       content.size); */
+		sprintf(keybuf, "Key #%d", i);
+		sprintf(contentbuf, "Contents #%d", i);
+		if ((db->put)(db, &key, &content, R_NOOVERWRITE)) {
+			sprintf(buf, "dbm_store #%d", i);
+			perror(buf);
+		}
+	}
+	if ((db->close)(db)) {
+		perror("closing hash file");
+		exit(1);
+	}
+	exit(0);
+}
+
+
+
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/makedb.sh
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/makedb.sh	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/makedb.sh	(revision 2404)
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+#	@(#)makedb.sh	8.1 (Berkeley) 6/4/93
+
+awk '{i++; print $0; print i;}' /usr/share/dict/words > WORDS
+ls /bin /usr/bin /usr/ucb /etc | egrep '^(...|....|.....|......)$' | \
+sort | uniq | \
+awk '{
+	printf "%s\n", $0
+	for (i = 0; i < 1000; i++)
+		printf "%s+", $0
+	printf "\n"
+}' > LONG.DATA
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tcreat3.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tcreat3.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tcreat3.c	(revision 2404)
@@ -0,0 +1,107 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)tcreat3.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/hash.tests/tcreat3.c,v 1.3 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+#include <db.h>
+
+#define INITIAL	25000
+#define MAXWORDS    25000	       /* # of elements in search table */
+
+char	wp1[8192];
+char	wp2[8192];
+main(argc, argv)
+char **argv;
+{
+	DBT item, key;
+	DB	*dbp;
+	HASHINFO ctl;
+	FILE *fp;
+	int	trash;
+
+	int i = 0;
+
+	argv++;
+	ctl.hash = NULL;
+	ctl.bsize = atoi(*argv++);
+	ctl.ffactor = atoi(*argv++);
+	ctl.nelem = atoi(*argv++);
+	ctl.lorder = 0;
+	if (!(dbp = dbopen( "hashtest",
+	    O_CREAT|O_TRUNC|O_RDWR, 0600, DB_HASH, &ctl))){
+		/* create table */
+		fprintf(stderr, "cannot create: hash table (size %d)\n",
+			INITIAL);
+		exit(1);
+	}
+
+	key.data = wp1;
+	item.data = wp2;
+	while ( fgets(wp1, 8192, stdin) &&
+		fgets(wp2, 8192, stdin) &&
+		i++ < MAXWORDS) {
+/*
+* put info in structure, and structure in the item
+*/
+		key.size = strlen(wp1);
+		item.size = strlen(wp2);
+
+/*
+ * enter key/data pair into the table
+ */
+		if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) {
+			fprintf(stderr, "cannot enter: key %s\n",
+				item.data);
+			exit(1);
+		}
+	}
+
+	(dbp->close)(dbp);
+	exit(0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tdel.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tdel.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tdel.c	(revision 2404)
@@ -0,0 +1,124 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)tdel.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/hash.tests/tdel.c,v 1.3 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <db.h>
+#include <stdio.h>
+
+#define INITIAL	25000
+#define MAXWORDS    25000	       /* # of elements in search table */
+
+/* Usage: thash pagesize fillfactor file */
+char	wp1[8192];
+char	wp2[8192];
+main(argc, argv)
+char **argv;
+{
+	DBT item, key;
+	DB	*dbp;
+	HASHINFO ctl;
+	FILE *fp;
+	int	stat;
+
+	int i = 0;
+
+	argv++;
+	ctl.nelem = INITIAL;
+	ctl.hash = NULL;
+	ctl.bsize = atoi(*argv++);
+	ctl.ffactor = atoi(*argv++);
+	ctl.cachesize = 1024 * 1024;	/* 1 MEG */
+	ctl.lorder = 0;
+	argc -= 2;
+	if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) {
+		/* create table */
+		fprintf(stderr, "cannot create: hash table size %d)\n",
+			INITIAL);
+		exit(1);
+	}
+
+	key.data = wp1;
+	item.data = wp2;
+	while ( fgets(wp1, 8192, stdin) &&
+		fgets(wp2, 8192, stdin) &&
+		i++ < MAXWORDS) {
+/*
+* put info in structure, and structure in the item
+*/
+		key.size = strlen(wp1);
+		item.size = strlen(wp2);
+
+/*
+ * enter key/data pair into the table
+ */
+		if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) {
+			fprintf(stderr, "cannot enter: key %s\n",
+				item.data);
+			exit(1);
+		}
+	}
+
+	if ( --argc ) {
+		fp = fopen ( argv[0], "r");
+		i = 0;
+		while ( fgets(wp1, 8192, fp) &&
+			fgets(wp2, 8192, fp) &&
+			i++ < MAXWORDS) {
+		    key.size = strlen(wp1);
+		    stat = (dbp->del)(dbp, &key, 0);
+		    if (stat) {
+			fprintf ( stderr, "Error retrieving %s\n", key.data );
+			exit(1);
+		    }
+		}
+		fclose(fp);
+	}
+	(dbp->close)(dbp);
+	exit(0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/testit
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/testit	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/testit	(revision 2404)
@@ -0,0 +1,147 @@
+#!/bin/csh -f
+#
+#	@(#)testit	8.1 (Berkeley) 6/4/93
+#
+
+echo ""
+echo "PAGE FILL "
+set name=WORDS
+	set i = 256
+	foreach j ( 11 14 21 )
+	    thash4 $i $j 25000 65536 $name < $name
+	end
+	set i = 512
+	foreach j ( 21 28 43 )
+	    thash4 $i $j 25000 65536  $name < $name
+	end
+	set i = 1024
+	foreach j ( 43 57 85 )
+	    thash4 $i $j 25000 65536 $name < $name
+	end
+	set i = 2048
+	foreach j ( 85 114 171 )
+	    thash4 $i $j 25000 65536 $name < $name
+	end
+	set i = 4096
+	foreach j ( 171 228 341 )
+	    thash4 $i $j 25000 65536 $name < $name
+	end
+	set i = 8192
+	foreach j ( 341 455 683 )
+	    thash4 $i $j 25000 65536 $name < $name
+	end
+	echo "PAGE FILL "
+	set i = 256
+	foreach j ( 11 14 21 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 25000 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+	set i = 512
+	foreach j ( 21 28 43 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 25000 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+	set i = 1024
+	foreach j ( 43 57 85 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 25000 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+	set i = 2048
+	foreach j ( 85 114 171 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 25000 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+	set i = 4096
+	foreach j ( 171 228 341 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 25000 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+	set i = 8192
+	foreach j ( 341 455 683 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 25000 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+set name=LONG.DATA
+	set i = 1024
+	foreach j ( 1 2 4 )
+	    echo thash4 $i $j 600 65536 $name 
+	    thash4 $i $j 600 65536 $name < $name
+	end
+
+	set i = 2048
+	foreach j ( 1 2 4 )
+	    echo thash4 $i $j 600 65536 $name 
+	    thash4 $i $j 600 65536 $name < $name
+	end
+	set i = 4096
+	foreach j ( 1 2 4 )
+	    echo thash4 $i $j 600 65536 $name 
+	    thash4 $i $j 600 65536 $name < $name
+	end
+	set i = 8192
+	foreach j ( 2 4 8 )
+	    echo thash4 $i $j 600 65536 $name 
+	    thash4 $i $j 600 65536 $name < $name
+	end
+	echo "PAGE FILL "
+	set i = 1024
+	foreach j ( 1 2 4 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 600 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+	set i = 2048
+	foreach j ( 1 2 4 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 600 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+	set i = 4096
+	foreach j ( 1 2 4 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 600 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+	set i = 8192
+	foreach j ( 2 4 8 )
+	    echo "$i"_"$j"
+	    tcreat3 $i $j 600 $name < $name
+	    tread2 65536 < $name
+	    tverify $name < $name
+	    tseq > /dev/null
+	    tdel $i $j  $name < $name
+	end
+driver2
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/thash4.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/thash4.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/thash4.c	(revision 2404)
@@ -0,0 +1,134 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)thash4.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/hash.tests/thash4.c,v 1.3 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <sys/timeb.h>
+#include <stdio.h>
+#include <errno.h>
+#include <db.h>
+
+#define INITIAL	25000
+#define MAXWORDS    25000	       /* # of elements in search table */
+
+/* Usage: thash pagesize fillfactor file */
+char	wp1[8192];
+char	wp2[8192];
+main(argc, argv)
+char **argv;
+{
+	DBT item, key, res;
+	DB *dbp;
+	HASHINFO ctl;
+	FILE *fp;
+	int	stat;
+	time_t	t;
+
+	int i = 0;
+
+	argv++;
+	ctl.hash = NULL;
+	ctl.bsize = atoi(*argv++);
+	ctl.ffactor = atoi(*argv++);
+	ctl.nelem = atoi(*argv++);
+	ctl.cachesize = atoi(*argv++);
+	ctl.lorder = 0;
+	if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) {
+		/* create table */
+		fprintf(stderr, "cannot create: hash table size %d)\n",
+			INITIAL);
+		fprintf(stderr, "\terrno: %d\n", errno);
+		exit(1);
+	}
+
+	key.data = wp1;
+	item.data = wp2;
+	while ( fgets(wp1, 8192, stdin) &&
+		fgets(wp2, 8192, stdin) &&
+		i++ < MAXWORDS) {
+/*
+* put info in structure, and structure in the item
+*/
+		key.size = strlen(wp1);
+		item.size = strlen(wp2);
+
+/*
+ * enter key/data pair into the table
+ */
+		if ((dbp->put)(dbp, &key, &item, R_NOOVERWRITE) != NULL) {
+			fprintf(stderr, "cannot enter: key %s\n",
+				item.data);
+			fprintf(stderr, "\terrno: %d\n", errno);
+			exit(1);
+		}
+	}
+
+	if ( --argc ) {
+		fp = fopen ( argv[0], "r");
+		i = 0;
+		while ( fgets(wp1, 256, fp) &&
+			fgets(wp2, 8192, fp) &&
+			i++ < MAXWORDS) {
+
+		    key.size = strlen(wp1);
+		    stat = (dbp->get)(dbp, &key, &res, 0);
+		    if (stat < 0 ) {
+			fprintf ( stderr, "Error retrieving %s\n", key.data );
+			fprintf(stderr, "\terrno: %d\n", errno);
+			exit(1);
+		    } else if ( stat > 0 ) {
+			fprintf ( stderr, "%s not found\n", key.data );
+			fprintf(stderr, "\terrno: %d\n", errno);
+			exit(1);
+		    }
+		}
+		fclose(fp);
+	}
+	dbp->close(dbp);
+	exit(0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tread2.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tread2.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tread2.c	(revision 2404)
@@ -0,0 +1,107 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)tread2.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/hash.tests/tread2.c,v 1.2 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+#include <db.h>
+
+#define INITIAL	25000
+#define MAXWORDS    25000	       /* # of elements in search table */
+
+typedef struct {		       /* info to be stored */
+	int num, siz;
+} info;
+
+char	wp1[8192];
+char	wp2[8192];
+main(argc, argv)
+char **argv;
+{
+	DBT item, key, res;
+	DB	*dbp;
+	HASHINFO ctl;
+	int	stat;
+
+	int i = 0;
+
+	ctl.nelem = INITIAL;
+	ctl.hash = NULL;
+	ctl.bsize = 64;
+	ctl.ffactor = 1;
+	ctl.cachesize = atoi(*argv++);
+	ctl.lorder = 0;
+	if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) {
+		/* create table */
+		fprintf(stderr, "cannot open: hash table\n" );
+		exit(1);
+	}
+
+	key.data = wp1;
+	item.data = wp2;
+	while ( fgets(wp1, 8192, stdin) &&
+		fgets(wp2, 8192, stdin) &&
+		i++ < MAXWORDS) {
+/*
+* put info in structure, and structure in the item
+*/
+		key.size = strlen(wp1);
+		item.size = strlen(wp2);
+
+		stat = (dbp->get)(dbp, &key, &res,0);
+		if (stat < 0) {
+		    fprintf ( stderr, "Error retrieving %s\n", key.data );
+		    exit(1);
+		} else if ( stat > 0 ) {
+		    fprintf ( stderr, "%s not found\n", key.data );
+		    exit(1);
+		}
+	}
+	(dbp->close)(dbp);
+	exit(0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tseq.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tseq.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tseq.c	(revision 2404)
@@ -0,0 +1,90 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)tseq.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/hash.tests/tseq.c,v 1.3 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+#include <db.h>
+
+#define INITIAL	25000
+#define MAXWORDS    25000	       /* # of elements in search table */
+
+
+char	wp[8192];
+char	cp[8192];
+main(argc, argv)
+char **argv;
+{
+	DBT item, key, res;
+	DB	*dbp;
+	FILE *fp;
+	int	stat;
+
+	if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) {
+		/* create table */
+		fprintf(stderr, "cannot open: hash table\n" );
+		exit(1);
+	}
+
+/*
+* put info in structure, and structure in the item
+*/
+	for ( stat = (dbp->seq) (dbp, &res, &item, 1 );
+	      stat == 0;
+	      stat = (dbp->seq) (dbp, &res, &item, 0 ) ) {
+
+	      bcopy ( res.data, wp, res.size );
+	      wp[res.size] = 0;
+	      bcopy ( item.data, cp, item.size );
+	      cp[item.size] = 0;
+
+	      printf ( "%s %s\n", wp, cp );
+	}
+	(dbp->close)(dbp);
+	exit(0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tverify.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tverify.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/hash.tests/tverify.c	(revision 2404)
@@ -0,0 +1,109 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)tverify.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/db/test/hash.tests/tverify.c,v 1.2 2002/03/22 21:52:02 obrien Exp $");
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+#include <db.h>
+
+#define INITIAL	25000
+#define MAXWORDS    25000	       /* # of elements in search table */
+
+typedef struct {		       /* info to be stored */
+	int num, siz;
+} info;
+
+char	wp1[8192];
+char	wp2[8192];
+main(argc, argv)
+char **argv;
+{
+	DBT key, res;
+	DB	*dbp;
+	HASHINFO ctl;
+	int	trash;
+	int	stat;
+
+	int i = 0;
+
+	ctl.nelem = INITIAL;
+	ctl.hash = NULL;
+	ctl.bsize = 64;
+	ctl.ffactor = 1;
+	ctl.cachesize = 1024 * 1024;	/* 1 MEG */
+	ctl.lorder = 0;
+	if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) {
+		/* create table */
+		fprintf(stderr, "cannot open: hash table\n" );
+		exit(1);
+	}
+
+	key.data = wp1;
+	while ( fgets(wp1, 8192, stdin) &&
+		fgets(wp2, 8192, stdin) &&
+		i++ < MAXWORDS) {
+/*
+* put info in structure, and structure in the item
+*/
+		key.size = strlen(wp1);
+
+		stat = (dbp->get)(dbp, &key, &res,0);
+		if (stat < 0) {
+		    fprintf ( stderr, "Error retrieving %s\n", key.data );
+		    exit(1);
+		} else if ( stat > 0 ) {
+		    fprintf ( stderr, "%s not found\n", key.data );
+		    exit(1);
+		}
+		if ( memcmp ( res.data, wp2, res.size ) ) {
+		    fprintf ( stderr, "data for %s is incorrect.  Data was %s.  Should have been %s\n", key.data, res.data, wp2 );
+		}
+	}
+	(dbp->close)(dbp);
+	exit(0);
+}
Index: /vendor/FreeBSD-libc/5.3/db/test/run.test
===================================================================
--- /vendor/FreeBSD-libc/5.3/db/test/run.test	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/db/test/run.test	(revision 2404)
@@ -0,0 +1,705 @@
+#!/bin/sh -
+#
+#	@(#)run.test	8.10 (Berkeley) 7/26/94
+#
+
+# db regression tests
+main()
+{
+
+	PROG=./dbtest
+	TMP1=t1
+	TMP2=t2
+	TMP3=t3
+
+	if [ -f /usr/share/dict/words ]; then
+		DICT=/usr/share/dict/words
+	elif [ -f /usr/dict/words ]; then
+		DICT=/usr/dict/words
+	else
+		echo 'run.test: no dictionary'
+		exit 1
+	fi
+	
+	if [ $# -eq 0 ]; then
+		for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do
+			test$t
+		done
+	else
+		while [ $# -gt 0 ]
+			do case "$1" in
+			test*)
+				$1;;
+			[0-9]*)
+				test$1;;
+			btree)
+				for t in 1 2 3 7 8 9 10 12 13; do
+					test$t
+				done;;
+			hash)
+				for t in 1 2 3 8 13 20; do
+					test$t
+				done;;
+			recno)
+				for t in 1 2 3 4 5 6 7 10 11; do
+					test$t
+				done;;
+			*)
+				echo "run.test: unknown test $1"
+				echo "usage: run.test test# | type"
+				exit 1
+			esac
+			shift
+		done
+	fi
+	rm -f $TMP1 $TMP2 $TMP3
+	exit 0
+}
+
+# Take the first hundred entries in the dictionary, and make them
+# be key/data pairs.
+test1()
+{
+	echo "Test 1: btree, hash: small key, small data pairs"
+	sed 200q $DICT > $TMP1
+	for type in btree hash; do
+		rm -f $TMP2 $TMP3
+		for i in `sed 200q $DICT`; do
+			echo p
+			echo k$i
+			echo d$i
+			echo g
+			echo k$i
+		done > $TMP2
+		$PROG -o $TMP3 $type $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test1: type $type: failed"
+			exit 1
+		fi
+	done
+	echo "Test 1: recno: small key, small data pairs"
+	rm -f $TMP2 $TMP3
+	sed 200q $DICT |
+	awk '{ 
+		++i;
+		printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
+	}' > $TMP2
+	$PROG -o $TMP3 recno $TMP2
+	if (cmp -s $TMP1 $TMP3) ; then :
+	else
+		echo "test1: type recno: failed"
+		exit 1
+	fi
+}
+
+# Take the first 200 entries in the dictionary, and give them
+# each a medium size data entry.
+test2()
+{
+	echo "Test 2: btree, hash: small key, medium data pairs"
+	mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
+	echo $mdata |
+	awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1
+	for type in hash btree; do
+		rm -f $TMP2 $TMP3
+		for i in `sed 200q $DICT`; do
+			echo p
+			echo k$i
+			echo d$mdata
+			echo g
+			echo k$i
+		done > $TMP2
+		$PROG -o $TMP3 $type $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test2: type $type: failed"
+			exit 1
+		fi
+	done
+	echo "Test 2: recno: small key, medium data pairs"
+	rm -f $TMP2 $TMP3
+	echo $mdata | 
+	awk '{  for (i = 1; i < 201; ++i)
+		printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
+	}' > $TMP2
+	$PROG -o $TMP3 recno $TMP2
+	if (cmp -s $TMP1 $TMP3) ; then :
+	else
+		echo "test2: type recno: failed"
+		exit 1
+	fi
+}
+
+# Insert the programs in /bin with their paths as their keys.
+test3()
+{
+	echo "Test 3: hash: small key, big data pairs"
+	rm -f $TMP1
+	(find /bin -type f -print | xargs cat) > $TMP1
+	for type in hash; do
+		rm -f $TMP2 $TMP3
+		for i in `find /bin -type f -print`; do
+			echo p
+			echo k$i
+			echo D$i
+			echo g
+			echo k$i
+		done > $TMP2
+		$PROG -o $TMP3 $type $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test3: $type: failed"
+			exit 1
+		fi
+	done
+	echo "Test 3: btree: small key, big data pairs"
+	for psize in 512 16384 65536; do
+		echo "    page size $psize"
+		for type in btree; do
+			rm -f $TMP2 $TMP3
+			for i in `find /bin -type f -print`; do
+				echo p
+				echo k$i
+				echo D$i
+				echo g
+				echo k$i
+			done > $TMP2
+			$PROG -i psize=$psize -o $TMP3 $type $TMP2
+			if (cmp -s $TMP1 $TMP3) ; then :
+			else
+				echo "test3: $type: page size $psize: failed"
+				exit 1
+			fi
+		done
+	done
+	echo "Test 3: recno: big data pairs"
+	rm -f $TMP2 $TMP3
+	find /bin -type f -print | 
+	awk '{
+		++i;
+		printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i);
+	}' > $TMP2
+	for psize in 512 16384 65536; do
+		echo "    page size $psize"
+		$PROG -i psize=$psize -o $TMP3 recno $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test3: recno: page size $psize: failed"
+			exit 1
+		fi
+	done
+}
+
+# Do random recno entries.
+test4()
+{
+	echo "Test 4: recno: random entries"
+	echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
+	awk '{
+		for (i = 37; i <= 37 + 88 * 17; i += 17) {
+			if (i % 41)
+				s = substr($0, 1, i % 41);
+			else
+				s = substr($0, 1);
+			printf("input key %d: %s\n", i, s);
+		}
+		for (i = 1; i <= 15; ++i) {
+			if (i % 41)
+				s = substr($0, 1, i % 41);
+			else
+				s = substr($0, 1);
+			printf("input key %d: %s\n", i, s);
+		}
+		for (i = 19234; i <= 19234 + 61 * 27; i += 27) {
+			if (i % 41)
+				s = substr($0, 1, i % 41);
+			else
+				s = substr($0, 1);
+			printf("input key %d: %s\n", i, s);
+		}
+		exit
+	}' > $TMP1
+	rm -f $TMP2 $TMP3
+	cat $TMP1 |
+	awk 'BEGIN {
+			i = 37;
+			incr = 17;
+		}
+		{
+			printf("p\nk%d\nd%s\n", i, $0);
+			if (i == 19234 + 61 * 27)
+				exit;
+			if (i == 37 + 88 * 17) {
+				i = 1;
+				incr = 1;
+			} else if (i == 15) {
+				i = 19234;
+				incr = 27;
+			} else
+				i += incr;
+		}
+		END {
+			for (i = 37; i <= 37 + 88 * 17; i += 17)
+				printf("g\nk%d\n", i);
+			for (i = 1; i <= 15; ++i)
+				printf("g\nk%d\n", i);
+			for (i = 19234; i <= 19234 + 61 * 27; i += 27)
+				printf("g\nk%d\n", i);
+		}' > $TMP2
+	$PROG -o $TMP3 recno $TMP2
+	if (cmp -s $TMP1 $TMP3) ; then :
+	else
+		echo "test4: type recno: failed"
+		exit 1
+	fi
+}
+
+# Do reverse order recno entries.
+test5()
+{
+	echo "Test 5: recno: reverse order entries"
+	echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
+	awk ' {
+		for (i = 1500; i; --i) {
+			if (i % 34)
+				s = substr($0, 1, i % 34);
+			else
+				s = substr($0, 1);
+			printf("input key %d: %s\n", i, s);
+		}
+		exit;
+	}' > $TMP1
+	rm -f $TMP2 $TMP3
+	cat $TMP1 |
+	awk 'BEGIN {
+			i = 1500;
+		}
+		{
+			printf("p\nk%d\nd%s\n", i, $0);
+			--i;
+		}
+		END {
+			for (i = 1500; i; --i) 
+				printf("g\nk%d\n", i);
+		}' > $TMP2
+	$PROG -o $TMP3 recno $TMP2
+	if (cmp -s $TMP1 $TMP3) ; then :
+	else
+		echo "test5: type recno: failed"
+		exit 1
+	fi
+}
+		
+# Do alternating order recno entries.
+test6()
+{
+	echo "Test 6: recno: alternating order entries"
+	echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
+	awk ' {
+		for (i = 1; i < 1200; i += 2) {
+			if (i % 34)
+				s = substr($0, 1, i % 34);
+			else
+				s = substr($0, 1);
+			printf("input key %d: %s\n", i, s);
+		}
+		for (i = 2; i < 1200; i += 2) {
+			if (i % 34)
+				s = substr($0, 1, i % 34);
+			else
+				s = substr($0, 1);
+			printf("input key %d: %s\n", i, s);
+		}
+		exit;
+	}' > $TMP1
+	rm -f $TMP2 $TMP3
+	cat $TMP1 |
+	awk 'BEGIN {
+			i = 1;
+			even = 0;
+		}
+		{
+			printf("p\nk%d\nd%s\n", i, $0);
+			i += 2;
+			if (i >= 1200) {
+				if (even == 1)
+					exit;
+				even = 1;
+				i = 2;
+			}
+		}
+		END {
+			for (i = 1; i < 1200; ++i) 
+				printf("g\nk%d\n", i);
+		}' > $TMP2
+	$PROG -o $TMP3 recno $TMP2
+	sort -o $TMP1 $TMP1
+	sort -o $TMP3 $TMP3
+	if (cmp -s $TMP1 $TMP3) ; then :
+	else
+		echo "test6: type recno: failed"
+		exit 1
+	fi
+}
+
+# Delete cursor record
+test7()
+{
+	echo "Test 7: btree, recno: delete cursor record"
+	echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
+	awk '{
+		for (i = 1; i <= 120; ++i)
+			printf("%05d: input key %d: %s\n", i, i, $0);
+		printf("%05d: input key %d: %s\n", 120, 120, $0);
+		printf("seq failed, no such key\n");
+		printf("%05d: input key %d: %s\n", 1, 1, $0);
+		printf("%05d: input key %d: %s\n", 2, 2, $0);
+		exit;
+	}' > $TMP1
+	rm -f $TMP2 $TMP3
+
+	for type in btree recno; do
+		cat $TMP1 |
+		awk '{
+			if (i == 120)
+				exit;
+			printf("p\nk%d\nd%s\n", ++i, $0);
+		}
+		END {
+			printf("fR_NEXT\n");
+			for (i = 1; i <= 120; ++i)
+				printf("s\n");
+			printf("fR_CURSOR\ns\nk120\n");
+			printf("r\n");
+			printf("fR_NEXT\ns\n");
+			printf("fR_CURSOR\ns\nk1\n");
+			printf("r\n");
+			printf("fR_FIRST\ns\n");
+		}' > $TMP2
+		$PROG -o $TMP3 recno $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test7: type $type: failed"
+			exit 1
+		fi
+	done
+}
+
+# Make sure that overflow pages are reused.
+test8()
+{
+	echo "Test 8: btree, hash: repeated small key, big data pairs"
+	rm -f $TMP1
+	echo "" | 
+	awk 'BEGIN {
+		for (i = 1; i <= 10; ++i) {
+			printf("p\nkkey1\nD/bin/sh\n");
+			printf("p\nkkey2\nD/bin/csh\n");
+			if (i % 8 == 0) {
+				printf("c\nkkey2\nD/bin/csh\n");
+				printf("c\nkkey1\nD/bin/sh\n");
+				printf("e\t%d of 10 (comparison)\n", i);
+			} else
+				printf("e\t%d of 10             \n", i);
+			printf("r\nkkey1\nr\nkkey2\n");
+		}
+	}' > $TMP1
+	$PROG btree $TMP1
+#	$PROG hash $TMP1
+	# No explicit test for success.
+}
+
+# Test btree duplicate keys
+test9()
+{
+	echo "Test 9: btree: duplicate keys"
+	echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
+	awk '{
+		for (i = 1; i <= 543; ++i)
+			printf("%05d: input key %d: %s\n", i, i, $0);
+		exit;
+	}' > $TMP1
+	rm -f $TMP2 $TMP3
+
+	for type in btree; do
+		cat $TMP1 | 
+		awk '{
+			if (i++ % 2)
+				printf("p\nkduplicatekey\nd%s\n", $0);
+			else
+				printf("p\nkunique%dkey\nd%s\n", i, $0);
+		}
+		END {
+				printf("o\n");
+		}' > $TMP2
+		$PROG -iflags=1 -o $TMP3 $type $TMP2
+		sort -o $TMP3 $TMP3
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test9: type $type: failed"
+			exit 1
+		fi
+	done
+}
+
+# Test use of cursor flags without initialization
+test10()
+{
+	echo "Test 10: btree, recno: test cursor flag use"
+	echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
+	awk '{
+		for (i = 1; i <= 20; ++i)
+			printf("%05d: input key %d: %s\n", i, i, $0);
+		exit;
+	}' > $TMP1
+	rm -f $TMP2 $TMP3
+
+	# Test that R_CURSOR doesn't succeed before cursor initialized
+	for type in btree recno; do
+		cat $TMP1 |
+		awk '{
+			if (i == 10)
+				exit;
+			printf("p\nk%d\nd%s\n", ++i, $0);
+		}
+		END {
+			printf("fR_CURSOR\nr\n");
+			printf("eR_CURSOR SHOULD HAVE FAILED\n");
+		}' > $TMP2
+		$PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1
+		if [ -s $TMP3 ] ; then
+			echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED"
+			exit 1
+		fi
+	done
+	for type in btree recno; do
+		cat $TMP1 |
+		awk '{
+			if (i == 10)
+				exit;
+			printf("p\nk%d\nd%s\n", ++i, $0);
+		}
+		END {
+			printf("fR_CURSOR\np\nk1\ndsome data\n");
+			printf("eR_CURSOR SHOULD HAVE FAILED\n");
+		}' > $TMP2
+		$PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1
+		if [ -s $TMP3 ] ; then
+			echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED"
+			exit 1
+		fi
+	done
+}
+
+# Test insert in reverse order.
+test11()
+{
+	echo "Test 11: recno: reverse order insert"
+	echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
+	awk '{
+		for (i = 1; i <= 779; ++i)
+			printf("%05d: input key %d: %s\n", i, i, $0);
+		exit;
+	}' > $TMP1
+	rm -f $TMP2 $TMP3
+
+	for type in recno; do
+		cat $TMP1 |
+		awk '{
+			if (i == 0) {
+				i = 1;
+				printf("p\nk1\nd%s\n", $0);
+				printf("%s\n", "fR_IBEFORE");
+			} else
+				printf("p\nk1\nd%s\n", $0);
+		}
+		END {
+				printf("or\n");
+		}' > $TMP2
+		$PROG -o $TMP3 $type $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test11: type $type: failed"
+			exit 1
+		fi
+	done
+}
+
+# Take the first 20000 entries in the dictionary, reverse them, and give
+# them each a small size data entry.  Use a small page size to make sure
+# the btree split code gets hammered.
+test12()
+{
+	echo "Test 12: btree: lots of keys, small page size"
+	mdata=abcdefghijklmnopqrstuvwxy
+	echo $mdata |
+	awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1
+	for type in btree; do
+		rm -f $TMP2 $TMP3
+		for i in `sed 20000q $DICT | rev`; do
+			echo p
+			echo k$i
+			echo d$mdata
+			echo g
+			echo k$i
+		done > $TMP2
+		$PROG -i psize=512 -o $TMP3 $type $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test12: type $type: failed"
+			exit 1
+		fi
+	done
+}
+
+# Test different byte orders.
+test13()
+{
+	echo "Test 13: btree, hash: differing byte orders"
+	sed 50q $DICT > $TMP1
+	for order in 1234 4321; do
+		for type in btree hash; do
+			rm -f byte.file $TMP2 $TMP3
+			for i in `sed 50q $DICT`; do
+				echo p
+				echo k$i
+				echo d$i
+				echo g
+				echo k$i
+			done > $TMP2
+			$PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2
+			if (cmp -s $TMP1 $TMP3) ; then :
+			else
+				echo "test13: $type/$order put failed"
+				exit 1
+			fi
+			for i in `sed 50q $DICT`; do
+				echo g
+				echo k$i
+			done > $TMP2
+			$PROG -s \
+			    -ilorder=$order -f byte.file -o $TMP3 $type $TMP2
+			if (cmp -s $TMP1 $TMP3) ; then :
+			else
+				echo "test13: $type/$order get failed"
+				exit 1
+			fi
+		done
+	done
+	rm -f byte.file
+}
+
+# Try a variety of bucketsizes and fill factors for hashing
+test20()
+{
+	echo\
+    "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536"
+	echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
+	awk '{
+		for (i = 1; i <= 10000; ++i) {
+			if (i % 34)
+				s = substr($0, 1, i % 34);
+			else
+				s = substr($0, 1);
+			printf("%s\n", s);
+		}
+		exit;
+	}' > $TMP1
+	sed 10000q $DICT |
+	awk 'BEGIN {
+		ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg"
+	}
+	{
+		if (++i % 34)
+			s = substr(ds, 1, i % 34);
+		else
+			s = substr(ds, 1);
+		printf("p\nk%s\nd%s\n", $0, s);
+	}' > $TMP2
+	sed 10000q $DICT |
+	awk '{
+		++i;
+		printf("g\nk%s\n", $0);
+	}' >> $TMP2
+	bsize=256
+	for ffactor in 11 14 21; do
+		echo "    bucketsize $bsize, fill factor $ffactor"
+		$PROG -o$TMP3 \
+		    -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
+		    hash $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test20: type hash:\
+bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
+			exit 1
+		fi
+	done
+	bsize=512
+	for ffactor in 21 28 43; do
+		echo "    bucketsize $bsize, fill factor $ffactor"
+		$PROG -o$TMP3 \
+		    -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
+		    hash $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test20: type hash:\
+bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
+			exit 1
+		fi
+	done
+	bsize=1024
+	for ffactor in 43 57 85; do
+		echo "    bucketsize $bsize, fill factor $ffactor"
+		$PROG -o$TMP3 \
+		    -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
+		    hash $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test20: type hash:\
+bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
+			exit 1
+		fi
+	done
+	bsize=2048
+	for ffactor in 85 114 171; do
+		echo "    bucketsize $bsize, fill factor $ffactor"
+		$PROG -o$TMP3 \
+		    -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
+		    hash $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test20: type hash:\
+bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
+			exit 1
+		fi
+	done
+	bsize=4096
+	for ffactor in 171 228 341; do
+		echo "    bucketsize $bsize, fill factor $ffactor"
+		$PROG -o$TMP3 \
+		    -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
+		    hash $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test20: type hash:\
+bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
+			exit 1
+		fi
+	done
+	bsize=8192
+	for ffactor in 341 455 683; do
+		echo "    bucketsize $bsize, fill factor $ffactor"
+		$PROG -o$TMP3 \
+		    -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
+		    hash $TMP2
+		if (cmp -s $TMP1 $TMP3) ; then :
+		else
+			echo "test20: type hash:\
+bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
+			exit 1
+		fi
+	done
+}
+
+main $*
Index: /vendor/FreeBSD-libc/5.3/gdtoa/README
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/README	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/README	(revision 2404)
@@ -0,0 +1,323 @@
+This directory contains source for a library of binary -> decimal
+and decimal -> binary conversion routines, for single-, double-,
+and extended-precision IEEE binary floating-point arithmetic, and
+other IEEE-like binary floating-point, including "double double",
+as in
+
+	T. J. Dekker, "A Floating-Point Technique for Extending the
+	Available Precision", Numer. Math. 18 (1971), pp. 224-242
+
+and
+
+	"Inside Macintosh: PowerPC Numerics", Addison-Wesley, 1994
+
+The conversion routines use double-precision floating-point arithmetic
+and, where necessary, high precision integer arithmetic.  The routines
+are generalizations of the strtod and dtoa routines described in
+
+	David M. Gay, "Correctly Rounded Binary-Decimal and
+	Decimal-Binary Conversions", Numerical Analysis Manuscript
+	No. 90-10, Bell Labs, Murray Hill, 1990;
+	http://cm.bell-labs.com/cm/cs/what/ampl/REFS/rounding.ps.gz
+
+(based in part on papers by Clinger and Steele & White: see the
+references in the above paper).
+
+The present conversion routines should be able to use any of IEEE binary,
+VAX, or IBM-mainframe double-precision arithmetic internally, but I (dmg)
+have so far only had a chance to test them with IEEE double precision
+arithmetic.
+
+The core conversion routines are strtodg for decimal -> binary conversions
+and gdtoa for binary -> decimal conversions.  These routines operate
+on arrays of unsigned 32-bit integers of type ULong, a signed 32-bit
+exponent of type Long, and arithmetic characteristics described in
+struct FPI; FPI, Long, and ULong are defined in gdtoa.h.  File arith.h
+is supposed to provide #defines that cause gdtoa.h to define its
+types correctly.  File arithchk.c is source for a program that
+generates a suitable arith.h on all systems where I've been able to
+test it.
+
+The core conversion routines are meant to be called by helper routines
+that know details of the particular binary arithmetic of interest and
+convert.  The present directory provides helper routines for 5 variants
+of IEEE binary floating-point arithmetic, each indicated by one or
+two letters:
+
+	f	IEEE single precision
+	d	IEEE double precision
+	x	IEEE extended precision, as on Intel 80x87
+		and software emulations of Motorola 68xxx chips
+		that do not pad the way the 68xxx does, but
+		only store 80 bits
+	xL	IEEE extended precision, as on Motorola 68xxx chips
+	Q	quad precision, as on Sun Sparc chips
+	dd	double double, pairs of IEEE double numbers
+		whose sum is the desired value
+
+For decimal -> binary conversions, there are three families of
+helper routines: one for round-nearest:
+
+	strtof
+	strtod
+	strtodd
+	strtopd
+	strtopf
+	strtopx
+	strtopxL
+	strtopQ
+
+one with rounding direction specified:
+
+	strtorf
+	strtord
+	strtordd
+	strtorx
+	strtorxL
+	strtorQ
+
+and one for computing an interval (at most one bit wide) that contains
+the decimal number:
+
+	strtoIf
+	strtoId
+	strtoIdd
+	strtoIx
+	strtoIxL
+	strtoIQ
+
+The latter call strtoIg, which makes one call on strtodg and adjusts
+the result to provide the desired interval.  On systems where native
+arithmetic can easily make one-ulp adjustments on values in the
+desired floating-point format, it might be more efficient to use the
+native arithmetic.  Routine strtodI is a variant of strtoId that
+illustrates one way to do this for IEEE binary double-precision
+arithmetic -- but whether this is more efficient remains to be seen.
+
+Functions strtod and strtof have "natural" return types, float and
+double -- strtod is specified by the C standard, and strtof appears
+in the stdlib.h of some systems, such as (at least some) Linux systems.
+The other functions write their results to their final argument(s):
+to the final two argument for the strtoI... (interval) functions,
+and to the final argument for the others (strtop... and strtor...).
+Where possible, these arguments have "natural" return types (double*
+or float*), to permit at least some type checking.  In reality, they
+are viewed as arrays of ULong (or, for the "x" functions, UShort)
+values. On systems where long double is the appropriate type, one can
+pass long double* final argument(s) to these routines.  The int value
+that these routines return is the return value from the call they make
+on strtodg; see the enum of possible return values in gdtoa.h.
+
+Source files g_ddfmt.c, misc.c, smisc.c, strtod.c, strtodg.c, and ulp.c
+should use true IEEE double arithmetic (not, e.g., double extended),
+at least for storing (and viewing the bits of) the variables declared
+"double" within them.
+
+One detail indicated in struct FPI is whether the target binary
+arithmetic departs from the IEEE standard by flushing denormalized
+numbers to 0.  On systems that do this, the helper routines for
+conversion to double-double format (when compiled with
+Sudden_Underflow #defined) penalize the bottom of the exponent
+range so that they return a nonzero result only when the least
+significant bit of the less significant member of the pair of
+double values returned can be expressed as a normalized double
+value.  An alternative would be to drop to 53-bit precision near
+the bottom of the exponent range.  To get correct rounding, this
+would (in general) require two calls on strtodg (one specifying
+126-bit arithmetic, then, if necessary, one specifying 53-bit
+arithmetic).
+
+By default, the core routine strtodg and strtod set errno to ERANGE
+if the result overflows to +Infinity or underflows to 0.  Compile
+these routines with NO_ERRNO #defined to inhibit errno assignments.
+
+Routine strtod is based on netlib's "dtoa.c from fp", and
+(f = strtod(s,se)) is more efficient for some conversions than, say,
+strtord(s,se,1,&f).  Parts of strtod require true IEEE double
+arithmetic with the default rounding mode (round-to-nearest) and, on
+systems with IEEE extended-precision registers, double-precision
+(53-bit) rounding precision.  If the machine uses (the equivalent of)
+Intel 80x87 arithmetic, the call
+	_control87(PC_53, MCW_PC);
+does this with many compilers.  Whether this or another call is
+appropriate depends on the compiler; for this to work, it may be
+necessary to #include "float.h" or another system-dependent header
+file.
+
+The values returned for NaNs may be signaling NaNs on some systems,
+since the rules for distinguishing signaling from quiet NaNs are
+system-dependent.  You can easily fix this by suitably modifying the
+ULto* routines in strtor*.c.
+
+C99's hexadecimal floating-point constants are recognized by the
+strto* routines (but this feature has not yet been heavily tested).
+Compiling with NO_HEX_FP #defined disables this feature.
+
+The strto* routines do not (yet) recognize C99's NaN(...) syntax; the
+strto* routines simply regard '(' as the first unprocessed input
+character.
+
+For binary -> decimal conversions, I've provided just one family
+of helper routines:
+
+	g_ffmt
+	g_dfmt
+	g_ddfmt
+	g_xfmt
+	g_xLfmt
+	g_Qfmt
+
+which do a "%g" style conversion either to a specified number of decimal
+places (if their ndig argument is positive), or to the shortest
+decimal string that rounds to the given binary floating-point value
+(if ndig <= 0).  They write into a buffer supplied as an argument
+and return either a pointer to the end of the string (a null character)
+in the buffer, if the buffer was long enough, or 0.  Other forms of
+conversion are easily done with the help of gdtoa(), such as %e or %f
+style and conversions with direction of rounding specified (so that, if
+desired, the decimal value is either >= or <= the binary value).
+
+For an example of more general conversions based on dtoa(), see
+netlib's "printf.c from ampl/solvers".
+
+For double-double -> decimal, g_ddfmt() assumes IEEE-like arithmetic
+of precision max(126, #bits(input)) bits, where #bits(input) is the
+number of mantissa bits needed to represent the sum of the two double
+values in the input.
+
+The makefile creates a library, gdtoa.a.  To use the helper
+routines, a program only needs to include gdtoa.h.  All the
+source files for gdtoa.a include a more extensive gdtoaimp.h;
+among other things, gdtoaimp.h has #defines that make "internal"
+names end in _D2A.  To make a "system" library, one could modify
+these #defines to make the names start with __.
+
+Various comments about possible #defines appear in gdtoaimp.h,
+but for most purposes, arith.h should set suitable #defines.
+
+Systems with preemptive scheduling of multiple threads require some
+manual intervention.  On such systems, it's necessary to compile
+dmisc.c, dtoa.c gdota.c, and misc.c with MULTIPLE_THREADS #defined,
+and to provide (or suitably #define) two locks, acquired by
+ACQUIRE_DTOA_LOCK(n) and freed by FREE_DTOA_LOCK(n) for n = 0 or 1.
+(The second lock, accessed in pow5mult, ensures lazy evaluation of
+only one copy of high powers of 5; omitting this lock would introduce
+a small probability of wasting memory, but would otherwise be harmless.)
+Routines that call dtoa or gdtoa directly must also invoke freedtoa(s)
+to free the value s returned by dtoa or gdtoa.  It's OK to do so whether
+or not MULTIPLE_THREADS is #defined, and the helper g_*fmt routines
+listed above all do this indirectly (in gfmt_D2A(), which they all call).
+
+By default, there is a private pool of memory of length 2000 bytes
+for intermediate quantities, and MALLOC (see gdtoaimp.h) is called only
+if the private pool does not suffice.   2000 is large enough that MALLOC
+is called only under very unusual circumstances (decimal -> binary
+conversion of very long strings) for conversions to and from double
+precision.  For systems with preemptivaly scheduled multiple threads
+or for conversions to extended or quad, it may be appropriate to
+#define PRIVATE_MEM nnnn, where nnnn is a suitable value > 2000.
+For extended and quad precisions, -DPRIVATE_MEM=20000 is probably
+plenty even for many digits at the ends of the exponent range.
+Use of the private pool avoids some overhead.
+
+Directory test provides some test routines.  See its README.
+I've also tested this stuff (except double double conversions)
+with Vern Paxson's testbase program: see
+
+	V. Paxson and W. Kahan, "A Program for Testing IEEE Binary-Decimal
+	Conversion", manuscript, May 1991,
+	ftp://ftp.ee.lbl.gov/testbase-report.ps.Z .
+
+(The same ftp directory has source for testbase.)
+
+Some system-dependent additions to CFLAGS in the makefile:
+
+	HU-UX: -Aa -Ae
+	OSF (DEC Unix): -ieee_with_no_inexact
+	SunOS 4.1x: -DKR_headers -DBad_float_h
+
+If you want to put this stuff into a shared library and your
+operating system requires export lists for shared libraries,
+the following would be an appropriate export list:
+
+	dtoa
+	freedtoa
+	g_Qfmt
+	g_ddfmt
+	g_dfmt
+	g_ffmt
+	g_xLfmt
+	g_xfmt
+	gdtoa
+	strtoIQ
+	strtoId
+	strtoIdd
+	strtoIf
+	strtoIx
+	strtoIxL
+	strtod
+	strtodI
+	strtodg
+	strtof
+	strtopQ
+	strtopd
+	strtopdd
+	strtopf
+	strtopx
+	strtopxL
+	strtorQ
+	strtord
+	strtordd
+	strtorf
+	strtorx
+	strtorxL
+
+When time permits, I (dmg) hope to write in more detail about the
+present conversion routines; for now, this README file must suffice.
+Meanwhile, if you wish to write helper functions for other kinds of
+IEEE-like arithmetic, some explanation of struct FPI and the bits
+array may be helpful.  Both gdtoa and strtodg operate on a bits array
+described by FPI *fpi.  The bits array is of type ULong, a 32-bit
+unsigned integer type.  Floating-point numbers have fpi->nbits bits,
+with the least significant 32 bits in bits[0], the next 32 bits in
+bits[1], etc.  These numbers are regarded as integers multiplied by
+2^e (i.e., 2 to the power of the exponent e), where e is the second
+argument (be) to gdtoa and is stored in *exp by strtodg.  The minimum
+and maximum exponent values fpi->emin and fpi->emax for normalized
+floating-point numbers reflect this arrangement.  For example, the
+P754 standard for binary IEEE arithmetic specifies doubles as having
+53 bits, with normalized values of the form 1.xxxxx... times 2^(b-1023),
+with 52 bits (the x's) and the biased exponent b represented explicitly;
+b is an unsigned integer in the range 1 <= b <= 2046 for normalized
+finite doubles, b = 0 for denormals, and b = 2047 for Infinities and NaNs.
+To turn an IEEE double into the representation used by strtodg and gdtoa,
+we multiply 1.xxxx... by 2^52 (to make it an integer) and reduce the
+exponent e = (b-1023) by 52:
+
+	fpi->emin = 1 - 1023 - 52
+	fpi->emax = 1046 - 1023 - 52
+
+In various wrappers for IEEE double, we actually write -53 + 1 rather
+than -52, to emphasize that there are 53 bits including one implicit bit.
+Field fpi->rounding indicates the desired rounding direction, with
+possible values
+	FPI_Round_zero = toward 0,
+	FPI_Round_near = unbiased rounding -- the IEEE default,
+	FPI_Round_up = toward +Infinity, and
+	FPI_Round_down = toward -Infinity
+given in gdtoa.h.
+
+Field fpi->sudden_underflow indicates whether strtodg should return
+denormals or flush them to zero.  Normal floating-point numbers have
+bit fpi->nbits in the bits array on.  Denormals have it off, with
+exponent = fpi->emin.  Strtodg provides distinct return values for normals
+and denormals; see gdtoa.h.
+
+Compiling g__fmt.c, strtod.c, and strtodg.c with -DUSE_LOCALE causes
+the decimal-point character to be taken from the current locale; otherwise
+it is '.'.
+
+Please send comments to
+
+	David M. Gay
+	dmg@acm.org
Index: /vendor/FreeBSD-libc/5.3/gdtoa/arithchk.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/arithchk.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/arithchk.c	(revision 2404)
@@ -0,0 +1,182 @@
+/****************************************************************
+Copyright (C) 1997, 1998 Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+****************************************************************/
+
+/* Try to deduce arith.h from arithmetic properties. */
+
+#include <stdio.h>
+
+ static int dalign;
+ typedef struct
+Akind {
+	char *name;
+	int   kind;
+	} Akind;
+
+ static Akind
+IEEE_8087	= { "IEEE_8087", 1 },
+IEEE_MC68k	= { "IEEE_MC68k", 2 },
+IBM		= { "IBM", 3 },
+VAX		= { "VAX", 4 },
+CRAY		= { "CRAY", 5};
+
+ static Akind *
+Lcheck()
+{
+	union {
+		double d;
+		long L[2];
+		} u;
+	struct {
+		double d;
+		long L;
+		} x[2];
+
+	if (sizeof(x) > 2*(sizeof(double) + sizeof(long)))
+		dalign = 1;
+	u.L[0] = u.L[1] = 0;
+	u.d = 1e13;
+	if (u.L[0] == 1117925532 && u.L[1] == -448790528)
+		return &IEEE_MC68k;
+	if (u.L[1] == 1117925532 && u.L[0] == -448790528)
+		return &IEEE_8087;
+	if (u.L[0] == -2065213935 && u.L[1] == 10752)
+		return &VAX;
+	if (u.L[0] == 1267827943 && u.L[1] == 704643072)
+		return &IBM;
+	return 0;
+	}
+
+ static Akind *
+icheck()
+{
+	union {
+		double d;
+		int L[2];
+		} u;
+	struct {
+		double d;
+		int L;
+		} x[2];
+
+	if (sizeof(x) > 2*(sizeof(double) + sizeof(int)))
+		dalign = 1;
+	u.L[0] = u.L[1] = 0;
+	u.d = 1e13;
+	if (u.L[0] == 1117925532 && u.L[1] == -448790528)
+		return &IEEE_MC68k;
+	if (u.L[1] == 1117925532 && u.L[0] == -448790528)
+		return &IEEE_8087;
+	if (u.L[0] == -2065213935 && u.L[1] == 10752)
+		return &VAX;
+	if (u.L[0] == 1267827943 && u.L[1] == 704643072)
+		return &IBM;
+	return 0;
+	}
+
+char *emptyfmt = "";	/* avoid possible warning message with printf("") */
+
+ static Akind *
+ccheck()
+{
+	union {
+		double d;
+		long L;
+		} u;
+	long Cray1;
+
+	/* Cray1 = 4617762693716115456 -- without overflow on non-Crays */
+	Cray1 = printf(emptyfmt) < 0 ? 0 : 4617762;
+	if (printf(emptyfmt, Cray1) >= 0)
+		Cray1 = 1000000*Cray1 + 693716;
+	if (printf(emptyfmt, Cray1) >= 0)
+		Cray1 = 1000000*Cray1 + 115456;
+	u.d = 1e13;
+	if (u.L == Cray1)
+		return &CRAY;
+	return 0;
+	}
+
+ static int
+fzcheck()
+{
+	double a, b;
+	int i;
+
+	a = 1.;
+	b = .1;
+	for(i = 155;; b *= b, i >>= 1) {
+		if (i & 1) {
+			a *= b;
+			if (i == 1)
+				break;
+			}
+		}
+	b = a * a;
+	return b == 0.;
+	}
+
+main()
+{
+	Akind *a = 0;
+	int Ldef = 0;
+	FILE *f;
+
+#ifdef WRITE_ARITH_H	/* for Symantec's buggy "make" */
+	f = fopen("arith.h", "w");
+	if (!f) {
+		printf("Cannot open arith.h\n");
+		return 1;
+		}
+#else
+	f = stdout;
+#endif
+
+	if (sizeof(double) == 2*sizeof(long))
+		a = Lcheck();
+	else if (sizeof(double) == 2*sizeof(int)) {
+		Ldef = 1;
+		a = icheck();
+		}
+	else if (sizeof(double) == sizeof(long))
+		a = ccheck();
+	if (a) {
+		fprintf(f, "#define %s\n#define Arith_Kind_ASL %d\n",
+			a->name, a->kind);
+		if (Ldef)
+			fprintf(f, "#define Long int\n#define Intcast (int)(long)\n");
+		if (dalign)
+			fprintf(f, "#define Double_Align\n");
+		if (sizeof(char*) == 8)
+			fprintf(f, "#define X64_bit_pointers\n");
+#ifndef NO_LONG_LONG
+		if (sizeof(long long) < 8)
+#endif
+			fprintf(f, "#define NO_LONG_LONG\n");
+		if (a->kind <= 2 && fzcheck())
+			fprintf(f, "#define Sudden_Underflow\n");
+		return 0;
+		}
+	fprintf(f, "/* Unknown arithmetic */\n");
+	return 1;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/dmisc.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/dmisc.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/dmisc.c	(revision 2404)
@@ -0,0 +1,222 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#ifndef MULTIPLE_THREADS
+ char *dtoa_result;
+#endif
+
+ char *
+#ifdef KR_headers
+rv_alloc(i) int i;
+#else
+rv_alloc(int i)
+#endif
+{
+	int j, k, *r;
+
+	j = sizeof(ULong);
+	for(k = 0;
+		sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
+		j <<= 1)
+			k++;
+	r = (int*)Balloc(k);
+	*r = k;
+	return
+#ifndef MULTIPLE_THREADS
+	dtoa_result =
+#endif
+		(char *)(r+1);
+	}
+
+ char *
+#ifdef KR_headers
+nrv_alloc(s, rve, n) char *s, **rve; int n;
+#else
+nrv_alloc(char *s, char **rve, int n)
+#endif
+{
+	char *rv, *t;
+
+	t = rv = rv_alloc(n);
+	while((*t = *s++) !=0)
+		t++;
+	if (rve)
+		*rve = t;
+	return rv;
+	}
+
+/* freedtoa(s) must be used to free values s returned by dtoa
+ * when MULTIPLE_THREADS is #defined.  It should be used in all cases,
+ * but for consistency with earlier versions of dtoa, it is optional
+ * when MULTIPLE_THREADS is not defined.
+ */
+
+ void
+#ifdef KR_headers
+freedtoa(s) char *s;
+#else
+freedtoa(char *s)
+#endif
+{
+	Bigint *b = (Bigint *)((int *)s - 1);
+	b->maxwds = 1 << (b->k = *(int*)b);
+	Bfree(b);
+#ifndef MULTIPLE_THREADS
+	if (s == dtoa_result)
+		dtoa_result = 0;
+#endif
+	}
+
+ int
+quorem
+#ifdef KR_headers
+	(b, S) Bigint *b, *S;
+#else
+	(Bigint *b, Bigint *S)
+#endif
+{
+	int n;
+	ULong *bx, *bxe, q, *sx, *sxe;
+#ifdef ULLong
+	ULLong borrow, carry, y, ys;
+#else
+	ULong borrow, carry, y, ys;
+#ifdef Pack_32
+	ULong si, z, zs;
+#endif
+#endif
+
+	n = S->wds;
+#ifdef DEBUG
+	/*debug*/ if (b->wds > n)
+	/*debug*/	Bug("oversize b in quorem");
+#endif
+	if (b->wds < n)
+		return 0;
+	sx = S->x;
+	sxe = sx + --n;
+	bx = b->x;
+	bxe = bx + n;
+	q = *bxe / (*sxe + 1);	/* ensure q <= true quotient */
+#ifdef DEBUG
+	/*debug*/ if (q > 9)
+	/*debug*/	Bug("oversized quotient in quorem");
+#endif
+	if (q) {
+		borrow = 0;
+		carry = 0;
+		do {
+#ifdef ULLong
+			ys = *sx++ * (ULLong)q + carry;
+			carry = ys >> 32;
+			y = *bx - (ys & 0xffffffffUL) - borrow;
+			borrow = y >> 32 & 1UL;
+			*bx++ = y & 0xffffffffUL;
+#else
+#ifdef Pack_32
+			si = *sx++;
+			ys = (si & 0xffff) * q + carry;
+			zs = (si >> 16) * q + (ys >> 16);
+			carry = zs >> 16;
+			y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
+			borrow = (y & 0x10000) >> 16;
+			z = (*bx >> 16) - (zs & 0xffff) - borrow;
+			borrow = (z & 0x10000) >> 16;
+			Storeinc(bx, z, y);
+#else
+			ys = *sx++ * q + carry;
+			carry = ys >> 16;
+			y = *bx - (ys & 0xffff) - borrow;
+			borrow = (y & 0x10000) >> 16;
+			*bx++ = y & 0xffff;
+#endif
+#endif
+			}
+			while(sx <= sxe);
+		if (!*bxe) {
+			bx = b->x;
+			while(--bxe > bx && !*bxe)
+				--n;
+			b->wds = n;
+			}
+		}
+	if (cmp(b, S) >= 0) {
+		q++;
+		borrow = 0;
+		carry = 0;
+		bx = b->x;
+		sx = S->x;
+		do {
+#ifdef ULLong
+			ys = *sx++ + carry;
+			carry = ys >> 32;
+			y = *bx - (ys & 0xffffffffUL) - borrow;
+			borrow = y >> 32 & 1UL;
+			*bx++ = y & 0xffffffffUL;
+#else
+#ifdef Pack_32
+			si = *sx++;
+			ys = (si & 0xffff) + carry;
+			zs = (si >> 16) + (ys >> 16);
+			carry = zs >> 16;
+			y = (*bx & 0xffff) - (ys & 0xffff) - borrow;
+			borrow = (y & 0x10000) >> 16;
+			z = (*bx >> 16) - (zs & 0xffff) - borrow;
+			borrow = (z & 0x10000) >> 16;
+			Storeinc(bx, z, y);
+#else
+			ys = *sx++ + carry;
+			carry = ys >> 16;
+			y = *bx - (ys & 0xffff) - borrow;
+			borrow = (y & 0x10000) >> 16;
+			*bx++ = y & 0xffff;
+#endif
+#endif
+			}
+			while(sx <= sxe);
+		bx = b->x;
+		bxe = bx + n;
+		if (!*bxe) {
+			while(--bxe > bx && !*bxe)
+				--n;
+			b->wds = n;
+			}
+		}
+	return q;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/dtoa.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/dtoa.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/dtoa.c	(revision 2404)
@@ -0,0 +1,759 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 1999 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
+ *
+ * Inspired by "How to Print Floating-Point Numbers Accurately" by
+ * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101].
+ *
+ * Modifications:
+ *	1. Rather than iterating, we use a simple numeric overestimate
+ *	   to determine k = floor(log10(d)).  We scale relevant
+ *	   quantities using O(log2(k)) rather than O(k) multiplications.
+ *	2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
+ *	   try to generate digits strictly left to right.  Instead, we
+ *	   compute with fewer bits and propagate the carry if necessary
+ *	   when rounding the final digit up.  This is often faster.
+ *	3. Under the assumption that input will be rounded nearest,
+ *	   mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
+ *	   That is, we allow equality in stopping tests when the
+ *	   round-nearest rule will give the same floating-point value
+ *	   as would satisfaction of the stopping test with strict
+ *	   inequality.
+ *	4. We remove common factors of powers of 2 from relevant
+ *	   quantities.
+ *	5. When converting floating-point integers less than 1e16,
+ *	   we use floating-point arithmetic rather than resorting
+ *	   to multiple-precision integers.
+ *	6. When asked to produce fewer than 15 digits, we first try
+ *	   to get by with floating-point arithmetic; we resort to
+ *	   multiple-precision integer arithmetic only if we cannot
+ *	   guarantee that the floating-point calculation has given
+ *	   the correctly rounded result.  For k requested digits and
+ *	   "uniformly" distributed input, the probability is
+ *	   something like 10^(k-15) that we must resort to the Long
+ *	   calculation.
+ */
+
+#ifdef Honor_FLT_ROUNDS
+#define Rounding rounding
+#undef Check_FLT_ROUNDS
+#define Check_FLT_ROUNDS
+#else
+#define Rounding Flt_Rounds
+#endif
+
+ char *
+dtoa
+#ifdef KR_headers
+	(d, mode, ndigits, decpt, sign, rve)
+	double d; int mode, ndigits, *decpt, *sign; char **rve;
+#else
+	(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
+#endif
+{
+ /*	Arguments ndigits, decpt, sign are similar to those
+	of ecvt and fcvt; trailing zeros are suppressed from
+	the returned string.  If not null, *rve is set to point
+	to the end of the return value.  If d is +-Infinity or NaN,
+	then *decpt is set to 9999.
+
+	mode:
+		0 ==> shortest string that yields d when read in
+			and rounded to nearest.
+		1 ==> like 0, but with Steele & White stopping rule;
+			e.g. with IEEE P754 arithmetic , mode 0 gives
+			1e23 whereas mode 1 gives 9.999999999999999e22.
+		2 ==> max(1,ndigits) significant digits.  This gives a
+			return value similar to that of ecvt, except
+			that trailing zeros are suppressed.
+		3 ==> through ndigits past the decimal point.  This
+			gives a return value similar to that from fcvt,
+			except that trailing zeros are suppressed, and
+			ndigits can be negative.
+		4,5 ==> similar to 2 and 3, respectively, but (in
+			round-nearest mode) with the tests of mode 0 to
+			possibly return a shorter string that rounds to d.
+			With IEEE arithmetic and compilation with
+			-DHonor_FLT_ROUNDS, modes 4 and 5 behave the same
+			as modes 2 and 3 when FLT_ROUNDS != 1.
+		6-9 ==> Debugging modes similar to mode - 4:  don't try
+			fast floating-point estimate (if applicable).
+
+		Values of mode other than 0-9 are treated as mode 0.
+
+		Sufficient space is allocated to the return value
+		to hold the suppressed trailing zeros.
+	*/
+
+	int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
+		j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
+		spec_case, try_quick;
+	Long L;
+#ifndef Sudden_Underflow
+	int denorm;
+	ULong x;
+#endif
+	Bigint *b, *b1, *delta, *mlo, *mhi, *S;
+	double d2, ds, eps;
+	char *s, *s0;
+#ifdef Honor_FLT_ROUNDS
+	int rounding;
+#endif
+#ifdef SET_INEXACT
+	int inexact, oldinexact;
+#endif
+
+#ifndef MULTIPLE_THREADS
+	if (dtoa_result) {
+		freedtoa(dtoa_result);
+		dtoa_result = 0;
+		}
+#endif
+
+	if (word0(d) & Sign_bit) {
+		/* set sign for everything, including 0's and NaNs */
+		*sign = 1;
+		word0(d) &= ~Sign_bit;	/* clear sign bit */
+		}
+	else
+		*sign = 0;
+
+#if defined(IEEE_Arith) + defined(VAX)
+#ifdef IEEE_Arith
+	if ((word0(d) & Exp_mask) == Exp_mask)
+#else
+	if (word0(d)  == 0x8000)
+#endif
+		{
+		/* Infinity or NaN */
+		*decpt = 9999;
+#ifdef IEEE_Arith
+		if (!word1(d) && !(word0(d) & 0xfffff))
+			return nrv_alloc("Infinity", rve, 8);
+#endif
+		return nrv_alloc("NaN", rve, 3);
+		}
+#endif
+#ifdef IBM
+	dval(d) += 0; /* normalize */
+#endif
+	if (!dval(d)) {
+		*decpt = 1;
+		return nrv_alloc("0", rve, 1);
+		}
+
+#ifdef SET_INEXACT
+	try_quick = oldinexact = get_inexact();
+	inexact = 1;
+#endif
+#ifdef Honor_FLT_ROUNDS
+	if ((rounding = Flt_Rounds) >= 2) {
+		if (*sign)
+			rounding = rounding == 2 ? 0 : 2;
+		else
+			if (rounding != 2)
+				rounding = 0;
+		}
+#endif
+
+	b = d2b(dval(d), &be, &bbits);
+#ifdef Sudden_Underflow
+	i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
+#else
+	if (( i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)) )!=0) {
+#endif
+		dval(d2) = dval(d);
+		word0(d2) &= Frac_mask1;
+		word0(d2) |= Exp_11;
+#ifdef IBM
+		if (( j = 11 - hi0bits(word0(d2) & Frac_mask) )!=0)
+			dval(d2) /= 1 << j;
+#endif
+
+		/* log(x)	~=~ log(1.5) + (x-1.5)/1.5
+		 * log10(x)	 =  log(x) / log(10)
+		 *		~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
+		 * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
+		 *
+		 * This suggests computing an approximation k to log10(d) by
+		 *
+		 * k = (i - Bias)*0.301029995663981
+		 *	+ ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
+		 *
+		 * We want k to be too large rather than too small.
+		 * The error in the first-order Taylor series approximation
+		 * is in our favor, so we just round up the constant enough
+		 * to compensate for any error in the multiplication of
+		 * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
+		 * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
+		 * adding 1e-13 to the constant term more than suffices.
+		 * Hence we adjust the constant term to 0.1760912590558.
+		 * (We could get a more accurate k by invoking log10,
+		 *  but this is probably not worthwhile.)
+		 */
+
+		i -= Bias;
+#ifdef IBM
+		i <<= 2;
+		i += j;
+#endif
+#ifndef Sudden_Underflow
+		denorm = 0;
+		}
+	else {
+		/* d is denormalized */
+
+		i = bbits + be + (Bias + (P-1) - 1);
+		x = i > 32  ? word0(d) << 64 - i | word1(d) >> i - 32
+			    : word1(d) << 32 - i;
+		dval(d2) = x;
+		word0(d2) -= 31*Exp_msk1; /* adjust exponent */
+		i -= (Bias + (P-1) - 1) + 1;
+		denorm = 1;
+		}
+#endif
+	ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
+	k = (int)ds;
+	if (ds < 0. && ds != k)
+		k--;	/* want k = floor(ds) */
+	k_check = 1;
+	if (k >= 0 && k <= Ten_pmax) {
+		if (dval(d) < tens[k])
+			k--;
+		k_check = 0;
+		}
+	j = bbits - i - 1;
+	if (j >= 0) {
+		b2 = 0;
+		s2 = j;
+		}
+	else {
+		b2 = -j;
+		s2 = 0;
+		}
+	if (k >= 0) {
+		b5 = 0;
+		s5 = k;
+		s2 += k;
+		}
+	else {
+		b2 -= k;
+		b5 = -k;
+		s5 = 0;
+		}
+	if (mode < 0 || mode > 9)
+		mode = 0;
+
+#ifndef SET_INEXACT
+#ifdef Check_FLT_ROUNDS
+	try_quick = Rounding == 1;
+#else
+	try_quick = 1;
+#endif
+#endif /*SET_INEXACT*/
+
+	if (mode > 5) {
+		mode -= 4;
+		try_quick = 0;
+		}
+	leftright = 1;
+	switch(mode) {
+		case 0:
+		case 1:
+			ilim = ilim1 = -1;
+			i = 18;
+			ndigits = 0;
+			break;
+		case 2:
+			leftright = 0;
+			/* no break */
+		case 4:
+			if (ndigits <= 0)
+				ndigits = 1;
+			ilim = ilim1 = i = ndigits;
+			break;
+		case 3:
+			leftright = 0;
+			/* no break */
+		case 5:
+			i = ndigits + k + 1;
+			ilim = i;
+			ilim1 = i - 1;
+			if (i <= 0)
+				i = 1;
+		}
+	s = s0 = rv_alloc(i);
+
+#ifdef Honor_FLT_ROUNDS
+	if (mode > 1 && rounding != 1)
+		leftright = 0;
+#endif
+
+	if (ilim >= 0 && ilim <= Quick_max && try_quick) {
+
+		/* Try to get by with floating-point arithmetic. */
+
+		i = 0;
+		dval(d2) = dval(d);
+		k0 = k;
+		ilim0 = ilim;
+		ieps = 2; /* conservative */
+		if (k > 0) {
+			ds = tens[k&0xf];
+			j = k >> 4;
+			if (j & Bletch) {
+				/* prevent overflows */
+				j &= Bletch - 1;
+				dval(d) /= bigtens[n_bigtens-1];
+				ieps++;
+				}
+			for(; j; j >>= 1, i++)
+				if (j & 1) {
+					ieps++;
+					ds *= bigtens[i];
+					}
+			dval(d) /= ds;
+			}
+		else if (( j1 = -k )!=0) {
+			dval(d) *= tens[j1 & 0xf];
+			for(j = j1 >> 4; j; j >>= 1, i++)
+				if (j & 1) {
+					ieps++;
+					dval(d) *= bigtens[i];
+					}
+			}
+		if (k_check && dval(d) < 1. && ilim > 0) {
+			if (ilim1 <= 0)
+				goto fast_failed;
+			ilim = ilim1;
+			k--;
+			dval(d) *= 10.;
+			ieps++;
+			}
+		dval(eps) = ieps*dval(d) + 7.;
+		word0(eps) -= (P-1)*Exp_msk1;
+		if (ilim == 0) {
+			S = mhi = 0;
+			dval(d) -= 5.;
+			if (dval(d) > dval(eps))
+				goto one_digit;
+			if (dval(d) < -dval(eps))
+				goto no_digits;
+			goto fast_failed;
+			}
+#ifndef No_leftright
+		if (leftright) {
+			/* Use Steele & White method of only
+			 * generating digits needed.
+			 */
+			dval(eps) = 0.5/tens[ilim-1] - dval(eps);
+			for(i = 0;;) {
+				L = dval(d);
+				dval(d) -= L;
+				*s++ = '0' + (int)L;
+				if (dval(d) < dval(eps))
+					goto ret1;
+				if (1. - dval(d) < dval(eps))
+					goto bump_up;
+				if (++i >= ilim)
+					break;
+				dval(eps) *= 10.;
+				dval(d) *= 10.;
+				}
+			}
+		else {
+#endif
+			/* Generate ilim digits, then fix them up. */
+			dval(eps) *= tens[ilim-1];
+			for(i = 1;; i++, dval(d) *= 10.) {
+				L = (Long)(dval(d));
+				if (!(dval(d) -= L))
+					ilim = i;
+				*s++ = '0' + (int)L;
+				if (i == ilim) {
+					if (dval(d) > 0.5 + dval(eps))
+						goto bump_up;
+					else if (dval(d) < 0.5 - dval(eps)) {
+						while(*--s == '0');
+						s++;
+						goto ret1;
+						}
+					break;
+					}
+				}
+#ifndef No_leftright
+			}
+#endif
+ fast_failed:
+		s = s0;
+		dval(d) = dval(d2);
+		k = k0;
+		ilim = ilim0;
+		}
+
+	/* Do we have a "small" integer? */
+
+	if (be >= 0 && k <= Int_max) {
+		/* Yes. */
+		ds = tens[k];
+		if (ndigits < 0 && ilim <= 0) {
+			S = mhi = 0;
+			if (ilim < 0 || dval(d) <= 5*ds)
+				goto no_digits;
+			goto one_digit;
+			}
+		for(i = 1;; i++, dval(d) *= 10.) {
+			L = (Long)(dval(d) / ds);
+			dval(d) -= L*ds;
+#ifdef Check_FLT_ROUNDS
+			/* If FLT_ROUNDS == 2, L will usually be high by 1 */
+			if (dval(d) < 0) {
+				L--;
+				dval(d) += ds;
+				}
+#endif
+			*s++ = '0' + (int)L;
+			if (!dval(d)) {
+#ifdef SET_INEXACT
+				inexact = 0;
+#endif
+				break;
+				}
+			if (i == ilim) {
+#ifdef Honor_FLT_ROUNDS
+				if (mode > 1)
+				switch(rounding) {
+				  case 0: goto ret1;
+				  case 2: goto bump_up;
+				  }
+#endif
+				dval(d) += dval(d);
+				if (dval(d) > ds || dval(d) == ds && L & 1) {
+ bump_up:
+					while(*--s == '9')
+						if (s == s0) {
+							k++;
+							*s = '0';
+							break;
+							}
+					++*s++;
+					}
+				break;
+				}
+			}
+		goto ret1;
+		}
+
+	m2 = b2;
+	m5 = b5;
+	mhi = mlo = 0;
+	if (leftright) {
+		i =
+#ifndef Sudden_Underflow
+			denorm ? be + (Bias + (P-1) - 1 + 1) :
+#endif
+#ifdef IBM
+			1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);
+#else
+			1 + P - bbits;
+#endif
+		b2 += i;
+		s2 += i;
+		mhi = i2b(1);
+		}
+	if (m2 > 0 && s2 > 0) {
+		i = m2 < s2 ? m2 : s2;
+		b2 -= i;
+		m2 -= i;
+		s2 -= i;
+		}
+	if (b5 > 0) {
+		if (leftright) {
+			if (m5 > 0) {
+				mhi = pow5mult(mhi, m5);
+				b1 = mult(mhi, b);
+				Bfree(b);
+				b = b1;
+				}
+			if (( j = b5 - m5 )!=0)
+				b = pow5mult(b, j);
+			}
+		else
+			b = pow5mult(b, b5);
+		}
+	S = i2b(1);
+	if (s5 > 0)
+		S = pow5mult(S, s5);
+
+	/* Check for special case that d is a normalized power of 2. */
+
+	spec_case = 0;
+	if ((mode < 2 || leftright)
+#ifdef Honor_FLT_ROUNDS
+			&& rounding == 1
+#endif
+				) {
+		if (!word1(d) && !(word0(d) & Bndry_mask)
+#ifndef Sudden_Underflow
+		 && word0(d) & (Exp_mask & ~Exp_msk1)
+#endif
+				) {
+			/* The special case */
+			b2 += Log2P;
+			s2 += Log2P;
+			spec_case = 1;
+			}
+		}
+
+	/* Arrange for convenient computation of quotients:
+	 * shift left if necessary so divisor has 4 leading 0 bits.
+	 *
+	 * Perhaps we should just compute leading 28 bits of S once
+	 * and for all and pass them and a shift to quorem, so it
+	 * can do shifts and ors to compute the numerator for q.
+	 */
+#ifdef Pack_32
+	if (( i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f )!=0)
+		i = 32 - i;
+#else
+	if (( i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf )!=0)
+		i = 16 - i;
+#endif
+	if (i > 4) {
+		i -= 4;
+		b2 += i;
+		m2 += i;
+		s2 += i;
+		}
+	else if (i < 4) {
+		i += 28;
+		b2 += i;
+		m2 += i;
+		s2 += i;
+		}
+	if (b2 > 0)
+		b = lshift(b, b2);
+	if (s2 > 0)
+		S = lshift(S, s2);
+	if (k_check) {
+		if (cmp(b,S) < 0) {
+			k--;
+			b = multadd(b, 10, 0);	/* we botched the k estimate */
+			if (leftright)
+				mhi = multadd(mhi, 10, 0);
+			ilim = ilim1;
+			}
+		}
+	if (ilim <= 0 && (mode == 3 || mode == 5)) {
+		if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) {
+			/* no digits, fcvt style */
+ no_digits:
+			k = -1 - ndigits;
+			goto ret;
+			}
+ one_digit:
+		*s++ = '1';
+		k++;
+		goto ret;
+		}
+	if (leftright) {
+		if (m2 > 0)
+			mhi = lshift(mhi, m2);
+
+		/* Compute mlo -- check for special case
+		 * that d is a normalized power of 2.
+		 */
+
+		mlo = mhi;
+		if (spec_case) {
+			mhi = Balloc(mhi->k);
+			Bcopy(mhi, mlo);
+			mhi = lshift(mhi, Log2P);
+			}
+
+		for(i = 1;;i++) {
+			dig = quorem(b,S) + '0';
+			/* Do we yet have the shortest decimal string
+			 * that will round to d?
+			 */
+			j = cmp(b, mlo);
+			delta = diff(S, mhi);
+			j1 = delta->sign ? 1 : cmp(b, delta);
+			Bfree(delta);
+#ifndef ROUND_BIASED
+			if (j1 == 0 && mode != 1 && !(word1(d) & 1)
+#ifdef Honor_FLT_ROUNDS
+				&& rounding >= 1
+#endif
+								   ) {
+				if (dig == '9')
+					goto round_9_up;
+				if (j > 0)
+					dig++;
+#ifdef SET_INEXACT
+				else if (!b->x[0] && b->wds <= 1)
+					inexact = 0;
+#endif
+				*s++ = dig;
+				goto ret;
+				}
+#endif
+			if (j < 0 || j == 0 && mode != 1
+#ifndef ROUND_BIASED
+							&& !(word1(d) & 1)
+#endif
+					) {
+				if (!b->x[0] && b->wds <= 1) {
+#ifdef SET_INEXACT
+					inexact = 0;
+#endif
+					goto accept_dig;
+					}
+#ifdef Honor_FLT_ROUNDS
+				if (mode > 1)
+				 switch(rounding) {
+				  case 0: goto accept_dig;
+				  case 2: goto keep_dig;
+				  }
+#endif /*Honor_FLT_ROUNDS*/
+				if (j1 > 0) {
+					b = lshift(b, 1);
+					j1 = cmp(b, S);
+					if ((j1 > 0 || j1 == 0 && dig & 1)
+					&& dig++ == '9')
+						goto round_9_up;
+					}
+ accept_dig:
+				*s++ = dig;
+				goto ret;
+				}
+			if (j1 > 0) {
+#ifdef Honor_FLT_ROUNDS
+				if (!rounding)
+					goto accept_dig;
+#endif
+				if (dig == '9') { /* possible if i == 1 */
+ round_9_up:
+					*s++ = '9';
+					goto roundoff;
+					}
+				*s++ = dig + 1;
+				goto ret;
+				}
+#ifdef Honor_FLT_ROUNDS
+ keep_dig:
+#endif
+			*s++ = dig;
+			if (i == ilim)
+				break;
+			b = multadd(b, 10, 0);
+			if (mlo == mhi)
+				mlo = mhi = multadd(mhi, 10, 0);
+			else {
+				mlo = multadd(mlo, 10, 0);
+				mhi = multadd(mhi, 10, 0);
+				}
+			}
+		}
+	else
+		for(i = 1;; i++) {
+			*s++ = dig = quorem(b,S) + '0';
+			if (!b->x[0] && b->wds <= 1) {
+#ifdef SET_INEXACT
+				inexact = 0;
+#endif
+				goto ret;
+				}
+			if (i >= ilim)
+				break;
+			b = multadd(b, 10, 0);
+			}
+
+	/* Round off last digit */
+
+#ifdef Honor_FLT_ROUNDS
+	switch(rounding) {
+	  case 0: goto trimzeros;
+	  case 2: goto roundoff;
+	  }
+#endif
+	b = lshift(b, 1);
+	j = cmp(b, S);
+	if (j > 0 || j == 0 && dig & 1) {
+ roundoff:
+		while(*--s == '9')
+			if (s == s0) {
+				k++;
+				*s++ = '1';
+				goto ret;
+				}
+		++*s++;
+		}
+	else {
+ trimzeros:
+		while(*--s == '0');
+		s++;
+		}
+ ret:
+	Bfree(S);
+	if (mhi) {
+		if (mlo && mlo != mhi)
+			Bfree(mlo);
+		Bfree(mhi);
+		}
+ ret1:
+#ifdef SET_INEXACT
+	if (inexact) {
+		if (!oldinexact) {
+			word0(d) = Exp_1 + (70 << Exp_shift);
+			word1(d) = 0;
+			dval(d) += 1.;
+			}
+		}
+	else if (!oldinexact)
+		clear_inexact();
+#endif
+	Bfree(b);
+	*s = 0;
+	*decpt = k + 1;
+	if (rve)
+		*rve = s;
+	return s0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/g_Qfmt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/g_Qfmt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/g_Qfmt.c	(revision 2404)
@@ -0,0 +1,120 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#define _3 3
+#endif
+#ifdef IEEE_8087
+#define _0 3
+#define _1 2
+#define _2 1
+#define _3 0
+#endif
+
+ char*
+#ifdef KR_headers
+g_Qfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; unsigned bufsize;
+#else
+g_Qfmt(char *buf, void *V, int ndig, unsigned bufsize)
+#endif
+{
+	static FPI fpi = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, 0 };
+	char *b, *s, *se;
+	ULong bits[4], *L, sign;
+	int decpt, ex, i, mode;
+
+	if (ndig < 0)
+		ndig = 0;
+	if (bufsize < ndig + 10)
+		return 0;
+
+	L = (ULong*)V;
+	sign = L[_0] & 0x80000000L;
+	bits[3] = L[_0] & 0xffff;
+	bits[2] = L[_1];
+	bits[1] = L[_2];
+	bits[0] = L[_3];
+	b = buf;
+	if ( (ex = (L[_0] & 0x7fff0000L) >> 16) !=0) {
+		if (ex == 0x7fff) {
+			/* Infinity or NaN */
+			if (bits[0] | bits[1] | bits[2] | bits[3])
+				b = strcpy(b, "NaN");
+			else {
+				b = buf;
+				if (sign)
+					*b++ = '-';
+				b = strcp(b, "Infinity");
+				}
+			return b;
+			}
+		i = STRTOG_Normal;
+		bits[3] |= 0x10000;
+		}
+	else if (bits[0] | bits[1] | bits[2] | bits[3]) {
+		i = STRTOG_Denormal;
+		ex = 1;
+		}
+	else {
+#ifndef IGNORE_ZERO_SIGN
+		if (sign)
+			*b++ = '-';
+#endif
+		*b++ = '0';
+		*b = 0;
+		return b;
+		}
+	ex -= 0x3fff + 112;
+	mode = 2;
+	if (ndig <= 0) {
+		if (bufsize < 48)
+			return 0;
+		mode = 0;
+		}
+	s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+	return g__fmt(buf, s, se, decpt, sign);
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/g__fmt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/g__fmt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/g__fmt.c	(revision 2404)
@@ -0,0 +1,101 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	dmg@acm.org
+ */
+
+#include "gdtoaimp.h"
+
+#ifdef USE_LOCALE
+#include "locale.h"
+#endif
+
+ char *
+#ifdef KR_headers
+g__fmt(b, s, se, decpt, sign) char *b; char *s; char *se; int decpt; ULong sign;
+#else
+g__fmt(char *b, char *s, char *se, int decpt, ULong sign)
+#endif
+{
+	int i, j, k;
+	char *s0 = s;
+#ifdef USE_LOCALE
+	char decimalpoint = *localeconv()->decimal_point;
+#else
+#define decimalpoint '.'
+#endif
+	if (sign)
+		*b++ = '-';
+	if (decpt <= -4 || decpt > se - s + 5) {
+		*b++ = *s++;
+		if (*s) {
+			*b++ = decimalpoint;
+			while((*b = *s++) !=0)
+				b++;
+			}
+		*b++ = 'e';
+		/* sprintf(b, "%+.2d", decpt - 1); */
+		if (--decpt < 0) {
+			*b++ = '-';
+			decpt = -decpt;
+			}
+		else
+			*b++ = '+';
+		for(j = 2, k = 10; 10*k <= decpt; j++, k *= 10){}
+		for(;;) {
+			i = decpt / k;
+			*b++ = i + '0';
+			if (--j <= 0)
+				break;
+			decpt -= i*k;
+			decpt *= 10;
+			}
+		*b = 0;
+		}
+	else if (decpt <= 0) {
+		*b++ = decimalpoint;
+		for(; decpt < 0; decpt++)
+			*b++ = '0';
+		while((*b = *s++) !=0)
+			b++;
+		}
+	else {
+		while((*b = *s++) !=0) {
+			b++;
+			if (--decpt == 0 && *s)
+				*b++ = decimalpoint;
+			}
+		for(; decpt > 0; decpt--)
+			*b++ = '0';
+		*b = 0;
+		}
+	freedtoa(s0);
+	return b;
+ 	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/g_ddfmt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/g_ddfmt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/g_ddfmt.c	(revision 2404)
@@ -0,0 +1,161 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+#include <string.h>
+
+ char *
+#ifdef KR_headers
+g_ddfmt(buf, dd, ndig, bufsize) char *buf; double *dd; int ndig; unsigned bufsize;
+#else
+g_ddfmt(char *buf, double *dd, int ndig, unsigned bufsize)
+#endif
+{
+	FPI fpi;
+	char *b, *s, *se;
+	ULong *L, bits0[4], *bits, *zx;
+	int bx, by, decpt, ex, ey, i, j, mode;
+	Bigint *x, *y, *z;
+	double ddx[2];
+
+	if (bufsize < 10 || bufsize < ndig + 8)
+		return 0;
+
+	L = (ULong*)dd;
+	if ((L[_0] & 0x7ff00000L) == 0x7ff00000L) {
+		/* Infinity or NaN */
+		if (L[_0] & 0xfffff || L[_1]) {
+ nanret:
+			return strcp(buf, "NaN");
+			}
+		if ((L[2+_0] & 0x7ff00000) == 0x7ff00000) {
+			if (L[2+_0] & 0xfffff || L[2+_1])
+				goto nanret;
+			if ((L[_0] ^ L[2+_0]) & 0x80000000L)
+				goto nanret;	/* Infinity - Infinity */
+			}
+ infret:
+		b = buf;
+		if (L[_0] & 0x80000000L)
+			*b++ = '-';
+		return strcp(b, "Infinity");
+		}
+	if ((L[2+_0] & 0x7ff00000) == 0x7ff00000) {
+		L += 2;
+		if (L[_0] & 0xfffff || L[_1])
+			goto nanret;
+		goto infret;
+		}
+	if (dd[0] + dd[1] == 0.) {
+		b = buf;
+#ifndef IGNORE_ZERO_SIGN
+		if (L[_0] & L[2+_0] & 0x80000000L)
+			*b++ = '-';
+#endif
+		*b++ = '0';
+		*b = 0;
+		return b;
+		}
+	if ((L[_0] & 0x7ff00000L) < (L[2+_0] & 0x7ff00000L)) {
+		ddx[1] = dd[0];
+		ddx[0] = dd[1];
+		dd = ddx;
+		L = (ULong*)dd;
+		}
+	z = d2b(dd[0], &ex, &bx);
+	if (dd[1] == 0.)
+		goto no_y;
+	x = z;
+	y = d2b(dd[1], &ey, &by);
+	if ( (i = ex - ey) !=0) {
+		if (i > 0) {
+			x = lshift(x, i);
+			ex = ey;
+			}
+		else
+			y = lshift(y, -i);
+		}
+	if ((L[_0] ^ L[2+_0]) & 0x80000000L) {
+		z = diff(x, y);
+		if (L[_0] & 0x80000000L)
+			z->sign = 1 - z->sign;
+		}
+	else {
+		z = sum(x, y);
+		if (L[_0] & 0x80000000L)
+			z->sign = 1;
+		}
+	Bfree(x);
+	Bfree(y);
+ no_y:
+	bits = zx = z->x;
+	for(i = 0; !*zx; zx++)
+		i += 32;
+	i += lo0bits(zx);
+	if (i) {
+		rshift(z, i);
+		ex += i;
+		}
+	fpi.nbits = z->wds * 32 - hi0bits(z->x[j = z->wds-1]);
+	if (fpi.nbits < 106) {
+		fpi.nbits = 106;
+		if (j < 3) {
+			for(i = 0; i <= j; i++)
+				bits0[i] = bits[i];
+			while(i < 4)
+				bits0[i++] = 0;
+			bits = bits0;
+			}
+		}
+	mode = 2;
+	if (ndig <= 0) {
+		if (bufsize < (int)(fpi.nbits * .301029995664) + 10) {
+			Bfree(z);
+			return 0;
+			}
+		mode = 0;
+		}
+	fpi.emin = 1-1023-53+1;
+	fpi.emax = 2046-1023-106+1;
+	fpi.rounding = FPI_Round_near;
+	fpi.sudden_underflow = 0;
+	i = STRTOG_Normal;
+	s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+	b = g__fmt(buf, s, se, decpt, z->sign);
+	Bfree(z);
+	return b;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/g_dfmt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/g_dfmt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/g_dfmt.c	(revision 2404)
@@ -0,0 +1,95 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ char*
+#ifdef KR_headers
+g_dfmt(buf, d, ndig, bufsize) char *buf; double *d; int ndig; unsigned bufsize;
+#else
+g_dfmt(char *buf, double *d, int ndig, unsigned bufsize)
+#endif
+{
+	static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, 0 };
+	char *b, *s, *se;
+	ULong bits[2], *L, sign;
+	int decpt, ex, i, mode;
+
+	if (ndig < 0)
+		ndig = 0;
+	if (bufsize < ndig + 10)
+		return 0;
+
+	L = (ULong*)d;
+	sign = L[_0] & 0x80000000L;
+	if ((L[_0] & 0x7ff00000) == 0x7ff00000) {
+		/* Infinity or NaN */
+		if (L[_0] & 0xfffff || L[_1]) {
+			return strcp(buf, "NaN");
+			}
+		b = buf;
+		if (sign)
+			*b++ = '-';
+		return strcp(b, "Infinity");
+		}
+	if (L[_1] == 0 && (L[_0] ^ sign) == 0 /*d == 0.*/) {
+		b = buf;
+#ifndef IGNORE_ZERO_SIGN
+		if (L[_0] & 0x80000000L)
+			*b++ = '-';
+#endif
+		*b++ = '0';
+		*b = 0;
+		return b;
+		}
+	bits[0] = L[_1];
+	bits[1] = L[_0] & 0xfffff;
+	if ( (ex = (L[_0] >> 20) & 0x7ff) !=0)
+		bits[1] |= 0x100000;
+	else
+		ex = 1;
+	ex -= 0x3ff + 52;
+	mode = 2;
+	if (ndig <= 0) {
+		if (bufsize < 25)
+			return 0;
+		mode = 0;
+		}
+	i = STRTOG_Normal;
+	s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+	return g__fmt(buf, s, se, decpt, sign);
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/g_ffmt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/g_ffmt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/g_ffmt.c	(revision 2404)
@@ -0,0 +1,94 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ char*
+#ifdef KR_headers
+g_ffmt(buf, f, ndig, bufsize) char *buf; float *f; int ndig; unsigned bufsize;
+#else
+g_ffmt(char *buf, float *f, int ndig, unsigned bufsize)
+#endif
+{
+	static FPI fpi = { 24, 1-127-24+1,  254-127-24+1, 1, 0 };
+	char *b, *s, *se;
+	ULong bits[1], *L, sign;
+	int decpt, ex, i, mode;
+
+	if (ndig < 0)
+		ndig = 0;
+	if (bufsize < ndig + 10)
+		return 0;
+
+	L = (ULong*)f;
+	sign = L[0] & 0x80000000L;
+	if ((L[0] & 0x7f800000) == 0x7f800000) {
+		/* Infinity or NaN */
+		if (L[0] & 0x7fffff) {
+			return strcp(buf, "NaN");
+			}
+		b = buf;
+		if (sign)
+			*b++ = '-';
+		return strcp(b, "Infinity");
+		}
+	if (*f == 0.) {
+		b = buf;
+#ifndef IGNORE_ZERO_SIGN
+		if (L[0] & 0x80000000L)
+			*b++ = '-';
+#endif
+		*b++ = '0';
+		*b = 0;
+		return b;
+		}
+	bits[0] = L[0] & 0x7fffff;
+	if ( (ex = (L[0] >> 23) & 0xff) !=0)
+		bits[0] |= 0x800000;
+	else
+		ex = 1;
+	ex -= 0x7f + 23;
+	mode = 2;
+	if (ndig <= 0) {
+		if (bufsize < 16)
+			return 0;
+		mode = 0;
+		}
+	i = STRTOG_Normal;
+	s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+	return g__fmt(buf, s, se, decpt, sign);
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/g_xLfmt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/g_xLfmt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/g_xLfmt.c	(revision 2404)
@@ -0,0 +1,114 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#endif
+#ifdef IEEE_8087
+#define _0 2
+#define _1 1
+#define _2 0
+#endif
+
+ char*
+#ifdef KR_headers
+g_xLfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; unsigned bufsize;
+#else
+g_xLfmt(char *buf, void *V, int ndig, unsigned bufsize)
+#endif
+{
+	static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0 };
+	char *b, *s, *se;
+	ULong bits[2], *L, sign;
+	int decpt, ex, i, mode;
+
+	if (ndig < 0)
+		ndig = 0;
+	if (bufsize < ndig + 10)
+		return 0;
+
+	L = (ULong*)V;
+	sign = L[_0] & 0x80000000L;
+	bits[1] = L[_1];
+	bits[0] = L[_2];
+	if ( (ex = (L[_0] >> 16) & 0x7fff) !=0) {
+		if (ex == 0x7fff) {
+			/* Infinity or NaN */
+			if (bits[0] | bits[1])
+				b = strcp(buf, "NaN");
+			else {
+				b = buf;
+				if (sign)
+					*b++ = '-';
+				b = strcp(b, "Infinity");
+				}
+			return b;
+			}
+		i = STRTOG_Normal;
+		}
+	else if (bits[0] | bits[1]) {
+		i = STRTOG_Denormal;
+		}
+	else {
+		b = buf;
+#ifndef IGNORE_ZERO_SIGN
+		if (sign)
+			*b++ = '-';
+#endif
+		*b++ = '0';
+		*b = 0;
+		return b;
+		}
+	ex -= 0x3fff + 63;
+	mode = 2;
+	if (ndig <= 0) {
+		if (bufsize < 32)
+			return 0;
+		mode = 0;
+		}
+	s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+	return g__fmt(buf, s, se, decpt, sign);
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/g_xfmt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/g_xfmt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/g_xfmt.c	(revision 2404)
@@ -0,0 +1,119 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#define _3 3
+#define _4 4
+#endif
+#ifdef IEEE_8087
+#define _0 4
+#define _1 3
+#define _2 2
+#define _3 1
+#define _4 0
+#endif
+
+ char*
+#ifdef KR_headers
+g_xfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; unsigned bufsize;
+#else
+g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
+#endif
+{
+	static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0 };
+	char *b, *s, *se;
+	ULong bits[2], sign;
+	UShort *L;
+	int decpt, ex, i, mode;
+
+	if (ndig < 0)
+		ndig = 0;
+	if (bufsize < ndig + 10)
+		return 0;
+
+	L = (UShort *)V;
+	sign = L[_0] & 0x8000;
+	bits[1] = (L[_1] << 16) | L[_2];
+	bits[0] = (L[_3] << 16) | L[_4];
+	if ( (ex = L[_0] & 0x7fff) !=0) {
+		if (ex == 0x7fff) {
+			/* Infinity or NaN */
+			if (bits[0] | bits[1])
+				b = strcp(buf, "NaN");
+			else {
+				b = buf;
+				if (sign)
+					*b++ = '-';
+				b = strcp(b, "Infinity");
+				}
+			return b;
+			}
+		i = STRTOG_Normal;
+		}
+	else if (bits[0] | bits[1]) {
+		i = STRTOG_Denormal;
+		}
+	else {
+		b = buf;
+#ifndef IGNORE_ZERO_SIGN
+		if (sign)
+			*b++ = '-';
+#endif
+		*b++ = '0';
+		*b = 0;
+		return b;
+		}
+	ex -= 0x3fff + 63;
+	mode = 2;
+	if (ndig <= 0) {
+		if (bufsize < 32)
+			return 0;
+		mode = 0;
+		}
+	s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se);
+	return g__fmt(buf, s, se, decpt, sign);
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/gdtoa.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/gdtoa.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/gdtoa.c	(revision 2404)
@@ -0,0 +1,764 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 1999 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ static Bigint *
+#ifdef KR_headers
+bitstob(bits, nbits, bbits) ULong *bits; int nbits; int *bbits;
+#else
+bitstob(ULong *bits, int nbits, int *bbits)
+#endif
+{
+	int i, k;
+	Bigint *b;
+	ULong *be, *x, *x0;
+
+	i = ULbits;
+	k = 0;
+	while(i < nbits) {
+		i <<= 1;
+		k++;
+		}
+#ifndef Pack_32
+	if (!k)
+		k = 1;
+#endif
+	b = Balloc(k);
+	be = bits + ((nbits - 1) >> kshift);
+	x = x0 = b->x;
+	do {
+		*x++ = *bits & ALL_ON;
+#ifdef Pack_16
+		*x++ = (*bits >> 16) & ALL_ON;
+#endif
+		} while(++bits <= be);
+	i = x - x0;
+	while(!x0[--i])
+		if (!i) {
+			b->wds = 0;
+			*bbits = 0;
+			goto ret;
+			}
+	b->wds = i + 1;
+	*bbits = i*ULbits + 32 - hi0bits(b->x[i]);
+ ret:
+	return b;
+	}
+
+/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
+ *
+ * Inspired by "How to Print Floating-Point Numbers Accurately" by
+ * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101].
+ *
+ * Modifications:
+ *	1. Rather than iterating, we use a simple numeric overestimate
+ *	   to determine k = floor(log10(d)).  We scale relevant
+ *	   quantities using O(log2(k)) rather than O(k) multiplications.
+ *	2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
+ *	   try to generate digits strictly left to right.  Instead, we
+ *	   compute with fewer bits and propagate the carry if necessary
+ *	   when rounding the final digit up.  This is often faster.
+ *	3. Under the assumption that input will be rounded nearest,
+ *	   mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
+ *	   That is, we allow equality in stopping tests when the
+ *	   round-nearest rule will give the same floating-point value
+ *	   as would satisfaction of the stopping test with strict
+ *	   inequality.
+ *	4. We remove common factors of powers of 2 from relevant
+ *	   quantities.
+ *	5. When converting floating-point integers less than 1e16,
+ *	   we use floating-point arithmetic rather than resorting
+ *	   to multiple-precision integers.
+ *	6. When asked to produce fewer than 15 digits, we first try
+ *	   to get by with floating-point arithmetic; we resort to
+ *	   multiple-precision integer arithmetic only if we cannot
+ *	   guarantee that the floating-point calculation has given
+ *	   the correctly rounded result.  For k requested digits and
+ *	   "uniformly" distributed input, the probability is
+ *	   something like 10^(k-15) that we must resort to the Long
+ *	   calculation.
+ */
+
+ char *
+gdtoa
+#ifdef KR_headers
+	(fpi, be, bits, kindp, mode, ndigits, decpt, rve)
+	FPI *fpi; int be; ULong *bits;
+	int *kindp, mode, ndigits, *decpt; char **rve;
+#else
+	(FPI *fpi, int be, ULong *bits, int *kindp, int mode, int ndigits, int *decpt, char **rve)
+#endif
+{
+ /*	Arguments ndigits and decpt are similar to the second and third
+	arguments of ecvt and fcvt; trailing zeros are suppressed from
+	the returned string.  If not null, *rve is set to point
+	to the end of the return value.  If d is +-Infinity or NaN,
+	then *decpt is set to 9999.
+
+	mode:
+		0 ==> shortest string that yields d when read in
+			and rounded to nearest.
+		1 ==> like 0, but with Steele & White stopping rule;
+			e.g. with IEEE P754 arithmetic , mode 0 gives
+			1e23 whereas mode 1 gives 9.999999999999999e22.
+		2 ==> max(1,ndigits) significant digits.  This gives a
+			return value similar to that of ecvt, except
+			that trailing zeros are suppressed.
+		3 ==> through ndigits past the decimal point.  This
+			gives a return value similar to that from fcvt,
+			except that trailing zeros are suppressed, and
+			ndigits can be negative.
+		4-9 should give the same return values as 2-3, i.e.,
+			4 <= mode <= 9 ==> same return as mode
+			2 + (mode & 1).  These modes are mainly for
+			debugging; often they run slower but sometimes
+			faster than modes 2-3.
+		4,5,8,9 ==> left-to-right digit generation.
+		6-9 ==> don't try fast floating-point estimate
+			(if applicable).
+
+		Values of mode other than 0-9 are treated as mode 0.
+
+		Sufficient space is allocated to the return value
+		to hold the suppressed trailing zeros.
+	*/
+
+	int bbits, b2, b5, be0, dig, i, ieps, ilim, ilim0, ilim1, inex;
+	int j, j1, k, k0, k_check, kind, leftright, m2, m5, nbits;
+	int rdir, s2, s5, spec_case, try_quick;
+	Long L;
+	Bigint *b, *b1, *delta, *mlo, *mhi, *mhi1, *S;
+	double d, d2, ds, eps;
+	char *s, *s0;
+
+#ifndef MULTIPLE_THREADS
+	if (dtoa_result) {
+		freedtoa(dtoa_result);
+		dtoa_result = 0;
+		}
+#endif
+	inex = 0;
+	kind = *kindp &= ~STRTOG_Inexact;
+	switch(kind & STRTOG_Retmask) {
+	  case STRTOG_Zero:
+		goto ret_zero;
+	  case STRTOG_Normal:
+	  case STRTOG_Denormal:
+		break;
+	  case STRTOG_Infinite:
+		*decpt = -32768;
+		return nrv_alloc("Infinity", rve, 8);
+	  case STRTOG_NaN:
+		*decpt = -32768;
+		return nrv_alloc("NaN", rve, 3);
+	  default:
+		return 0;
+	  }
+	b = bitstob(bits, nbits = fpi->nbits, &bbits);
+	be0 = be;
+	if ( (i = trailz(b)) !=0) {
+		rshift(b, i);
+		be += i;
+		bbits -= i;
+		}
+	if (!b->wds) {
+		Bfree(b);
+ ret_zero:
+		*decpt = 1;
+		return nrv_alloc("0", rve, 1);
+		}
+
+	dval(d) = b2d(b, &i);
+	i = be + bbits - 1;
+	word0(d) &= Frac_mask1;
+	word0(d) |= Exp_11;
+#ifdef IBM
+	if ( (j = 11 - hi0bits(word0(d) & Frac_mask)) !=0)
+		dval(d) /= 1 << j;
+#endif
+
+	/* log(x)	~=~ log(1.5) + (x-1.5)/1.5
+	 * log10(x)	 =  log(x) / log(10)
+	 *		~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
+	 * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
+	 *
+	 * This suggests computing an approximation k to log10(d) by
+	 *
+	 * k = (i - Bias)*0.301029995663981
+	 *	+ ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
+	 *
+	 * We want k to be too large rather than too small.
+	 * The error in the first-order Taylor series approximation
+	 * is in our favor, so we just round up the constant enough
+	 * to compensate for any error in the multiplication of
+	 * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
+	 * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
+	 * adding 1e-13 to the constant term more than suffices.
+	 * Hence we adjust the constant term to 0.1760912590558.
+	 * (We could get a more accurate k by invoking log10,
+	 *  but this is probably not worthwhile.)
+	 */
+#ifdef IBM
+	i <<= 2;
+	i += j;
+#endif
+	ds = (dval(d)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
+
+	/* correct assumption about exponent range */
+	if ((j = i) < 0)
+		j = -j;
+	if ((j -= 1077) > 0)
+		ds += j * 7e-17;
+
+	k = (int)ds;
+	if (ds < 0. && ds != k)
+		k--;	/* want k = floor(ds) */
+	k_check = 1;
+#ifdef IBM
+	j = be + bbits - 1;
+	if ( (j1 = j & 3) !=0)
+		dval(d) *= 1 << j1;
+	word0(d) += j << Exp_shift - 2 & Exp_mask;
+#else
+	word0(d) += (be + bbits - 1) << Exp_shift;
+#endif
+	if (k >= 0 && k <= Ten_pmax) {
+		if (dval(d) < tens[k])
+			k--;
+		k_check = 0;
+		}
+	j = bbits - i - 1;
+	if (j >= 0) {
+		b2 = 0;
+		s2 = j;
+		}
+	else {
+		b2 = -j;
+		s2 = 0;
+		}
+	if (k >= 0) {
+		b5 = 0;
+		s5 = k;
+		s2 += k;
+		}
+	else {
+		b2 -= k;
+		b5 = -k;
+		s5 = 0;
+		}
+	if (mode < 0 || mode > 9)
+		mode = 0;
+	try_quick = 1;
+	if (mode > 5) {
+		mode -= 4;
+		try_quick = 0;
+		}
+	leftright = 1;
+	switch(mode) {
+		case 0:
+		case 1:
+			ilim = ilim1 = -1;
+			i = (int)(nbits * .30103) + 3;
+			ndigits = 0;
+			break;
+		case 2:
+			leftright = 0;
+			/* no break */
+		case 4:
+			if (ndigits <= 0)
+				ndigits = 1;
+			ilim = ilim1 = i = ndigits;
+			break;
+		case 3:
+			leftright = 0;
+			/* no break */
+		case 5:
+			i = ndigits + k + 1;
+			ilim = i;
+			ilim1 = i - 1;
+			if (i <= 0)
+				i = 1;
+		}
+	s = s0 = rv_alloc(i);
+
+	if ( (rdir = fpi->rounding - 1) !=0) {
+		if (rdir < 0)
+			rdir = 2;
+		if (kind & STRTOG_Neg)
+			rdir = 3 - rdir;
+		}
+
+	/* Now rdir = 0 ==> round near, 1 ==> round up, 2 ==> round down. */
+
+	if (ilim >= 0 && ilim <= Quick_max && try_quick && !rdir
+#ifndef IMPRECISE_INEXACT
+		&& k == 0
+#endif
+								) {
+
+		/* Try to get by with floating-point arithmetic. */
+
+		i = 0;
+		d2 = dval(d);
+#ifdef IBM
+		if ( (j = 11 - hi0bits(word0(d) & Frac_mask)) !=0)
+			dval(d) /= 1 << j;
+#endif
+		k0 = k;
+		ilim0 = ilim;
+		ieps = 2; /* conservative */
+		if (k > 0) {
+			ds = tens[k&0xf];
+			j = k >> 4;
+			if (j & Bletch) {
+				/* prevent overflows */
+				j &= Bletch - 1;
+				dval(d) /= bigtens[n_bigtens-1];
+				ieps++;
+				}
+			for(; j; j >>= 1, i++)
+				if (j & 1) {
+					ieps++;
+					ds *= bigtens[i];
+					}
+			}
+		else  {
+			ds = 1.;
+			if ( (j1 = -k) !=0) {
+				dval(d) *= tens[j1 & 0xf];
+				for(j = j1 >> 4; j; j >>= 1, i++)
+					if (j & 1) {
+						ieps++;
+						dval(d) *= bigtens[i];
+						}
+				}
+			}
+		if (k_check && dval(d) < 1. && ilim > 0) {
+			if (ilim1 <= 0)
+				goto fast_failed;
+			ilim = ilim1;
+			k--;
+			dval(d) *= 10.;
+			ieps++;
+			}
+		dval(eps) = ieps*dval(d) + 7.;
+		word0(eps) -= (P-1)*Exp_msk1;
+		if (ilim == 0) {
+			S = mhi = 0;
+			dval(d) -= 5.;
+			if (dval(d) > dval(eps))
+				goto one_digit;
+			if (dval(d) < -dval(eps))
+				goto no_digits;
+			goto fast_failed;
+			}
+#ifndef No_leftright
+		if (leftright) {
+			/* Use Steele & White method of only
+			 * generating digits needed.
+			 */
+			dval(eps) = ds*0.5/tens[ilim-1] - dval(eps);
+			for(i = 0;;) {
+				L = (Long)(dval(d)/ds);
+				dval(d) -= L*ds;
+				*s++ = '0' + (int)L;
+				if (dval(d) < dval(eps)) {
+					if (dval(d))
+						inex = STRTOG_Inexlo;
+					goto ret1;
+					}
+				if (ds - dval(d) < dval(eps))
+					goto bump_up;
+				if (++i >= ilim)
+					break;
+				dval(eps) *= 10.;
+				dval(d) *= 10.;
+				}
+			}
+		else {
+#endif
+			/* Generate ilim digits, then fix them up. */
+			dval(eps) *= tens[ilim-1];
+			for(i = 1;; i++, dval(d) *= 10.) {
+				if ( (L = (Long)(dval(d)/ds)) !=0)
+					dval(d) -= L*ds;
+				*s++ = '0' + (int)L;
+				if (i == ilim) {
+					ds *= 0.5;
+					if (dval(d) > ds + dval(eps))
+						goto bump_up;
+					else if (dval(d) < ds - dval(eps)) {
+						while(*--s == '0'){}
+						s++;
+						if (dval(d))
+							inex = STRTOG_Inexlo;
+						goto ret1;
+						}
+					break;
+					}
+				}
+#ifndef No_leftright
+			}
+#endif
+ fast_failed:
+		s = s0;
+		dval(d) = d2;
+		k = k0;
+		ilim = ilim0;
+		}
+
+	/* Do we have a "small" integer? */
+
+	if (be >= 0 && k <= Int_max) {
+		/* Yes. */
+		ds = tens[k];
+		if (ndigits < 0 && ilim <= 0) {
+			S = mhi = 0;
+			if (ilim < 0 || dval(d) <= 5*ds)
+				goto no_digits;
+			goto one_digit;
+			}
+		for(i = 1;; i++, dval(d) *= 10.) {
+			L = dval(d) / ds;
+			dval(d) -= L*ds;
+#ifdef Check_FLT_ROUNDS
+			/* If FLT_ROUNDS == 2, L will usually be high by 1 */
+			if (dval(d) < 0) {
+				L--;
+				dval(d) += ds;
+				}
+#endif
+			*s++ = '0' + (int)L;
+			if (dval(d) == 0.)
+				break;
+			if (i == ilim) {
+				if (rdir) {
+					if (rdir == 1)
+						goto bump_up;
+					inex = STRTOG_Inexlo;
+					goto ret1;
+					}
+				dval(d) += dval(d);
+				if (dval(d) > ds || dval(d) == ds && L & 1) {
+ bump_up:
+					inex = STRTOG_Inexhi;
+					while(*--s == '9')
+						if (s == s0) {
+							k++;
+							*s = '0';
+							break;
+							}
+					++*s++;
+					}
+				else
+					inex = STRTOG_Inexlo;
+				break;
+				}
+			}
+		goto ret1;
+		}
+
+	m2 = b2;
+	m5 = b5;
+	mhi = mlo = 0;
+	if (leftright) {
+		if (mode < 2) {
+			i = nbits - bbits;
+			if (be - i++ < fpi->emin)
+				/* denormal */
+				i = be - fpi->emin + 1;
+			}
+		else {
+			j = ilim - 1;
+			if (m5 >= j)
+				m5 -= j;
+			else {
+				s5 += j -= m5;
+				b5 += j;
+				m5 = 0;
+				}
+			if ((i = ilim) < 0) {
+				m2 -= i;
+				i = 0;
+				}
+			}
+		b2 += i;
+		s2 += i;
+		mhi = i2b(1);
+		}
+	if (m2 > 0 && s2 > 0) {
+		i = m2 < s2 ? m2 : s2;
+		b2 -= i;
+		m2 -= i;
+		s2 -= i;
+		}
+	if (b5 > 0) {
+		if (leftright) {
+			if (m5 > 0) {
+				mhi = pow5mult(mhi, m5);
+				b1 = mult(mhi, b);
+				Bfree(b);
+				b = b1;
+				}
+			if ( (j = b5 - m5) !=0)
+				b = pow5mult(b, j);
+			}
+		else
+			b = pow5mult(b, b5);
+		}
+	S = i2b(1);
+	if (s5 > 0)
+		S = pow5mult(S, s5);
+
+	/* Check for special case that d is a normalized power of 2. */
+
+	spec_case = 0;
+	if (mode < 2) {
+		if (bbits == 1 && be0 > fpi->emin + 1) {
+			/* The special case */
+			b2++;
+			s2++;
+			spec_case = 1;
+			}
+		}
+
+	/* Arrange for convenient computation of quotients:
+	 * shift left if necessary so divisor has 4 leading 0 bits.
+	 *
+	 * Perhaps we should just compute leading 28 bits of S once
+	 * and for all and pass them and a shift to quorem, so it
+	 * can do shifts and ors to compute the numerator for q.
+	 */
+#ifdef Pack_32
+	if ( (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) !=0)
+		i = 32 - i;
+#else
+	if ( (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) !=0)
+		i = 16 - i;
+#endif
+	if (i > 4) {
+		i -= 4;
+		b2 += i;
+		m2 += i;
+		s2 += i;
+		}
+	else if (i < 4) {
+		i += 28;
+		b2 += i;
+		m2 += i;
+		s2 += i;
+		}
+	if (b2 > 0)
+		b = lshift(b, b2);
+	if (s2 > 0)
+		S = lshift(S, s2);
+	if (k_check) {
+		if (cmp(b,S) < 0) {
+			k--;
+			b = multadd(b, 10, 0);	/* we botched the k estimate */
+			if (leftright)
+				mhi = multadd(mhi, 10, 0);
+			ilim = ilim1;
+			}
+		}
+	if (ilim <= 0 && mode > 2) {
+		if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) {
+			/* no digits, fcvt style */
+ no_digits:
+			k = -1 - ndigits;
+			inex = STRTOG_Inexlo;
+			goto ret;
+			}
+ one_digit:
+		inex = STRTOG_Inexhi;
+		*s++ = '1';
+		k++;
+		goto ret;
+		}
+	if (leftright) {
+		if (m2 > 0)
+			mhi = lshift(mhi, m2);
+
+		/* Compute mlo -- check for special case
+		 * that d is a normalized power of 2.
+		 */
+
+		mlo = mhi;
+		if (spec_case) {
+			mhi = Balloc(mhi->k);
+			Bcopy(mhi, mlo);
+			mhi = lshift(mhi, 1);
+			}
+
+		for(i = 1;;i++) {
+			dig = quorem(b,S) + '0';
+			/* Do we yet have the shortest decimal string
+			 * that will round to d?
+			 */
+			j = cmp(b, mlo);
+			delta = diff(S, mhi);
+			j1 = delta->sign ? 1 : cmp(b, delta);
+			Bfree(delta);
+#ifndef ROUND_BIASED
+			if (j1 == 0 && !mode && !(bits[0] & 1) && !rdir) {
+				if (dig == '9')
+					goto round_9_up;
+				if (j <= 0) {
+					if (b->wds > 1 || b->x[0])
+						inex = STRTOG_Inexlo;
+					}
+				else {
+					dig++;
+					inex = STRTOG_Inexhi;
+					}
+				*s++ = dig;
+				goto ret;
+				}
+#endif
+			if (j < 0 || j == 0 && !mode
+#ifndef ROUND_BIASED
+							&& !(bits[0] & 1)
+#endif
+					) {
+				if (rdir && (b->wds > 1 || b->x[0])) {
+					if (rdir == 2) {
+						inex = STRTOG_Inexlo;
+						goto accept;
+						}
+					while (cmp(S,mhi) > 0) {
+						*s++ = dig;
+						mhi1 = multadd(mhi, 10, 0);
+						if (mlo == mhi)
+							mlo = mhi1;
+						mhi = mhi1;
+						b = multadd(b, 10, 0);
+						dig = quorem(b,S) + '0';
+						}
+					if (dig++ == '9')
+						goto round_9_up;
+					inex = STRTOG_Inexhi;
+					goto accept;
+					}
+				if (j1 > 0) {
+					b = lshift(b, 1);
+					j1 = cmp(b, S);
+					if ((j1 > 0 || j1 == 0 && dig & 1)
+					&& dig++ == '9')
+						goto round_9_up;
+					inex = STRTOG_Inexhi;
+					}
+				if (b->wds > 1 || b->x[0])
+					inex = STRTOG_Inexlo;
+ accept:
+				*s++ = dig;
+				goto ret;
+				}
+			if (j1 > 0 && rdir != 2) {
+				if (dig == '9') { /* possible if i == 1 */
+ round_9_up:
+					*s++ = '9';
+					inex = STRTOG_Inexhi;
+					goto roundoff;
+					}
+				inex = STRTOG_Inexhi;
+				*s++ = dig + 1;
+				goto ret;
+				}
+			*s++ = dig;
+			if (i == ilim)
+				break;
+			b = multadd(b, 10, 0);
+			if (mlo == mhi)
+				mlo = mhi = multadd(mhi, 10, 0);
+			else {
+				mlo = multadd(mlo, 10, 0);
+				mhi = multadd(mhi, 10, 0);
+				}
+			}
+		}
+	else
+		for(i = 1;; i++) {
+			*s++ = dig = quorem(b,S) + '0';
+			if (i >= ilim)
+				break;
+			b = multadd(b, 10, 0);
+			}
+
+	/* Round off last digit */
+
+	if (rdir) {
+		if (rdir == 2 || b->wds <= 1 && !b->x[0])
+			goto chopzeros;
+		goto roundoff;
+		}
+	b = lshift(b, 1);
+	j = cmp(b, S);
+	if (j > 0 || j == 0 && dig & 1) {
+ roundoff:
+		inex = STRTOG_Inexhi;
+		while(*--s == '9')
+			if (s == s0) {
+				k++;
+				*s++ = '1';
+				goto ret;
+				}
+		++*s++;
+		}
+	else {
+ chopzeros:
+		if (b->wds > 1 || b->x[0])
+			inex = STRTOG_Inexlo;
+		while(*--s == '0'){}
+		s++;
+		}
+ ret:
+	Bfree(S);
+	if (mhi) {
+		if (mlo && mlo != mhi)
+			Bfree(mlo);
+		Bfree(mhi);
+		}
+ ret1:
+	Bfree(b);
+	*s = 0;
+	*decpt = k + 1;
+	if (rve)
+		*rve = s;
+	*kindp |= inex;
+	return s0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/gdtoa.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/gdtoa.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/gdtoa.h	(revision 2404)
@@ -0,0 +1,159 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#ifndef GDTOA_H_INCLUDED
+#define GDTOA_H_INCLUDED
+
+#include "arith.h"
+
+#ifndef Long
+#define Long long
+#endif
+#ifndef ULong
+typedef unsigned Long ULong;
+#endif
+#ifndef UShort
+typedef unsigned short UShort;
+#endif
+
+#ifndef ANSI
+#ifdef KR_headers
+#define ANSI(x) ()
+#define Void /*nothing*/
+#else
+#define ANSI(x) x
+#define Void void
+#endif
+#endif /* ANSI */
+
+#ifndef CONST
+#ifdef KR_headers
+#define CONST /* blank */
+#else
+#define CONST const
+#endif
+#endif /* CONST */
+
+ enum {	/* return values from strtodg */
+	STRTOG_Zero	= 0,
+	STRTOG_Normal	= 1,
+	STRTOG_Denormal	= 2,
+	STRTOG_Infinite	= 3,
+	STRTOG_NaN	= 4,
+	STRTOG_NaNbits	= 5,
+	STRTOG_NoNumber	= 6,
+	STRTOG_Retmask	= 7,
+
+	/* The following may be or-ed into one of the above values. */
+
+	STRTOG_Neg	= 0x08,
+	STRTOG_Inexlo	= 0x10,
+	STRTOG_Inexhi	= 0x20,
+	STRTOG_Inexact	= 0x30,
+	STRTOG_Underflow= 0x40,
+	STRTOG_Overflow	= 0x80
+	};
+
+ typedef struct
+FPI {
+	int nbits;
+	int emin;
+	int emax;
+	int rounding;
+	int sudden_underflow;
+	} FPI;
+
+enum {	/* FPI.rounding values: same as FLT_ROUNDS */
+	FPI_Round_zero = 0,
+	FPI_Round_near = 1,
+	FPI_Round_up = 2,
+	FPI_Round_down = 3
+	};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern char* dtoa  ANSI((double d, int mode, int ndigits, int *decpt,
+			int *sign, char **rve));
+extern char* gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp,
+			int mode, int ndigits, int *decpt, char **rve));
+extern void freedtoa ANSI((char*));
+extern float  strtof ANSI((CONST char *, char **));
+extern double strtod ANSI((CONST char *, char **));
+extern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*));
+
+extern char*	g_ddfmt  ANSI((char*, double*, int, unsigned));
+extern char*	g_dfmt   ANSI((char*, double*, int, unsigned));
+extern char*	g_ffmt   ANSI((char*, float*,  int, unsigned));
+extern char*	g_Qfmt   ANSI((char*, void*,   int, unsigned));
+extern char*	g_xfmt   ANSI((char*, void*,   int, unsigned));
+extern char*	g_xLfmt  ANSI((char*, void*,   int, unsigned));
+
+extern int	strtoId  ANSI((CONST char*, char**, double*, double*));
+extern int	strtoIdd ANSI((CONST char*, char**, double*, double*));
+extern int	strtoIf  ANSI((CONST char*, char**, float*, float*));
+extern int	strtoIQ  ANSI((CONST char*, char**, void*, void*));
+extern int	strtoIx  ANSI((CONST char*, char**, void*, void*));
+extern int	strtoIxL ANSI((CONST char*, char**, void*, void*));
+extern int	strtord  ANSI((CONST char*, char**, int, double*));
+extern int	strtordd ANSI((CONST char*, char**, int, double*));
+extern int	strtorf  ANSI((CONST char*, char**, int, float*));
+extern int	strtorQ  ANSI((CONST char*, char**, int, void*));
+extern int	strtorx  ANSI((CONST char*, char**, int, void*));
+extern int	strtorxL ANSI((CONST char*, char**, int, void*));
+#if 1
+extern int	strtodI  ANSI((CONST char*, char**, double*));
+extern int	strtopd  ANSI((CONST char*, char**, double*));
+extern int	strtopdd ANSI((CONST char*, char**, double*));
+extern int	strtopf  ANSI((CONST char*, char**, float*));
+extern int	strtopQ  ANSI((CONST char*, char**, void*));
+extern int	strtopx  ANSI((CONST char*, char**, void*));
+extern int	strtopxL ANSI((CONST char*, char**, void*));
+#else
+#define strtopd(s,se,x) strtord(s,se,1,x)
+#define strtopdd(s,se,x) strtordd(s,se,1,x)
+#define strtopf(s,se,x) strtorf(s,se,1,x)
+#define strtopQ(s,se,x) strtorQ(s,se,1,x)
+#define strtopx(s,se,x) strtorx(s,se,1,x)
+#define strtopxL(s,se,x) strtorxL(s,se,1,x)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* GDTOA_H_INCLUDED */
Index: /vendor/FreeBSD-libc/5.3/gdtoa/gdtoaimp.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/gdtoaimp.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/gdtoaimp.h	(revision 2404)
@@ -0,0 +1,692 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* $FreeBSD: src/contrib/gdtoa/gdtoaimp.h,v 1.7 2005/01/18 18:56:18 das Exp $ */
+
+/* This is a variation on dtoa.c that converts arbitary binary
+   floating-point formats to and from decimal notation.  It uses
+   double-precision arithmetic internally, so there are still
+   various #ifdefs that adapt the calculations to the native
+   double-precision arithmetic (any of IEEE, VAX D_floating,
+   or IBM mainframe arithmetic).
+
+   Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* On a machine with IEEE extended-precision registers, it is
+ * necessary to specify double-precision (53-bit) rounding precision
+ * before invoking strtod or dtoa.  If the machine uses (the equivalent
+ * of) Intel 80x87 arithmetic, the call
+ *	_control87(PC_53, MCW_PC);
+ * does this with many compilers.  Whether this or another call is
+ * appropriate depends on the compiler; for this to work, it may be
+ * necessary to #include "float.h" or another system-dependent header
+ * file.
+ */
+
+/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
+ *
+ * This strtod returns a nearest machine number to the input decimal
+ * string (or sets errno to ERANGE).  With IEEE arithmetic, ties are
+ * broken by the IEEE round-even rule.  Otherwise ties are broken by
+ * biased rounding (add half and chop).
+ *
+ * Inspired loosely by William D. Clinger's paper "How to Read Floating
+ * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
+ *
+ * Modifications:
+ *
+ *	1. We only require IEEE, IBM, or VAX double-precision
+ *		arithmetic (not IEEE double-extended).
+ *	2. We get by with floating-point arithmetic in a case that
+ *		Clinger missed -- when we're computing d * 10^n
+ *		for a small integer d and the integer n is not too
+ *		much larger than 22 (the maximum integer k for which
+ *		we can represent 10^k exactly), we may be able to
+ *		compute (d*10^k) * 10^(e-k) with just one roundoff.
+ *	3. Rather than a bit-at-a-time adjustment of the binary
+ *		result in the hard case, we use floating-point
+ *		arithmetic to determine the adjustment to within
+ *		one bit; only in really hard cases do we need to
+ *		compute a second residual.
+ *	4. Because of 3., we don't need a large table of powers of 10
+ *		for ten-to-e (just some small tables, e.g. of 10^k
+ *		for 0 <= k <= 22).
+ */
+
+/*
+ * #define IEEE_8087 for IEEE-arithmetic machines where the least
+ *	significant byte has the lowest address.
+ * #define IEEE_MC68k for IEEE-arithmetic machines where the most
+ *	significant byte has the lowest address.
+ * #define Long int on machines with 32-bit ints and 64-bit longs.
+ * #define Sudden_Underflow for IEEE-format machines without gradual
+ *	underflow (i.e., that flush to zero on underflow).
+ * #define IBM for IBM mainframe-style floating-point arithmetic.
+ * #define VAX for VAX-style floating-point arithmetic (D_floating).
+ * #define No_leftright to omit left-right logic in fast floating-point
+ *	computation of dtoa.
+ * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.
+ * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
+ *	that use extended-precision instructions to compute rounded
+ *	products and quotients) with IBM.
+ * #define ROUND_BIASED for IEEE-format with biased rounding.
+ * #define Inaccurate_Divide for IEEE-format with correctly rounded
+ *	products but inaccurate quotients, e.g., for Intel i860.
+ * #define NO_LONG_LONG on machines that do not have a "long long"
+ *	integer type (of >= 64 bits).  On such machines, you can
+ *	#define Just_16 to store 16 bits per 32-bit Long when doing
+ *	high-precision integer arithmetic.  Whether this speeds things
+ *	up or slows things down depends on the machine and the number
+ *	being converted.  If long long is available and the name is
+ *	something other than "long long", #define Llong to be the name,
+ *	and if "unsigned Llong" does not work as an unsigned version of
+ *	Llong, #define #ULLong to be the corresponding unsigned type.
+ * #define KR_headers for old-style C function headers.
+ * #define Bad_float_h if your system lacks a float.h or if it does not
+ *	define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
+ *	FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
+ * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
+ *	if memory is available and otherwise does something you deem
+ *	appropriate.  If MALLOC is undefined, malloc will be invoked
+ *	directly -- and assumed always to succeed.
+ * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
+ *	memory allocations from a private pool of memory when possible.
+ *	When used, the private pool is PRIVATE_MEM bytes long:  2304 bytes,
+ *	unless #defined to be a different length.  This default length
+ *	suffices to get rid of MALLOC calls except for unusual cases,
+ *	such as decimal-to-binary conversion of a very long string of
+ *	digits.  When converting IEEE double precision values, the
+ *	longest string gdtoa can return is about 751 bytes long.  For
+ *	conversions by strtod of strings of 800 digits and all gdtoa
+ *	conversions of IEEE doubles in single-threaded executions with
+ *	8-byte pointers, PRIVATE_MEM >= 7400 appears to suffice; with
+ *	4-byte pointers, PRIVATE_MEM >= 7112 appears adequate.
+ * #define INFNAN_CHECK on IEEE systems to cause strtod to check for
+ *	Infinity and NaN (case insensitively).  On some systems (e.g.,
+ *	some HP systems), it may be necessary to #define NAN_WORD0
+ *	appropriately -- to the most significant word of a quiet NaN.
+ *	(On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
+ *	When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,
+ *	strtodg also accepts (case insensitively) strings of the form
+ *	NaN(x), where x is a string of hexadecimal digits and spaces;
+ *	if there is only one string of hexadecimal digits, it is taken
+ *	for the fraction bits of the resulting NaN; if there are two or
+ *	more strings of hexadecimal digits, each string is assigned
+ *	to the next available sequence of 32-bit words of fractions
+ *	bits (starting with the most significant), right-aligned in
+ *	each sequence.
+ * #define MULTIPLE_THREADS if the system offers preemptively scheduled
+ *	multiple threads.  In this case, you must provide (or suitably
+ *	#define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
+ *	by FREE_DTOA_LOCK(n) for n = 0 or 1.  (The second lock, accessed
+ *	in pow5mult, ensures lazy evaluation of only one copy of high
+ *	powers of 5; omitting this lock would introduce a small
+ *	probability of wasting memory, but would otherwise be harmless.)
+ *	You must also invoke freedtoa(s) to free the value s returned by
+ *	dtoa.  You may do so whether or not MULTIPLE_THREADS is #defined.
+ * #define IMPRECISE_INEXACT if you do not care about the setting of
+ *	the STRTOG_Inexact bits in the special case of doing IEEE double
+ *	precision conversions (which could also be done by the strtog in
+ *	dtoa.c).
+ * #define NO_HEX_FP to disable recognition of C9x's hexadecimal
+ *	floating-point constants.
+ * #define -DNO_ERRNO to suppress setting errno (in strtod.c and
+ *	strtodg.c).
+ * #define NO_STRING_H to use private versions of memcpy.
+ *	On some K&R systems, it may also be necessary to
+ *	#define DECLARE_SIZE_T in this case.
+ * #define YES_ALIAS to permit aliasing certain double values with
+ *	arrays of ULongs.  This leads to slightly better code with
+ *	some compilers and was always used prior to 19990916, but it
+ *	is not strictly legal and can cause trouble with aggressively
+ *	optimizing compilers (e.g., gcc 2.95.1 under -O2).
+ * #define USE_LOCALE to use the current locale's decimal_point value.
+ */
+
+#ifndef GDTOAIMP_H_INCLUDED
+#define GDTOAIMP_H_INCLUDED
+#include "gdtoa.h"
+
+#ifdef DEBUG
+#include "stdio.h"
+#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
+#endif
+
+#include "limits.h"
+#include "stdlib.h"
+#include "string.h"
+#include "libc_private.h"
+
+#include "namespace.h"
+#include <pthread.h>
+#include "un-namespace.h"
+
+#ifdef KR_headers
+#define Char char
+#else
+#define Char void
+#endif
+
+#ifdef MALLOC
+extern Char *MALLOC ANSI((size_t));
+#else
+#define MALLOC malloc
+#endif
+
+#define INFNAN_CHECK
+#define USE_LOCALE
+#define Honor_FLT_ROUNDS
+
+#undef IEEE_Arith
+#undef Avoid_Underflow
+#ifdef IEEE_MC68k
+#define IEEE_Arith
+#endif
+#ifdef IEEE_8087
+#define IEEE_Arith
+#endif
+
+#include "errno.h"
+#ifdef Bad_float_h
+
+#ifdef IEEE_Arith
+#define DBL_DIG 15
+#define DBL_MAX_10_EXP 308
+#define DBL_MAX_EXP 1024
+#define FLT_RADIX 2
+#define DBL_MAX 1.7976931348623157e+308
+#endif
+
+#ifdef IBM
+#define DBL_DIG 16
+#define DBL_MAX_10_EXP 75
+#define DBL_MAX_EXP 63
+#define FLT_RADIX 16
+#define DBL_MAX 7.2370055773322621e+75
+#endif
+
+#ifdef VAX
+#define DBL_DIG 16
+#define DBL_MAX_10_EXP 38
+#define DBL_MAX_EXP 127
+#define FLT_RADIX 2
+#define DBL_MAX 1.7014118346046923e+38
+#define n_bigtens 2
+#endif
+
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647
+#endif
+
+#else /* ifndef Bad_float_h */
+#include "float.h"
+#endif /* Bad_float_h */
+
+#ifdef IEEE_Arith
+#define Scale_Bit 0x10
+#define n_bigtens 5
+#endif
+
+#ifdef IBM
+#define n_bigtens 3
+#endif
+
+#ifdef VAX
+#define n_bigtens 2
+#endif
+
+#ifndef __MATH_H__
+#include "math.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
+Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
+#endif
+
+typedef union { double d; ULong L[2]; } U;
+
+#ifdef YES_ALIAS
+#define dval(x) x
+#ifdef IEEE_8087
+#define word0(x) ((ULong *)&x)[1]
+#define word1(x) ((ULong *)&x)[0]
+#else
+#define word0(x) ((ULong *)&x)[0]
+#define word1(x) ((ULong *)&x)[1]
+#endif
+#else /* !YES_ALIAS */
+#ifdef IEEE_8087
+#define word0(x) ((U*)&x)->L[1]
+#define word1(x) ((U*)&x)->L[0]
+#else
+#define word0(x) ((U*)&x)->L[0]
+#define word1(x) ((U*)&x)->L[1]
+#endif
+#define dval(x) ((U*)&x)->d
+#endif /* YES_ALIAS */
+
+/* The following definition of Storeinc is appropriate for MIPS processors.
+ * An alternative that might be better on some machines is
+ * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
+ */
+#if defined(IEEE_8087) + defined(VAX)
+#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
+((unsigned short *)a)[0] = (unsigned short)c, a++)
+#else
+#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
+((unsigned short *)a)[1] = (unsigned short)c, a++)
+#endif
+
+/* #define P DBL_MANT_DIG */
+/* Ten_pmax = floor(P*log(2)/log(5)) */
+/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
+/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
+/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
+
+#ifdef IEEE_Arith
+#define Exp_shift  20
+#define Exp_shift1 20
+#define Exp_msk1    0x100000
+#define Exp_msk11   0x100000
+#define Exp_mask  0x7ff00000
+#define P 53
+#define Bias 1023
+#define Emin (-1022)
+#define Exp_1  0x3ff00000
+#define Exp_11 0x3ff00000
+#define Ebits 11
+#define Frac_mask  0xfffff
+#define Frac_mask1 0xfffff
+#define Ten_pmax 22
+#define Bletch 0x10
+#define Bndry_mask  0xfffff
+#define Bndry_mask1 0xfffff
+#define LSB 1
+#define Sign_bit 0x80000000
+#define Log2P 1
+#define Tiny0 0
+#define Tiny1 1
+#define Quick_max 14
+#define Int_max 14
+
+#ifndef Flt_Rounds
+#ifdef FLT_ROUNDS
+#define Flt_Rounds FLT_ROUNDS
+#else
+#define Flt_Rounds 1
+#endif
+#endif /*Flt_Rounds*/
+
+#else /* ifndef IEEE_Arith */
+#undef  Sudden_Underflow
+#define Sudden_Underflow
+#ifdef IBM
+#undef Flt_Rounds
+#define Flt_Rounds 0
+#define Exp_shift  24
+#define Exp_shift1 24
+#define Exp_msk1   0x1000000
+#define Exp_msk11  0x1000000
+#define Exp_mask  0x7f000000
+#define P 14
+#define Bias 65
+#define Exp_1  0x41000000
+#define Exp_11 0x41000000
+#define Ebits 8	/* exponent has 7 bits, but 8 is the right value in b2d */
+#define Frac_mask  0xffffff
+#define Frac_mask1 0xffffff
+#define Bletch 4
+#define Ten_pmax 22
+#define Bndry_mask  0xefffff
+#define Bndry_mask1 0xffffff
+#define LSB 1
+#define Sign_bit 0x80000000
+#define Log2P 4
+#define Tiny0 0x100000
+#define Tiny1 0
+#define Quick_max 14
+#define Int_max 15
+#else /* VAX */
+#undef Flt_Rounds
+#define Flt_Rounds 1
+#define Exp_shift  23
+#define Exp_shift1 7
+#define Exp_msk1    0x80
+#define Exp_msk11   0x800000
+#define Exp_mask  0x7f80
+#define P 56
+#define Bias 129
+#define Exp_1  0x40800000
+#define Exp_11 0x4080
+#define Ebits 8
+#define Frac_mask  0x7fffff
+#define Frac_mask1 0xffff007f
+#define Ten_pmax 24
+#define Bletch 2
+#define Bndry_mask  0xffff007f
+#define Bndry_mask1 0xffff007f
+#define LSB 0x10000
+#define Sign_bit 0x8000
+#define Log2P 1
+#define Tiny0 0x80
+#define Tiny1 0
+#define Quick_max 15
+#define Int_max 15
+#endif /* IBM, VAX */
+#endif /* IEEE_Arith */
+
+#ifndef IEEE_Arith
+#define ROUND_BIASED
+#endif
+
+#ifdef RND_PRODQUOT
+#define rounded_product(a,b) a = rnd_prod(a, b)
+#define rounded_quotient(a,b) a = rnd_quot(a, b)
+#ifdef KR_headers
+extern double rnd_prod(), rnd_quot();
+#else
+extern double rnd_prod(double, double), rnd_quot(double, double);
+#endif
+#else
+#define rounded_product(a,b) a *= b
+#define rounded_quotient(a,b) a /= b
+#endif
+
+#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
+#define Big1 0xffffffff
+
+#undef  Pack_16
+#ifndef Pack_32
+#define Pack_32
+#endif
+
+#ifdef NO_LONG_LONG
+#undef ULLong
+#ifdef Just_16
+#undef Pack_32
+#define Pack_16
+/* When Pack_32 is not defined, we store 16 bits per 32-bit Long.
+ * This makes some inner loops simpler and sometimes saves work
+ * during multiplications, but it often seems to make things slightly
+ * slower.  Hence the default is now to store 32 bits per Long.
+ */
+#endif
+#else	/* long long available */
+#ifndef Llong
+#define Llong long long
+#endif
+#ifndef ULLong
+#define ULLong unsigned Llong
+#endif
+#endif /* NO_LONG_LONG */
+
+#ifdef Pack_32
+#define ULbits 32
+#define kshift 5
+#define kmask 31
+#define ALL_ON 0xffffffff
+#else
+#define ULbits 16
+#define kshift 4
+#define kmask 15
+#define ALL_ON 0xffff
+#endif
+
+#define MULTIPLE_THREADS
+extern pthread_mutex_t __gdtoa_locks[2];
+#define ACQUIRE_DTOA_LOCK(n)	do {				\
+	if (__isthreaded)					\
+		_pthread_mutex_lock(&__gdtoa_locks[n]);		\
+} while(0)
+#define FREE_DTOA_LOCK(n)	do {				\
+	if (__isthreaded)					\
+		_pthread_mutex_unlock(&__gdtoa_locks[n]);	\
+} while(0)
+
+#define Kmax 15
+
+ struct
+Bigint {
+	struct Bigint *next;
+	int k, maxwds, sign, wds;
+	ULong x[1];
+	};
+
+ typedef struct Bigint Bigint;
+
+#ifdef NO_STRING_H
+#ifdef DECLARE_SIZE_T
+typedef unsigned int size_t;
+#endif
+extern void memcpy_D2A ANSI((void*, const void*, size_t));
+#define Bcopy(x,y) memcpy_D2A(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))
+#else /* !NO_STRING_H */
+#define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))
+#endif /* NO_STRING_H */
+
+/*
+ * Paranoia: Protect exported symbols, including ones in files we don't
+ * compile right now.  The standard strtof and strtod survive.
+ */
+#define	dtoa		__dtoa
+#define	gdtoa		__gdtoa
+#define	freedtoa	__freedtoa
+#define	strtodg		__strtodg
+#define	g_ddfmt		__g_ddfmt
+#define	g_dfmt		__g_dfmt
+#define	g_ffmt		__g_ffmt
+#define	g_Qfmt		__g_Qfmt
+#define	g_xfmt		__g_xfmt
+#define	g_xLfmt		__g_xLfmt
+#define	strtoId		__strtoId
+#define	strtoIdd	__strtoIdd
+#define	strtoIf		__strtoIf
+#define	strtoIQ		__strtoIQ
+#define	strtoIx		__strtoIx
+#define	strtoIxL	__strtoIxL
+#define	strtord		__strtord
+#define	strtordd	__strtordd
+#define	strtorf		__strtorf
+#define	strtorQ		__strtorQ
+#define	strtorx		__strtorx
+#define	strtorxL	__strtorxL
+#define	strtodI		__strtodI
+#define	strtopd		__strtopd
+#define	strtopdd	__strtopdd
+#define	strtopf		__strtopf
+#define	strtopQ		__strtopQ
+#define	strtopx		__strtopx
+#define	strtopxL	__strtopxL
+
+/* Protect gdtoa-internal symbols */
+#define	Balloc		__Balloc_D2A
+#define	Bfree		__Bfree_D2A
+#define	ULtoQ		__ULtoQ_D2A
+#define	ULtof		__ULtof_D2A
+#define	ULtod		__ULtod_D2A
+#define	ULtodd		__ULtodd_D2A
+#define	ULtox		__ULtox_D2A
+#define	ULtoxL		__ULtoxL_D2A
+#define	any_on		__any_on_D2A
+#define	b2d		__b2d_D2A
+#define	bigtens		__bigtens_D2A
+#define	cmp		__cmp_D2A
+#define	copybits	__copybits_D2A
+#define	d2b		__d2b_D2A
+#define	decrement	__decrement_D2A
+#define	diff		__diff_D2A
+#define	dtoa_result	__dtoa_result_D2A
+#define	g__fmt		__g__fmt_D2A
+#define	gethex		__gethex_D2A
+#define	hexdig		__hexdig_D2A
+#define	hexdig_init_D2A	__hexdig_init_D2A
+#define	hexnan		__hexnan_D2A
+#define	hi0bits		__hi0bits_D2A
+#define	i2b		__i2b_D2A
+#define	increment	__increment_D2A
+#define	lo0bits		__lo0bits_D2A
+#define	lshift		__lshift_D2A
+#define	match		__match_D2A
+#define	mult		__mult_D2A
+#define	multadd		__multadd_D2A
+#define	nrv_alloc	__nrv_alloc_D2A
+#define	pow5mult	__pow5mult_D2A
+#define	quorem		__quorem_D2A
+#define	ratio		__ratio_D2A
+#define	rshift		__rshift_D2A
+#define	rv_alloc	__rv_alloc_D2A
+#define	s2b		__s2b_D2A
+#define	set_ones	__set_ones_D2A
+#define	strcp		__strcp_D2A
+#define	strcp_D2A      	__strcp_D2A
+#define	strtoIg		__strtoIg_D2A
+#define	sum		__sum_D2A
+#define	tens		__tens_D2A
+#define	tinytens	__tinytens_D2A
+#define	tinytens	__tinytens_D2A
+#define	trailz		__trailz_D2A
+#define	ulp		__ulp_D2A
+
+ extern char *dtoa_result;
+ extern CONST double bigtens[], tens[], tinytens[];
+ extern unsigned char hexdig[];
+
+ extern Bigint *Balloc ANSI((int));
+ extern void Bfree ANSI((Bigint*));
+ extern void ULtof ANSI((ULong*, ULong*, Long, int));
+ extern void ULtod ANSI((ULong*, ULong*, Long, int));
+ extern void ULtodd ANSI((ULong*, ULong*, Long, int));
+ extern void ULtoQ ANSI((ULong*, ULong*, Long, int));
+ extern void ULtox ANSI((UShort*, ULong*, Long, int));
+ extern void ULtoxL ANSI((ULong*, ULong*, Long, int));
+ extern ULong any_on ANSI((Bigint*, int));
+ extern double b2d ANSI((Bigint*, int*));
+ extern int cmp ANSI((Bigint*, Bigint*));
+ extern void copybits ANSI((ULong*, int, Bigint*));
+ extern Bigint *d2b ANSI((double, int*, int*));
+ extern int decrement ANSI((Bigint*));
+ extern Bigint *diff ANSI((Bigint*, Bigint*));
+ extern char *dtoa ANSI((double d, int mode, int ndigits,
+			int *decpt, int *sign, char **rve));
+ extern void freedtoa ANSI((char*));
+ extern char *gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp,
+			  int mode, int ndigits, int *decpt, char **rve));
+ extern char *g__fmt ANSI((char*, char*, char*, int, ULong));
+ extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int));
+ extern void hexdig_init_D2A(Void);
+ extern int hexnan ANSI((CONST char**, FPI*, ULong*));
+ extern int hi0bits ANSI((ULong));
+ extern Bigint *i2b ANSI((int));
+ extern Bigint *increment ANSI((Bigint*));
+ extern int lo0bits ANSI((ULong*));
+ extern Bigint *lshift ANSI((Bigint*, int));
+ extern int match ANSI((CONST char**, char*));
+ extern Bigint *mult ANSI((Bigint*, Bigint*));
+ extern Bigint *multadd ANSI((Bigint*, int, int));
+ extern char *nrv_alloc ANSI((char*, char **, int));
+ extern Bigint *pow5mult ANSI((Bigint*, int));
+ extern int quorem ANSI((Bigint*, Bigint*));
+ extern double ratio ANSI((Bigint*, Bigint*));
+ extern void rshift ANSI((Bigint*, int));
+ extern char *rv_alloc ANSI((int));
+ extern Bigint *s2b ANSI((CONST char*, int, int, ULong));
+ extern Bigint *set_ones ANSI((Bigint*, int));
+ extern char *strcp ANSI((char*, const char*));
+ extern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*));
+
+ extern int strtoId ANSI((CONST char *, char **, double *, double *));
+ extern int strtoIdd ANSI((CONST char *, char **, double *, double *));
+ extern int strtoIf ANSI((CONST char *, char **, float *, float *));
+ extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*));
+ extern int strtoIQ ANSI((CONST char *, char **, void *, void *));
+ extern int strtoIx ANSI((CONST char *, char **, void *, void *));
+ extern int strtoIxL ANSI((CONST char *, char **, void *, void *));
+ extern double strtod ANSI((const char *s00, char **se));
+ extern int strtopQ ANSI((CONST char *, char **, Void *));
+ extern int strtopf ANSI((CONST char *, char **, float *));
+ extern int strtopd ANSI((CONST char *, char **, double *));
+ extern int strtopdd ANSI((CONST char *, char **, double *));
+ extern int strtopx ANSI((CONST char *, char **, Void *));
+ extern int strtopxL ANSI((CONST char *, char **, Void *));
+ extern int strtord ANSI((CONST char *, char **, int, double *));
+ extern int strtordd ANSI((CONST char *, char **, int, double *));
+ extern int strtorf ANSI((CONST char *, char **, int, float *));
+ extern int strtorQ ANSI((CONST char *, char **, int, void *));
+ extern int strtorx ANSI((CONST char *, char **, int, void *));
+ extern int strtorxL ANSI((CONST char *, char **, int, void *));
+ extern Bigint *sum ANSI((Bigint*, Bigint*));
+ extern int trailz ANSI((Bigint*));
+ extern double ulp ANSI((double));
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifdef IEEE_Arith
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#else
+#define _0 1
+#define _1 0
+#endif
+#else
+#undef INFNAN_CHECK
+#endif
+
+#ifdef INFNAN_CHECK
+
+#ifndef NAN_WORD0
+#define NAN_WORD0 0x7ff80000
+#endif
+
+#ifndef NAN_WORD1
+#define NAN_WORD1 0
+#endif
+#endif	/* INFNAN_CHECK */
+
+#undef SI
+#ifdef Sudden_Underflow
+#define SI 1
+#else
+#define SI 0
+#endif
+
+#endif /* GDTOAIMP_H_INCLUDED */
Index: /vendor/FreeBSD-libc/5.3/gdtoa/gethex.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/gethex.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/gethex.c	(revision 2404)
@@ -0,0 +1,249 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	dmg@acm.org
+ */
+
+#include "gdtoaimp.h"
+
+#ifdef USE_LOCALE
+#include "locale.h"
+#endif
+
+ int
+#ifdef KR_headers
+gethex(sp, fpi, exp, bp, sign)
+	CONST char **sp; FPI *fpi; Long *exp; Bigint **bp; int sign;
+#else
+gethex( CONST char **sp, FPI *fpi, Long *exp, Bigint **bp, int sign)
+#endif
+{
+	Bigint *b;
+	CONST unsigned char *decpt, *s0, *s, *s1;
+	int esign, havedig, irv, k, n, nbits, up;
+	ULong L, lostbits, *x;
+	Long e, e1;
+#ifdef USE_LOCALE
+	unsigned char decimalpoint = *localeconv()->decimal_point;
+#else
+#define decimalpoint '.'
+#endif
+
+	if (!hexdig['0'])
+		hexdig_init_D2A();
+	havedig = 0;
+	s0 = *(CONST unsigned char **)sp + 2;
+	while(s0[havedig] == '0')
+		havedig++;
+	s0 += havedig;
+	s = s0;
+	decpt = 0;
+	if (!hexdig[*s]) {
+		if (*s == decimalpoint) {
+			decpt = ++s;
+			if (!hexdig[*s])
+				goto ret0;
+			}
+		else {
+ ret0:
+			*sp = (char*)s;
+			return havedig ? STRTOG_Zero : STRTOG_NoNumber;
+			}
+		while(*s == '0')
+			s++;
+		havedig = 1;
+		if (!hexdig[*s])
+			goto ret0;
+		s0 = s;
+		}
+	while(hexdig[*s])
+		s++;
+	if (*s == decimalpoint && !decpt) {
+		decpt = ++s;
+		while(hexdig[*s])
+			s++;
+		}
+	e = 0;
+	if (decpt)
+		e = -(((Long)(s-decpt)) << 2);
+	s1 = s;
+	switch(*s) {
+	  case 'p':
+	  case 'P':
+		esign = 0;
+		switch(*++s) {
+		  case '-':
+			esign = 1;
+			/* no break */
+		  case '+':
+			s++;
+		  }
+		if ((n = hexdig[*s]) == 0 || n > 0x19) {
+			s = s1;
+			break;
+			}
+		e1 = n - 0x10;
+		while((n = hexdig[*++s]) !=0 && n <= 0x19)
+			e1 = 10*e1 + n - 0x10;
+		if (esign)
+			e1 = -e1;
+		e += e1;
+	  }
+	*sp = (char*)s;
+	n = s1 - s0 - 1;
+	for(k = 0; n > 7; n >>= 1)
+		k++;
+	b = Balloc(k);
+	x = b->x;
+	n = 0;
+	L = 0;
+	while(s1 > s0) {
+		if (*--s1 == decimalpoint)
+			continue;
+		if (n == 32) {
+			*x++ = L;
+			L = 0;
+			n = 0;
+			}
+		L |= (hexdig[*s1] & 0x0f) << n;
+		n += 4;
+		}
+	*x++ = L;
+	b->wds = n = x - b->x;
+	n = 32*n - hi0bits(L);
+	nbits = fpi->nbits;
+	lostbits = 0;
+	x = b->x;
+	if (n > nbits) {
+		n -= nbits;
+		if (any_on(b,n)) {
+			lostbits = 1;
+			k = n - 1;
+			if (x[k>>kshift] & 1 << (k & kmask)) {
+				lostbits = 2;
+				if (k > 1 && any_on(b,k-1))
+					lostbits = 3;
+				}
+			}
+		rshift(b, n);
+		e += n;
+		}
+	else if (n < nbits) {
+		n = nbits - n;
+		b = lshift(b, n);
+		e -= n;
+		x = b->x;
+		}
+	if (e > fpi->emax) {
+ ovfl:
+		Bfree(b);
+		*bp = 0;
+		return STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi;
+		}
+	irv = STRTOG_Normal;
+	if (e < fpi->emin) {
+		irv = STRTOG_Denormal;
+		n = fpi->emin - e;
+		if (n >= nbits) {
+			switch (fpi->rounding) {
+			  case FPI_Round_near:
+				if (n == nbits && (n < 2 || any_on(b,n-1)))
+					goto one_bit;
+				break;
+			  case FPI_Round_up:
+				if (!sign)
+					goto one_bit;
+				break;
+			  case FPI_Round_down:
+				if (sign) {
+ one_bit:
+					*exp = fpi->emin;
+					x[0] = b->wds = 1;
+					*bp = b;
+					return STRTOG_Denormal | STRTOG_Inexhi
+						| STRTOG_Underflow;
+					}
+			  }
+			Bfree(b);
+			*bp = 0;
+			return STRTOG_Zero | STRTOG_Inexlo | STRTOG_Underflow;
+			}
+		k = n - 1;
+		if (lostbits)
+			lostbits = 1;
+		else if (k > 0)
+			lostbits = any_on(b,k);
+		if (x[k>>kshift] & 1 << (k & kmask))
+			lostbits |= 2;
+		nbits -= n;
+		rshift(b,n);
+		e = fpi->emin;
+		}
+	if (lostbits) {
+		up = 0;
+		switch(fpi->rounding) {
+		  case FPI_Round_zero:
+			break;
+		  case FPI_Round_near:
+			if (lostbits & 2
+			 && (lostbits & 1) | x[0] & 1)
+				up = 1;
+			break;
+		  case FPI_Round_up:
+			up = 1 - sign;
+			break;
+		  case FPI_Round_down:
+			up = sign;
+		  }
+		if (up) {
+			k = b->wds;
+			b = increment(b);
+			x = b->x;
+			if (irv == STRTOG_Denormal) {
+				if (nbits == fpi->nbits - 1
+				 && x[nbits >> kshift] & 1 << (nbits & kmask))
+					irv =  STRTOG_Normal;
+				}
+			else if (b->wds > k
+			 || (n = nbits & kmask) !=0
+			     && hi0bits(x[k-1]) < 32-n) {
+				rshift(b,1);
+				if (++e > fpi->emax)
+					goto ovfl;
+				}
+			irv |= STRTOG_Inexhi;
+			}
+		else
+			irv |= STRTOG_Inexlo;
+		}
+	*bp = b;
+	*exp = e;
+	return irv;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/glue/Makefile.inc
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/glue/Makefile.inc	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/glue/Makefile.inc	(revision 2404)
@@ -0,0 +1,21 @@
+# $FreeBSD: src/lib/libc/gdtoa/Makefile.inc,v 1.6 2004/01/18 10:32:49 das Exp $
+
+# netlib gdtoa sources
+.PATH: ${.CURDIR}/gdtoa
+
+MISRCS+=_hdtoa.c _ldtoa.c glue.c
+GDTOASRCS=dmisc.c dtoa.c gdtoa.c gethex.c gmisc.c \
+	hd_init.c hexnan.c misc.c smisc.c \
+	strtoIg.c strtod.c strtodg.c strtof.c strtord.c sum.c ulp.c
+.if exists(${.CURDIR}/${MACHINE_ARCH}/stdlib/gdtoa.mk)
+.include "${.CURDIR}/${MACHINE_ARCH}/stdlib/gdtoa.mk"
+.endif
+
+CFLAGS+=-I${.CURDIR}/../../contrib/gdtoa
+
+.for src in ${GDTOASRCS}
+MISRCS+=gdtoa_${src}
+CLEANFILES+=gdtoa_${src}
+gdtoa_${src}:
+	ln -sf ${.CURDIR}/../../contrib/gdtoa/${src} ${.TARGET}
+.endfor
Index: /vendor/FreeBSD-libc/5.3/gdtoa/glue/_hdtoa.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/glue/_hdtoa.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/glue/_hdtoa.c	(revision 2404)
@@ -0,0 +1,432 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gdtoa/_hdtoa.c,v 1.2 2004/01/21 04:51:50 grehan Exp $");
+
+#include <float.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <math.h>
+#include <stdlib.h>
+#include "fpmath.h"
+#include "gdtoaimp.h"
+
+/* Strings values used by dtoa() */
+#define	INFSTR	"Infinity"
+#define	NANSTR	"NaN"
+
+#define	DBL_BIAS	(DBL_MAX_EXP - 1)
+#define	LDBL_BIAS	(LDBL_MAX_EXP - 1)
+
+#ifdef	LDBL_IMPLICIT_NBIT
+#define	LDBL_NBIT_ADJ	0
+#else
+#define	LDBL_NBIT_ADJ	1
+#endif
+
+/*
+ * Efficiently compute the log2 of an integer.  Uses a combination of
+ * arcane tricks found in fortune and arcane tricks not (yet) in
+ * fortune.  This routine behaves similarly to fls(9).
+ */
+static int
+log2_32(uint32_t n)
+{
+
+        n |= (n >> 1);
+        n |= (n >> 2);
+        n |= (n >> 4);
+        n |= (n >> 8);
+        n |= (n >> 16);
+
+	n = (n & 0x55555555) + ((n & 0xaaaaaaaa) >> 1);
+	n = (n & 0x33333333) + ((n & 0xcccccccc) >> 2);
+	n = (n & 0x0f0f0f0f) + ((n & 0xf0f0f0f0) >> 4);
+	n = (n & 0x00ff00ff) + ((n & 0xff00ff00) >> 8);
+	n = (n & 0x0000ffff) + ((n & 0xffff0000) >> 16);
+	return (n - 1);
+}
+
+#if (LDBL_MANH_SIZE > 32 || LDBL_MANL_SIZE > 32)
+
+static int
+log2_64(uint64_t n)
+{
+
+	if (n >> 32 != 0)
+		return (log2_32((uint32_t)(n >> 32)) + 32);
+	else
+		return (log2_32((uint32_t)n));
+}
+
+#endif	/* (LDBL_MANH_SIZE > 32 || LDBL_MANL_SIZE > 32) */
+
+/*
+ * Round up the given digit string.  If the digit string is fff...f,
+ * this procedure sets it to 100...0 and returns 1 to indicate that
+ * the exponent needs to be bumped.  Otherwise, 0 is returned.
+ */
+static int
+roundup(char *s0, int ndigits)
+{
+	char *s;
+
+	for (s = s0 + ndigits - 1; *s == 0xf; s--) {
+		if (s == s0) {
+			*s = 1;
+			return (1);
+		}
+		++*s;
+	}
+	++*s;
+	return (0);
+}
+
+/*
+ * Round the given digit string to ndigits digits according to the
+ * current rounding mode.  Note that this could produce a string whose
+ * value is not representable in the corresponding floating-point
+ * type.  The exponent pointed to by decpt is adjusted if necessary.
+ */
+static void
+dorounding(char *s0, int ndigits, int sign, int *decpt)
+{
+	int adjust = 0;	/* do we need to adjust the exponent? */
+
+	switch (FLT_ROUNDS) {
+	case 0:		/* toward zero */
+	default:	/* implementation-defined */
+		break;
+	case 1:		/* to nearest, halfway rounds to even */
+		if ((s0[ndigits] > 8) ||
+		    (s0[ndigits] == 8 && s0[ndigits - 1] & 1))
+			adjust = roundup(s0, ndigits);
+		break;
+	case 2:		/* toward +inf */
+		if (sign == 0)
+			adjust = roundup(s0, ndigits);
+		break;
+	case 3:		/* toward -inf */
+		if (sign != 0)
+			adjust = roundup(s0, ndigits);
+		break;
+	}
+
+	if (adjust)
+		*decpt += 4;
+}
+
+/*
+ * This procedure converts a double-precision number in IEEE format
+ * into a string of hexadecimal digits and an exponent of 2.  Its
+ * behavior is bug-for-bug compatible with dtoa() in mode 2, with the
+ * following exceptions:
+ *
+ * - An ndigits < 0 causes it to use as many digits as necessary to
+ *   represent the number exactly.
+ * - The additional xdigs argument should point to either the string
+ *   "0123456789ABCDEF" or the string "0123456789abcdef", depending on
+ *   which case is desired.
+ * - This routine does not repeat dtoa's mistake of setting decpt
+ *   to 9999 in the case of an infinity or NaN.  INT_MAX is used
+ *   for this purpose instead.
+ *
+ * Note that the C99 standard does not specify what the leading digit
+ * should be for non-zero numbers.  For instance, 0x1.3p3 is the same
+ * as 0x2.6p2 is the same as 0x4.cp3.  This implementation chooses the
+ * first digit so that subsequent digits are aligned on nibble
+ * boundaries (before rounding).
+ *
+ * Inputs:	d, xdigs, ndigits
+ * Outputs:	decpt, sign, rve
+ */
+char *
+__hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign,
+    char **rve)
+{
+	union IEEEd2bits u;
+	char *s, *s0;
+	int bufsize;
+	int impnbit;	/* implicit normalization bit */
+	int pos;
+	int shift;	/* for subnormals, # of shifts required to normalize */
+	int sigfigs;	/* number of significant hex figures in result */
+
+	u.d = d;
+	*sign = u.bits.sign;
+
+	switch (fpclassify(d)) {
+	case FP_NORMAL:
+		sigfigs = (DBL_MANT_DIG + 3) / 4;
+		impnbit = 1 << ((DBL_MANT_DIG - 1) % 4);
+		*decpt = u.bits.exp - DBL_BIAS + 1 -
+		    ((DBL_MANT_DIG - 1) % 4);
+		break;
+	case FP_ZERO:
+		*decpt = 1;
+		return (nrv_alloc("0", rve, 1));
+	case FP_SUBNORMAL:
+		/*
+		 * The position of the highest-order bit tells us by
+		 * how much to adjust the exponent (decpt).  The
+		 * adjustment is raised to the next nibble boundary
+		 * since we will later choose the leftmost hexadecimal
+		 * digit so that all subsequent digits align on nibble
+		 * boundaries.
+		 */
+		if (u.bits.manh != 0) {
+			pos = log2_32(u.bits.manh);
+			shift = DBL_MANH_SIZE - pos;
+		} else {
+			pos = log2_32(u.bits.manl);
+			shift = DBL_MANH_SIZE + DBL_MANL_SIZE - pos;
+		}
+		sigfigs = (3 + DBL_MANT_DIG - shift) / 4;
+		impnbit = 0;
+		*decpt = DBL_MIN_EXP - ((shift + 3) & ~(4 - 1));
+		break;
+	case FP_INFINITE:
+		*decpt = INT_MAX;
+		return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1));
+	case FP_NAN:
+		*decpt = INT_MAX;
+		return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1));
+	default:
+		abort();
+	}
+
+	/* FP_NORMAL or FP_SUBNORMAL */
+
+	if (ndigits == 0)		/* dtoa() compatibility */
+		ndigits = 1;
+
+	/*
+	 * For simplicity, we generate all the digits even if the
+	 * caller has requested fewer.
+	 */
+	bufsize = (sigfigs > ndigits) ? sigfigs : ndigits;
+	s0 = rv_alloc(bufsize);
+
+	/*
+	 * We work from right to left, first adding any requested zero
+	 * padding, then the least significant portion of the
+	 * mantissa, followed by the most significant.  The buffer is
+	 * filled with the byte values 0x0 through 0xf, which are
+	 * converted to xdigs[0x0] through xdigs[0xf] after the
+	 * rounding phase.
+	 */
+	for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--)
+		*s = 0;
+	for (; s > s0 + sigfigs - (DBL_MANL_SIZE / 4) - 1 && s > s0; s--) {
+		*s = u.bits.manl & 0xf;
+		u.bits.manl >>= 4;
+	}
+	for (; s > s0; s--) {
+		*s = u.bits.manh & 0xf;
+		u.bits.manh >>= 4;
+	}
+
+	/*
+	 * At this point, we have snarfed all the bits in the
+	 * mantissa, with the possible exception of the highest-order
+	 * (partial) nibble, which is dealt with by the next
+	 * statement.  That nibble is usually in manh, but it could be
+	 * in manl instead for small subnormals.  We also tack on the
+	 * implicit normalization bit if appropriate.
+	 */
+	*s = u.bits.manh | u.bits.manl | impnbit;
+
+	/* If ndigits < 0, we are expected to auto-size the precision. */
+	if (ndigits < 0) {
+		for (ndigits = sigfigs; s0[ndigits - 1] == 0; ndigits--)
+			;
+	}
+
+	if (sigfigs > ndigits && s0[ndigits] != 0)
+		dorounding(s0, ndigits, u.bits.sign, decpt);
+
+	s = s0 + ndigits;
+	if (rve != NULL)
+		*rve = s;
+	*s-- = '\0';
+	for (; s >= s0; s--)
+		*s = xdigs[(unsigned int)*s];
+
+	return (s0);
+}
+
+#if (LDBL_MANT_DIG > DBL_MANT_DIG)
+
+/*
+ * This is the long double version of __hdtoa().
+ *
+ * On architectures that have an explicit integer bit, unnormals and
+ * pseudo-denormals cause problems in the conversion routine, so they
+ * are ``fixed'' by effectively toggling the integer bit.  Although
+ * this is not correct behavior, the hardware will not produce these
+ * formats externally.
+ */
+char *
+__hldtoa(long double e, const char *xdigs, int ndigits, int *decpt, int *sign,
+    char **rve)
+{
+	union IEEEl2bits u;
+	char *s, *s0;
+	int bufsize;
+	int impnbit;	/* implicit normalization bit */
+	int pos;
+	int shift;	/* for subnormals, # of shifts required to normalize */
+	int sigfigs;	/* number of significant hex figures in result */
+
+	u.e = e;
+	*sign = u.bits.sign;
+
+	switch (fpclassify(e)) {
+	case FP_NORMAL:
+		sigfigs = (LDBL_MANT_DIG + 3) / 4;
+		impnbit = 1 << ((LDBL_MANT_DIG - 1) % 4);
+		*decpt = u.bits.exp - LDBL_BIAS + 1 -
+		    ((LDBL_MANT_DIG - 1) % 4);
+		break;
+	case FP_ZERO:
+		*decpt = 1;
+		return (nrv_alloc("0", rve, 1));
+	case FP_SUBNORMAL:
+		/*
+		 * The position of the highest-order bit tells us by
+		 * how much to adjust the exponent (decpt).  The
+		 * adjustment is raised to the next nibble boundary
+		 * since we will later choose the leftmost hexadecimal
+		 * digit so that all subsequent digits align on nibble
+		 * boundaries.
+		 */
+#ifdef	LDBL_IMPLICIT_NBIT
+		/* Don't trust the normalization bit to be off. */
+		u.bits.manh &= ~(~0ULL << (LDBL_MANH_SIZE - 1));
+#endif
+		if (u.bits.manh != 0) {
+#if LDBL_MANH_SIZE > 32
+			pos = log2_64(u.bits.manh);
+#else
+			pos = log2_32(u.bits.manh);
+#endif
+			shift = LDBL_MANH_SIZE - LDBL_NBIT_ADJ - pos;
+		} else {
+#if LDBL_MANL_SIZE > 32
+			pos = log2_64(u.bits.manl);
+#else
+			pos = log2_32(u.bits.manl);
+#endif
+			shift = LDBL_MANH_SIZE + LDBL_MANL_SIZE -
+			    LDBL_NBIT_ADJ - pos;
+		}
+		sigfigs = (3 + LDBL_MANT_DIG - LDBL_NBIT_ADJ - shift) / 4;
+		*decpt = LDBL_MIN_EXP + LDBL_NBIT_ADJ -
+		    ((shift + 3) & ~(4 - 1));
+		impnbit = 0;
+		break;
+	case FP_INFINITE:
+		*decpt = INT_MAX;
+		return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1));
+	case FP_NAN:
+		*decpt = INT_MAX;
+		return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1));
+	default:
+		abort();
+	}
+
+	/* FP_NORMAL or FP_SUBNORMAL */
+
+	if (ndigits == 0)		/* dtoa() compatibility */
+		ndigits = 1;
+
+	/*
+	 * For simplicity, we generate all the digits even if the
+	 * caller has requested fewer.
+	 */
+	bufsize = (sigfigs > ndigits) ? sigfigs : ndigits;
+	s0 = rv_alloc(bufsize);
+
+	/*
+	 * We work from right to left, first adding any requested zero
+	 * padding, then the least significant portion of the
+	 * mantissa, followed by the most significant.  The buffer is
+	 * filled with the byte values 0x0 through 0xf, which are
+	 * converted to xdigs[0x0] through xdigs[0xf] after the
+	 * rounding phase.
+	 */
+	for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--)
+		*s = 0;
+	for (; s > s0 + sigfigs - (LDBL_MANL_SIZE / 4) - 1 && s > s0; s--) {
+		*s = u.bits.manl & 0xf;
+		u.bits.manl >>= 4;
+	}
+	for (; s > s0; s--) {
+		*s = u.bits.manh & 0xf;
+		u.bits.manh >>= 4;
+	}
+
+	/*
+	 * At this point, we have snarfed all the bits in the
+	 * mantissa, with the possible exception of the highest-order
+	 * (partial) nibble, which is dealt with by the next
+	 * statement.  That nibble is usually in manh, but it could be
+	 * in manl instead for small subnormals.  We also tack on the
+	 * implicit normalization bit if appropriate.
+	 */
+	*s = u.bits.manh | u.bits.manl | impnbit;
+
+	/* If ndigits < 0, we are expected to auto-size the precision. */
+	if (ndigits < 0) {
+		for (ndigits = sigfigs; s0[ndigits - 1] == 0; ndigits--)
+			;
+	}
+
+	if (sigfigs > ndigits && s0[ndigits] != 0)
+		dorounding(s0, ndigits, u.bits.sign, decpt);
+
+	s = s0 + ndigits;
+	if (rve != NULL)
+		*rve = s;
+	*s-- = '\0';
+	for (; s >= s0; s--)
+		*s = xdigs[(unsigned int)*s];
+
+	return (s0);
+}
+
+#else	/* (LDBL_MANT_DIG == DBL_MANT_DIG) */
+
+char *
+__hldtoa(long double e, const char *xdigs, int ndigits, int *decpt, int *sign,
+    char **rve)
+{
+
+	return (__hdtoa((double)e, xdigs, ndigits, decpt, sign, rve));
+}
+
+#endif	/* (LDBL_MANT_DIG == DBL_MANT_DIG) */
Index: /vendor/FreeBSD-libc/5.3/gdtoa/glue/_ldtoa.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/glue/_ldtoa.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/glue/_ldtoa.c	(revision 2404)
@@ -0,0 +1,100 @@
+/*-
+ * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gdtoa/_ldtoa.c,v 1.2 2004/01/18 07:53:49 das Exp $");
+
+#include <float.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <math.h>
+#include <stdlib.h>
+#include "fpmath.h"
+#include "gdtoaimp.h"
+
+/*
+ * ldtoa() is a wrapper for gdtoa() that makes it smell like dtoa(),
+ * except that the floating point argument is passed by reference.
+ * When dtoa() is passed a NaN or infinity, it sets expt to 9999.
+ * However, a long double could have a valid exponent of 9999, so we
+ * use INT_MAX in ldtoa() instead.
+ */
+char *
+__ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign,
+    char **rve)
+{
+	static FPI fpi = {
+		LDBL_MANT_DIG,			/* nbits */
+		LDBL_MIN_EXP - LDBL_MANT_DIG,	/* emin */
+		LDBL_MAX_EXP - LDBL_MANT_DIG,	/* emax */
+		FPI_Round_near,	       		/* rounding */
+#ifdef Sudden_Underflow	/* unused, but correct anyway */
+		1
+#else
+		0
+#endif
+	};
+	int be, kind;
+	char *ret;
+	union IEEEl2bits u;
+	uint32_t bits[(LDBL_MANT_DIG + 31) / 32];
+
+	u.e = *ld;
+	*sign = u.bits.sign;
+	be = u.bits.exp - (LDBL_MAX_EXP - 1) - (LDBL_MANT_DIG - 1);
+	LDBL_TO_ARRAY32(u, bits);
+
+	switch (fpclassify(u.e)) {
+	case FP_NORMAL:
+		kind = STRTOG_Normal;
+#ifdef	LDBL_IMPLICIT_NBIT
+		bits[LDBL_MANT_DIG / 32] |= 1 << ((LDBL_MANT_DIG - 1) % 32);
+#endif /* LDBL_IMPLICIT_NBIT */
+		break;
+	case FP_ZERO:
+		kind = STRTOG_Zero;
+		break;
+	case FP_SUBNORMAL:
+		kind = STRTOG_Denormal;
+#ifdef	LDBL_IMPLICIT_NBIT
+		be++;
+#endif
+		break;
+	case FP_INFINITE:
+		kind = STRTOG_Infinite;
+		break;
+	case FP_NAN:
+		kind = STRTOG_NaN;
+		break;
+	default:
+		abort();
+	}
+
+	ret = gdtoa(&fpi, be, (ULong *)bits, &kind, mode, ndigits, decpt, rve);
+	if (*decpt == -32768)
+		*decpt = INT_MAX;
+	return ret;
+}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/glue/glue.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/glue/glue.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/glue/glue.c	(revision 2404)
@@ -0,0 +1,13 @@
+/*
+ * Machine-independent glue to integrate David Gay's gdtoa
+ * package into libc.
+ *
+ * $FreeBSD: src/lib/libc/gdtoa/glue.c,v 1.2 2003/06/21 08:20:14 das Exp $
+ */
+
+#include <pthread.h>
+
+pthread_mutex_t __gdtoa_locks[] = {
+	PTHREAD_MUTEX_INITIALIZER,
+	PTHREAD_MUTEX_INITIALIZER
+};
Index: /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisQ.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisQ.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisQ.c	(revision 2404)
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+/*
+ * Machine-dependent glue to integrate David Gay's gdtoa
+ * package into libc for architectures where a long double
+ * uses quad precision, such as sparc64.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gdtoa/machdep_ldisQ.c,v 1.2 2003/04/09 05:58:43 das Exp $");
+
+#include "gdtoaimp.h"
+
+long double
+strtold(const char * __restrict s, char ** __restrict sp)
+{
+	long double result;
+
+	strtopQ(s, sp, &result);
+	return result;
+}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisd.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisd.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisd.c	(revision 2404)
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+/*
+ * Machine-dependent glue to integrate David Gay's gdtoa
+ * package into libc for architectures where a long double
+ * is the same as a double, such as the Alpha.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gdtoa/machdep_ldisd.c,v 1.1 2003/03/12 20:29:58 das Exp $");
+
+#include "gdtoaimp.h"
+
+long double
+strtold(const char * __restrict s, char ** __restrict sp)
+{
+
+	return strtod(s, sp);
+}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisx.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisx.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/glue/machdep_ldisx.c	(revision 2404)
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+/*
+ * Machine-dependent glue to integrate David Gay's gdtoa
+ * package into libc for architectures where a long double
+ * is an IEEE extended precision number.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gdtoa/machdep_ldisx.c,v 1.2 2003/04/09 05:58:43 das Exp $");
+
+#include "gdtoaimp.h"
+
+long double
+strtold(const char * __restrict s, char ** __restrict sp)
+{
+	long double result;
+
+	strtopx(s, sp, &result);
+	return result;
+}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/gmisc.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/gmisc.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/gmisc.c	(revision 2404)
@@ -0,0 +1,92 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ void
+#ifdef KR_headers
+rshift(b, k) Bigint *b; int k;
+#else
+rshift(Bigint *b, int k)
+#endif
+{
+	ULong *x, *x1, *xe, y;
+	int n;
+
+	x = x1 = b->x;
+	n = k >> kshift;
+	if (n < b->wds) {
+		xe = x + b->wds;
+		x += n;
+		if (k &= kmask) {
+			n = ULbits - k;
+			y = *x++ >> k;
+			while(x < xe) {
+				*x1++ = (y | (*x << n)) & ALL_ON;
+				y = *x++ >> k;
+				}
+			if ((*x1 = y) !=0)
+				x1++;
+			}
+		else
+			while(x < xe)
+				*x1++ = *x++;
+		}
+	if ((b->wds = x1 - b->x) == 0)
+		b->x[0] = 0;
+	}
+
+ int
+#ifdef KR_headers
+trailz(b) Bigint *b;
+#else
+trailz(Bigint *b)
+#endif
+{
+	ULong L, *x, *xe;
+	int n = 0;
+
+	x = b->x;
+	xe = x + b->wds;
+	for(n = 0; x < xe && !*x; x++)
+		n += ULbits;
+	if (x < xe) {
+		L = *x;
+		n += lo0bits(&L);
+		}
+	return n;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/hd_init.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/hd_init.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/hd_init.c	(revision 2404)
@@ -0,0 +1,61 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ unsigned char hexdig[256];
+
+ static void
+#ifdef KR_headers
+htinit(h, s, inc) unsigned char *h; unsigned char *s; int inc;
+#else
+htinit(unsigned char *h, unsigned char *s, int inc)
+#endif
+{
+	int i, j;
+	for(i = 0; (j = s[i]) !=0; i++)
+		h[j] = i + inc;
+	}
+
+ void
+hexdig_init_D2A(Void)
+{
+#define USC (unsigned char *)
+	htinit(hexdig, USC "0123456789", 0x10);
+	htinit(hexdig, USC "abcdef", 0x10 + 10);
+	htinit(hexdig, USC "ABCDEF", 0x10 + 10);
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/hexnan.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/hexnan.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/hexnan.c	(revision 2404)
@@ -0,0 +1,137 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ static void
+#ifdef KR_headers
+L_shift(x, x1, i) ULong *x; ULong *x1; int i;
+#else
+L_shift(ULong *x, ULong *x1, int i)
+#endif
+{
+	int j;
+
+	i = 8 - i;
+	i <<= 2;
+	j = ULbits - i;
+	do {
+		*x |= x[1] << j;
+		x[1] >>= i;
+		} while(++x < x1);
+	}
+
+ int
+#ifdef KR_headers
+hexnan(sp, fpi, x0)
+	CONST char **sp; FPI *fpi; ULong *x0;
+#else
+hexnan( CONST char **sp, FPI *fpi, ULong *x0)
+#endif
+{
+	ULong c, h, *x, *x1, *xe;
+	CONST char *s;
+	int havedig, hd0, i, nbits;
+
+	if (!hexdig['0'])
+		hexdig_init_D2A();
+	nbits = fpi->nbits;
+	x = x0 + (nbits >> kshift);
+	if (nbits & kmask)
+		x++;
+	*--x = 0;
+	x1 = xe = x;
+	havedig = hd0 = i = 0;
+	s = *sp;
+	while(c = *(CONST unsigned char*)++s) {
+		if (!(h = hexdig[c])) {
+			if (c <= ' ') {
+				if (hd0 < havedig) {
+					if (x < x1 && i < 8)
+						L_shift(x, x1, i);
+					if (x <= x0) {
+						i = 8;
+						continue;
+						}
+					hd0 = havedig;
+					*--x = 0;
+					x1 = x;
+					i = 0;
+					}
+				continue;
+				}
+			if (/*(*/ c == ')' && havedig) {
+				*sp = s + 1;
+				break;
+				}
+			return STRTOG_NaN;
+			}
+		havedig++;
+		if (++i > 8) {
+			if (x <= x0)
+				continue;
+			i = 1;
+			*--x = 0;
+			}
+		*x = (*x << 4) | h & 0xf;
+		}
+	if (!havedig)
+		return STRTOG_NaN;
+	if (x < x1 && i < 8)
+		L_shift(x, x1, i);
+	if (x > x0) {
+		x1 = x0;
+		do *x1++ = *x++;
+			while(x <= xe);
+		do *x1++ = 0;
+			while(x1 <= xe);
+		}
+	else {
+		/* truncate high-order word if necessary */
+		if ( (i = nbits & (ULbits-1)) !=0)
+			*xe &= ((ULong)0xffffffff) >> (ULbits - i);
+		}
+	for(x1 = xe;; --x1) {
+		if (*x1 != 0)
+			break;
+		if (x1 == x0) {
+			*x1 = 1;
+			break;
+			}
+		}
+	return STRTOG_NaNbits;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/makefile
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/makefile	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/makefile	(revision 2404)
@@ -0,0 +1,69 @@
+# /****************************************************************
+# Copyright (C) 1998 by Lucent Technologies
+# All Rights Reserved
+#
+# Permission to use, copy, modify, and distribute this software and
+# its documentation for any purpose and without fee is hereby
+# granted, provided that the above copyright notice appear in all
+# copies and that both that the copyright notice and this
+# permission notice and warranty disclaimer appear in supporting
+# documentation, and that the name of Lucent or any of its entities
+# not be used in advertising or publicity pertaining to
+# distribution of the software without specific, written prior
+# permission.
+#
+# LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+# IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+# THIS SOFTWARE.
+#
+# ****************************************************************/
+
+.SUFFIXES: .c .o
+CC = cc
+CFLAGS = -g -DINFNAN_CHECK
+
+.c.o:
+	$(CC) -c $(CFLAGS) $*.c
+
+all: arith.h gdtoa.a
+
+arith.h: arithchk.c
+	$(CC) $(CFLAGS) arithchk.c || $(CC) -DNO_LONG_LONG $(CFLAGS) arithchk.c
+	./a.out >arith.h
+	rm -f a.out arithchk.o
+
+gdtoa.a: dmisc.c dtoa.c g_Qfmt.c g__fmt.c g_ddfmt.c g_dfmt.c g_ffmt.c\
+	 g_xLfmt.c g_xfmt.c gdtoa.c gethex.c gmisc.c hd_init.c hexnan.c\
+	 misc.c smisc.c strtoIQ.c strtoId.c strtoIdd.c strtoIf.c strtoIg.c\
+	 strtoIx.c strtoIxL.c strtod.c strtodI.c strtodg.c strtof.c strtopQ.c\
+	 strtopd.c strtopdd.c strtopf.c strtopx.c strtopxL.c strtorQ.c\
+	 strtord.c strtordd.c strtorf.c strtorx.c strtorxL.c sum.c ulp.c
+	$(CC) -c $(CFLAGS) $?
+	x=`echo $? | sed 's/\.c/.o/g'` && ar ruv gdtoa.a $$x && rm $$x
+	ranlib gdtoa.a || true
+
+# If your system lacks ranlib, you do not need it.
+
+xs0 = README arithchk.c dmisc.c dtoa.c g_Qfmt.c g__fmt.c g_ddfmt.c g_dfmt.c\
+	 g_ffmt.c g_xLfmt.c g_xfmt.c gdtoa.c gdtoa.h gdtoaimp.h gethex.c\
+	 gmisc.c hd_init.c hexnan.c makefile misc.c smisc.c strtoIQ.c\
+	 strtoId.c strtoIdd.c strtoIf.c strtoIg.c strtoIx.c strtoIxL.c\
+	 strtod.c strtodI.c strtodg.c strtof.c strtopQ.c strtopd.c strtopdd.c\
+	 strtopf.c strtopx.c strtopxL.c strtorQ.c strtord.c strtordd.c\
+	 strtorf.c strtorx.c strtorxL.c sum.c ulp.c
+
+# "make xsum.out" to check for transmission errors; source for xsum is
+# netlib's "xsum.c from f2c", e.g.,
+# ftp://netlib.bell-labs.com/netlib/f2c/xsum.c.gz
+
+xsum.out: xsum0.out $(xs0)
+	xsum $(xs0) >xsum1.out
+	cmp xsum0.out xsum1.out && mv xsum1.out xsum.out || diff xsum[01].out
+
+clean:
+	rm -f arith.h *.[ao] xsum.out xsum1.out
Index: /vendor/FreeBSD-libc/5.3/gdtoa/misc.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/misc.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/misc.c	(revision 2404)
@@ -0,0 +1,862 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 1999 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ static Bigint *freelist[Kmax+1];
+#ifndef Omit_Private_Memory
+#ifndef PRIVATE_MEM
+#define PRIVATE_MEM 2304
+#endif
+#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
+static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
+#endif
+
+ Bigint *
+Balloc
+#ifdef KR_headers
+	(k) int k;
+#else
+	(int k)
+#endif
+{
+	int x;
+	Bigint *rv;
+#ifndef Omit_Private_Memory
+	unsigned int len;
+#endif
+
+	ACQUIRE_DTOA_LOCK(0);
+	if ( (rv = freelist[k]) !=0) {
+		freelist[k] = rv->next;
+		}
+	else {
+		x = 1 << k;
+#ifdef Omit_Private_Memory
+		rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong));
+#else
+		len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
+			/sizeof(double);
+		if (pmem_next - private_mem + len <= PRIVATE_mem) {
+			rv = (Bigint*)pmem_next;
+			pmem_next += len;
+			}
+		else
+			rv = (Bigint*)MALLOC(len*sizeof(double));
+#endif
+		rv->k = k;
+		rv->maxwds = x;
+		}
+	FREE_DTOA_LOCK(0);
+	rv->sign = rv->wds = 0;
+	return rv;
+	}
+
+ void
+Bfree
+#ifdef KR_headers
+	(v) Bigint *v;
+#else
+	(Bigint *v)
+#endif
+{
+	if (v) {
+		ACQUIRE_DTOA_LOCK(0);
+		v->next = freelist[v->k];
+		freelist[v->k] = v;
+		FREE_DTOA_LOCK(0);
+		}
+	}
+
+ int
+lo0bits
+#ifdef KR_headers
+	(y) ULong *y;
+#else
+	(ULong *y)
+#endif
+{
+	register int k;
+	register ULong x = *y;
+
+	if (x & 7) {
+		if (x & 1)
+			return 0;
+		if (x & 2) {
+			*y = x >> 1;
+			return 1;
+			}
+		*y = x >> 2;
+		return 2;
+		}
+	k = 0;
+	if (!(x & 0xffff)) {
+		k = 16;
+		x >>= 16;
+		}
+	if (!(x & 0xff)) {
+		k += 8;
+		x >>= 8;
+		}
+	if (!(x & 0xf)) {
+		k += 4;
+		x >>= 4;
+		}
+	if (!(x & 0x3)) {
+		k += 2;
+		x >>= 2;
+		}
+	if (!(x & 1)) {
+		k++;
+		x >>= 1;
+		if (!x & 1)
+			return 32;
+		}
+	*y = x;
+	return k;
+	}
+
+ Bigint *
+multadd
+#ifdef KR_headers
+	(b, m, a) Bigint *b; int m, a;
+#else
+	(Bigint *b, int m, int a)	/* multiply by m and add a */
+#endif
+{
+	int i, wds;
+#ifdef ULLong
+	ULong *x;
+	ULLong carry, y;
+#else
+	ULong carry, *x, y;
+#ifdef Pack_32
+	ULong xi, z;
+#endif
+#endif
+	Bigint *b1;
+
+	wds = b->wds;
+	x = b->x;
+	i = 0;
+	carry = a;
+	do {
+#ifdef ULLong
+		y = *x * (ULLong)m + carry;
+		carry = y >> 32;
+		*x++ = y & 0xffffffffUL;
+#else
+#ifdef Pack_32
+		xi = *x;
+		y = (xi & 0xffff) * m + carry;
+		z = (xi >> 16) * m + (y >> 16);
+		carry = z >> 16;
+		*x++ = (z << 16) + (y & 0xffff);
+#else
+		y = *x * m + carry;
+		carry = y >> 16;
+		*x++ = y & 0xffff;
+#endif
+#endif
+		}
+		while(++i < wds);
+	if (carry) {
+		if (wds >= b->maxwds) {
+			b1 = Balloc(b->k+1);
+			Bcopy(b1, b);
+			Bfree(b);
+			b = b1;
+			}
+		b->x[wds++] = carry;
+		b->wds = wds;
+		}
+	return b;
+	}
+
+ int
+hi0bits
+#ifdef KR_headers
+	(x) register ULong x;
+#else
+	(register ULong x)
+#endif
+{
+	register int k = 0;
+
+	if (!(x & 0xffff0000)) {
+		k = 16;
+		x <<= 16;
+		}
+	if (!(x & 0xff000000)) {
+		k += 8;
+		x <<= 8;
+		}
+	if (!(x & 0xf0000000)) {
+		k += 4;
+		x <<= 4;
+		}
+	if (!(x & 0xc0000000)) {
+		k += 2;
+		x <<= 2;
+		}
+	if (!(x & 0x80000000)) {
+		k++;
+		if (!(x & 0x40000000))
+			return 32;
+		}
+	return k;
+	}
+
+ Bigint *
+i2b
+#ifdef KR_headers
+	(i) int i;
+#else
+	(int i)
+#endif
+{
+	Bigint *b;
+
+	b = Balloc(1);
+	b->x[0] = i;
+	b->wds = 1;
+	return b;
+	}
+
+ Bigint *
+mult
+#ifdef KR_headers
+	(a, b) Bigint *a, *b;
+#else
+	(Bigint *a, Bigint *b)
+#endif
+{
+	Bigint *c;
+	int k, wa, wb, wc;
+	ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
+	ULong y;
+#ifdef ULLong
+	ULLong carry, z;
+#else
+	ULong carry, z;
+#ifdef Pack_32
+	ULong z2;
+#endif
+#endif
+
+	if (a->wds < b->wds) {
+		c = a;
+		a = b;
+		b = c;
+		}
+	k = a->k;
+	wa = a->wds;
+	wb = b->wds;
+	wc = wa + wb;
+	if (wc > a->maxwds)
+		k++;
+	c = Balloc(k);
+	for(x = c->x, xa = x + wc; x < xa; x++)
+		*x = 0;
+	xa = a->x;
+	xae = xa + wa;
+	xb = b->x;
+	xbe = xb + wb;
+	xc0 = c->x;
+#ifdef ULLong
+	for(; xb < xbe; xc0++) {
+		if ( (y = *xb++) !=0) {
+			x = xa;
+			xc = xc0;
+			carry = 0;
+			do {
+				z = *x++ * (ULLong)y + *xc + carry;
+				carry = z >> 32;
+				*xc++ = z & 0xffffffffUL;
+				}
+				while(x < xae);
+			*xc = carry;
+			}
+		}
+#else
+#ifdef Pack_32
+	for(; xb < xbe; xb++, xc0++) {
+		if ( (y = *xb & 0xffff) !=0) {
+			x = xa;
+			xc = xc0;
+			carry = 0;
+			do {
+				z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
+				carry = z >> 16;
+				z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
+				carry = z2 >> 16;
+				Storeinc(xc, z2, z);
+				}
+				while(x < xae);
+			*xc = carry;
+			}
+		if ( (y = *xb >> 16) !=0) {
+			x = xa;
+			xc = xc0;
+			carry = 0;
+			z2 = *xc;
+			do {
+				z = (*x & 0xffff) * y + (*xc >> 16) + carry;
+				carry = z >> 16;
+				Storeinc(xc, z, z2);
+				z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
+				carry = z2 >> 16;
+				}
+				while(x < xae);
+			*xc = z2;
+			}
+		}
+#else
+	for(; xb < xbe; xc0++) {
+		if ( (y = *xb++) !=0) {
+			x = xa;
+			xc = xc0;
+			carry = 0;
+			do {
+				z = *x++ * y + *xc + carry;
+				carry = z >> 16;
+				*xc++ = z & 0xffff;
+				}
+				while(x < xae);
+			*xc = carry;
+			}
+		}
+#endif
+#endif
+	for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;
+	c->wds = wc;
+	return c;
+	}
+
+ static Bigint *p5s;
+
+ Bigint *
+pow5mult
+#ifdef KR_headers
+	(b, k) Bigint *b; int k;
+#else
+	(Bigint *b, int k)
+#endif
+{
+	Bigint *b1, *p5, *p51;
+	int i;
+	static int p05[3] = { 5, 25, 125 };
+
+	if ( (i = k & 3) !=0)
+		b = multadd(b, p05[i-1], 0);
+
+	if (!(k >>= 2))
+		return b;
+	if ((p5 = p5s) == 0) {
+		/* first time */
+#ifdef MULTIPLE_THREADS
+		ACQUIRE_DTOA_LOCK(1);
+		if (!(p5 = p5s)) {
+			p5 = p5s = i2b(625);
+			p5->next = 0;
+			}
+		FREE_DTOA_LOCK(1);
+#else
+		p5 = p5s = i2b(625);
+		p5->next = 0;
+#endif
+		}
+	for(;;) {
+		if (k & 1) {
+			b1 = mult(b, p5);
+			Bfree(b);
+			b = b1;
+			}
+		if (!(k >>= 1))
+			break;
+		if ((p51 = p5->next) == 0) {
+#ifdef MULTIPLE_THREADS
+			ACQUIRE_DTOA_LOCK(1);
+			if (!(p51 = p5->next)) {
+				p51 = p5->next = mult(p5,p5);
+				p51->next = 0;
+				}
+			FREE_DTOA_LOCK(1);
+#else
+			p51 = p5->next = mult(p5,p5);
+			p51->next = 0;
+#endif
+			}
+		p5 = p51;
+		}
+	return b;
+	}
+
+ Bigint *
+lshift
+#ifdef KR_headers
+	(b, k) Bigint *b; int k;
+#else
+	(Bigint *b, int k)
+#endif
+{
+	int i, k1, n, n1;
+	Bigint *b1;
+	ULong *x, *x1, *xe, z;
+
+	n = k >> kshift;
+	k1 = b->k;
+	n1 = n + b->wds + 1;
+	for(i = b->maxwds; n1 > i; i <<= 1)
+		k1++;
+	b1 = Balloc(k1);
+	x1 = b1->x;
+	for(i = 0; i < n; i++)
+		*x1++ = 0;
+	x = b->x;
+	xe = x + b->wds;
+	if (k &= kmask) {
+#ifdef Pack_32
+		k1 = 32 - k;
+		z = 0;
+		do {
+			*x1++ = *x << k | z;
+			z = *x++ >> k1;
+			}
+			while(x < xe);
+		if ((*x1 = z) !=0)
+			++n1;
+#else
+		k1 = 16 - k;
+		z = 0;
+		do {
+			*x1++ = *x << k  & 0xffff | z;
+			z = *x++ >> k1;
+			}
+			while(x < xe);
+		if (*x1 = z)
+			++n1;
+#endif
+		}
+	else do
+		*x1++ = *x++;
+		while(x < xe);
+	b1->wds = n1 - 1;
+	Bfree(b);
+	return b1;
+	}
+
+ int
+cmp
+#ifdef KR_headers
+	(a, b) Bigint *a, *b;
+#else
+	(Bigint *a, Bigint *b)
+#endif
+{
+	ULong *xa, *xa0, *xb, *xb0;
+	int i, j;
+
+	i = a->wds;
+	j = b->wds;
+#ifdef DEBUG
+	if (i > 1 && !a->x[i-1])
+		Bug("cmp called with a->x[a->wds-1] == 0");
+	if (j > 1 && !b->x[j-1])
+		Bug("cmp called with b->x[b->wds-1] == 0");
+#endif
+	if (i -= j)
+		return i;
+	xa0 = a->x;
+	xa = xa0 + j;
+	xb0 = b->x;
+	xb = xb0 + j;
+	for(;;) {
+		if (*--xa != *--xb)
+			return *xa < *xb ? -1 : 1;
+		if (xa <= xa0)
+			break;
+		}
+	return 0;
+	}
+
+ Bigint *
+diff
+#ifdef KR_headers
+	(a, b) Bigint *a, *b;
+#else
+	(Bigint *a, Bigint *b)
+#endif
+{
+	Bigint *c;
+	int i, wa, wb;
+	ULong *xa, *xae, *xb, *xbe, *xc;
+#ifdef ULLong
+	ULLong borrow, y;
+#else
+	ULong borrow, y;
+#ifdef Pack_32
+	ULong z;
+#endif
+#endif
+
+	i = cmp(a,b);
+	if (!i) {
+		c = Balloc(0);
+		c->wds = 1;
+		c->x[0] = 0;
+		return c;
+		}
+	if (i < 0) {
+		c = a;
+		a = b;
+		b = c;
+		i = 1;
+		}
+	else
+		i = 0;
+	c = Balloc(a->k);
+	c->sign = i;
+	wa = a->wds;
+	xa = a->x;
+	xae = xa + wa;
+	wb = b->wds;
+	xb = b->x;
+	xbe = xb + wb;
+	xc = c->x;
+	borrow = 0;
+#ifdef ULLong
+	do {
+		y = (ULLong)*xa++ - *xb++ - borrow;
+		borrow = y >> 32 & 1UL;
+		*xc++ = y & 0xffffffffUL;
+		}
+		while(xb < xbe);
+	while(xa < xae) {
+		y = *xa++ - borrow;
+		borrow = y >> 32 & 1UL;
+		*xc++ = y & 0xffffffffUL;
+		}
+#else
+#ifdef Pack_32
+	do {
+		y = (*xa & 0xffff) - (*xb & 0xffff) - borrow;
+		borrow = (y & 0x10000) >> 16;
+		z = (*xa++ >> 16) - (*xb++ >> 16) - borrow;
+		borrow = (z & 0x10000) >> 16;
+		Storeinc(xc, z, y);
+		}
+		while(xb < xbe);
+	while(xa < xae) {
+		y = (*xa & 0xffff) - borrow;
+		borrow = (y & 0x10000) >> 16;
+		z = (*xa++ >> 16) - borrow;
+		borrow = (z & 0x10000) >> 16;
+		Storeinc(xc, z, y);
+		}
+#else
+	do {
+		y = *xa++ - *xb++ - borrow;
+		borrow = (y & 0x10000) >> 16;
+		*xc++ = y & 0xffff;
+		}
+		while(xb < xbe);
+	while(xa < xae) {
+		y = *xa++ - borrow;
+		borrow = (y & 0x10000) >> 16;
+		*xc++ = y & 0xffff;
+		}
+#endif
+#endif
+	while(!*--xc)
+		wa--;
+	c->wds = wa;
+	return c;
+	}
+
+ double
+b2d
+#ifdef KR_headers
+	(a, e) Bigint *a; int *e;
+#else
+	(Bigint *a, int *e)
+#endif
+{
+	ULong *xa, *xa0, w, y, z;
+	int k;
+	double d;
+#ifdef VAX
+	ULong d0, d1;
+#else
+#define d0 word0(d)
+#define d1 word1(d)
+#endif
+
+	xa0 = a->x;
+	xa = xa0 + a->wds;
+	y = *--xa;
+#ifdef DEBUG
+	if (!y) Bug("zero y in b2d");
+#endif
+	k = hi0bits(y);
+	*e = 32 - k;
+#ifdef Pack_32
+	if (k < Ebits) {
+		d0 = Exp_1 | y >> Ebits - k;
+		w = xa > xa0 ? *--xa : 0;
+		d1 = y << (32-Ebits) + k | w >> Ebits - k;
+		goto ret_d;
+		}
+	z = xa > xa0 ? *--xa : 0;
+	if (k -= Ebits) {
+		d0 = Exp_1 | y << k | z >> 32 - k;
+		y = xa > xa0 ? *--xa : 0;
+		d1 = z << k | y >> 32 - k;
+		}
+	else {
+		d0 = Exp_1 | y;
+		d1 = z;
+		}
+#else
+	if (k < Ebits + 16) {
+		z = xa > xa0 ? *--xa : 0;
+		d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;
+		w = xa > xa0 ? *--xa : 0;
+		y = xa > xa0 ? *--xa : 0;
+		d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;
+		goto ret_d;
+		}
+	z = xa > xa0 ? *--xa : 0;
+	w = xa > xa0 ? *--xa : 0;
+	k -= Ebits + 16;
+	d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
+	y = xa > xa0 ? *--xa : 0;
+	d1 = w << k + 16 | y << k;
+#endif
+ ret_d:
+#ifdef VAX
+	word0(d) = d0 >> 16 | d0 << 16;
+	word1(d) = d1 >> 16 | d1 << 16;
+#endif
+	return dval(d);
+	}
+#undef d0
+#undef d1
+
+ Bigint *
+d2b
+#ifdef KR_headers
+	(d, e, bits) double d; int *e, *bits;
+#else
+	(double d, int *e, int *bits)
+#endif
+{
+	Bigint *b;
+	int de, i, k;
+	ULong *x, y, z;
+#ifdef VAX
+	ULong d0, d1;
+	d0 = word0(d) >> 16 | word0(d) << 16;
+	d1 = word1(d) >> 16 | word1(d) << 16;
+#else
+#define d0 word0(d)
+#define d1 word1(d)
+#endif
+
+#ifdef Pack_32
+	b = Balloc(1);
+#else
+	b = Balloc(2);
+#endif
+	x = b->x;
+
+	z = d0 & Frac_mask;
+	d0 &= 0x7fffffff;	/* clear sign bit, which we ignore */
+#ifdef Sudden_Underflow
+	de = (int)(d0 >> Exp_shift);
+#ifndef IBM
+	z |= Exp_msk11;
+#endif
+#else
+	if ( (de = (int)(d0 >> Exp_shift)) !=0)
+		z |= Exp_msk1;
+#endif
+#ifdef Pack_32
+	if ( (y = d1) !=0) {
+		if ( (k = lo0bits(&y)) !=0) {
+			x[0] = y | z << 32 - k;
+			z >>= k;
+			}
+		else
+			x[0] = y;
+		i = b->wds = (x[1] = z) !=0 ? 2 : 1;
+		}
+	else {
+#ifdef DEBUG
+		if (!z)
+			Bug("Zero passed to d2b");
+#endif
+		k = lo0bits(&z);
+		x[0] = z;
+		i = b->wds = 1;
+		k += 32;
+		}
+#else
+	if ( (y = d1) !=0) {
+		if ( (k = lo0bits(&y)) !=0)
+			if (k >= 16) {
+				x[0] = y | z << 32 - k & 0xffff;
+				x[1] = z >> k - 16 & 0xffff;
+				x[2] = z >> k;
+				i = 2;
+				}
+			else {
+				x[0] = y & 0xffff;
+				x[1] = y >> 16 | z << 16 - k & 0xffff;
+				x[2] = z >> k & 0xffff;
+				x[3] = z >> k+16;
+				i = 3;
+				}
+		else {
+			x[0] = y & 0xffff;
+			x[1] = y >> 16;
+			x[2] = z & 0xffff;
+			x[3] = z >> 16;
+			i = 3;
+			}
+		}
+	else {
+#ifdef DEBUG
+		if (!z)
+			Bug("Zero passed to d2b");
+#endif
+		k = lo0bits(&z);
+		if (k >= 16) {
+			x[0] = z;
+			i = 0;
+			}
+		else {
+			x[0] = z & 0xffff;
+			x[1] = z >> 16;
+			i = 1;
+			}
+		k += 32;
+		}
+	while(!x[i])
+		--i;
+	b->wds = i + 1;
+#endif
+#ifndef Sudden_Underflow
+	if (de) {
+#endif
+#ifdef IBM
+		*e = (de - Bias - (P-1) << 2) + k;
+		*bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
+#else
+		*e = de - Bias - (P-1) + k;
+		*bits = P - k;
+#endif
+#ifndef Sudden_Underflow
+		}
+	else {
+		*e = de - Bias - (P-1) + 1 + k;
+#ifdef Pack_32
+		*bits = 32*i - hi0bits(x[i-1]);
+#else
+		*bits = (i+2)*16 - hi0bits(x[i]);
+#endif
+		}
+#endif
+	return b;
+	}
+#undef d0
+#undef d1
+
+ CONST double
+#ifdef IEEE_Arith
+bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };
+CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256
+		};
+#else
+#ifdef IBM
+bigtens[] = { 1e16, 1e32, 1e64 };
+CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 };
+#else
+bigtens[] = { 1e16, 1e32 };
+CONST double tinytens[] = { 1e-16, 1e-32 };
+#endif
+#endif
+
+ CONST double
+tens[] = {
+		1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+		1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+		1e20, 1e21, 1e22
+#ifdef VAX
+		, 1e23, 1e24
+#endif
+		};
+
+ char *
+#ifdef KR_headers
+strcp_D2A(a, b) char *a; char *b;
+#else
+strcp_D2A(char *a, CONST char *b)
+#endif
+{
+	while(*a = *b++)
+		a++;
+	return a;
+	}
+
+#ifdef NO_STRING_H
+
+ Char *
+#ifdef KR_headers
+memcpy_D2A(a, b, len) Char *a; Char *b; size_t len;
+#else
+memcpy_D2A(void *a1, void *b1, size_t len)
+#endif
+{
+	register char *a = (char*)a1, *ae = a + len;
+	register char *b = (char*)b1, *a0 = a;
+	while(a < ae)
+		*a++ = *b++;
+	return a0;
+	}
+
+#endif /* NO_STRING_H */
Index: /vendor/FreeBSD-libc/5.3/gdtoa/smisc.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/smisc.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/smisc.c	(revision 2404)
@@ -0,0 +1,197 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 1999 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ Bigint *
+s2b
+#ifdef KR_headers
+	(s, nd0, nd, y9) CONST char *s; int nd0, nd; ULong y9;
+#else
+	(CONST char *s, int nd0, int nd, ULong y9)
+#endif
+{
+	Bigint *b;
+	int i, k;
+	Long x, y;
+
+	x = (nd + 8) / 9;
+	for(k = 0, y = 1; x > y; y <<= 1, k++) ;
+#ifdef Pack_32
+	b = Balloc(k);
+	b->x[0] = y9;
+	b->wds = 1;
+#else
+	b = Balloc(k+1);
+	b->x[0] = y9 & 0xffff;
+	b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;
+#endif
+
+	i = 9;
+	if (9 < nd0) {
+		s += 9;
+		do b = multadd(b, 10, *s++ - '0');
+			while(++i < nd0);
+		s++;
+		}
+	else
+		s += 10;
+	for(; i < nd; i++)
+		b = multadd(b, 10, *s++ - '0');
+	return b;
+	}
+
+ double
+ratio
+#ifdef KR_headers
+	(a, b) Bigint *a, *b;
+#else
+	(Bigint *a, Bigint *b)
+#endif
+{
+	double da, db;
+	int k, ka, kb;
+
+	dval(da) = b2d(a, &ka);
+	dval(db) = b2d(b, &kb);
+	k = ka - kb + ULbits*(a->wds - b->wds);
+#ifdef IBM
+	if (k > 0) {
+		word0(da) += (k >> 2)*Exp_msk1;
+		if (k &= 3)
+			dval(da) *= 1 << k;
+		}
+	else {
+		k = -k;
+		word0(db) += (k >> 2)*Exp_msk1;
+		if (k &= 3)
+			dval(db) *= 1 << k;
+		}
+#else
+	if (k > 0)
+		word0(da) += k*Exp_msk1;
+	else {
+		k = -k;
+		word0(db) += k*Exp_msk1;
+		}
+#endif
+	return dval(da) / dval(db);
+	}
+
+#ifdef INFNAN_CHECK
+
+ int
+match
+#ifdef KR_headers
+	(sp, t) char **sp, *t;
+#else
+	(CONST char **sp, char *t)
+#endif
+{
+	int c, d;
+	CONST char *s = *sp;
+
+	while( (d = *t++) !=0) {
+		if ((c = *++s) >= 'A' && c <= 'Z')
+			c += 'a' - 'A';
+		if (c != d)
+			return 0;
+		}
+	*sp = s + 1;
+	return 1;
+	}
+#endif /* INFNAN_CHECK */
+
+ void
+#ifdef KR_headers
+copybits(c, n, b) ULong *c; int n; Bigint *b;
+#else
+copybits(ULong *c, int n, Bigint *b)
+#endif
+{
+	ULong *ce, *x, *xe;
+#ifdef Pack_16
+	int nw, nw1;
+#endif
+
+	ce = c + ((n-1) >> kshift) + 1;
+	x = b->x;
+#ifdef Pack_32
+	xe = x + b->wds;
+	while(x < xe)
+		*c++ = *x++;
+#else
+	nw = b->wds;
+	nw1 = nw & 1;
+	for(xe = x + (nw - nw1); x < xe; x += 2)
+		Storeinc(c, x[1], x[0]);
+	if (nw1)
+		*c++ = *x;
+#endif
+	while(c < ce)
+		*c++ = 0;
+	}
+
+ ULong
+#ifdef KR_headers
+any_on(b, k) Bigint *b; int k;
+#else
+any_on(Bigint *b, int k)
+#endif
+{
+	int n, nwds;
+	ULong *x, *x0, x1, x2;
+
+	x = b->x;
+	nwds = b->wds;
+	n = k >> kshift;
+	if (n > nwds)
+		n = nwds;
+	else if (n < nwds && (k &= kmask)) {
+		x1 = x2 = x[n];
+		x1 >>= k;
+		x1 <<= k;
+		if (x1 != x2)
+			return 1;
+		}
+	x0 = x;
+	x += n;
+	while(x > x0)
+		if (*--x)
+			return 1;
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtoIQ.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtoIQ.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtoIQ.c	(revision 2404)
@@ -0,0 +1,69 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtoIQ(s, sp, a, b) CONST char *s; char **sp; void *a; void *b;
+#else
+strtoIQ(CONST char *s, char **sp, void *a, void *b)
+#endif
+{
+	static FPI fpi = { 113, 1-16383-113+1, 32766-16383-113+1, 1, SI };
+	Long exp[2];
+	Bigint *B[2];
+	int k, rv[2];
+	ULong *L = (ULong *)a, *M = (ULong *)b;
+
+	B[0] = Balloc(2);
+	B[0]->wds = 4;
+	k = strtoIg(s, sp, &fpi, exp, B, rv);
+	ULtoQ(L, B[0]->x, exp[0], rv[0]);
+	Bfree(B[0]);
+	if (B[1]) {
+		ULtoQ(M, B[1]->x, exp[1], rv[1]);
+		Bfree(B[1]);
+		}
+	else {
+		M[0] = L[0];
+		M[1] = L[1];
+		M[2] = L[2];
+		M[3] = L[3];
+		}
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtoId.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtoId.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtoId.c	(revision 2404)
@@ -0,0 +1,66 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtoId(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1;
+#else
+strtoId(CONST char *s, char **sp, double *f0, double *f1)
+#endif
+{
+	static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
+	Long exp[2];
+	Bigint *B[2];
+	int k, rv[2];
+
+	B[0] = Balloc(1);
+	B[0]->wds = 2;
+	k = strtoIg(s, sp, &fpi, exp, B, rv);
+	ULtod((ULong*)f0, B[0]->x, exp[0], rv[0]);
+	Bfree(B[0]);
+	if (B[1]) {
+		ULtod((ULong*)f1, B[1]->x, exp[1], rv[1]);
+		Bfree(B[1]);
+		}
+	else {
+		((ULong*)f1)[0] = ((ULong*)f0)[0];
+		((ULong*)f1)[1] = ((ULong*)f0)[1];
+		}
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtoIdd.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtoIdd.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtoIdd.c	(revision 2404)
@@ -0,0 +1,72 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtoIdd(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1;
+#else
+strtoIdd(CONST char *s, char **sp, double *f0, double *f1)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi = { 106, 1-1023, 2046-1023-106+1, 1, 1 };
+#else
+	static FPI fpi = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 };
+#endif
+	Long exp[2];
+	Bigint *B[2];
+	int k, rv[2];
+
+	B[0] = Balloc(2);
+	B[0]->wds = 4;
+	k = strtoIg(s, sp, &fpi, exp, B, rv);
+	ULtodd((ULong*)f0, B[0]->x, exp[0], rv[0]);
+	Bfree(B[0]);
+	if (B[1]) {
+		ULtodd((ULong*)f1, B[1]->x, exp[1], rv[1]);
+		Bfree(B[1]);
+		}
+	else {
+		((ULong*)f1)[0] = ((ULong*)f0)[0];
+		((ULong*)f1)[1] = ((ULong*)f0)[1];
+		((ULong*)f1)[2] = ((ULong*)f0)[2];
+		((ULong*)f1)[3] = ((ULong*)f0)[3];
+		}
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtoIf.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtoIf.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtoIf.c	(revision 2404)
@@ -0,0 +1,64 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtoIf(s, sp, f0, f1) CONST char *s; char **sp; float *f0, *f1;
+#else
+strtoIf(CONST char *s, char **sp, float *f0, float *f1)
+#endif
+{
+	static FPI fpi = { 24, 1-127-24+1,  254-127-24+1, 1, SI };
+	Long exp[2];
+	Bigint *B[2];
+	int k, rv[2];
+
+	B[0] = Balloc(0);
+	B[0]->wds = 1;
+	k = strtoIg(s, sp, &fpi, exp, B, rv);
+	ULtof((ULong*)f0, B[0]->x, exp[0], rv[0]);
+	Bfree(B[0]);
+	if (B[1]) {
+		ULtof((ULong*)f1, B[1]->x, exp[1], rv[1]);
+		Bfree(B[1]);
+		}
+	else
+		*(ULong*)f1 = *(ULong*)f0;
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtoIg.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtoIg.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtoIg.c	(revision 2404)
@@ -0,0 +1,139 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtoIg(s00, se, fpi, exp, B, rvp) CONST char *s00; char **se; FPI *fpi; Long *exp; Bigint **B; int *rvp;
+#else
+strtoIg(CONST char *s00, char **se, FPI *fpi, Long *exp, Bigint **B, int *rvp)
+#endif
+{
+	Bigint *b, *b1;
+	int i, nb, nw, nw1, rv, rv1, swap;
+	unsigned int nb1, nb11;
+	Long e1;
+
+	b = *B;
+	rv = strtodg(s00, se, fpi, exp, b->x);
+	if (!(rv & STRTOG_Inexact)) {
+		B[1] = 0;
+		return *rvp = rv;
+		}
+	e1 = exp[0];
+	rv1 = rv ^ STRTOG_Inexact;
+	b1 = Balloc(b->k);
+	Bcopy(b1, b);
+	nb = fpi->nbits;
+	nb1 = nb & 31;
+	nb11 = (nb1 - 1) & 31;
+	nw = b->wds;
+	nw1 = nw - 1;
+	if (rv & STRTOG_Inexlo) {
+		swap = 0;
+		b1 = increment(b1);
+		if (fpi->sudden_underflow
+		 && (rv & STRTOG_Retmask) == STRTOG_Zero) {
+			b1->x[0] = 0;
+			b1->x[nw1] = 1L << nb11;
+			rv1 += STRTOG_Normal - STRTOG_Zero;
+			rv1 &= ~STRTOG_Underflow;
+			goto swapcheck;
+			}
+		if (b1->wds > nw
+		 || nb1 && b1->x[nw1] & 1L << nb1) {
+			if (++e1 > fpi->emax)
+				rv1 = STRTOG_Infinite | STRTOG_Inexhi;
+			rshift(b1, 1);
+			}
+		else if ((rv & STRTOG_Retmask) == STRTOG_Denormal) {
+			if (b1->x[nw1] & 1L << nb11) {
+				rv1 += STRTOG_Normal - STRTOG_Denormal;
+				rv1 &= ~STRTOG_Underflow;
+				}
+			}
+		}
+	else {
+		swap = STRTOG_Neg;
+		if ((rv & STRTOG_Retmask) == STRTOG_Infinite) {
+			b1 = set_ones(b1, nb);
+			e1 = fpi->emax;
+			rv1 = STRTOG_Normal | STRTOG_Inexlo;
+			goto swapcheck;
+			}
+		decrement(b1);
+		if ((rv & STRTOG_Retmask) == STRTOG_Denormal) {
+			for(i = nw1; !b1->x[i]; --i)
+				if (!i) {
+					rv1 = STRTOG_Zero | STRTOG_Inexlo;
+					break;
+					}
+			goto swapcheck;
+			}
+		if (!(b1->x[nw1] & 1L << nb11)) {
+			if (e1 == fpi->emin) {
+				if (fpi->sudden_underflow)
+					rv1 += STRTOG_Zero - STRTOG_Normal;
+				else
+					rv1 += STRTOG_Denormal - STRTOG_Normal;
+				rv1 |= STRTOG_Underflow;
+				}
+			else {
+				b1 = lshift(b1, 1);
+				b1->x[0] |= 1;
+				--e1;
+				}
+			}
+		}
+ swapcheck:
+	if (swap ^ (rv & STRTOG_Neg)) {
+		rvp[0] = rv1;
+		rvp[1] = rv;
+		B[0] = b1;
+		B[1] = b;
+		exp[1] = exp[0];
+		exp[0] = e1;
+		}
+	else {
+		rvp[0] = rv;
+		rvp[1] = rv1;
+		B[1] = b1;
+		exp[1] = e1;
+		}
+	return rv;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtoIx.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtoIx.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtoIx.c	(revision 2404)
@@ -0,0 +1,70 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtoIx(s, sp, a, b) CONST char *s; char **sp; void *a; void *b;
+#else
+strtoIx(CONST char *s, char **sp, void *a, void *b)
+#endif
+{
+	static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+	Long exp[2];
+	Bigint *B[2];
+	int k, rv[2];
+	UShort *L = (UShort *)a, *M = (UShort *)b;
+
+	B[0] = Balloc(1);
+	B[0]->wds = 2;
+	k = strtoIg(s, sp, &fpi, exp, B, rv);
+	ULtox(L, B[0]->x, exp[0], rv[0]);
+	Bfree(B[0]);
+	if (B[1]) {
+		ULtox(M, B[1]->x, exp[1], rv[1]);
+		Bfree(B[1]);
+		}
+	else {
+		M[0] = L[0];
+		M[1] = L[1];
+		M[2] = L[2];
+		M[3] = L[3];
+		M[4] = L[4];
+		}
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtoIxL.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtoIxL.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtoIxL.c	(revision 2404)
@@ -0,0 +1,68 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtoIxL(s, sp, a, b) CONST char *s; char **sp; void *a; void *b;
+#else
+strtoIxL(CONST char *s, char **sp, void *a, void *b)
+#endif
+{
+	static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+	Long exp[2];
+	Bigint *B[2];
+	int k, rv[2];
+	ULong *L = (ULong *)a, *M = (ULong *)b;
+
+	B[0] = Balloc(1);
+	B[0]->wds = 2;
+	k = strtoIg(s, sp, &fpi, exp, B, rv);
+	ULtoxL(L, B[0]->x, exp[0], rv[0]);
+	Bfree(B[0]);
+	if (B[1]) {
+		ULtoxL(M, B[1]->x, exp[1], rv[1]);
+		Bfree(B[1]);
+		}
+	else {
+		M[0] = L[0];
+		M[1] = L[1];
+		M[2] = L[2];
+		}
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtod.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtod.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtod.c	(revision 2404)
@@ -0,0 +1,966 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	dmg@acm.org
+ */
+
+#include "gdtoaimp.h"
+
+#ifdef USE_LOCALE
+#include "locale.h"
+#endif
+
+#ifdef IEEE_Arith
+#ifndef NO_IEEE_Scale
+#define Avoid_Underflow
+#undef tinytens
+/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */
+/* flag unnecessarily.  It leads to a song and dance at the end of strtod. */
+static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,
+		9007199254740992.e-256
+		};
+#endif
+#endif
+
+#ifdef Honor_FLT_ROUNDS
+#define Rounding rounding
+#undef Check_FLT_ROUNDS
+#define Check_FLT_ROUNDS
+#else
+#define Rounding Flt_Rounds
+#endif
+
+ double
+strtod
+#ifdef KR_headers
+	(s00, se) CONST char *s00; char **se;
+#else
+	(CONST char *s00, char **se)
+#endif
+{
+#ifdef Avoid_Underflow
+	int scale;
+#endif
+	int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
+		 e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
+	CONST char *s, *s0, *s1;
+	double aadj, aadj1, adj, rv, rv0;
+	Long L;
+	ULong y, z;
+	Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
+#ifdef SET_INEXACT
+	int inexact, oldinexact;
+#endif
+#ifdef Honor_FLT_ROUNDS
+	int rounding;
+#endif
+
+	sign = nz0 = nz = 0;
+	dval(rv) = 0.;
+	for(s = s00;;s++) switch(*s) {
+		case '-':
+			sign = 1;
+			/* no break */
+		case '+':
+			if (*++s)
+				goto break2;
+			/* no break */
+		case 0:
+			goto ret0;
+		case '\t':
+		case '\n':
+		case '\v':
+		case '\f':
+		case '\r':
+		case ' ':
+			continue;
+		default:
+			goto break2;
+		}
+ break2:
+	if (*s == '0') {
+#ifndef NO_HEX_FP
+		{
+		static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
+		Long exp;
+		ULong bits[2];
+		switch(s[1]) {
+		  case 'x':
+		  case 'X':
+			switch((i = gethex(&s, &fpi, &exp, &bb, sign)) & STRTOG_Retmask) {
+			  case STRTOG_NoNumber:
+				s = s00;
+				sign = 0;
+			  case STRTOG_Zero:
+				break;
+			  default:
+				if (bb) {
+					copybits(bits, fpi.nbits, bb);
+					Bfree(bb);
+					}
+				ULtod(((U*)&rv)->L, bits, exp, i);
+			  }
+			goto ret;
+		  }
+		}
+#endif
+		nz0 = 1;
+		while(*++s == '0') ;
+		if (!*s)
+			goto ret;
+		}
+	s0 = s;
+	y = z = 0;
+	for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
+		if (nd < 9)
+			y = 10*y + c - '0';
+		else if (nd < 16)
+			z = 10*z + c - '0';
+	nd0 = nd;
+#ifdef USE_LOCALE
+	if (c == *localeconv()->decimal_point)
+#else
+	if (c == '.')
+#endif
+		{
+		c = *++s;
+		if (!nd) {
+			for(; c == '0'; c = *++s)
+				nz++;
+			if (c > '0' && c <= '9') {
+				s0 = s;
+				nf += nz;
+				nz = 0;
+				goto have_dig;
+				}
+			goto dig_done;
+			}
+		for(; c >= '0' && c <= '9'; c = *++s) {
+ have_dig:
+			nz++;
+			if (c -= '0') {
+				nf += nz;
+				for(i = 1; i < nz; i++)
+					if (nd++ < 9)
+						y *= 10;
+					else if (nd <= DBL_DIG + 1)
+						z *= 10;
+				if (nd++ < 9)
+					y = 10*y + c;
+				else if (nd <= DBL_DIG + 1)
+					z = 10*z + c;
+				nz = 0;
+				}
+			}
+		}
+ dig_done:
+	e = 0;
+	if (c == 'e' || c == 'E') {
+		if (!nd && !nz && !nz0) {
+			goto ret0;
+			}
+		s00 = s;
+		esign = 0;
+		switch(c = *++s) {
+			case '-':
+				esign = 1;
+			case '+':
+				c = *++s;
+			}
+		if (c >= '0' && c <= '9') {
+			while(c == '0')
+				c = *++s;
+			if (c > '0' && c <= '9') {
+				L = c - '0';
+				s1 = s;
+				while((c = *++s) >= '0' && c <= '9')
+					L = 10*L + c - '0';
+				if (s - s1 > 8 || L > 19999)
+					/* Avoid confusion from exponents
+					 * so large that e might overflow.
+					 */
+					e = 19999; /* safe for 16 bit ints */
+				else
+					e = (int)L;
+				if (esign)
+					e = -e;
+				}
+			else
+				e = 0;
+			}
+		else
+			s = s00;
+		}
+	if (!nd) {
+		if (!nz && !nz0) {
+#ifdef INFNAN_CHECK
+			/* Check for Nan and Infinity */
+			ULong bits[2];
+			static FPI fpinan =	/* only 52 explicit bits */
+				{ 52, 1-1023-53+1, 2046-1023-53+1, 1, SI };
+			switch(c) {
+			  case 'i':
+			  case 'I':
+				if (match(&s,"nf")) {
+					--s;
+					if (!match(&s,"inity"))
+						++s;
+					word0(rv) = 0x7ff00000;
+					word1(rv) = 0;
+					goto ret;
+					}
+				break;
+			  case 'n':
+			  case 'N':
+				if (match(&s, "an")) {
+#ifndef No_Hex_NaN
+					if (*s == '(' /*)*/
+					 && hexnan(&s, &fpinan, bits)
+							== STRTOG_NaNbits) {
+						word0(rv) = 0x7ff00000 | bits[1];
+						word1(rv) = bits[0];
+						}
+					else {
+						word0(rv) = NAN_WORD0;
+						word1(rv) = NAN_WORD1;
+						}
+#endif
+					goto ret;
+					}
+			  }
+#endif /* INFNAN_CHECK */
+ ret0:
+			s = s00;
+			sign = 0;
+			}
+		goto ret;
+		}
+	e1 = e -= nf;
+
+	/* Now we have nd0 digits, starting at s0, followed by a
+	 * decimal point, followed by nd-nd0 digits.  The number we're
+	 * after is the integer represented by those digits times
+	 * 10**e */
+
+	if (!nd0)
+		nd0 = nd;
+	k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
+	dval(rv) = y;
+	if (k > 9) {
+#ifdef SET_INEXACT
+		if (k > DBL_DIG)
+			oldinexact = get_inexact();
+#endif
+		dval(rv) = tens[k - 9] * dval(rv) + z;
+		}
+	bd0 = 0;
+	if (nd <= DBL_DIG
+#ifndef RND_PRODQUOT
+#ifndef Honor_FLT_ROUNDS
+		&& Flt_Rounds == 1
+#endif
+#endif
+			) {
+		if (!e)
+			goto ret;
+		if (e > 0) {
+			if (e <= Ten_pmax) {
+#ifdef VAX
+				goto vax_ovfl_check;
+#else
+#ifdef Honor_FLT_ROUNDS
+				/* round correctly FLT_ROUNDS = 2 or 3 */
+				if (sign) {
+					rv = -rv;
+					sign = 0;
+					}
+#endif
+				/* rv = */ rounded_product(dval(rv), tens[e]);
+				goto ret;
+#endif
+				}
+			i = DBL_DIG - nd;
+			if (e <= Ten_pmax + i) {
+				/* A fancier test would sometimes let us do
+				 * this for larger i values.
+				 */
+#ifdef Honor_FLT_ROUNDS
+				/* round correctly FLT_ROUNDS = 2 or 3 */
+				if (sign) {
+					rv = -rv;
+					sign = 0;
+					}
+#endif
+				e -= i;
+				dval(rv) *= tens[i];
+#ifdef VAX
+				/* VAX exponent range is so narrow we must
+				 * worry about overflow here...
+				 */
+ vax_ovfl_check:
+				word0(rv) -= P*Exp_msk1;
+				/* rv = */ rounded_product(dval(rv), tens[e]);
+				if ((word0(rv) & Exp_mask)
+				 > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
+					goto ovfl;
+				word0(rv) += P*Exp_msk1;
+#else
+				/* rv = */ rounded_product(dval(rv), tens[e]);
+#endif
+				goto ret;
+				}
+			}
+#ifndef Inaccurate_Divide
+		else if (e >= -Ten_pmax) {
+#ifdef Honor_FLT_ROUNDS
+			/* round correctly FLT_ROUNDS = 2 or 3 */
+			if (sign) {
+				rv = -rv;
+				sign = 0;
+				}
+#endif
+			/* rv = */ rounded_quotient(dval(rv), tens[-e]);
+			goto ret;
+			}
+#endif
+		}
+	e1 += nd - k;
+
+#ifdef IEEE_Arith
+#ifdef SET_INEXACT
+	inexact = 1;
+	if (k <= DBL_DIG)
+		oldinexact = get_inexact();
+#endif
+#ifdef Avoid_Underflow
+	scale = 0;
+#endif
+#ifdef Honor_FLT_ROUNDS
+	if ((rounding = Flt_Rounds) >= 2) {
+		if (sign)
+			rounding = rounding == 2 ? 0 : 2;
+		else
+			if (rounding != 2)
+				rounding = 0;
+		}
+#endif
+#endif /*IEEE_Arith*/
+
+	/* Get starting approximation = rv * 10**e1 */
+
+	if (e1 > 0) {
+		if ( (i = e1 & 15) !=0)
+			dval(rv) *= tens[i];
+		if (e1 &= ~15) {
+			if (e1 > DBL_MAX_10_EXP) {
+ ovfl:
+#ifndef NO_ERRNO
+				errno = ERANGE;
+#endif
+				/* Can't trust HUGE_VAL */
+#ifdef IEEE_Arith
+#ifdef Honor_FLT_ROUNDS
+				switch(rounding) {
+				  case 0: /* toward 0 */
+				  case 3: /* toward -infinity */
+					word0(rv) = Big0;
+					word1(rv) = Big1;
+					break;
+				  default:
+					word0(rv) = Exp_mask;
+					word1(rv) = 0;
+				  }
+#else /*Honor_FLT_ROUNDS*/
+				word0(rv) = Exp_mask;
+				word1(rv) = 0;
+#endif /*Honor_FLT_ROUNDS*/
+#ifdef SET_INEXACT
+				/* set overflow bit */
+				dval(rv0) = 1e300;
+				dval(rv0) *= dval(rv0);
+#endif
+#else /*IEEE_Arith*/
+				word0(rv) = Big0;
+				word1(rv) = Big1;
+#endif /*IEEE_Arith*/
+				if (bd0)
+					goto retfree;
+				goto ret;
+				}
+			e1 >>= 4;
+			for(j = 0; e1 > 1; j++, e1 >>= 1)
+				if (e1 & 1)
+					dval(rv) *= bigtens[j];
+		/* The last multiplication could overflow. */
+			word0(rv) -= P*Exp_msk1;
+			dval(rv) *= bigtens[j];
+			if ((z = word0(rv) & Exp_mask)
+			 > Exp_msk1*(DBL_MAX_EXP+Bias-P))
+				goto ovfl;
+			if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
+				/* set to largest number */
+				/* (Can't trust DBL_MAX) */
+				word0(rv) = Big0;
+				word1(rv) = Big1;
+				}
+			else
+				word0(rv) += P*Exp_msk1;
+			}
+		}
+	else if (e1 < 0) {
+		e1 = -e1;
+		if ( (i = e1 & 15) !=0)
+			dval(rv) /= tens[i];
+		if (e1 >>= 4) {
+			if (e1 >= 1 << n_bigtens)
+				goto undfl;
+#ifdef Avoid_Underflow
+			if (e1 & Scale_Bit)
+				scale = 2*P;
+			for(j = 0; e1 > 0; j++, e1 >>= 1)
+				if (e1 & 1)
+					dval(rv) *= tinytens[j];
+			if (scale && (j = 2*P + 1 - ((word0(rv) & Exp_mask)
+						>> Exp_shift)) > 0) {
+				/* scaled rv is denormal; zap j low bits */
+				if (j >= 32) {
+					word1(rv) = 0;
+					if (j >= 53)
+					 word0(rv) = (P+2)*Exp_msk1;
+					else
+					 word0(rv) &= 0xffffffff << j-32;
+					}
+				else
+					word1(rv) &= 0xffffffff << j;
+				}
+#else
+			for(j = 0; e1 > 1; j++, e1 >>= 1)
+				if (e1 & 1)
+					dval(rv) *= tinytens[j];
+			/* The last multiplication could underflow. */
+			dval(rv0) = dval(rv);
+			dval(rv) *= tinytens[j];
+			if (!dval(rv)) {
+				dval(rv) = 2.*dval(rv0);
+				dval(rv) *= tinytens[j];
+#endif
+				if (!dval(rv)) {
+ undfl:
+					dval(rv) = 0.;
+#ifndef NO_ERRNO
+					errno = ERANGE;
+#endif
+					if (bd0)
+						goto retfree;
+					goto ret;
+					}
+#ifndef Avoid_Underflow
+				word0(rv) = Tiny0;
+				word1(rv) = Tiny1;
+				/* The refinement below will clean
+				 * this approximation up.
+				 */
+				}
+#endif
+			}
+		}
+
+	/* Now the hard part -- adjusting rv to the correct value.*/
+
+	/* Put digits into bd: true value = bd * 10^e */
+
+	bd0 = s2b(s0, nd0, nd, y);
+
+	for(;;) {
+		bd = Balloc(bd0->k);
+		Bcopy(bd, bd0);
+		bb = d2b(dval(rv), &bbe, &bbbits);	/* rv = bb * 2^bbe */
+		bs = i2b(1);
+
+		if (e >= 0) {
+			bb2 = bb5 = 0;
+			bd2 = bd5 = e;
+			}
+		else {
+			bb2 = bb5 = -e;
+			bd2 = bd5 = 0;
+			}
+		if (bbe >= 0)
+			bb2 += bbe;
+		else
+			bd2 -= bbe;
+		bs2 = bb2;
+#ifdef Honor_FLT_ROUNDS
+		if (rounding != 1)
+			bs2++;
+#endif
+#ifdef Avoid_Underflow
+		j = bbe - scale;
+		i = j + bbbits - 1;	/* logb(rv) */
+		if (i < Emin)	/* denormal */
+			j += P - Emin;
+		else
+			j = P + 1 - bbbits;
+#else /*Avoid_Underflow*/
+#ifdef Sudden_Underflow
+#ifdef IBM
+		j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
+#else
+		j = P + 1 - bbbits;
+#endif
+#else /*Sudden_Underflow*/
+		j = bbe;
+		i = j + bbbits - 1;	/* logb(rv) */
+		if (i < Emin)	/* denormal */
+			j += P - Emin;
+		else
+			j = P + 1 - bbbits;
+#endif /*Sudden_Underflow*/
+#endif /*Avoid_Underflow*/
+		bb2 += j;
+		bd2 += j;
+#ifdef Avoid_Underflow
+		bd2 += scale;
+#endif
+		i = bb2 < bd2 ? bb2 : bd2;
+		if (i > bs2)
+			i = bs2;
+		if (i > 0) {
+			bb2 -= i;
+			bd2 -= i;
+			bs2 -= i;
+			}
+		if (bb5 > 0) {
+			bs = pow5mult(bs, bb5);
+			bb1 = mult(bs, bb);
+			Bfree(bb);
+			bb = bb1;
+			}
+		if (bb2 > 0)
+			bb = lshift(bb, bb2);
+		if (bd5 > 0)
+			bd = pow5mult(bd, bd5);
+		if (bd2 > 0)
+			bd = lshift(bd, bd2);
+		if (bs2 > 0)
+			bs = lshift(bs, bs2);
+		delta = diff(bb, bd);
+		dsign = delta->sign;
+		delta->sign = 0;
+		i = cmp(delta, bs);
+#ifdef Honor_FLT_ROUNDS
+		if (rounding != 1) {
+			if (i < 0) {
+				/* Error is less than an ulp */
+				if (!delta->x[0] && delta->wds <= 1) {
+					/* exact */
+#ifdef SET_INEXACT
+					inexact = 0;
+#endif
+					break;
+					}
+				if (rounding) {
+					if (dsign) {
+						adj = 1.;
+						goto apply_adj;
+						}
+					}
+				else if (!dsign) {
+					adj = -1.;
+					if (!word1(rv)
+					 && !(word0(rv) & Frac_mask)) {
+						y = word0(rv) & Exp_mask;
+#ifdef Avoid_Underflow
+						if (!scale || y > 2*P*Exp_msk1)
+#else
+						if (y)
+#endif
+						  {
+						  delta = lshift(delta,Log2P);
+						  if (cmp(delta, bs) <= 0)
+							adj = -0.5;
+						  }
+						}
+ apply_adj:
+#ifdef Avoid_Underflow
+					if (scale && (y = word0(rv) & Exp_mask)
+						<= 2*P*Exp_msk1)
+					  word0(adj) += (2*P+1)*Exp_msk1 - y;
+#else
+#ifdef Sudden_Underflow
+					if ((word0(rv) & Exp_mask) <=
+							P*Exp_msk1) {
+						word0(rv) += P*Exp_msk1;
+						dval(rv) += adj*ulp(dval(rv));
+						word0(rv) -= P*Exp_msk1;
+						}
+					else
+#endif /*Sudden_Underflow*/
+#endif /*Avoid_Underflow*/
+					dval(rv) += adj*ulp(dval(rv));
+					}
+				break;
+				}
+			adj = ratio(delta, bs);
+			if (adj < 1.)
+				adj = 1.;
+			if (adj <= 0x7ffffffe) {
+				/* adj = rounding ? ceil(adj) : floor(adj); */
+				y = adj;
+				if (y != adj) {
+					if (!((rounding>>1) ^ dsign))
+						y++;
+					adj = y;
+					}
+				}
+#ifdef Avoid_Underflow
+			if (scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
+				word0(adj) += (2*P+1)*Exp_msk1 - y;
+#else
+#ifdef Sudden_Underflow
+			if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
+				word0(rv) += P*Exp_msk1;
+				adj *= ulp(dval(rv));
+				if (dsign)
+					dval(rv) += adj;
+				else
+					dval(rv) -= adj;
+				word0(rv) -= P*Exp_msk1;
+				goto cont;
+				}
+#endif /*Sudden_Underflow*/
+#endif /*Avoid_Underflow*/
+			adj *= ulp(dval(rv));
+			if (dsign)
+				dval(rv) += adj;
+			else
+				dval(rv) -= adj;
+			goto cont;
+			}
+#endif /*Honor_FLT_ROUNDS*/
+
+		if (i < 0) {
+			/* Error is less than half an ulp -- check for
+			 * special case of mantissa a power of two.
+			 */
+			if (dsign || word1(rv) || word0(rv) & Bndry_mask
+#ifdef IEEE_Arith
+#ifdef Avoid_Underflow
+			 || (word0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1
+#else
+			 || (word0(rv) & Exp_mask) <= Exp_msk1
+#endif
+#endif
+				) {
+#ifdef SET_INEXACT
+				if (!delta->x[0] && delta->wds <= 1)
+					inexact = 0;
+#endif
+				break;
+				}
+			if (!delta->x[0] && delta->wds <= 1) {
+				/* exact result */
+#ifdef SET_INEXACT
+				inexact = 0;
+#endif
+				break;
+				}
+			delta = lshift(delta,Log2P);
+			if (cmp(delta, bs) > 0)
+				goto drop_down;
+			break;
+			}
+		if (i == 0) {
+			/* exactly half-way between */
+			if (dsign) {
+				if ((word0(rv) & Bndry_mask1) == Bndry_mask1
+				 &&  word1(rv) == (
+#ifdef Avoid_Underflow
+			(scale && (y = word0(rv) & Exp_mask) <= 2*P*Exp_msk1)
+		? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :
+#endif
+						   0xffffffff)) {
+					/*boundary case -- increment exponent*/
+					word0(rv) = (word0(rv) & Exp_mask)
+						+ Exp_msk1
+#ifdef IBM
+						| Exp_msk1 >> 4
+#endif
+						;
+					word1(rv) = 0;
+#ifdef Avoid_Underflow
+					dsign = 0;
+#endif
+					break;
+					}
+				}
+			else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {
+ drop_down:
+				/* boundary case -- decrement exponent */
+#ifdef Sudden_Underflow /*{{*/
+				L = word0(rv) & Exp_mask;
+#ifdef IBM
+				if (L <  Exp_msk1)
+#else
+#ifdef Avoid_Underflow
+				if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1))
+#else
+				if (L <= Exp_msk1)
+#endif /*Avoid_Underflow*/
+#endif /*IBM*/
+					goto undfl;
+				L -= Exp_msk1;
+#else /*Sudden_Underflow}{*/
+#ifdef Avoid_Underflow
+				if (scale) {
+					L = word0(rv) & Exp_mask;
+					if (L <= (2*P+1)*Exp_msk1) {
+						if (L > (P+2)*Exp_msk1)
+							/* round even ==> */
+							/* accept rv */
+							break;
+						/* rv = smallest denormal */
+						goto undfl;
+						}
+					}
+#endif /*Avoid_Underflow*/
+				L = (word0(rv) & Exp_mask) - Exp_msk1;
+#endif /*Sudden_Underflow}*/
+				word0(rv) = L | Bndry_mask1;
+				word1(rv) = 0xffffffff;
+#ifdef IBM
+				goto cont;
+#else
+				break;
+#endif
+				}
+#ifndef ROUND_BIASED
+			if (!(word1(rv) & LSB))
+				break;
+#endif
+			if (dsign)
+				dval(rv) += ulp(dval(rv));
+#ifndef ROUND_BIASED
+			else {
+				dval(rv) -= ulp(dval(rv));
+#ifndef Sudden_Underflow
+				if (!dval(rv))
+					goto undfl;
+#endif
+				}
+#ifdef Avoid_Underflow
+			dsign = 1 - dsign;
+#endif
+#endif
+			break;
+			}
+		if ((aadj = ratio(delta, bs)) <= 2.) {
+			if (dsign)
+				aadj = aadj1 = 1.;
+			else if (word1(rv) || word0(rv) & Bndry_mask) {
+#ifndef Sudden_Underflow
+				if (word1(rv) == Tiny1 && !word0(rv))
+					goto undfl;
+#endif
+				aadj = 1.;
+				aadj1 = -1.;
+				}
+			else {
+				/* special case -- power of FLT_RADIX to be */
+				/* rounded down... */
+
+				if (aadj < 2./FLT_RADIX)
+					aadj = 1./FLT_RADIX;
+				else
+					aadj *= 0.5;
+				aadj1 = -aadj;
+				}
+			}
+		else {
+			aadj *= 0.5;
+			aadj1 = dsign ? aadj : -aadj;
+#ifdef Check_FLT_ROUNDS
+			switch(Rounding) {
+				case 2: /* towards +infinity */
+					aadj1 -= 0.5;
+					break;
+				case 0: /* towards 0 */
+				case 3: /* towards -infinity */
+					aadj1 += 0.5;
+				}
+#else
+			if (Flt_Rounds == 0)
+				aadj1 += 0.5;
+#endif /*Check_FLT_ROUNDS*/
+			}
+		y = word0(rv) & Exp_mask;
+
+		/* Check for overflow */
+
+		if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
+			dval(rv0) = dval(rv);
+			word0(rv) -= P*Exp_msk1;
+			adj = aadj1 * ulp(dval(rv));
+			dval(rv) += adj;
+			if ((word0(rv) & Exp_mask) >=
+					Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
+				if (word0(rv0) == Big0 && word1(rv0) == Big1)
+					goto ovfl;
+				word0(rv) = Big0;
+				word1(rv) = Big1;
+				goto cont;
+				}
+			else
+				word0(rv) += P*Exp_msk1;
+			}
+		else {
+#ifdef Avoid_Underflow
+			if (scale && y <= 2*P*Exp_msk1) {
+				if (aadj <= 0x7fffffff) {
+					if ((z = aadj) <= 0)
+						z = 1;
+					aadj = z;
+					aadj1 = dsign ? aadj : -aadj;
+					}
+				word0(aadj1) += (2*P+1)*Exp_msk1 - y;
+				}
+			adj = aadj1 * ulp(dval(rv));
+			dval(rv) += adj;
+#else
+#ifdef Sudden_Underflow
+			if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
+				dval(rv0) = dval(rv);
+				word0(rv) += P*Exp_msk1;
+				adj = aadj1 * ulp(dval(rv));
+				dval(rv) += adj;
+#ifdef IBM
+				if ((word0(rv) & Exp_mask) <  P*Exp_msk1)
+#else
+				if ((word0(rv) & Exp_mask) <= P*Exp_msk1)
+#endif
+					{
+					if (word0(rv0) == Tiny0
+					 && word1(rv0) == Tiny1)
+						goto undfl;
+					word0(rv) = Tiny0;
+					word1(rv) = Tiny1;
+					goto cont;
+					}
+				else
+					word0(rv) -= P*Exp_msk1;
+				}
+			else {
+				adj = aadj1 * ulp(dval(rv));
+				dval(rv) += adj;
+				}
+#else /*Sudden_Underflow*/
+			/* Compute adj so that the IEEE rounding rules will
+			 * correctly round rv + adj in some half-way cases.
+			 * If rv * ulp(rv) is denormalized (i.e.,
+			 * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
+			 * trouble from bits lost to denormalization;
+			 * example: 1.2e-307 .
+			 */
+			if (y <= (P-1)*Exp_msk1 && aadj > 1.) {
+				aadj1 = (double)(int)(aadj + 0.5);
+				if (!dsign)
+					aadj1 = -aadj1;
+				}
+			adj = aadj1 * ulp(dval(rv));
+			dval(rv) += adj;
+#endif /*Sudden_Underflow*/
+#endif /*Avoid_Underflow*/
+			}
+		z = word0(rv) & Exp_mask;
+#ifndef SET_INEXACT
+#ifdef Avoid_Underflow
+		if (!scale)
+#endif
+		if (y == z) {
+			/* Can we stop now? */
+			L = (Long)aadj;
+			aadj -= L;
+			/* The tolerances below are conservative. */
+			if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
+				if (aadj < .4999999 || aadj > .5000001)
+					break;
+				}
+			else if (aadj < .4999999/FLT_RADIX)
+				break;
+			}
+#endif
+ cont:
+		Bfree(bb);
+		Bfree(bd);
+		Bfree(bs);
+		Bfree(delta);
+		}
+#ifdef SET_INEXACT
+	if (inexact) {
+		if (!oldinexact) {
+			word0(rv0) = Exp_1 + (70 << Exp_shift);
+			word1(rv0) = 0;
+			dval(rv0) += 1.;
+			}
+		}
+	else if (!oldinexact)
+		clear_inexact();
+#endif
+#ifdef Avoid_Underflow
+	if (scale) {
+		word0(rv0) = Exp_1 - 2*P*Exp_msk1;
+		word1(rv0) = 0;
+		dval(rv) *= dval(rv0);
+#ifndef NO_ERRNO
+		/* try to avoid the bug of testing an 8087 register value */
+		if (word0(rv) == 0 && word1(rv) == 0)
+			errno = ERANGE;
+#endif
+		}
+#endif /* Avoid_Underflow */
+#ifdef SET_INEXACT
+	if (inexact && !(word0(rv) & Exp_mask)) {
+		/* set underflow bit */
+		dval(rv0) = 1e-300;
+		dval(rv0) *= dval(rv0);
+		}
+#endif
+ retfree:
+	Bfree(bb);
+	Bfree(bd);
+	Bfree(bs);
+	Bfree(bd0);
+	Bfree(delta);
+ ret:
+	if (se)
+		*se = (char *)s;
+	return sign ? -dval(rv) : dval(rv);
+	}
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtodI.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtodI.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtodI.c	(revision 2404)
@@ -0,0 +1,177 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ static double
+#ifdef KR_headers
+ulpdown(d) double *d;
+#else
+ulpdown(double *d)
+#endif
+{
+	double u;
+	ULong *L = (ULong*)d;
+
+	u = ulp(*d);
+	if (!(L[_1] | L[_0] & 0xfffff)
+	 && (L[_0] & 0x7ff00000) > 0x00100000)
+		u *= 0.5;
+	return u;
+	}
+
+ int
+#ifdef KR_headers
+strtodI(s, sp, dd) CONST char *s; char **sp; double *dd;
+#else
+strtodI(CONST char *s, char **sp, double *dd)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, 1 };
+#else
+	static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, 0 };
+#endif
+	ULong bits[2], sign;
+	Long exp;
+	int j, k;
+	typedef union {
+		double d[2];
+		ULong L[4];
+		} U;
+	U *u;
+
+	k = strtodg(s, sp, &fpi, &exp, bits);
+	u = (U*)dd;
+	sign = k & STRTOG_Neg ? 0x80000000L : 0;
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+		u->d[0] = u->d[1] = 0.;
+		break;
+
+	  case STRTOG_Zero:
+		u->d[0] = u->d[1] = 0.;
+#ifdef Sudden_Underflow
+		if (k & STRTOG_Inexact) {
+			if (sign)
+				u->L[_0] = 0x80100000L;
+			else
+				u->L[2+_0] = 0x100000L;
+			}
+		break;
+#else
+		goto contain;
+#endif
+
+	  case STRTOG_Denormal:
+		u->L[_1] = bits[0];
+		u->L[_0] = bits[1];
+		goto contain;
+
+	  case STRTOG_Normal:
+		u->L[_1] = bits[0];
+		u->L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
+	  contain:
+		j = k & STRTOG_Inexact;
+		if (sign) {
+			u->L[_0] |= sign;
+			j = STRTOG_Inexact - j;
+			}
+		switch(j) {
+		  case STRTOG_Inexlo:
+#ifdef Sudden_Underflow
+			if ((u->L[_0] & 0x7ff00000) < 0x3500000) {
+				u->L[2+_0] = u->L[_0] + 0x3500000;
+				u->L[2+_1] = u->L[_1];
+				u->d[1] += ulp(u->d[1]);
+				u->L[2+_0] -= 0x3500000;
+				if (!(u->L[2+_0] & 0x7ff00000)) {
+					u->L[2+_0] = sign;
+					u->L[2+_1] = 0;
+					}
+				}
+			else
+#endif
+			u->d[1] = u->d[0] + ulp(u->d[0]);
+			break;
+		  case STRTOG_Inexhi:
+			u->d[1] = u->d[0];
+#ifdef Sudden_Underflow
+			if ((u->L[_0] & 0x7ff00000) < 0x3500000) {
+				u->L[_0] += 0x3500000;
+				u->d[0] -= ulpdown(u->d);
+				u->L[_0] -= 0x3500000;
+				if (!(u->L[_0] & 0x7ff00000)) {
+					u->L[_0] = sign;
+					u->L[_1] = 0;
+					}
+				}
+			else
+#endif
+			u->d[0] -= ulpdown(u->d);
+			break;
+		  default:
+			u->d[1] = u->d[0];
+		  }
+		break;
+
+	  case STRTOG_Infinite:
+		u->L[_0] = u->L[2+_0] = sign | 0x7ff00000;
+		u->L[_1] = u->L[2+_1] = 0;
+		if (k & STRTOG_Inexact) {
+			if (sign) {
+				u->L[2+_0] = 0xffefffffL;
+				u->L[2+_1] = 0xffffffffL;
+				}
+			else {
+				u->L[_0] = 0x7fefffffL;
+				u->L[_1] = 0xffffffffL;
+				}
+			}
+		break;
+
+	  case STRTOG_NaN:
+		u->L[_0] = u->L[2+_0] = 0x7fffffff | sign;
+		u->L[_1] = u->L[2+_1] = (ULong)-1;
+		break;
+
+	  case STRTOG_NaNbits:
+		u->L[_0] = u->L[2+_0] = 0x7ff00000 | sign | bits[1];
+		u->L[_1] = u->L[2+_1] = bits[0];
+	  }
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtodg.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtodg.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtodg.c	(revision 2404)
@@ -0,0 +1,1001 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	dmg@acm.org
+ */
+
+#include "gdtoaimp.h"
+
+#ifdef USE_LOCALE
+#include "locale.h"
+#endif
+
+ static CONST int
+fivesbits[] = {	 0,  3,  5,  7, 10, 12, 14, 17, 19, 21,
+		24, 26, 28, 31, 33, 35, 38, 40, 42, 45,
+		47, 49, 52
+#ifdef VAX
+		, 54, 56
+#endif
+		};
+
+ Bigint *
+#ifdef KR_headers
+increment(b) Bigint *b;
+#else
+increment(Bigint *b)
+#endif
+{
+	ULong *x, *xe;
+	Bigint *b1;
+#ifdef Pack_16
+	ULong carry = 1, y;
+#endif
+
+	x = b->x;
+	xe = x + b->wds;
+#ifdef Pack_32
+	do {
+		if (*x < (ULong)0xffffffffL) {
+			++*x;
+			return b;
+			}
+		*x++ = 0;
+		} while(x < xe);
+#else
+	do {
+		y = *x + carry;
+		carry = y >> 16;
+		*x++ = y & 0xffff;
+		if (!carry)
+			return b;
+		} while(x < xe);
+	if (carry)
+#endif
+	{
+		if (b->wds >= b->maxwds) {
+			b1 = Balloc(b->k+1);
+			Bcopy(b1,b);
+			Bfree(b);
+			b = b1;
+			}
+		b->x[b->wds++] = 1;
+		}
+	return b;
+	}
+
+ int
+#ifdef KR_headers
+decrement(b) Bigint *b;
+#else
+decrement(Bigint *b)
+#endif
+{
+	ULong *x, *xe;
+#ifdef Pack_16
+	ULong borrow = 1, y;
+#endif
+
+	x = b->x;
+	xe = x + b->wds;
+#ifdef Pack_32
+	do {
+		if (*x) {
+			--*x;
+			break;
+			}
+		*x++ = 0xffffffffL;
+		}
+		while(x < xe);
+#else
+	do {
+		y = *x - borrow;
+		borrow = (y & 0x10000) >> 16;
+		*x++ = y & 0xffff;
+		} while(borrow && x < xe);
+#endif
+	return STRTOG_Inexlo;
+	}
+
+ static int
+#ifdef KR_headers
+all_on(b, n) Bigint *b; int n;
+#else
+all_on(Bigint *b, int n)
+#endif
+{
+	ULong *x, *xe;
+
+	x = b->x;
+	xe = x + (n >> kshift);
+	while(x < xe)
+		if ((*x++ & ALL_ON) != ALL_ON)
+			return 0;
+	if (n &= kmask)
+		return ((*x | (ALL_ON << n)) & ALL_ON) == ALL_ON;
+	return 1;
+	}
+
+ Bigint *
+#ifdef KR_headers
+set_ones(b, n) Bigint *b; int n;
+#else
+set_ones(Bigint *b, int n)
+#endif
+{
+	int k;
+	ULong *x, *xe;
+
+	k = (n + ((1 << kshift) - 1)) >> kshift;
+	if (b->k < k) {
+		Bfree(b);
+		b = Balloc(k);
+		}
+	k = n >> kshift;
+	if (n &= kmask)
+		k++;
+	b->wds = k;
+	x = b->x;
+	xe = x + k;
+	while(x < xe)
+		*x++ = ALL_ON;
+	if (n)
+		x[-1] >>= ULbits - n;
+	return b;
+	}
+
+ static int
+rvOK
+#ifdef KR_headers
+ (d, fpi, exp, bits, exact, rd, irv)
+ double d; FPI *fpi; Long *exp; ULong *bits; int exact, rd, *irv;
+#else
+ (double d, FPI *fpi, Long *exp, ULong *bits, int exact, int rd, int *irv)
+#endif
+{
+	Bigint *b;
+	ULong carry, inex, lostbits;
+	int bdif, e, j, k, k1, nb, rv;
+
+	carry = rv = 0;
+	b = d2b(d, &e, &bdif);
+	bdif -= nb = fpi->nbits;
+	e += bdif;
+	if (bdif <= 0) {
+		if (exact)
+			goto trunc;
+		goto ret;
+		}
+	if (P == nb) {
+		if (
+#ifndef IMPRECISE_INEXACT
+			exact &&
+#endif
+			fpi->rounding ==
+#ifdef RND_PRODQUOT
+					FPI_Round_near
+#else
+					Flt_Rounds
+#endif
+			) goto trunc;
+		goto ret;
+		}
+	switch(rd) {
+	  case 1:
+		goto trunc;
+	  case 2:
+		break;
+	  default: /* round near */
+		k = bdif - 1;
+		if (k < 0)
+			goto trunc;
+		if (!k) {
+			if (!exact)
+				goto ret;
+			if (b->x[0] & 2)
+				break;
+			goto trunc;
+			}
+		if (b->x[k>>kshift] & ((ULong)1 << (k & kmask)))
+			break;
+		goto trunc;
+	  }
+	/* "break" cases: round up 1 bit, then truncate; bdif > 0 */
+	carry = 1;
+ trunc:
+	inex = lostbits = 0;
+	if (bdif > 0) {
+		if ( (lostbits = any_on(b, bdif)) !=0)
+			inex = STRTOG_Inexlo;
+		rshift(b, bdif);
+		if (carry) {
+			inex = STRTOG_Inexhi;
+			b = increment(b);
+			if ( (j = nb & kmask) !=0)
+				j = 32 - j;
+			if (hi0bits(b->x[b->wds - 1]) != j) {
+				if (!lostbits)
+					lostbits = b->x[0] & 1;
+				rshift(b, 1);
+				e++;
+				}
+			}
+		}
+	else if (bdif < 0)
+		b = lshift(b, -bdif);
+	if (e < fpi->emin) {
+		k = fpi->emin - e;
+		e = fpi->emin;
+		if (k > nb || fpi->sudden_underflow) {
+			b->wds = inex = 0;
+			*irv = STRTOG_Underflow | STRTOG_Inexlo;
+			}
+		else {
+			k1 = k - 1;
+			if (k1 > 0 && !lostbits)
+				lostbits = any_on(b, k1);
+			if (!lostbits && !exact)
+				goto ret;
+			lostbits |=
+			  carry = b->x[k1>>kshift] & (1 << (k1 & kmask));
+			rshift(b, k);
+			*irv = STRTOG_Denormal;
+			if (carry) {
+				b = increment(b);
+				inex = STRTOG_Inexhi | STRTOG_Underflow;
+				}
+			else if (lostbits)
+				inex = STRTOG_Inexlo | STRTOG_Underflow;
+			}
+		}
+	else if (e > fpi->emax) {
+		e = fpi->emax + 1;
+		*irv = STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi;
+#ifndef NO_ERRNO
+		errno = ERANGE;
+#endif
+		b->wds = inex = 0;
+		}
+	*exp = e;
+	copybits(bits, nb, b);
+	*irv |= inex;
+	rv = 1;
+ ret:
+	Bfree(b);
+	return rv;
+	}
+
+ static int
+#ifdef KR_headers
+mantbits(d) double d;
+#else
+mantbits(double d)
+#endif
+{
+	ULong L;
+#ifdef VAX
+	L = word1(d) << 16 | word1(d) >> 16;
+	if (L)
+#else
+	if ( (L = word1(d)) !=0)
+#endif
+		return P - lo0bits(&L);
+#ifdef VAX
+	L = word0(d) << 16 | word0(d) >> 16 | Exp_msk11;
+#else
+	L = word0(d) | Exp_msk1;
+#endif
+	return P - 32 - lo0bits(&L);
+	}
+
+ int
+strtodg
+#ifdef KR_headers
+	(s00, se, fpi, exp, bits)
+	CONST char *s00; char **se; FPI *fpi; Long *exp; ULong *bits;
+#else
+	(CONST char *s00, char **se, FPI *fpi, Long *exp, ULong *bits)
+#endif
+{
+	int abe, abits, asub;
+	int bb0, bb2, bb5, bbe, bd2, bd5, bbbits, bs2;
+	int c, denorm, dsign, e, e1, e2, emin, esign, finished, i, inex, irv;
+	int j, k, nbits, nd, nd0, nf, nz, nz0, rd, rvbits, rve, rve1, sign;
+	int sudden_underflow;
+	CONST char *s, *s0, *s1;
+	double adj, adj0, rv, tol;
+	Long L;
+	ULong y, z;
+	Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0;
+
+	irv = STRTOG_Zero;
+	denorm = sign = nz0 = nz = 0;
+	dval(rv) = 0.;
+	rvb = 0;
+	nbits = fpi->nbits;
+	for(s = s00;;s++) switch(*s) {
+		case '-':
+			sign = 1;
+			/* no break */
+		case '+':
+			if (*++s)
+				goto break2;
+			/* no break */
+		case 0:
+			sign = 0;
+			irv = STRTOG_NoNumber;
+			s = s00;
+			goto ret;
+		case '\t':
+		case '\n':
+		case '\v':
+		case '\f':
+		case '\r':
+		case ' ':
+			continue;
+		default:
+			goto break2;
+		}
+ break2:
+	if (*s == '0') {
+#ifndef NO_HEX_FP
+		switch(s[1]) {
+		  case 'x':
+		  case 'X':
+			irv = gethex(&s, fpi, exp, &rvb, sign);
+			if (irv == STRTOG_NoNumber) {
+				s = s00;
+				sign = 0;
+				}
+			goto ret;
+		  }
+#endif
+		nz0 = 1;
+		while(*++s == '0') ;
+		if (!*s)
+			goto ret;
+		}
+	sudden_underflow = fpi->sudden_underflow;
+	s0 = s;
+	y = z = 0;
+	for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
+		if (nd < 9)
+			y = 10*y + c - '0';
+		else if (nd < 16)
+			z = 10*z + c - '0';
+	nd0 = nd;
+#ifdef USE_LOCALE
+	if (c == *localeconv()->decimal_point)
+#else
+	if (c == '.')
+#endif
+		{
+		c = *++s;
+		if (!nd) {
+			for(; c == '0'; c = *++s)
+				nz++;
+			if (c > '0' && c <= '9') {
+				s0 = s;
+				nf += nz;
+				nz = 0;
+				goto have_dig;
+				}
+			goto dig_done;
+			}
+		for(; c >= '0' && c <= '9'; c = *++s) {
+ have_dig:
+			nz++;
+			if (c -= '0') {
+				nf += nz;
+				for(i = 1; i < nz; i++)
+					if (nd++ < 9)
+						y *= 10;
+					else if (nd <= DBL_DIG + 1)
+						z *= 10;
+				if (nd++ < 9)
+					y = 10*y + c;
+				else if (nd <= DBL_DIG + 1)
+					z = 10*z + c;
+				nz = 0;
+				}
+			}
+		}
+ dig_done:
+	e = 0;
+	if (c == 'e' || c == 'E') {
+		if (!nd && !nz && !nz0) {
+			irv = STRTOG_NoNumber;
+			s = s00;
+			goto ret;
+			}
+		s00 = s;
+		esign = 0;
+		switch(c = *++s) {
+			case '-':
+				esign = 1;
+			case '+':
+				c = *++s;
+			}
+		if (c >= '0' && c <= '9') {
+			while(c == '0')
+				c = *++s;
+			if (c > '0' && c <= '9') {
+				L = c - '0';
+				s1 = s;
+				while((c = *++s) >= '0' && c <= '9')
+					L = 10*L + c - '0';
+				if (s - s1 > 8 || L > 19999)
+					/* Avoid confusion from exponents
+					 * so large that e might overflow.
+					 */
+					e = 19999; /* safe for 16 bit ints */
+				else
+					e = (int)L;
+				if (esign)
+					e = -e;
+				}
+			else
+				e = 0;
+			}
+		else
+			s = s00;
+		}
+	if (!nd) {
+		if (!nz && !nz0) {
+#ifdef INFNAN_CHECK
+			/* Check for Nan and Infinity */
+			switch(c) {
+			  case 'i':
+			  case 'I':
+				if (match(&s,"nf")) {
+					--s;
+					if (!match(&s,"inity"))
+						++s;
+					irv = STRTOG_Infinite;
+					goto infnanexp;
+					}
+				break;
+			  case 'n':
+			  case 'N':
+				if (match(&s, "an")) {
+					irv = STRTOG_NaN;
+					*exp = fpi->emax + 1;
+#ifndef No_Hex_NaN
+					if (*s == '(') /*)*/
+						irv = hexnan(&s, fpi, bits);
+#endif
+					goto infnanexp;
+					}
+			  }
+#endif /* INFNAN_CHECK */
+			irv = STRTOG_NoNumber;
+			s = s00;
+			}
+		goto ret;
+		}
+
+	irv = STRTOG_Normal;
+	e1 = e -= nf;
+	rd = 0;
+	switch(fpi->rounding & 3) {
+	  case FPI_Round_up:
+		rd = 2 - sign;
+		break;
+	  case FPI_Round_zero:
+		rd = 1;
+		break;
+	  case FPI_Round_down:
+		rd = 1 + sign;
+	  }
+
+	/* Now we have nd0 digits, starting at s0, followed by a
+	 * decimal point, followed by nd-nd0 digits.  The number we're
+	 * after is the integer represented by those digits times
+	 * 10**e */
+
+	if (!nd0)
+		nd0 = nd;
+	k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
+	dval(rv) = y;
+	if (k > 9)
+		dval(rv) = tens[k - 9] * dval(rv) + z;
+	bd0 = 0;
+	if (nbits <= P && nd <= DBL_DIG) {
+		if (!e) {
+			if (rvOK(dval(rv), fpi, exp, bits, 1, rd, &irv))
+				goto ret;
+			}
+		else if (e > 0) {
+			if (e <= Ten_pmax) {
+#ifdef VAX
+				goto vax_ovfl_check;
+#else
+				i = fivesbits[e] + mantbits(dval(rv)) <= P;
+				/* rv = */ rounded_product(dval(rv), tens[e]);
+				if (rvOK(dval(rv), fpi, exp, bits, i, rd, &irv))
+					goto ret;
+				e1 -= e;
+				goto rv_notOK;
+#endif
+				}
+			i = DBL_DIG - nd;
+			if (e <= Ten_pmax + i) {
+				/* A fancier test would sometimes let us do
+				 * this for larger i values.
+				 */
+				e2 = e - i;
+				e1 -= i;
+				dval(rv) *= tens[i];
+#ifdef VAX
+				/* VAX exponent range is so narrow we must
+				 * worry about overflow here...
+				 */
+ vax_ovfl_check:
+				dval(adj) = dval(rv);
+				word0(adj) -= P*Exp_msk1;
+				/* adj = */ rounded_product(dval(adj), tens[e2]);
+				if ((word0(adj) & Exp_mask)
+				 > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
+					goto rv_notOK;
+				word0(adj) += P*Exp_msk1;
+				dval(rv) = dval(adj);
+#else
+				/* rv = */ rounded_product(dval(rv), tens[e2]);
+#endif
+				if (rvOK(dval(rv), fpi, exp, bits, 0, rd, &irv))
+					goto ret;
+				e1 -= e2;
+				}
+			}
+#ifndef Inaccurate_Divide
+		else if (e >= -Ten_pmax) {
+			/* rv = */ rounded_quotient(dval(rv), tens[-e]);
+			if (rvOK(dval(rv), fpi, exp, bits, 0, rd, &irv))
+				goto ret;
+			e1 -= e;
+			}
+#endif
+		}
+ rv_notOK:
+	e1 += nd - k;
+
+	/* Get starting approximation = rv * 10**e1 */
+
+	e2 = 0;
+	if (e1 > 0) {
+		if ( (i = e1 & 15) !=0)
+			dval(rv) *= tens[i];
+		if (e1 &= ~15) {
+			e1 >>= 4;
+			while(e1 >= (1 << n_bigtens-1)) {
+				e2 += ((word0(rv) & Exp_mask)
+					>> Exp_shift1) - Bias;
+				word0(rv) &= ~Exp_mask;
+				word0(rv) |= Bias << Exp_shift1;
+				dval(rv) *= bigtens[n_bigtens-1];
+				e1 -= 1 << n_bigtens-1;
+				}
+			e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
+			word0(rv) &= ~Exp_mask;
+			word0(rv) |= Bias << Exp_shift1;
+			for(j = 0; e1 > 0; j++, e1 >>= 1)
+				if (e1 & 1)
+					dval(rv) *= bigtens[j];
+			}
+		}
+	else if (e1 < 0) {
+		e1 = -e1;
+		if ( (i = e1 & 15) !=0)
+			dval(rv) /= tens[i];
+		if (e1 &= ~15) {
+			e1 >>= 4;
+			while(e1 >= (1 << n_bigtens-1)) {
+				e2 += ((word0(rv) & Exp_mask)
+					>> Exp_shift1) - Bias;
+				word0(rv) &= ~Exp_mask;
+				word0(rv) |= Bias << Exp_shift1;
+				dval(rv) *= tinytens[n_bigtens-1];
+				e1 -= 1 << n_bigtens-1;
+				}
+			e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
+			word0(rv) &= ~Exp_mask;
+			word0(rv) |= Bias << Exp_shift1;
+			for(j = 0; e1 > 0; j++, e1 >>= 1)
+				if (e1 & 1)
+					dval(rv) *= tinytens[j];
+			}
+		}
+
+	rvb = d2b(dval(rv), &rve, &rvbits);	/* rv = rvb * 2^rve */
+	rve += e2;
+	if ((j = rvbits - nbits) > 0) {
+		rshift(rvb, j);
+		rvbits = nbits;
+		rve += j;
+		}
+	bb0 = 0;	/* trailing zero bits in rvb */
+	e2 = rve + rvbits - nbits;
+	if (e2 > fpi->emax) {
+		rvb->wds = 0;
+		irv = STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi;
+#ifndef NO_ERRNO
+		errno = ERANGE;
+#endif
+ infnanexp:
+		*exp = fpi->emax + 1;
+		goto ret;
+		}
+	rve1 = rve + rvbits - nbits;
+	if (e2 < (emin = fpi->emin)) {
+		denorm = 1;
+		j = rve - emin;
+		if (j > 0) {
+			rvb = lshift(rvb, j);
+			rvbits += j;
+			}
+		else if (j < 0) {
+			rvbits += j;
+			if (rvbits <= 0) {
+				if (rvbits < -1) {
+ ufl:
+					rvb->wds = 0;
+					rvb->x[0] = 0;
+					*exp = emin;
+					irv = STRTOG_Underflow | STRTOG_Inexlo;
+					goto ret;
+					}
+				rvb->x[0] = rvb->wds = rvbits = 1;
+				}
+			else
+				rshift(rvb, -j);
+			}
+		rve = rve1 = emin;
+		if (sudden_underflow && e2 + 1 < emin)
+			goto ufl;
+		}
+
+	/* Now the hard part -- adjusting rv to the correct value.*/
+
+	/* Put digits into bd: true value = bd * 10^e */
+
+	bd0 = s2b(s0, nd0, nd, y);
+
+	for(;;) {
+		bd = Balloc(bd0->k);
+		Bcopy(bd, bd0);
+		bb = Balloc(rvb->k);
+		Bcopy(bb, rvb);
+		bbbits = rvbits - bb0;
+		bbe = rve + bb0;
+		bs = i2b(1);
+
+		if (e >= 0) {
+			bb2 = bb5 = 0;
+			bd2 = bd5 = e;
+			}
+		else {
+			bb2 = bb5 = -e;
+			bd2 = bd5 = 0;
+			}
+		if (bbe >= 0)
+			bb2 += bbe;
+		else
+			bd2 -= bbe;
+		bs2 = bb2;
+		j = nbits + 1 - bbbits;
+		i = bbe + bbbits - nbits;
+		if (i < emin)	/* denormal */
+			j += i - emin;
+		bb2 += j;
+		bd2 += j;
+		i = bb2 < bd2 ? bb2 : bd2;
+		if (i > bs2)
+			i = bs2;
+		if (i > 0) {
+			bb2 -= i;
+			bd2 -= i;
+			bs2 -= i;
+			}
+		if (bb5 > 0) {
+			bs = pow5mult(bs, bb5);
+			bb1 = mult(bs, bb);
+			Bfree(bb);
+			bb = bb1;
+			}
+		bb2 -= bb0;
+		if (bb2 > 0)
+			bb = lshift(bb, bb2);
+		else if (bb2 < 0)
+			rshift(bb, -bb2);
+		if (bd5 > 0)
+			bd = pow5mult(bd, bd5);
+		if (bd2 > 0)
+			bd = lshift(bd, bd2);
+		if (bs2 > 0)
+			bs = lshift(bs, bs2);
+		asub = 1;
+		inex = STRTOG_Inexhi;
+		delta = diff(bb, bd);
+		if (delta->wds <= 1 && !delta->x[0])
+			break;
+		dsign = delta->sign;
+		delta->sign = finished = 0;
+		L = 0;
+		i = cmp(delta, bs);
+		if (rd && i <= 0) {
+			irv = STRTOG_Normal;
+			if ( (finished = dsign ^ (rd&1)) !=0) {
+				if (dsign != 0) {
+					irv |= STRTOG_Inexhi;
+					goto adj1;
+					}
+				irv |= STRTOG_Inexlo;
+				if (rve1 == emin)
+					goto adj1;
+				for(i = 0, j = nbits; j >= ULbits;
+						i++, j -= ULbits) {
+					if (rvb->x[i] & ALL_ON)
+						goto adj1;
+					}
+				if (j > 1 && lo0bits(rvb->x + i) < j - 1)
+					goto adj1;
+				rve = rve1 - 1;
+				rvb = set_ones(rvb, rvbits = nbits);
+				break;
+				}
+			irv |= dsign ? STRTOG_Inexlo : STRTOG_Inexhi;
+			break;
+			}
+		if (i < 0) {
+			/* Error is less than half an ulp -- check for
+			 * special case of mantissa a power of two.
+			 */
+			irv = dsign
+				? STRTOG_Normal | STRTOG_Inexlo
+				: STRTOG_Normal | STRTOG_Inexhi;
+			if (dsign || bbbits > 1 || denorm || rve1 == emin)
+				break;
+			delta = lshift(delta,1);
+			if (cmp(delta, bs) > 0) {
+				irv = STRTOG_Normal | STRTOG_Inexlo;
+				goto drop_down;
+				}
+			break;
+			}
+		if (i == 0) {
+			/* exactly half-way between */
+			if (dsign) {
+				if (denorm && all_on(rvb, rvbits)) {
+					/*boundary case -- increment exponent*/
+					rvb->wds = 1;
+					rvb->x[0] = 1;
+					rve = emin + nbits - (rvbits = 1);
+					irv = STRTOG_Normal | STRTOG_Inexhi;
+					denorm = 0;
+					break;
+					}
+				irv = STRTOG_Normal | STRTOG_Inexlo;
+				}
+			else if (bbbits == 1) {
+				irv = STRTOG_Normal;
+ drop_down:
+				/* boundary case -- decrement exponent */
+				if (rve1 == emin) {
+					irv = STRTOG_Normal | STRTOG_Inexhi;
+					if (rvb->wds == 1 && rvb->x[0] == 1)
+						sudden_underflow = 1;
+					break;
+					}
+				rve -= nbits;
+				rvb = set_ones(rvb, rvbits = nbits);
+				break;
+				}
+			else
+				irv = STRTOG_Normal | STRTOG_Inexhi;
+			if (bbbits < nbits && !denorm || !(rvb->x[0] & 1))
+				break;
+			if (dsign) {
+				rvb = increment(rvb);
+				if ( (j = rvbits >> kshift) !=0)
+					j = 32 - j;
+				if (hi0bits(rvb->x[(rvb->wds - 1) >> kshift])
+						!= j)
+					rvbits++;
+				irv = STRTOG_Normal | STRTOG_Inexhi;
+				}
+			else {
+				if (bbbits == 1)
+					goto undfl;
+				decrement(rvb);
+				irv = STRTOG_Normal | STRTOG_Inexlo;
+				}
+			break;
+			}
+		if ((dval(adj) = ratio(delta, bs)) <= 2.) {
+ adj1:
+			inex = STRTOG_Inexlo;
+			if (dsign) {
+				asub = 0;
+				inex = STRTOG_Inexhi;
+				}
+			else if (denorm && bbbits <= 1) {
+ undfl:
+				rvb->wds = 0;
+				rve = emin;
+				irv = STRTOG_Underflow | STRTOG_Inexlo;
+				break;
+				}
+			adj0 = dval(adj) = 1.;
+			}
+		else {
+			adj0 = dval(adj) *= 0.5;
+			if (dsign) {
+				asub = 0;
+				inex = STRTOG_Inexlo;
+				}
+			if (dval(adj) < 2147483647.) {
+				L = adj0;
+				adj0 -= L;
+				switch(rd) {
+				  case 0:
+					if (adj0 >= .5)
+						goto inc_L;
+					break;
+				  case 1:
+					if (asub && adj0 > 0.)
+						goto inc_L;
+					break;
+				  case 2:
+					if (!asub && adj0 > 0.) {
+ inc_L:
+						L++;
+						inex = STRTOG_Inexact - inex;
+						}
+				  }
+				dval(adj) = L;
+				}
+			}
+		y = rve + rvbits;
+
+		/* adj *= ulp(dval(rv)); */
+		/* if (asub) rv -= adj; else rv += adj; */
+
+		if (!denorm && rvbits < nbits) {
+			rvb = lshift(rvb, j = nbits - rvbits);
+			rve -= j;
+			rvbits = nbits;
+			}
+		ab = d2b(dval(adj), &abe, &abits);
+		if (abe < 0)
+			rshift(ab, -abe);
+		else if (abe > 0)
+			ab = lshift(ab, abe);
+		rvb0 = rvb;
+		if (asub) {
+			/* rv -= adj; */
+			j = hi0bits(rvb->x[rvb->wds-1]);
+			rvb = diff(rvb, ab);
+			k = rvb0->wds - 1;
+			if (denorm)
+				/* do nothing */;
+			else if (rvb->wds <= k
+				|| hi0bits( rvb->x[k]) >
+				   hi0bits(rvb0->x[k])) {
+				/* unlikely; can only have lost 1 high bit */
+				if (rve1 == emin) {
+					--rvbits;
+					denorm = 1;
+					}
+				else {
+					rvb = lshift(rvb, 1);
+					--rve;
+					--rve1;
+					L = finished = 0;
+					}
+				}
+			}
+		else {
+			rvb = sum(rvb, ab);
+			k = rvb->wds - 1;
+			if (k >= rvb0->wds
+			 || hi0bits(rvb->x[k]) < hi0bits(rvb0->x[k])) {
+				if (denorm) {
+					if (++rvbits == nbits)
+						denorm = 0;
+					}
+				else {
+					rshift(rvb, 1);
+					rve++;
+					rve1++;
+					L = 0;
+					}
+				}
+			}
+		Bfree(ab);
+		Bfree(rvb0);
+		if (finished)
+			break;
+
+		z = rve + rvbits;
+		if (y == z && L) {
+			/* Can we stop now? */
+			tol = dval(adj) * 5e-16; /* > max rel error */
+			dval(adj) = adj0 - .5;
+			if (dval(adj) < -tol) {
+				if (adj0 > tol) {
+					irv |= inex;
+					break;
+					}
+				}
+			else if (dval(adj) > tol && adj0 < 1. - tol) {
+				irv |= inex;
+				break;
+				}
+			}
+		bb0 = denorm ? 0 : trailz(rvb);
+		Bfree(bb);
+		Bfree(bd);
+		Bfree(bs);
+		Bfree(delta);
+		}
+	if (!denorm && rvbits < nbits) {
+		j = nbits - rvbits;
+		rvb = lshift(rvb, j);
+		rve -= j;
+		}
+	*exp = rve;
+	Bfree(bb);
+	Bfree(bd);
+	Bfree(bs);
+	Bfree(bd0);
+	Bfree(delta);
+ ret:
+	if (denorm) {
+		if (sudden_underflow) {
+			rvb->wds = 0;
+			irv = STRTOG_Underflow | STRTOG_Inexlo;
+			}
+		else  {
+			irv = (irv & ~STRTOG_Retmask) |
+				(rvb->wds > 0 ? STRTOG_Denormal : STRTOG_Zero);
+			if (irv & STRTOG_Inexact)
+				irv |= STRTOG_Underflow;
+			}
+		}
+	if (se)
+		*se = (char *)s;
+	if (sign)
+		irv |= STRTOG_Neg;
+	if (rvb) {
+		copybits(bits, nbits, rvb);
+		Bfree(rvb);
+		}
+	return irv;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtof.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtof.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtof.c	(revision 2404)
@@ -0,0 +1,83 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ float
+#ifdef KR_headers
+strtof(s, sp) CONST char *s; char **sp;
+#else
+strtof(CONST char *s, char **sp)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi = { 24, 1-127-24+1,  254-127-24+1, 1, 1 };
+#else
+	static FPI fpi = { 24, 1-127-24+1,  254-127-24+1, 1, 0 };
+#endif
+	ULong bits[1];
+	Long exp;
+	int k;
+	union { ULong L[1]; float f; } u;
+
+	k = strtodg(s, sp, &fpi, &exp, bits);
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		u.L[0] = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_NaNbits:
+		u.L[0] = bits[0] & 0x7fffff | exp + 0x7f + 23 << 23;
+		break;
+
+	  case STRTOG_Denormal:
+		u.L[0] = bits[0];
+		break;
+
+	  case STRTOG_Infinite:
+		u.L[0] = 0x7f800000;
+		break;
+
+	  case STRTOG_NaN:
+		u.L[0] = 0x7fffffff;
+	  }
+	if (k & STRTOG_Neg)
+		u.L[0] |= 0x80000000L;
+	return u.f;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtopQ.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtopQ.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtopQ.c	(revision 2404)
@@ -0,0 +1,109 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#define _3 3
+#endif
+#ifdef IEEE_8087
+#define _0 3
+#define _1 2
+#define _2 1
+#define _3 0
+#endif
+
+ int
+#ifdef KR_headers
+strtopQ(s, sp, V) CONST char *s; char **sp; void *V;
+#else
+strtopQ(CONST char *s, char **sp, void *V)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, 1 };
+#else
+	static FPI fpi = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, 0 };
+#endif
+	ULong bits[4];
+	Long exp;
+	int k;
+	ULong *L = (ULong*)V;
+
+	k = strtodg(s, sp, &fpi, &exp, bits);
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = L[1] = L[2] = L[3] = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_NaNbits:
+		L[_3] = bits[0];
+		L[_2] = bits[1];
+		L[_1] = bits[2];
+		L[_0] = (bits[3] & ~0x10000) | ((exp + 0x3fff + 112) << 16);
+		break;
+
+	  case STRTOG_Denormal:
+		L[_3] = bits[0];
+		L[_2] = bits[1];
+		L[_1] = bits[2];
+		L[_0] = bits[3];
+		break;
+
+	  case STRTOG_Infinite:
+		L[_0] = 0x7fff0000;
+		L[_1] = L[_2] = L[_3] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		L[_0] = 0x7fffffff;
+		L[_1] = L[_2] = L[_3] = (ULong)-1;
+	  }
+	if (k & STRTOG_Neg)
+		L[_0] |= 0x80000000L;
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtopd.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtopd.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtopd.c	(revision 2404)
@@ -0,0 +1,55 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtopd(s, sp, d) char *s; char **sp; double *d;
+#else
+strtopd(CONST char *s, char **sp, double *d)
+#endif
+{
+	static FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
+	ULong bits[2];
+	Long exp;
+	int k;
+
+	k = strtodg(s, sp, &fpi0, &exp, bits);
+	ULtod((ULong*)d, bits, exp, k);
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtopdd.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtopdd.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtopdd.c	(revision 2404)
@@ -0,0 +1,184 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtopdd(s, sp, dd) CONST char *s; char **sp; double *dd;
+#else
+strtopdd(CONST char *s, char **sp, double *dd)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi = { 106, 1-1023, 2046-1023-106+1, 1, 1 };
+#else
+	static FPI fpi = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 };
+#endif
+	ULong bits[4];
+	Long exp;
+	int i, j, rv;
+	typedef union {
+		double d[2];
+		ULong L[4];
+		} U;
+	U *u;
+
+	rv = strtodg(s, sp, &fpi, &exp, bits);
+	u = (U*)dd;
+	switch(rv & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		u->d[0] = u->d[1] = 0.;
+		break;
+
+	  case STRTOG_Normal:
+		u->L[_1] = (bits[1] >> 21 | bits[2] << 11) & 0xffffffffL;
+		u->L[_0] = bits[2] >> 21 | bits[3] << 11 & 0xfffff
+			  | exp + 0x3ff + 105 << 20;
+		exp += 0x3ff + 52;
+		if (bits[1] &= 0x1fffff) {
+			i = hi0bits(bits[1]) - 11;
+			if (i >= exp) {
+				i = exp - 1;
+				exp = 0;
+				}
+			else
+				exp -= i;
+			if (i > 0) {
+				bits[1] = bits[1] << i | bits[0] >> 32-i;
+				bits[0] = bits[0] << i & 0xffffffffL;
+				}
+			}
+		else if (bits[0]) {
+			i = hi0bits(bits[0]) + 21;
+			if (i >= exp) {
+				i = exp - 1;
+				exp = 0;
+				}
+			else
+				exp -= i;
+			if (i < 32) {
+				bits[1] = bits[0] >> 32 - i;
+				bits[0] = bits[0] << i & 0xffffffffL;
+				}
+			else {
+				bits[1] = bits[0] << i - 32;
+				bits[0] = 0;
+				}
+			}
+		else {
+			u->L[2] = u->L[3] = 0;
+			break;
+			}
+		u->L[2+_1] = bits[0];
+		u->L[2+_0] = bits[1] & 0xfffff | exp << 20;
+		break;
+
+	  case STRTOG_Denormal:
+		if (bits[3])
+			goto nearly_normal;
+		if (bits[2])
+			goto partly_normal;
+		if (bits[1] & 0xffe00000)
+			goto hardly_normal;
+		/* completely denormal */
+		u->L[2] = u->L[3] = 0;
+		u->L[_1] = bits[0];
+		u->L[_0] = bits[1];
+		break;
+
+	  nearly_normal:
+		i = hi0bits(bits[3]) - 11;	/* i >= 12 */
+		j = 32 - i;
+		u->L[_0] = (bits[3] << i | bits[2] >> j) & 0xfffff
+			| 65 - i << 20;
+		u->L[_1] = (bits[2] << i | bits[1] >> j) & 0xffffffffL;
+		u->L[2+_0] = bits[1] & (1L << j) - 1;
+		u->L[2+_1] = bits[0];
+		break;
+
+	  partly_normal:
+		i = hi0bits(bits[2]) - 11;
+		if (i < 0) {
+			j = -i;
+			i += 32;
+			u->L[_0] = bits[2] >> j & 0xfffff | (33 + j) << 20;
+			u->L[_1] = (bits[2] << i | bits[1] >> j) & 0xffffffffL;
+			u->L[2+_0] = bits[1] & (1L << j) - 1;
+			u->L[2+_1] = bits[0];
+			break;
+			}
+		if (i == 0) {
+			u->L[_0] = bits[2] & 0xfffff | 33 << 20;
+			u->L[_1] = bits[1];
+			u->L[2+_0] = 0;
+			u->L[2+_1] = bits[0];
+			break;
+			}
+		j = 32 - i;
+		u->L[_0] = (bits[2] << i | bits[1] >> j) & 0xfffff
+				| j + 1 << 20;
+		u->L[_1] = (bits[1] << i | bits[0] >> j) & 0xffffffffL;
+		u->L[2+_0] = 0;
+		u->L[2+_1] = bits[0] & (1L << j) - 1;
+		break;
+
+	  hardly_normal:
+		j = 11 - hi0bits(bits[1]);
+		i = 32 - j;
+		u->L[_0] = bits[1] >> j & 0xfffff | j + 1 << 20;
+		u->L[_1] = (bits[1] << i | bits[0] >> j) & 0xffffffffL;
+		u->L[2+_0] = 0;
+		u->L[2+_1] = bits[0] & (1L << j) - 1;
+		break;
+
+	  case STRTOG_Infinite:
+		u->L[_0] = u->L[2+_0] = 0x7ff00000;
+		u->L[_1] = u->L[2+_1] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		u->L[_0] = u->L[2+_0] = 0x7fffffff;
+		u->L[_1] = u->L[2+_1] = (ULong)-1;
+	  }
+	if (rv & STRTOG_Neg) {
+		u->L[  _0] |= 0x80000000L;
+		u->L[2+_0] |= 0x80000000L;
+		}
+	return rv;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtopf.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtopf.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtopf.c	(revision 2404)
@@ -0,0 +1,83 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ int
+#ifdef KR_headers
+strtopf(s, sp, f) CONST char *s; char **sp; float *f;
+#else
+strtopf(CONST char *s, char **sp, float *f)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi = { 24, 1-127-24+1,  254-127-24+1, 1, 1 };
+#else
+	static FPI fpi = { 24, 1-127-24+1,  254-127-24+1, 1, 0 };
+#endif
+	ULong bits[1], *L;
+	Long exp;
+	int k;
+
+	k = strtodg(s, sp, &fpi, &exp, bits);
+	L = (ULong*)f;
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_NaNbits:
+		L[0] = bits[0] & 0x7fffff | exp + 0x7f + 23 << 23;
+		break;
+
+	  case STRTOG_Denormal:
+		L[0] = bits[0];
+		break;
+
+	  case STRTOG_Infinite:
+		L[0] = 0x7f800000;
+		break;
+
+	  case STRTOG_NaN:
+		L[0] = 0x7fffffff;
+	  }
+	if (k & STRTOG_Neg)
+		L[0] |= 0x80000000L;
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtopx.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtopx.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtopx.c	(revision 2404)
@@ -0,0 +1,106 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#define _3 3
+#define _4 4
+#endif
+#ifdef IEEE_8087
+#define _0 4
+#define _1 3
+#define _2 2
+#define _3 1
+#define _4 0
+#endif
+
+ int
+#ifdef KR_headers
+strtopx(s, sp, V) CONST char *s; char **sp; void *V;
+#else
+strtopx(CONST char *s, char **sp, void *V)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 1 };
+#else
+	static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0 };
+#endif
+	ULong bits[2];
+	Long exp;
+	int k;
+	UShort *L = (UShort*)V;
+
+	k = strtodg(s, sp, &fpi, &exp, bits);
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = L[1] = L[2] = L[3] = L[4] = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_Denormal:
+	  case STRTOG_NaNbits:
+		L[_4] = (UShort)bits[0];
+		L[_3] = (UShort)(bits[0] >> 16);
+		L[_2] = (UShort)bits[1];
+		L[_1] = (UShort)(bits[1] >> 16);
+		L[_0] = exp + 0x3fff + 63;
+		break;
+
+	  case STRTOG_Infinite:
+		L[_0] = 0x7fff;
+		L[_1] = L[_2] = L[_3] = L[_4] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		L[_0] = 0x7fff;
+		L[_1] = L[_2] = L[_3] = L[_4] = (UShort)-1;
+	  }
+	if (k & STRTOG_Neg)
+		L[_0] |= 0x8000;
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtopxL.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtopxL.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtopxL.c	(revision 2404)
@@ -0,0 +1,100 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#endif
+#ifdef IEEE_8087
+#define _0 2
+#define _1 1
+#define _2 0
+#endif
+
+ int
+#ifdef KR_headers
+strtopxL(s, sp, V) CONST char *s; char **sp; void *V;
+#else
+strtopxL(CONST char *s, char **sp, void *V)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 1 };
+#else
+	static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0 };
+#endif
+	ULong bits[2];
+	Long exp;
+	int k;
+	ULong *L = (ULong*)V;
+
+	k = strtodg(s, sp, &fpi, &exp, bits);
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = L[1] = L[2] = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_Denormal:
+	  case STRTOG_NaNbits:
+		L[_2] = bits[0];
+		L[_1] = bits[1];
+		L[_0] = (exp + 0x3fff + 63) << 16;
+		break;
+
+	  case STRTOG_Infinite:
+		L[_0] = 0x7fff << 16;
+		L[_1] = L[_2] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		L[_0] = 0x7fff << 16;
+		L[_1] = L[_2] = (ULong)-1;
+	  }
+	if (k & STRTOG_Neg)
+		L[_0] |= 0x80000000L;
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtorQ.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtorQ.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtorQ.c	(revision 2404)
@@ -0,0 +1,121 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#define _3 3
+#endif
+#ifdef IEEE_8087
+#define _0 3
+#define _1 2
+#define _2 1
+#define _3 0
+#endif
+
+ void
+#ifdef KR_headers
+ULtoQ(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+#else
+ULtoQ(ULong *L, ULong *bits, Long exp, int k)
+#endif
+{
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = L[1] = L[2] = L[3] = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_NaNbits:
+		L[_3] = bits[0];
+		L[_2] = bits[1];
+		L[_1] = bits[2];
+		L[_0] = (bits[3] & ~0x10000) | ((exp + 0x3fff + 112) << 16);
+		break;
+
+	  case STRTOG_Denormal:
+		L[_3] = bits[0];
+		L[_2] = bits[1];
+		L[_1] = bits[2];
+		L[_0] = bits[3];
+		break;
+
+	  case STRTOG_Infinite:
+		L[_0] = 0x7fff0000;
+		L[_1] = L[_2] = L[_3] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		L[_0] = 0x7fffffff;
+		L[_1] = L[_2] = L[_3] = (ULong)-1;
+	  }
+	if (k & STRTOG_Neg)
+		L[_0] |= 0x80000000L;
+	}
+
+ int
+#ifdef KR_headers
+strtorQ(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L;
+#else
+strtorQ(CONST char *s, char **sp, int rounding, void *L)
+#endif
+{
+	static FPI fpi0 = { 113, 1-16383-113+1, 32766-16383-113+1, 1, SI };
+	FPI *fpi, fpi1;
+	ULong bits[4];
+	Long exp;
+	int k;
+
+	fpi = &fpi0;
+	if (rounding != FPI_Round_near) {
+		fpi1 = fpi0;
+		fpi1.rounding = rounding;
+		fpi = &fpi1;
+		}
+	k = strtodg(s, sp, fpi, &exp, bits);
+	ULtoQ((ULong*)L, bits, exp, k);
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtord.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtord.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtord.c	(revision 2404)
@@ -0,0 +1,99 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ void
+#ifdef KR_headers
+ULtod(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+#else
+ULtod(ULong *L, ULong *bits, Long exp, int k)
+#endif
+{
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = L[1] = 0;
+		break;
+
+	  case STRTOG_Denormal:
+		L[_1] = bits[0];
+		L[_0] = bits[1];
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_NaNbits:
+		L[_1] = bits[0];
+		L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
+		break;
+
+	  case STRTOG_Infinite:
+		L[_0] = 0x7ff00000;
+		L[_1] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		L[_0] = 0x7fffffff;
+		L[_1] = (ULong)-1;
+	  }
+	if (k & STRTOG_Neg)
+		L[_0] |= 0x80000000L;
+	}
+
+ int
+#ifdef KR_headers
+strtord(s, sp, rounding, d) CONST char *s; char **sp; int rounding; double *d;
+#else
+strtord(CONST char *s, char **sp, int rounding, double *d)
+#endif
+{
+	static FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
+	FPI *fpi, fpi1;
+	ULong bits[2];
+	Long exp;
+	int k;
+
+	fpi = &fpi0;
+	if (rounding != FPI_Round_near) {
+		fpi1 = fpi0;
+		fpi1.rounding = rounding;
+		fpi = &fpi1;
+		}
+	k = strtodg(s, sp, fpi, &exp, bits);
+	ULtod((ULong*)d, bits, exp, k);
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtordd.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtordd.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtordd.c	(revision 2404)
@@ -0,0 +1,205 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ void
+#ifdef KR_headers
+ULtodd(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+#else
+ULtodd(ULong *L, ULong *bits, Long exp, int k)
+#endif
+{
+	int i, j;
+
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = L[1] = L[2] = L[3] = 0;
+		break;
+
+	  case STRTOG_Normal:
+		L[_1] = (bits[1] >> 21 | bits[2] << 11) & (ULong)0xffffffffL;
+		L[_0] = bits[2] >> 21 | bits[3] << 11 & 0xfffff
+			  | exp + 0x3ff + 105 << 20;
+		exp += 0x3ff + 52;
+		if (bits[1] &= 0x1fffff) {
+			i = hi0bits(bits[1]) - 11;
+			if (i >= exp) {
+				i = exp - 1;
+				exp = 0;
+				}
+			else
+				exp -= i;
+			if (i > 0) {
+				bits[1] = bits[1] << i | bits[0] >> 32-i;
+				bits[0] = bits[0] << i & (ULong)0xffffffffL;
+				}
+			}
+		else if (bits[0]) {
+			i = hi0bits(bits[0]) + 21;
+			if (i >= exp) {
+				i = exp - 1;
+				exp = 0;
+				}
+			else
+				exp -= i;
+			if (i < 32) {
+				bits[1] = bits[0] >> 32 - i;
+				bits[0] = bits[0] << i & (ULong)0xffffffffL;
+				}
+			else {
+				bits[1] = bits[0] << i - 32;
+				bits[0] = 0;
+				}
+			}
+		else {
+			L[2] = L[3] = 0;
+			break;
+			}
+		L[2+_1] = bits[0];
+		L[2+_0] = bits[1] & 0xfffff | exp << 20;
+		break;
+
+	  case STRTOG_Denormal:
+		if (bits[3])
+			goto nearly_normal;
+		if (bits[2])
+			goto partly_normal;
+		if (bits[1] & 0xffe00000)
+			goto hardly_normal;
+		/* completely denormal */
+		L[2] = L[3] = 0;
+		L[_1] = bits[0];
+		L[_0] = bits[1];
+		break;
+
+	  nearly_normal:
+		i = hi0bits(bits[3]) - 11;	/* i >= 12 */
+		j = 32 - i;
+		L[_0] = (bits[3] << i | bits[2] >> j) & 0xfffff
+			| 65 - i << 20;
+		L[_1] = (bits[2] << i | bits[1] >> j) & 0xffffffffL;
+		L[2+_0] = bits[1] & ((ULong)1L << j) - 1;
+		L[2+_1] = bits[0];
+		break;
+
+	  partly_normal:
+		i = hi0bits(bits[2]) - 11;
+		if (i < 0) {
+			j = -i;
+			i += 32;
+			L[_0] = bits[2] >> j & 0xfffff | (33 + j) << 20;
+			L[_1] = (bits[2] << i | bits[1] >> j) & 0xffffffffL;
+			L[2+_0] = bits[1] & ((ULong)1L << j) - 1;
+			L[2+_1] = bits[0];
+			break;
+			}
+		if (i == 0) {
+			L[_0] = bits[2] & 0xfffff | 33 << 20;
+			L[_1] = bits[1];
+			L[2+_0] = 0;
+			L[2+_1] = bits[0];
+			break;
+			}
+		j = 32 - i;
+		L[_0] = (bits[2] << i | bits[1] >> j) & 0xfffff
+				| j + 1 << 20;
+		L[_1] = (bits[1] << i | bits[0] >> j) & 0xffffffffL;
+		L[2+_0] = 0;
+		L[2+_1] = bits[0] & (1L << j) - 1;
+		break;
+
+	  hardly_normal:
+		j = 11 - hi0bits(bits[1]);
+		i = 32 - j;
+		L[_0] = bits[1] >> j & 0xfffff | j + 1 << 20;
+		L[_1] = (bits[1] << i | bits[0] >> j) & 0xffffffffL;
+		L[2+_0] = 0;
+		L[2+_1] = bits[0] & ((ULong)1L << j) - 1;
+		break;
+
+	  case STRTOG_Infinite:
+		L[_0] = L[2+_0] = 0x7ff00000;
+		L[_1] = L[2+_1] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		L[_0] = L[2+_0] = 0x7fffffff;
+		L[_1] = L[2+_1] = (ULong)-1;
+		break;
+
+	  case STRTOG_NaNbits:
+		L[_1] = (bits[1] >> 21 | bits[2] << 11) & (ULong)0xffffffffL;
+		L[_0] = bits[2] >> 21 | bits[3] << 11
+			  | (ULong)0x7ff00000L;
+		L[2+_1] = bits[0];
+		L[2+_0] = bits[1] | (ULong)0x7ff00000L;
+	  }
+	if (k & STRTOG_Neg) {
+		L[_0] |= 0x80000000L;
+		L[2+_0] |= 0x80000000L;
+		}
+	}
+
+ int
+#ifdef KR_headers
+strtordd(s, sp, rounding, dd) CONST char *s; char **sp; int rounding; double *dd;
+#else
+strtordd(CONST char *s, char **sp, int rounding, double *dd)
+#endif
+{
+#ifdef Sudden_Underflow
+	static FPI fpi0 = { 106, 1-1023, 2046-1023-106+1, 1, 1 };
+#else
+	static FPI fpi0 = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 };
+#endif
+	FPI *fpi, fpi1;
+	ULong bits[4];
+	Long exp;
+	int k;
+
+	fpi = &fpi0;
+	if (rounding != FPI_Round_near) {
+		fpi1 = fpi0;
+		fpi1.rounding = rounding;
+		fpi = &fpi1;
+		}
+	k = strtodg(s, sp, fpi, &exp, bits);
+	ULtodd((ULong*)dd, bits, exp, k);
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtorf.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtorf.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtorf.c	(revision 2404)
@@ -0,0 +1,95 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ void
+#ifdef KR_headers
+ULtof(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+#else
+ULtof(ULong *L, ULong *bits, Long exp, int k)
+#endif
+{
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		*L = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_NaNbits:
+		L[0] = bits[0] & 0x7fffff | exp + 0x7f + 23 << 23;
+		break;
+
+	  case STRTOG_Denormal:
+		L[0] = bits[0];
+		break;
+
+	  case STRTOG_Infinite:
+		L[0] = 0x7f800000;
+		break;
+
+	  case STRTOG_NaN:
+		L[0] = 0x7fffffff;
+	  }
+	if (k & STRTOG_Neg)
+		L[0] |= 0x80000000L;
+	}
+
+ int
+#ifdef KR_headers
+strtorf(s, sp, rounding, f) CONST char *s; char **sp; int rounding; float *f;
+#else
+strtorf(CONST char *s, char **sp, int rounding, float *f)
+#endif
+{
+	static FPI fpi0 = { 24, 1-127-24+1,  254-127-24+1, 1, SI };
+	FPI *fpi, fpi1;
+	ULong bits[1];
+	Long exp;
+	int k;
+
+	fpi = &fpi0;
+	if (rounding != FPI_Round_near) {
+		fpi1 = fpi0;
+		fpi1.rounding = rounding;
+		fpi = &fpi1;
+		}
+	k = strtodg(s, sp, fpi, &exp, bits);
+	ULtof((ULong*)f, bits, exp, k);
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtorx.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtorx.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtorx.c	(revision 2404)
@@ -0,0 +1,118 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#define _3 3
+#define _4 4
+#endif
+#ifdef IEEE_8087
+#define _0 4
+#define _1 3
+#define _2 2
+#define _3 1
+#define _4 0
+#endif
+
+ void
+#ifdef KR_headers
+ULtox(L, bits, exp, k) UShort *L; ULong *bits; Long exp; int k;
+#else
+ULtox(UShort *L, ULong *bits, Long exp, int k)
+#endif
+{
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = L[1] = L[2] = L[3] = L[4] = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_Denormal:
+	  case STRTOG_NaNbits:
+		L[_4] = (UShort)bits[0];
+		L[_3] = (UShort)(bits[0] >> 16);
+		L[_2] = (UShort)bits[1];
+		L[_1] = (UShort)(bits[1] >> 16);
+		L[_0] = exp + 0x3fff + 63;
+		break;
+
+	  case STRTOG_Infinite:
+		L[_0] = 0x7fff;
+		L[_1] = L[_2] = L[_3] = L[_4] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		L[_0] = 0x7fff;
+		L[_1] = L[_2] = L[_3] = L[_4] = (UShort)-1;
+	  }
+	if (k & STRTOG_Neg)
+		L[_0] |= 0x8000;
+	}
+
+ int
+#ifdef KR_headers
+strtorx(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L;
+#else
+strtorx(CONST char *s, char **sp, int rounding, void *L)
+#endif
+{
+	static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+	FPI *fpi, fpi1;
+	ULong bits[2];
+	Long exp;
+	int k;
+
+	fpi = &fpi0;
+	if (rounding != FPI_Round_near) {
+		fpi1 = fpi0;
+		fpi1.rounding = rounding;
+		fpi = &fpi1;
+		}
+	k = strtodg(s, sp, fpi, &exp, bits);
+	ULtox((UShort*)L, bits, exp, k);
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/strtorxL.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/strtorxL.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/strtorxL.c	(revision 2404)
@@ -0,0 +1,112 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#endif
+#ifdef IEEE_8087
+#define _0 2
+#define _1 1
+#define _2 0
+#endif
+
+ void
+#ifdef KR_headers
+ULtoxL(L, bits, exp, k) ULong *L; ULong *bits; Long exp; int k;
+#else
+ULtoxL(ULong *L, ULong *bits, Long exp, int k)
+#endif
+{
+	switch(k & STRTOG_Retmask) {
+	  case STRTOG_NoNumber:
+	  case STRTOG_Zero:
+		L[0] = L[1] = L[2] = 0;
+		break;
+
+	  case STRTOG_Normal:
+	  case STRTOG_Denormal:
+	  case STRTOG_NaNbits:
+		L[_0] = (exp + 0x3fff + 63) << 16;
+		L[_1] = bits[1];
+		L[_2] = bits[0];
+		break;
+
+	  case STRTOG_Infinite:
+		L[_0] = 0x7fff << 16;
+		L[_1] = L[_2] = 0;
+		break;
+
+	  case STRTOG_NaN:
+		L[_0] = 0x7fff << 16;
+		L[_1] = L[_2] = (ULong)-1;
+	  }
+	if (k & STRTOG_Neg)
+		L[_0] |= 0x80000000L;
+	}
+
+ int
+#ifdef KR_headers
+strtorxL(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L;
+#else
+strtorxL(CONST char *s, char **sp, int rounding, void *L)
+#endif
+{
+	static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
+	FPI *fpi, fpi1;
+	ULong bits[2];
+	Long exp;
+	int k;
+
+	fpi = &fpi0;
+	if (rounding != FPI_Round_near) {
+		fpi1 = fpi0;
+		fpi1.rounding = rounding;
+		fpi = &fpi1;
+		}
+	k = strtodg(s, sp, fpi, &exp, bits);
+	ULtoxL((ULong*)L, bits, exp, k);
+	return k;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/sum.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/sum.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/sum.c	(revision 2404)
@@ -0,0 +1,104 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ Bigint *
+#ifdef KR_headers
+sum(a, b) Bigint *a; Bigint *b;
+#else
+sum(Bigint *a, Bigint *b)
+#endif
+{
+	Bigint *c;
+	ULong carry, *xc, *xa, *xb, *xe, y;
+#ifdef Pack_32
+	ULong z;
+#endif
+
+	if (a->wds < b->wds) {
+		c = b; b = a; a = c;
+		}
+	c = Balloc(a->k);
+	c->wds = a->wds;
+	carry = 0;
+	xa = a->x;
+	xb = b->x;
+	xc = c->x;
+	xe = xc + b->wds;
+#ifdef Pack_32
+	do {
+		y = (*xa & 0xffff) + (*xb & 0xffff) + carry;
+		carry = (y & 0x10000) >> 16;
+		z = (*xa++ >> 16) + (*xb++ >> 16) + carry;
+		carry = (z & 0x10000) >> 16;
+		Storeinc(xc, z, y);
+		}
+		while(xc < xe);
+	xe += a->wds - b->wds;
+	while(xc < xe) {
+		y = (*xa & 0xffff) + carry;
+		carry = (y & 0x10000) >> 16;
+		z = (*xa++ >> 16) + carry;
+		carry = (z & 0x10000) >> 16;
+		Storeinc(xc, z, y);
+		}
+#else
+	do {
+		y = *xa++ + *xb++ + carry;
+		carry = (y & 0x10000) >> 16;
+		*xc++ = y & 0xffff;
+		}
+		while(xc < xe);
+	xe += a->wds - b->wds;
+	while(xc < xe) {
+		y = *xa++ + carry;
+		carry = (y & 0x10000) >> 16;
+		*xc++ = y & 0xffff;
+		}
+#endif
+	if (carry) {
+		if (c->wds == c->maxwds) {
+			b = Balloc(c->k + 1);
+			Bcopy(b, c);
+			Bfree(c);
+			c = b;
+			}
+		c->x[c->wds++] = 1;
+		}
+	return c;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/Q.ou0
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/Q.ou0	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/Q.ou0	(revision 2404)
@@ -0,0 +1,1180 @@
+
+Input: 1.23
+
+strtoQ consumes 4 bytes and returns 17
+with bits = #3fff3ae1 47ae147a e147ae14 7ae147ae
+g_Qfmt(0) gives 4 bytes: "1.23"
+
+strtoIQ returns 17, consuming 4 bytes.
+fI[0] = #3fff3ae1 47ae147a e147ae14 7ae147ae
+fI[1] = #3fff3ae1 47ae147a e147ae14 7ae147af
+fI[0] == strtod
+
+
+Input: 1.23e+20
+
+strtoQ consumes 8 bytes and returns 1
+with bits = #4041aabd f2145b43 0 0
+g_Qfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIQ returns 1, consuming 8 bytes.
+fI[0] == fI[1] = #4041aabd f2145b43 0 0
+
+
+Input: 1.23e-20
+
+strtoQ consumes 8 bytes and returns 17
+with bits = #3fbcd0ae 4cf76753 9e4cbca ad934841
+g_Qfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIQ returns 17, consuming 8 bytes.
+fI[0] = #3fbcd0ae 4cf76753 9e4cbca ad934841
+fI[1] = #3fbcd0ae 4cf76753 9e4cbca ad934842
+fI[0] == strtod
+
+
+Input: 1.23456789
+
+strtoQ consumes 10 bytes and returns 17
+with bits = #3fff3c0c a4283de1 b7eb6945 1304948f
+g_Qfmt(0) gives 10 bytes: "1.23456789"
+
+strtoIQ returns 17, consuming 10 bytes.
+fI[0] = #3fff3c0c a4283de1 b7eb6945 1304948f
+fI[1] = #3fff3c0c a4283de1 b7eb6945 13049490
+fI[0] == strtod
+
+
+Input: 1.23456589e+20
+
+strtoQ consumes 14 bytes and returns 1
+with bits = #4041ac53 7a660b99 74000000 0
+g_Qfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoIQ returns 1, consuming 14 bytes.
+fI[0] == fI[1] = #4041ac53 7a660b99 74000000 0
+
+
+Input: 1.23e+30
+
+strtoQ consumes 8 bytes and returns 1
+with bits = #4062f0cb 4e8fb79 4945600 0
+g_Qfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIQ returns 1, consuming 8 bytes.
+fI[0] == fI[1] = #4062f0cb 4e8fb79 4945600 0
+
+
+Input: 1.23e-30
+
+strtoQ consumes 8 bytes and returns 17
+with bits = #3f9b8f28 66f5010a a9d63f9e d7e8ba14
+g_Qfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIQ returns 17, consuming 8 bytes.
+fI[0] = #3f9b8f28 66f5010a a9d63f9e d7e8ba14
+fI[1] = #3f9b8f28 66f5010a a9d63f9e d7e8ba15
+fI[0] == strtod
+
+
+Input: 1.23456789e-20
+
+strtoQ consumes 14 bytes and returns 33
+with bits = #3fbcd268 1471e7ad a6a4a029 d86c1fa2
+g_Qfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoIQ returns 33, consuming 14 bytes.
+fI[0] = #3fbcd268 1471e7ad a6a4a029 d86c1fa1
+fI[1] = #3fbcd268 1471e7ad a6a4a029 d86c1fa2
+fI[1] == strtod
+
+
+Input: 1.23456789e-30
+
+strtoQ consumes 14 bytes and returns 17
+with bits = #3f9b90a3 e33bbd99 51f85855 5a6b19d4
+g_Qfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoIQ returns 17, consuming 14 bytes.
+fI[0] = #3f9b90a3 e33bbd99 51f85855 5a6b19d4
+fI[1] = #3f9b90a3 e33bbd99 51f85855 5a6b19d5
+fI[0] == strtod
+
+
+Input: 1.234567890123456789
+
+strtoQ consumes 20 bytes and returns 17
+with bits = #3fff3c0c a428c59f b71a4194 68dd175b
+g_Qfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIQ returns 17, consuming 20 bytes.
+fI[0] = #3fff3c0c a428c59f b71a4194 68dd175b
+fI[1] = #3fff3c0c a428c59f b71a4194 68dd175c
+fI[0] == strtod
+
+
+Input: 1.23456789012345678901234567890123456789
+
+strtoQ consumes 40 bytes and returns 17
+with bits = #3fff3c0c a428c59f b71a7be1 6b6b6d5b
+g_Qfmt(0) gives 36 bytes: "1.2345678901234567890123456789012346"
+
+strtoIQ returns 17, consuming 40 bytes.
+fI[0] = #3fff3c0c a428c59f b71a7be1 6b6b6d5b
+fI[1] = #3fff3c0c a428c59f b71a7be1 6b6b6d5c
+fI[0] == strtod
+
+
+Input: 1.23e306
+
+strtoQ consumes 8 bytes and returns 33
+with bits = #43f7c067 6cd1c61f 4daac5f1 e9fa3b55
+g_Qfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoIQ returns 33, consuming 8 bytes.
+fI[0] = #43f7c067 6cd1c61f 4daac5f1 e9fa3b54
+fI[1] = #43f7c067 6cd1c61f 4daac5f1 e9fa3b55
+fI[1] == strtod
+
+
+Input: 1.23e-306
+
+strtoQ consumes 9 bytes and returns 17
+with bits = #3c06ba3b 85da396e 7e496ab7 d233c3dd
+g_Qfmt(0) gives 9 bytes: "1.23e-306"
+
+strtoIQ returns 17, consuming 9 bytes.
+fI[0] = #3c06ba3b 85da396e 7e496ab7 d233c3dd
+fI[1] = #3c06ba3b 85da396e 7e496ab7 d233c3de
+fI[0] == strtod
+
+
+Input: 1.23e-320
+
+strtoQ consumes 9 bytes and returns 33
+with bits = #3bd83731 86e30898 7e33b2e8 355f847b
+g_Qfmt(0) gives 9 bytes: "1.23e-320"
+
+strtoIQ returns 33, consuming 9 bytes.
+fI[0] = #3bd83731 86e30898 7e33b2e8 355f847a
+fI[1] = #3bd83731 86e30898 7e33b2e8 355f847b
+fI[1] == strtod
+
+
+Input: 1.23e-20
+
+strtoQ consumes 8 bytes and returns 17
+with bits = #3fbcd0ae 4cf76753 9e4cbca ad934841
+g_Qfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIQ returns 17, consuming 8 bytes.
+fI[0] = #3fbcd0ae 4cf76753 9e4cbca ad934841
+fI[1] = #3fbcd0ae 4cf76753 9e4cbca ad934842
+fI[0] == strtod
+
+
+Input: 1.23456789e307
+
+strtoQ consumes 14 bytes and returns 17
+with bits = #43fb194b 14bdaecd bcea468c 902464cf
+g_Qfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoIQ returns 17, consuming 14 bytes.
+fI[0] = #43fb194b 14bdaecd bcea468c 902464cf
+fI[1] = #43fb194b 14bdaecd bcea468c 902464d0
+fI[0] == strtod
+
+
+Input: 1.23456589e-307
+
+strtoQ consumes 15 bytes and returns 17
+with bits = #3c036319 6bb9845f a6d234e3 39163574
+g_Qfmt(0) gives 15 bytes: "1.23456589e-307"
+
+strtoIQ returns 17, consuming 15 bytes.
+fI[0] = #3c036319 6bb9845f a6d234e3 39163574
+fI[1] = #3c036319 6bb9845f a6d234e3 39163575
+fI[0] == strtod
+
+
+Input: 1.234567890123456789
+
+strtoQ consumes 20 bytes and returns 17
+with bits = #3fff3c0c a428c59f b71a4194 68dd175b
+g_Qfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIQ returns 17, consuming 20 bytes.
+fI[0] = #3fff3c0c a428c59f b71a4194 68dd175b
+fI[1] = #3fff3c0c a428c59f b71a4194 68dd175c
+fI[0] == strtod
+
+
+Input: 1.234567890123456789e301
+
+strtoQ consumes 24 bytes and returns 33
+with bits = #43e726f5 175f5641 3017ea80 763990ef
+g_Qfmt(0) gives 25 bytes: "1.234567890123456789e+301"
+
+strtoIQ returns 33, consuming 24 bytes.
+fI[0] = #43e726f5 175f5641 3017ea80 763990ee
+fI[1] = #43e726f5 175f5641 3017ea80 763990ef
+fI[1] == strtod
+
+
+Input: 1.234567890123456789e-301
+
+strtoQ consumes 25 bytes and returns 17
+with bits = #3c1752a6 4e34ba0d 35b19b04 3222fce5
+g_Qfmt(0) gives 25 bytes: "1.234567890123456789e-301"
+
+strtoIQ returns 17, consuming 25 bytes.
+fI[0] = #3c1752a6 4e34ba0d 35b19b04 3222fce5
+fI[1] = #3c1752a6 4e34ba0d 35b19b04 3222fce6
+fI[0] == strtod
+
+
+Input: 1.234567890123456789e-321
+
+strtoQ consumes 25 bytes and returns 17
+with bits = #3bd4f3c2 3699d4db 99d1ea94 2fecd7de
+g_Qfmt(0) gives 25 bytes: "1.234567890123456789e-321"
+
+strtoIQ returns 17, consuming 25 bytes.
+fI[0] = #3bd4f3c2 3699d4db 99d1ea94 2fecd7de
+fI[1] = #3bd4f3c2 3699d4db 99d1ea94 2fecd7df
+fI[0] == strtod
+
+
+Input: 1e23
+
+strtoQ consumes 4 bytes and returns 1
+with bits = #404b52d0 2c7e14af 68000000 0
+g_Qfmt(0) gives 5 bytes: "1e+23"
+
+strtoIQ returns 1, consuming 4 bytes.
+fI[0] == fI[1] = #404b52d0 2c7e14af 68000000 0
+
+
+Input: 1e310
+
+strtoQ consumes 5 bytes and returns 33
+with bits = #4404bd03 c8140697 9e9ff00e fefd4cbd
+g_Qfmt(0) gives 6 bytes: "1e+310"
+
+strtoIQ returns 33, consuming 5 bytes.
+fI[0] = #4404bd03 c8140697 9e9ff00e fefd4cbc
+fI[1] = #4404bd03 c8140697 9e9ff00e fefd4cbd
+fI[1] == strtod
+
+
+Input: 9.0259718793241475e-277
+
+strtoQ consumes 23 bytes and returns 17
+with bits = #3c69ffff ffffffff f9ed5779 ac118fe1
+g_Qfmt(0) gives 23 bytes: "9.0259718793241475e-277"
+
+strtoIQ returns 17, consuming 23 bytes.
+fI[0] = #3c69ffff ffffffff f9ed5779 ac118fe1
+fI[1] = #3c69ffff ffffffff f9ed5779 ac118fe2
+fI[0] == strtod
+
+
+Input: 9.025971879324147880346310405869e-277
+
+strtoQ consumes 37 bytes and returns 33
+with bits = #3c6a0000 0 0 9a
+g_Qfmt(0) gives 37 bytes: "9.025971879324147880346310405869e-277"
+
+strtoIQ returns 33, consuming 37 bytes.
+fI[0] = #3c6a0000 0 0 99
+fI[1] = #3c6a0000 0 0 9a
+fI[1] == strtod
+
+
+Input: 9.025971879324147880346310405868e-277
+
+strtoQ consumes 37 bytes and returns 17
+with bits = #3c69ffff ffffffff ffffffff fffffcb5
+g_Qfmt(0) gives 37 bytes: "9.025971879324147880346310405868e-277"
+
+strtoIQ returns 17, consuming 37 bytes.
+fI[0] = #3c69ffff ffffffff ffffffff fffffcb5
+fI[1] = #3c69ffff ffffffff ffffffff fffffcb6
+fI[0] == strtod
+
+
+Input: 2.2250738585072014e-308
+
+strtoQ consumes 23 bytes and returns 33
+with bits = #3c010000 0 8c304c cf867de0
+g_Qfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoIQ returns 33, consuming 23 bytes.
+fI[0] = #3c010000 0 8c304c cf867ddf
+fI[1] = #3c010000 0 8c304c cf867de0
+fI[1] == strtod
+
+
+Input: 2.2250738585072013e-308
+
+strtoQ consumes 23 bytes and returns 33
+with bits = #3c00ffff ffffffff fa9e4c4f 4c1e8a10
+g_Qfmt(0) gives 23 bytes: "2.2250738585072013e-308"
+
+strtoIQ returns 33, consuming 23 bytes.
+fI[0] = #3c00ffff ffffffff fa9e4c4f 4c1e8a0f
+fI[1] = #3c00ffff ffffffff fa9e4c4f 4c1e8a10
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff1999 99999999 99999999 99999999
+g_Qfmt(0) gives 36 bytes: "1.0999999999999999999999999999999999"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff1999 99999999 99999999 99999999
+fI[1] = #3fff1999 99999999 99999999 9999999a
+fI[0] == strtod
+
+
+Input: -1.1
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff1999 99999999 99999999 99999999
+g_Qfmt(0) gives 37 bytes: "-1.0999999999999999999999999999999999"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff1999 99999999 99999999 9999999a
+fI[1] = #bfff1999 99999999 99999999 99999999
+fI[1] == strtod
+
+
+Input: 1.2
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff3333 33333333 33333333 33333333
+g_Qfmt(0) gives 3 bytes: "1.2"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff3333 33333333 33333333 33333333
+fI[1] = #3fff3333 33333333 33333333 33333334
+fI[0] == strtod
+
+
+Input: -1.2
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff3333 33333333 33333333 33333333
+g_Qfmt(0) gives 4 bytes: "-1.2"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff3333 33333333 33333333 33333334
+fI[1] = #bfff3333 33333333 33333333 33333333
+fI[1] == strtod
+
+
+Input: 1.3
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff4ccc cccccccc cccccccc cccccccc
+g_Qfmt(0) gives 36 bytes: "1.2999999999999999999999999999999998"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff4ccc cccccccc cccccccc cccccccc
+fI[1] = #3fff4ccc cccccccc cccccccc cccccccd
+fI[0] == strtod
+
+
+Input: -1.3
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff4ccc cccccccc cccccccc cccccccc
+g_Qfmt(0) gives 37 bytes: "-1.2999999999999999999999999999999998"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff4ccc cccccccc cccccccc cccccccd
+fI[1] = #bfff4ccc cccccccc cccccccc cccccccc
+fI[1] == strtod
+
+
+Input: 1.4
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff6666 66666666 66666666 66666666
+g_Qfmt(0) gives 3 bytes: "1.4"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff6666 66666666 66666666 66666666
+fI[1] = #3fff6666 66666666 66666666 66666667
+fI[0] == strtod
+
+
+Input: -1.4
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff6666 66666666 66666666 66666666
+g_Qfmt(0) gives 4 bytes: "-1.4"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff6666 66666666 66666666 66666667
+fI[1] = #bfff6666 66666666 66666666 66666666
+fI[1] == strtod
+
+
+Input: 1.5
+
+strtoQ consumes 3 bytes and returns 1
+with bits = #3fff8000 0 0 0
+g_Qfmt(0) gives 3 bytes: "1.5"
+
+strtoIQ returns 1, consuming 3 bytes.
+fI[0] == fI[1] = #3fff8000 0 0 0
+
+
+Input: -1.5
+
+strtoQ consumes 4 bytes and returns 9
+with bits = #bfff8000 0 0 0
+g_Qfmt(0) gives 4 bytes: "-1.5"
+
+strtoIQ returns 9, consuming 4 bytes.
+fI[0] == fI[1] = #bfff8000 0 0 0
+
+
+Input: 1.6
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff9999 99999999 99999999 99999999
+g_Qfmt(0) gives 36 bytes: "1.5999999999999999999999999999999999"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff9999 99999999 99999999 99999999
+fI[1] = #3fff9999 99999999 99999999 9999999a
+fI[0] == strtod
+
+
+Input: -1.6
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff9999 99999999 99999999 99999999
+g_Qfmt(0) gives 37 bytes: "-1.5999999999999999999999999999999999"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff9999 99999999 99999999 9999999a
+fI[1] = #bfff9999 99999999 99999999 99999999
+fI[1] == strtod
+
+
+Input: 1.7
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffb333 33333333 33333333 33333333
+g_Qfmt(0) gives 3 bytes: "1.7"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffb333 33333333 33333333 33333333
+fI[1] = #3fffb333 33333333 33333333 33333334
+fI[0] == strtod
+
+
+Input: -1.7
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffb333 33333333 33333333 33333333
+g_Qfmt(0) gives 4 bytes: "-1.7"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffb333 33333333 33333333 33333334
+fI[1] = #bfffb333 33333333 33333333 33333333
+fI[1] == strtod
+
+
+Input: 1.8
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffcccc cccccccc cccccccc cccccccc
+g_Qfmt(0) gives 36 bytes: "1.7999999999999999999999999999999998"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fffcccc cccccccc cccccccc cccccccc
+fI[1] = #3fffcccc cccccccc cccccccc cccccccd
+fI[0] == strtod
+
+
+Input: -1.8
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffcccc cccccccc cccccccc cccccccc
+g_Qfmt(0) gives 37 bytes: "-1.7999999999999999999999999999999998"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfffcccc cccccccc cccccccc cccccccd
+fI[1] = #bfffcccc cccccccc cccccccc cccccccc
+fI[1] == strtod
+
+
+Input: 1.9
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffe666 66666666 66666666 66666666
+g_Qfmt(0) gives 3 bytes: "1.9"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffe666 66666666 66666666 66666666
+fI[1] = #3fffe666 66666666 66666666 66666667
+fI[0] == strtod
+
+
+Input: -1.9
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffe666 66666666 66666666 66666666
+g_Qfmt(0) gives 4 bytes: "-1.9"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffe666 66666666 66666666 66666667
+fI[1] = #bfffe666 66666666 66666666 66666666
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff1999 99999999 99999999 9999999a
+g_Qfmt(0) gives 3 bytes: "1.1"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff1999 99999999 99999999 99999999
+fI[1] = #3fff1999 99999999 99999999 9999999a
+fI[1] == strtod
+
+
+Input: -1.1
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff1999 99999999 99999999 9999999a
+g_Qfmt(0) gives 4 bytes: "-1.1"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff1999 99999999 99999999 9999999a
+fI[1] = #bfff1999 99999999 99999999 99999999
+fI[0] == strtod
+
+
+Input: 1.2
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff3333 33333333 33333333 33333333
+g_Qfmt(0) gives 3 bytes: "1.2"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff3333 33333333 33333333 33333333
+fI[1] = #3fff3333 33333333 33333333 33333334
+fI[0] == strtod
+
+
+Input: -1.2
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff3333 33333333 33333333 33333333
+g_Qfmt(0) gives 4 bytes: "-1.2"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff3333 33333333 33333333 33333334
+fI[1] = #bfff3333 33333333 33333333 33333333
+fI[1] == strtod
+
+
+Input: 1.3
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff4ccc cccccccc cccccccc cccccccd
+g_Qfmt(0) gives 3 bytes: "1.3"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff4ccc cccccccc cccccccc cccccccc
+fI[1] = #3fff4ccc cccccccc cccccccc cccccccd
+fI[1] == strtod
+
+
+Input: -1.3
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff4ccc cccccccc cccccccc cccccccd
+g_Qfmt(0) gives 4 bytes: "-1.3"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff4ccc cccccccc cccccccc cccccccd
+fI[1] = #bfff4ccc cccccccc cccccccc cccccccc
+fI[0] == strtod
+
+
+Input: 1.4
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff6666 66666666 66666666 66666666
+g_Qfmt(0) gives 3 bytes: "1.4"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff6666 66666666 66666666 66666666
+fI[1] = #3fff6666 66666666 66666666 66666667
+fI[0] == strtod
+
+
+Input: -1.4
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff6666 66666666 66666666 66666666
+g_Qfmt(0) gives 4 bytes: "-1.4"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff6666 66666666 66666666 66666667
+fI[1] = #bfff6666 66666666 66666666 66666666
+fI[1] == strtod
+
+
+Input: 1.5
+
+strtoQ consumes 3 bytes and returns 1
+with bits = #3fff8000 0 0 0
+g_Qfmt(0) gives 3 bytes: "1.5"
+
+strtoIQ returns 1, consuming 3 bytes.
+fI[0] == fI[1] = #3fff8000 0 0 0
+
+
+Input: -1.5
+
+strtoQ consumes 4 bytes and returns 9
+with bits = #bfff8000 0 0 0
+g_Qfmt(0) gives 4 bytes: "-1.5"
+
+strtoIQ returns 9, consuming 4 bytes.
+fI[0] == fI[1] = #bfff8000 0 0 0
+
+
+Input: 1.6
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff9999 99999999 99999999 9999999a
+g_Qfmt(0) gives 3 bytes: "1.6"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff9999 99999999 99999999 99999999
+fI[1] = #3fff9999 99999999 99999999 9999999a
+fI[1] == strtod
+
+
+Input: -1.6
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff9999 99999999 99999999 9999999a
+g_Qfmt(0) gives 4 bytes: "-1.6"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff9999 99999999 99999999 9999999a
+fI[1] = #bfff9999 99999999 99999999 99999999
+fI[0] == strtod
+
+
+Input: 1.7
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffb333 33333333 33333333 33333333
+g_Qfmt(0) gives 3 bytes: "1.7"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffb333 33333333 33333333 33333333
+fI[1] = #3fffb333 33333333 33333333 33333334
+fI[0] == strtod
+
+
+Input: -1.7
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffb333 33333333 33333333 33333333
+g_Qfmt(0) gives 4 bytes: "-1.7"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffb333 33333333 33333333 33333334
+fI[1] = #bfffb333 33333333 33333333 33333333
+fI[1] == strtod
+
+
+Input: 1.8
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fffcccc cccccccc cccccccc cccccccd
+g_Qfmt(0) gives 3 bytes: "1.8"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fffcccc cccccccc cccccccc cccccccc
+fI[1] = #3fffcccc cccccccc cccccccc cccccccd
+fI[1] == strtod
+
+
+Input: -1.8
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfffcccc cccccccc cccccccc cccccccd
+g_Qfmt(0) gives 4 bytes: "-1.8"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfffcccc cccccccc cccccccc cccccccd
+fI[1] = #bfffcccc cccccccc cccccccc cccccccc
+fI[0] == strtod
+
+
+Input: 1.9
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffe666 66666666 66666666 66666666
+g_Qfmt(0) gives 3 bytes: "1.9"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffe666 66666666 66666666 66666666
+fI[1] = #3fffe666 66666666 66666666 66666667
+fI[0] == strtod
+
+
+Input: -1.9
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffe666 66666666 66666666 66666666
+g_Qfmt(0) gives 4 bytes: "-1.9"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffe666 66666666 66666666 66666667
+fI[1] = #bfffe666 66666666 66666666 66666666
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff1999 99999999 99999999 9999999a
+g_Qfmt(0) gives 3 bytes: "1.1"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff1999 99999999 99999999 99999999
+fI[1] = #3fff1999 99999999 99999999 9999999a
+fI[1] == strtod
+
+
+Input: -1.1
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff1999 99999999 99999999 99999999
+g_Qfmt(0) gives 37 bytes: "-1.0999999999999999999999999999999999"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff1999 99999999 99999999 9999999a
+fI[1] = #bfff1999 99999999 99999999 99999999
+fI[1] == strtod
+
+
+Input: 1.2
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff3333 33333333 33333333 33333334
+g_Qfmt(0) gives 36 bytes: "1.2000000000000000000000000000000002"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff3333 33333333 33333333 33333333
+fI[1] = #3fff3333 33333333 33333333 33333334
+fI[1] == strtod
+
+
+Input: -1.2
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff3333 33333333 33333333 33333333
+g_Qfmt(0) gives 4 bytes: "-1.2"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff3333 33333333 33333333 33333334
+fI[1] = #bfff3333 33333333 33333333 33333333
+fI[1] == strtod
+
+
+Input: 1.3
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff4ccc cccccccc cccccccc cccccccd
+g_Qfmt(0) gives 3 bytes: "1.3"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff4ccc cccccccc cccccccc cccccccc
+fI[1] = #3fff4ccc cccccccc cccccccc cccccccd
+fI[1] == strtod
+
+
+Input: -1.3
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff4ccc cccccccc cccccccc cccccccc
+g_Qfmt(0) gives 37 bytes: "-1.2999999999999999999999999999999998"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff4ccc cccccccc cccccccc cccccccd
+fI[1] = #bfff4ccc cccccccc cccccccc cccccccc
+fI[1] == strtod
+
+
+Input: 1.4
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff6666 66666666 66666666 66666667
+g_Qfmt(0) gives 36 bytes: "1.4000000000000000000000000000000001"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff6666 66666666 66666666 66666666
+fI[1] = #3fff6666 66666666 66666666 66666667
+fI[1] == strtod
+
+
+Input: -1.4
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff6666 66666666 66666666 66666666
+g_Qfmt(0) gives 4 bytes: "-1.4"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff6666 66666666 66666666 66666667
+fI[1] = #bfff6666 66666666 66666666 66666666
+fI[1] == strtod
+
+
+Input: 1.5
+
+strtoQ consumes 3 bytes and returns 1
+with bits = #3fff8000 0 0 0
+g_Qfmt(0) gives 3 bytes: "1.5"
+
+strtoIQ returns 1, consuming 3 bytes.
+fI[0] == fI[1] = #3fff8000 0 0 0
+
+
+Input: -1.5
+
+strtoQ consumes 4 bytes and returns 9
+with bits = #bfff8000 0 0 0
+g_Qfmt(0) gives 4 bytes: "-1.5"
+
+strtoIQ returns 9, consuming 4 bytes.
+fI[0] == fI[1] = #bfff8000 0 0 0
+
+
+Input: 1.6
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff9999 99999999 99999999 9999999a
+g_Qfmt(0) gives 3 bytes: "1.6"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff9999 99999999 99999999 99999999
+fI[1] = #3fff9999 99999999 99999999 9999999a
+fI[1] == strtod
+
+
+Input: -1.6
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff9999 99999999 99999999 99999999
+g_Qfmt(0) gives 37 bytes: "-1.5999999999999999999999999999999999"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff9999 99999999 99999999 9999999a
+fI[1] = #bfff9999 99999999 99999999 99999999
+fI[1] == strtod
+
+
+Input: 1.7
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fffb333 33333333 33333333 33333334
+g_Qfmt(0) gives 36 bytes: "1.7000000000000000000000000000000002"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffb333 33333333 33333333 33333333
+fI[1] = #3fffb333 33333333 33333333 33333334
+fI[1] == strtod
+
+
+Input: -1.7
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffb333 33333333 33333333 33333333
+g_Qfmt(0) gives 4 bytes: "-1.7"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffb333 33333333 33333333 33333334
+fI[1] = #bfffb333 33333333 33333333 33333333
+fI[1] == strtod
+
+
+Input: 1.8
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fffcccc cccccccc cccccccc cccccccd
+g_Qfmt(0) gives 3 bytes: "1.8"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fffcccc cccccccc cccccccc cccccccc
+fI[1] = #3fffcccc cccccccc cccccccc cccccccd
+fI[1] == strtod
+
+
+Input: -1.8
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffcccc cccccccc cccccccc cccccccc
+g_Qfmt(0) gives 37 bytes: "-1.7999999999999999999999999999999998"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfffcccc cccccccc cccccccc cccccccd
+fI[1] = #bfffcccc cccccccc cccccccc cccccccc
+fI[1] == strtod
+
+
+Input: 1.9
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fffe666 66666666 66666666 66666667
+g_Qfmt(0) gives 36 bytes: "1.9000000000000000000000000000000001"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffe666 66666666 66666666 66666666
+fI[1] = #3fffe666 66666666 66666666 66666667
+fI[1] == strtod
+
+
+Input: -1.9
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffe666 66666666 66666666 66666666
+g_Qfmt(0) gives 4 bytes: "-1.9"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffe666 66666666 66666666 66666667
+fI[1] = #bfffe666 66666666 66666666 66666666
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff1999 99999999 99999999 99999999
+g_Qfmt(0) gives 36 bytes: "1.0999999999999999999999999999999999"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff1999 99999999 99999999 99999999
+fI[1] = #3fff1999 99999999 99999999 9999999a
+fI[0] == strtod
+
+
+Input: -1.1
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff1999 99999999 99999999 9999999a
+g_Qfmt(0) gives 4 bytes: "-1.1"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff1999 99999999 99999999 9999999a
+fI[1] = #bfff1999 99999999 99999999 99999999
+fI[0] == strtod
+
+
+Input: 1.2
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff3333 33333333 33333333 33333333
+g_Qfmt(0) gives 3 bytes: "1.2"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff3333 33333333 33333333 33333333
+fI[1] = #3fff3333 33333333 33333333 33333334
+fI[0] == strtod
+
+
+Input: -1.2
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff3333 33333333 33333333 33333334
+g_Qfmt(0) gives 37 bytes: "-1.2000000000000000000000000000000002"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff3333 33333333 33333333 33333334
+fI[1] = #bfff3333 33333333 33333333 33333333
+fI[0] == strtod
+
+
+Input: 1.3
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff4ccc cccccccc cccccccc cccccccc
+g_Qfmt(0) gives 36 bytes: "1.2999999999999999999999999999999998"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff4ccc cccccccc cccccccc cccccccc
+fI[1] = #3fff4ccc cccccccc cccccccc cccccccd
+fI[0] == strtod
+
+
+Input: -1.3
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff4ccc cccccccc cccccccc cccccccd
+g_Qfmt(0) gives 4 bytes: "-1.3"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff4ccc cccccccc cccccccc cccccccd
+fI[1] = #bfff4ccc cccccccc cccccccc cccccccc
+fI[0] == strtod
+
+
+Input: 1.4
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff6666 66666666 66666666 66666666
+g_Qfmt(0) gives 3 bytes: "1.4"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff6666 66666666 66666666 66666666
+fI[1] = #3fff6666 66666666 66666666 66666667
+fI[0] == strtod
+
+
+Input: -1.4
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff6666 66666666 66666666 66666667
+g_Qfmt(0) gives 37 bytes: "-1.4000000000000000000000000000000001"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff6666 66666666 66666666 66666667
+fI[1] = #bfff6666 66666666 66666666 66666666
+fI[0] == strtod
+
+
+Input: 1.5
+
+strtoQ consumes 3 bytes and returns 1
+with bits = #3fff8000 0 0 0
+g_Qfmt(0) gives 3 bytes: "1.5"
+
+strtoIQ returns 1, consuming 3 bytes.
+fI[0] == fI[1] = #3fff8000 0 0 0
+
+
+Input: -1.5
+
+strtoQ consumes 4 bytes and returns 9
+with bits = #bfff8000 0 0 0
+g_Qfmt(0) gives 4 bytes: "-1.5"
+
+strtoIQ returns 9, consuming 4 bytes.
+fI[0] == fI[1] = #bfff8000 0 0 0
+
+
+Input: 1.6
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff9999 99999999 99999999 99999999
+g_Qfmt(0) gives 36 bytes: "1.5999999999999999999999999999999999"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff9999 99999999 99999999 99999999
+fI[1] = #3fff9999 99999999 99999999 9999999a
+fI[0] == strtod
+
+
+Input: -1.6
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff9999 99999999 99999999 9999999a
+g_Qfmt(0) gives 4 bytes: "-1.6"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff9999 99999999 99999999 9999999a
+fI[1] = #bfff9999 99999999 99999999 99999999
+fI[0] == strtod
+
+
+Input: 1.7
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffb333 33333333 33333333 33333333
+g_Qfmt(0) gives 3 bytes: "1.7"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffb333 33333333 33333333 33333333
+fI[1] = #3fffb333 33333333 33333333 33333334
+fI[0] == strtod
+
+
+Input: -1.7
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfffb333 33333333 33333333 33333334
+g_Qfmt(0) gives 37 bytes: "-1.7000000000000000000000000000000002"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffb333 33333333 33333333 33333334
+fI[1] = #bfffb333 33333333 33333333 33333333
+fI[0] == strtod
+
+
+Input: 1.8
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffcccc cccccccc cccccccc cccccccc
+g_Qfmt(0) gives 36 bytes: "1.7999999999999999999999999999999998"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fffcccc cccccccc cccccccc cccccccc
+fI[1] = #3fffcccc cccccccc cccccccc cccccccd
+fI[0] == strtod
+
+
+Input: -1.8
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfffcccc cccccccc cccccccc cccccccd
+g_Qfmt(0) gives 4 bytes: "-1.8"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfffcccc cccccccc cccccccc cccccccd
+fI[1] = #bfffcccc cccccccc cccccccc cccccccc
+fI[0] == strtod
+
+
+Input: 1.9
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffe666 66666666 66666666 66666666
+g_Qfmt(0) gives 3 bytes: "1.9"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffe666 66666666 66666666 66666666
+fI[1] = #3fffe666 66666666 66666666 66666667
+fI[0] == strtod
+
+
+Input: -1.9
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfffe666 66666666 66666666 66666667
+g_Qfmt(0) gives 37 bytes: "-1.9000000000000000000000000000000001"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffe666 66666666 66666666 66666667
+fI[1] = #bfffe666 66666666 66666666 66666666
+fI[0] == strtod
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/Q.ou1
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/Q.ou1	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/Q.ou1	(revision 2404)
@@ -0,0 +1,1468 @@
+
+Input: 1.23
+
+strtoQ consumes 4 bytes and returns 17
+with bits = #3fff3ae1 47ae147a e147ae14 7ae147ae
+printf("%.35Lg") gives 1.23
+g_Qfmt(0) gives 4 bytes: "1.23"
+
+strtoIQ returns 17, consuming 4 bytes.
+fI[0] = #3fff3ae1 47ae147a e147ae14 7ae147ae
+= 1.23
+fI[1] = #3fff3ae1 47ae147a e147ae14 7ae147af
+= 1.2300000000000000000000000000000002
+fI[0] == strtod
+
+
+Input: 1.23e+20
+
+strtoQ consumes 8 bytes and returns 1
+with bits = #4041aabd f2145b43 0 0
+printf("%.35Lg") gives 123000000000000000000
+g_Qfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIQ returns 1, consuming 8 bytes.
+fI[0] == fI[1] = #4041aabd f2145b43 0 0
+= 123000000000000000000
+
+
+Input: 1.23e-20
+
+strtoQ consumes 8 bytes and returns 17
+with bits = #3fbcd0ae 4cf76753 9e4cbca ad934841
+printf("%.35Lg") gives 1.2299999999999999999999999999999999e-20
+g_Qfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIQ returns 17, consuming 8 bytes.
+fI[0] = #3fbcd0ae 4cf76753 9e4cbca ad934841
+= 1.2299999999999999999999999999999999e-20
+fI[1] = #3fbcd0ae 4cf76753 9e4cbca ad934842
+= 1.2300000000000000000000000000000001e-20
+fI[0] == strtod
+
+
+Input: 1.23456789
+
+strtoQ consumes 10 bytes and returns 17
+with bits = #3fff3c0c a4283de1 b7eb6945 1304948f
+printf("%.35Lg") gives 1.2345678899999999999999999999999999
+g_Qfmt(0) gives 10 bytes: "1.23456789"
+
+strtoIQ returns 17, consuming 10 bytes.
+fI[0] = #3fff3c0c a4283de1 b7eb6945 1304948f
+= 1.2345678899999999999999999999999999
+fI[1] = #3fff3c0c a4283de1 b7eb6945 13049490
+= 1.2345678900000000000000000000000001
+fI[0] == strtod
+
+
+Input: 1.23456589e+20
+
+strtoQ consumes 14 bytes and returns 1
+with bits = #4041ac53 7a660b99 74000000 0
+printf("%.35Lg") gives 123456589000000000000
+g_Qfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoIQ returns 1, consuming 14 bytes.
+fI[0] == fI[1] = #4041ac53 7a660b99 74000000 0
+= 123456589000000000000
+
+
+Input: 1.23e+30
+
+strtoQ consumes 8 bytes and returns 1
+with bits = #4062f0cb 4e8fb79 4945600 0
+printf("%.35Lg") gives 1230000000000000000000000000000
+g_Qfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIQ returns 1, consuming 8 bytes.
+fI[0] == fI[1] = #4062f0cb 4e8fb79 4945600 0
+= 1230000000000000000000000000000
+
+
+Input: 1.23e-30
+
+strtoQ consumes 8 bytes and returns 17
+with bits = #3f9b8f28 66f5010a a9d63f9e d7e8ba14
+printf("%.35Lg") gives 1.2299999999999999999999999999999999e-30
+g_Qfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIQ returns 17, consuming 8 bytes.
+fI[0] = #3f9b8f28 66f5010a a9d63f9e d7e8ba14
+= 1.2299999999999999999999999999999999e-30
+fI[1] = #3f9b8f28 66f5010a a9d63f9e d7e8ba15
+= 1.2300000000000000000000000000000001e-30
+fI[0] == strtod
+
+
+Input: 1.23456789e-20
+
+strtoQ consumes 14 bytes and returns 33
+with bits = #3fbcd268 1471e7ad a6a4a029 d86c1fa2
+printf("%.35Lg") gives 1.2345678900000000000000000000000001e-20
+g_Qfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoIQ returns 33, consuming 14 bytes.
+fI[0] = #3fbcd268 1471e7ad a6a4a029 d86c1fa1
+= 1.2345678899999999999999999999999999e-20
+fI[1] = #3fbcd268 1471e7ad a6a4a029 d86c1fa2
+= 1.2345678900000000000000000000000001e-20
+fI[1] == strtod
+
+
+Input: 1.23456789e-30
+
+strtoQ consumes 14 bytes and returns 17
+with bits = #3f9b90a3 e33bbd99 51f85855 5a6b19d4
+printf("%.35Lg") gives 1.23456789e-30
+g_Qfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoIQ returns 17, consuming 14 bytes.
+fI[0] = #3f9b90a3 e33bbd99 51f85855 5a6b19d4
+= 1.23456789e-30
+fI[1] = #3f9b90a3 e33bbd99 51f85855 5a6b19d5
+= 1.2345678900000000000000000000000001e-30
+fI[0] == strtod
+
+
+Input: 1.234567890123456789
+
+strtoQ consumes 20 bytes and returns 17
+with bits = #3fff3c0c a428c59f b71a4194 68dd175b
+printf("%.35Lg") gives 1.234567890123456789
+g_Qfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIQ returns 17, consuming 20 bytes.
+fI[0] = #3fff3c0c a428c59f b71a4194 68dd175b
+= 1.234567890123456789
+fI[1] = #3fff3c0c a428c59f b71a4194 68dd175c
+= 1.2345678901234567890000000000000002
+fI[0] == strtod
+
+
+Input: 1.23456789012345678901234567890123456789
+
+strtoQ consumes 40 bytes and returns 17
+with bits = #3fff3c0c a428c59f b71a7be1 6b6b6d5b
+printf("%.35Lg") gives 1.2345678901234567890123456789012346
+g_Qfmt(0) gives 36 bytes: "1.2345678901234567890123456789012346"
+
+strtoIQ returns 17, consuming 40 bytes.
+fI[0] = #3fff3c0c a428c59f b71a7be1 6b6b6d5b
+= 1.2345678901234567890123456789012346
+fI[1] = #3fff3c0c a428c59f b71a7be1 6b6b6d5c
+= 1.2345678901234567890123456789012347
+fI[0] == strtod
+
+
+Input: 1.23e306
+
+strtoQ consumes 8 bytes and returns 33
+with bits = #43f7c067 6cd1c61f 4daac5f1 e9fa3b55
+printf("%.35Lg") gives 1.23e+306
+g_Qfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoIQ returns 33, consuming 8 bytes.
+fI[0] = #43f7c067 6cd1c61f 4daac5f1 e9fa3b54
+= 1.2299999999999999999999999999999999e+306
+fI[1] = #43f7c067 6cd1c61f 4daac5f1 e9fa3b55
+= 1.23e+306
+fI[1] == strtod
+
+
+Input: 1.23e-306
+
+strtoQ consumes 9 bytes and returns 17
+with bits = #3c06ba3b 85da396e 7e496ab7 d233c3dd
+printf("%.35Lg") gives 1.23e-306
+g_Qfmt(0) gives 9 bytes: "1.23e-306"
+
+strtoIQ returns 17, consuming 9 bytes.
+fI[0] = #3c06ba3b 85da396e 7e496ab7 d233c3dd
+= 1.23e-306
+fI[1] = #3c06ba3b 85da396e 7e496ab7 d233c3de
+= 1.2300000000000000000000000000000001e-306
+fI[0] == strtod
+
+
+Input: 1.23e-320
+
+strtoQ consumes 9 bytes and returns 33
+with bits = #3bd83731 86e30898 7e33b2e8 355f847b
+printf("%.35Lg") gives 1.2300000000000000000000000000000001e-320
+g_Qfmt(0) gives 9 bytes: "1.23e-320"
+
+strtoIQ returns 33, consuming 9 bytes.
+fI[0] = #3bd83731 86e30898 7e33b2e8 355f847a
+= 1.2299999999999999999999999999999999e-320
+fI[1] = #3bd83731 86e30898 7e33b2e8 355f847b
+= 1.2300000000000000000000000000000001e-320
+fI[1] == strtod
+
+
+Input: 1.23e-20
+
+strtoQ consumes 8 bytes and returns 17
+with bits = #3fbcd0ae 4cf76753 9e4cbca ad934841
+printf("%.35Lg") gives 1.2299999999999999999999999999999999e-20
+g_Qfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIQ returns 17, consuming 8 bytes.
+fI[0] = #3fbcd0ae 4cf76753 9e4cbca ad934841
+= 1.2299999999999999999999999999999999e-20
+fI[1] = #3fbcd0ae 4cf76753 9e4cbca ad934842
+= 1.2300000000000000000000000000000001e-20
+fI[0] == strtod
+
+
+Input: 1.23456789e307
+
+strtoQ consumes 14 bytes and returns 17
+with bits = #43fb194b 14bdaecd bcea468c 902464cf
+printf("%.35Lg") gives 1.2345678899999999999999999999999999e+307
+g_Qfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoIQ returns 17, consuming 14 bytes.
+fI[0] = #43fb194b 14bdaecd bcea468c 902464cf
+= 1.2345678899999999999999999999999999e+307
+fI[1] = #43fb194b 14bdaecd bcea468c 902464d0
+= 1.2345678900000000000000000000000001e+307
+fI[0] == strtod
+
+
+Input: 1.23456589e-307
+
+strtoQ consumes 15 bytes and returns 17
+with bits = #3c036319 6bb9845f a6d234e3 39163574
+printf("%.35Lg") gives 1.23456589e-307
+g_Qfmt(0) gives 15 bytes: "1.23456589e-307"
+
+strtoIQ returns 17, consuming 15 bytes.
+fI[0] = #3c036319 6bb9845f a6d234e3 39163574
+= 1.23456589e-307
+fI[1] = #3c036319 6bb9845f a6d234e3 39163575
+= 1.2345658900000000000000000000000002e-307
+fI[0] == strtod
+
+
+Input: 1.234567890123456789
+
+strtoQ consumes 20 bytes and returns 17
+with bits = #3fff3c0c a428c59f b71a4194 68dd175b
+printf("%.35Lg") gives 1.234567890123456789
+g_Qfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIQ returns 17, consuming 20 bytes.
+fI[0] = #3fff3c0c a428c59f b71a4194 68dd175b
+= 1.234567890123456789
+fI[1] = #3fff3c0c a428c59f b71a4194 68dd175c
+= 1.2345678901234567890000000000000002
+fI[0] == strtod
+
+
+Input: 1.234567890123456789e301
+
+strtoQ consumes 24 bytes and returns 33
+with bits = #43e726f5 175f5641 3017ea80 763990ef
+printf("%.35Lg") gives 1.2345678901234567890000000000000001e+301
+g_Qfmt(0) gives 25 bytes: "1.234567890123456789e+301"
+
+strtoIQ returns 33, consuming 24 bytes.
+fI[0] = #43e726f5 175f5641 3017ea80 763990ee
+= 1.2345678901234567889999999999999999e+301
+fI[1] = #43e726f5 175f5641 3017ea80 763990ef
+= 1.2345678901234567890000000000000001e+301
+fI[1] == strtod
+
+
+Input: 1.234567890123456789e-301
+
+strtoQ consumes 25 bytes and returns 17
+with bits = #3c1752a6 4e34ba0d 35b19b04 3222fce5
+printf("%.35Lg") gives 1.234567890123456789e-301
+g_Qfmt(0) gives 25 bytes: "1.234567890123456789e-301"
+
+strtoIQ returns 17, consuming 25 bytes.
+fI[0] = #3c1752a6 4e34ba0d 35b19b04 3222fce5
+= 1.234567890123456789e-301
+fI[1] = #3c1752a6 4e34ba0d 35b19b04 3222fce6
+= 1.2345678901234567890000000000000002e-301
+fI[0] == strtod
+
+
+Input: 1.234567890123456789e-321
+
+strtoQ consumes 25 bytes and returns 17
+with bits = #3bd4f3c2 3699d4db 99d1ea94 2fecd7de
+printf("%.35Lg") gives 1.234567890123456789e-321
+g_Qfmt(0) gives 25 bytes: "1.234567890123456789e-321"
+
+strtoIQ returns 17, consuming 25 bytes.
+fI[0] = #3bd4f3c2 3699d4db 99d1ea94 2fecd7de
+= 1.234567890123456789e-321
+fI[1] = #3bd4f3c2 3699d4db 99d1ea94 2fecd7df
+= 1.2345678901234567890000000000000001e-321
+fI[0] == strtod
+
+
+Input: 1e23
+
+strtoQ consumes 4 bytes and returns 1
+with bits = #404b52d0 2c7e14af 68000000 0
+printf("%.35Lg") gives 100000000000000000000000
+g_Qfmt(0) gives 5 bytes: "1e+23"
+
+strtoIQ returns 1, consuming 4 bytes.
+fI[0] == fI[1] = #404b52d0 2c7e14af 68000000 0
+= 100000000000000000000000
+
+
+Input: 1e310
+
+strtoQ consumes 5 bytes and returns 33
+with bits = #4404bd03 c8140697 9e9ff00e fefd4cbd
+printf("%.35Lg") gives 1e+310
+g_Qfmt(0) gives 6 bytes: "1e+310"
+
+strtoIQ returns 33, consuming 5 bytes.
+fI[0] = #4404bd03 c8140697 9e9ff00e fefd4cbc
+= 9.9999999999999999999999999999999992e+309
+fI[1] = #4404bd03 c8140697 9e9ff00e fefd4cbd
+= 1e+310
+fI[1] == strtod
+
+
+Input: 9.0259718793241475e-277
+
+strtoQ consumes 23 bytes and returns 17
+with bits = #3c69ffff ffffffff f9ed5779 ac118fe1
+printf("%.35Lg") gives 9.0259718793241474999999999999999997e-277
+g_Qfmt(0) gives 23 bytes: "9.0259718793241475e-277"
+
+strtoIQ returns 17, consuming 23 bytes.
+fI[0] = #3c69ffff ffffffff f9ed5779 ac118fe1
+= 9.0259718793241474999999999999999997e-277
+fI[1] = #3c69ffff ffffffff f9ed5779 ac118fe2
+= 9.0259718793241475000000000000000006e-277
+fI[0] == strtod
+
+
+Input: 9.025971879324147880346310405869e-277
+
+strtoQ consumes 37 bytes and returns 33
+with bits = #3c6a0000 0 0 9a
+printf("%.35Lg") gives 9.0259718793241478803463104058690004e-277
+g_Qfmt(0) gives 37 bytes: "9.025971879324147880346310405869e-277"
+
+strtoIQ returns 33, consuming 37 bytes.
+fI[0] = #3c6a0000 0 0 99
+= 9.0259718793241478803463104058689987e-277
+fI[1] = #3c6a0000 0 0 9a
+= 9.0259718793241478803463104058690004e-277
+fI[1] == strtod
+
+
+Input: 9.025971879324147880346310405868e-277
+
+strtoQ consumes 37 bytes and returns 17
+with bits = #3c69ffff ffffffff ffffffff fffffcb5
+printf("%.35Lg") gives 9.025971879324147880346310405868e-277
+g_Qfmt(0) gives 37 bytes: "9.025971879324147880346310405868e-277"
+
+strtoIQ returns 17, consuming 37 bytes.
+fI[0] = #3c69ffff ffffffff ffffffff fffffcb5
+= 9.025971879324147880346310405868e-277
+fI[1] = #3c69ffff ffffffff ffffffff fffffcb6
+= 9.0259718793241478803463104058680009e-277
+fI[0] == strtod
+
+
+Input: 2.2250738585072014e-308
+
+strtoQ consumes 23 bytes and returns 33
+with bits = #3c010000 0 8c304c cf867de0
+printf("%.35Lg") gives 2.2250738585072014000000000000000001e-308
+g_Qfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoIQ returns 33, consuming 23 bytes.
+fI[0] = #3c010000 0 8c304c cf867ddf
+= 2.2250738585072013999999999999999997e-308
+fI[1] = #3c010000 0 8c304c cf867de0
+= 2.2250738585072014000000000000000001e-308
+fI[1] == strtod
+
+
+Input: 2.2250738585072013e-308
+
+strtoQ consumes 23 bytes and returns 33
+with bits = #3c00ffff ffffffff fa9e4c4f 4c1e8a10
+printf("%.35Lg") gives 2.2250738585072013e-308
+g_Qfmt(0) gives 23 bytes: "2.2250738585072013e-308"
+
+strtoIQ returns 33, consuming 23 bytes.
+fI[0] = #3c00ffff ffffffff fa9e4c4f 4c1e8a0f
+= 2.2250738585072012999999999999999998e-308
+fI[1] = #3c00ffff ffffffff fa9e4c4f 4c1e8a10
+= 2.2250738585072013e-308
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff1999 99999999 99999999 99999999
+printf("%.35Lg") gives 1.0999999999999999999999999999999999
+g_Qfmt(0) gives 36 bytes: "1.0999999999999999999999999999999999"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff1999 99999999 99999999 99999999
+= 1.0999999999999999999999999999999999
+fI[1] = #3fff1999 99999999 99999999 9999999a
+= 1.1000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.1
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff1999 99999999 99999999 99999999
+printf("%.35Lg") gives -1.0999999999999999999999999999999999
+g_Qfmt(0) gives 37 bytes: "-1.0999999999999999999999999999999999"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff1999 99999999 99999999 9999999a
+= -1.1000000000000000000000000000000001
+fI[1] = #bfff1999 99999999 99999999 99999999
+= -1.0999999999999999999999999999999999
+fI[1] == strtod
+
+
+Input: 1.2
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff3333 33333333 33333333 33333333
+printf("%.35Lg") gives 1.2
+g_Qfmt(0) gives 3 bytes: "1.2"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff3333 33333333 33333333 33333333
+= 1.2
+fI[1] = #3fff3333 33333333 33333333 33333334
+= 1.2000000000000000000000000000000002
+fI[0] == strtod
+
+
+Input: -1.2
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff3333 33333333 33333333 33333333
+printf("%.35Lg") gives -1.2
+g_Qfmt(0) gives 4 bytes: "-1.2"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff3333 33333333 33333333 33333334
+= -1.2000000000000000000000000000000002
+fI[1] = #bfff3333 33333333 33333333 33333333
+= -1.2
+fI[1] == strtod
+
+
+Input: 1.3
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff4ccc cccccccc cccccccc cccccccc
+printf("%.35Lg") gives 1.2999999999999999999999999999999998
+g_Qfmt(0) gives 36 bytes: "1.2999999999999999999999999999999998"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff4ccc cccccccc cccccccc cccccccc
+= 1.2999999999999999999999999999999998
+fI[1] = #3fff4ccc cccccccc cccccccc cccccccd
+= 1.3
+fI[0] == strtod
+
+
+Input: -1.3
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff4ccc cccccccc cccccccc cccccccc
+printf("%.35Lg") gives -1.2999999999999999999999999999999998
+g_Qfmt(0) gives 37 bytes: "-1.2999999999999999999999999999999998"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff4ccc cccccccc cccccccc cccccccd
+= -1.3
+fI[1] = #bfff4ccc cccccccc cccccccc cccccccc
+= -1.2999999999999999999999999999999998
+fI[1] == strtod
+
+
+Input: 1.4
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff6666 66666666 66666666 66666666
+printf("%.35Lg") gives 1.3999999999999999999999999999999999
+g_Qfmt(0) gives 3 bytes: "1.4"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff6666 66666666 66666666 66666666
+= 1.3999999999999999999999999999999999
+fI[1] = #3fff6666 66666666 66666666 66666667
+= 1.4000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.4
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff6666 66666666 66666666 66666666
+printf("%.35Lg") gives -1.3999999999999999999999999999999999
+g_Qfmt(0) gives 4 bytes: "-1.4"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff6666 66666666 66666666 66666667
+= -1.4000000000000000000000000000000001
+fI[1] = #bfff6666 66666666 66666666 66666666
+= -1.3999999999999999999999999999999999
+fI[1] == strtod
+
+
+Input: 1.5
+
+strtoQ consumes 3 bytes and returns 1
+with bits = #3fff8000 0 0 0
+printf("%.35Lg") gives 1.5
+g_Qfmt(0) gives 3 bytes: "1.5"
+
+strtoIQ returns 1, consuming 3 bytes.
+fI[0] == fI[1] = #3fff8000 0 0 0
+= 1.5
+
+
+Input: -1.5
+
+strtoQ consumes 4 bytes and returns 9
+with bits = #bfff8000 0 0 0
+printf("%.35Lg") gives -1.5
+g_Qfmt(0) gives 4 bytes: "-1.5"
+
+strtoIQ returns 9, consuming 4 bytes.
+fI[0] == fI[1] = #bfff8000 0 0 0
+= -1.5
+
+
+Input: 1.6
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff9999 99999999 99999999 99999999
+printf("%.35Lg") gives 1.5999999999999999999999999999999999
+g_Qfmt(0) gives 36 bytes: "1.5999999999999999999999999999999999"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff9999 99999999 99999999 99999999
+= 1.5999999999999999999999999999999999
+fI[1] = #3fff9999 99999999 99999999 9999999a
+= 1.6000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.6
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff9999 99999999 99999999 99999999
+printf("%.35Lg") gives -1.5999999999999999999999999999999999
+g_Qfmt(0) gives 37 bytes: "-1.5999999999999999999999999999999999"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff9999 99999999 99999999 9999999a
+= -1.6000000000000000000000000000000001
+fI[1] = #bfff9999 99999999 99999999 99999999
+= -1.5999999999999999999999999999999999
+fI[1] == strtod
+
+
+Input: 1.7
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffb333 33333333 33333333 33333333
+printf("%.35Lg") gives 1.7
+g_Qfmt(0) gives 3 bytes: "1.7"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffb333 33333333 33333333 33333333
+= 1.7
+fI[1] = #3fffb333 33333333 33333333 33333334
+= 1.7000000000000000000000000000000002
+fI[0] == strtod
+
+
+Input: -1.7
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffb333 33333333 33333333 33333333
+printf("%.35Lg") gives -1.7
+g_Qfmt(0) gives 4 bytes: "-1.7"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffb333 33333333 33333333 33333334
+= -1.7000000000000000000000000000000002
+fI[1] = #bfffb333 33333333 33333333 33333333
+= -1.7
+fI[1] == strtod
+
+
+Input: 1.8
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffcccc cccccccc cccccccc cccccccc
+printf("%.35Lg") gives 1.7999999999999999999999999999999998
+g_Qfmt(0) gives 36 bytes: "1.7999999999999999999999999999999998"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fffcccc cccccccc cccccccc cccccccc
+= 1.7999999999999999999999999999999998
+fI[1] = #3fffcccc cccccccc cccccccc cccccccd
+= 1.8
+fI[0] == strtod
+
+
+Input: -1.8
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffcccc cccccccc cccccccc cccccccc
+printf("%.35Lg") gives -1.7999999999999999999999999999999998
+g_Qfmt(0) gives 37 bytes: "-1.7999999999999999999999999999999998"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfffcccc cccccccc cccccccc cccccccd
+= -1.8
+fI[1] = #bfffcccc cccccccc cccccccc cccccccc
+= -1.7999999999999999999999999999999998
+fI[1] == strtod
+
+
+Input: 1.9
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffe666 66666666 66666666 66666666
+printf("%.35Lg") gives 1.8999999999999999999999999999999999
+g_Qfmt(0) gives 3 bytes: "1.9"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffe666 66666666 66666666 66666666
+= 1.8999999999999999999999999999999999
+fI[1] = #3fffe666 66666666 66666666 66666667
+= 1.9000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.9
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffe666 66666666 66666666 66666666
+printf("%.35Lg") gives -1.8999999999999999999999999999999999
+g_Qfmt(0) gives 4 bytes: "-1.9"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffe666 66666666 66666666 66666667
+= -1.9000000000000000000000000000000001
+fI[1] = #bfffe666 66666666 66666666 66666666
+= -1.8999999999999999999999999999999999
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff1999 99999999 99999999 9999999a
+printf("%.35Lg") gives 1.1000000000000000000000000000000001
+g_Qfmt(0) gives 3 bytes: "1.1"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff1999 99999999 99999999 99999999
+= 1.0999999999999999999999999999999999
+fI[1] = #3fff1999 99999999 99999999 9999999a
+= 1.1000000000000000000000000000000001
+fI[1] == strtod
+
+
+Input: -1.1
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff1999 99999999 99999999 9999999a
+printf("%.35Lg") gives -1.1000000000000000000000000000000001
+g_Qfmt(0) gives 4 bytes: "-1.1"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff1999 99999999 99999999 9999999a
+= -1.1000000000000000000000000000000001
+fI[1] = #bfff1999 99999999 99999999 99999999
+= -1.0999999999999999999999999999999999
+fI[0] == strtod
+
+
+Input: 1.2
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff3333 33333333 33333333 33333333
+printf("%.35Lg") gives 1.2
+g_Qfmt(0) gives 3 bytes: "1.2"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff3333 33333333 33333333 33333333
+= 1.2
+fI[1] = #3fff3333 33333333 33333333 33333334
+= 1.2000000000000000000000000000000002
+fI[0] == strtod
+
+
+Input: -1.2
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff3333 33333333 33333333 33333333
+printf("%.35Lg") gives -1.2
+g_Qfmt(0) gives 4 bytes: "-1.2"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff3333 33333333 33333333 33333334
+= -1.2000000000000000000000000000000002
+fI[1] = #bfff3333 33333333 33333333 33333333
+= -1.2
+fI[1] == strtod
+
+
+Input: 1.3
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff4ccc cccccccc cccccccc cccccccd
+printf("%.35Lg") gives 1.3
+g_Qfmt(0) gives 3 bytes: "1.3"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff4ccc cccccccc cccccccc cccccccc
+= 1.2999999999999999999999999999999998
+fI[1] = #3fff4ccc cccccccc cccccccc cccccccd
+= 1.3
+fI[1] == strtod
+
+
+Input: -1.3
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff4ccc cccccccc cccccccc cccccccd
+printf("%.35Lg") gives -1.3
+g_Qfmt(0) gives 4 bytes: "-1.3"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff4ccc cccccccc cccccccc cccccccd
+= -1.3
+fI[1] = #bfff4ccc cccccccc cccccccc cccccccc
+= -1.2999999999999999999999999999999998
+fI[0] == strtod
+
+
+Input: 1.4
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff6666 66666666 66666666 66666666
+printf("%.35Lg") gives 1.3999999999999999999999999999999999
+g_Qfmt(0) gives 3 bytes: "1.4"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff6666 66666666 66666666 66666666
+= 1.3999999999999999999999999999999999
+fI[1] = #3fff6666 66666666 66666666 66666667
+= 1.4000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.4
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff6666 66666666 66666666 66666666
+printf("%.35Lg") gives -1.3999999999999999999999999999999999
+g_Qfmt(0) gives 4 bytes: "-1.4"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff6666 66666666 66666666 66666667
+= -1.4000000000000000000000000000000001
+fI[1] = #bfff6666 66666666 66666666 66666666
+= -1.3999999999999999999999999999999999
+fI[1] == strtod
+
+
+Input: 1.5
+
+strtoQ consumes 3 bytes and returns 1
+with bits = #3fff8000 0 0 0
+printf("%.35Lg") gives 1.5
+g_Qfmt(0) gives 3 bytes: "1.5"
+
+strtoIQ returns 1, consuming 3 bytes.
+fI[0] == fI[1] = #3fff8000 0 0 0
+= 1.5
+
+
+Input: -1.5
+
+strtoQ consumes 4 bytes and returns 9
+with bits = #bfff8000 0 0 0
+printf("%.35Lg") gives -1.5
+g_Qfmt(0) gives 4 bytes: "-1.5"
+
+strtoIQ returns 9, consuming 4 bytes.
+fI[0] == fI[1] = #bfff8000 0 0 0
+= -1.5
+
+
+Input: 1.6
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff9999 99999999 99999999 9999999a
+printf("%.35Lg") gives 1.6000000000000000000000000000000001
+g_Qfmt(0) gives 3 bytes: "1.6"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff9999 99999999 99999999 99999999
+= 1.5999999999999999999999999999999999
+fI[1] = #3fff9999 99999999 99999999 9999999a
+= 1.6000000000000000000000000000000001
+fI[1] == strtod
+
+
+Input: -1.6
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff9999 99999999 99999999 9999999a
+printf("%.35Lg") gives -1.6000000000000000000000000000000001
+g_Qfmt(0) gives 4 bytes: "-1.6"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff9999 99999999 99999999 9999999a
+= -1.6000000000000000000000000000000001
+fI[1] = #bfff9999 99999999 99999999 99999999
+= -1.5999999999999999999999999999999999
+fI[0] == strtod
+
+
+Input: 1.7
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffb333 33333333 33333333 33333333
+printf("%.35Lg") gives 1.7
+g_Qfmt(0) gives 3 bytes: "1.7"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffb333 33333333 33333333 33333333
+= 1.7
+fI[1] = #3fffb333 33333333 33333333 33333334
+= 1.7000000000000000000000000000000002
+fI[0] == strtod
+
+
+Input: -1.7
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffb333 33333333 33333333 33333333
+printf("%.35Lg") gives -1.7
+g_Qfmt(0) gives 4 bytes: "-1.7"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffb333 33333333 33333333 33333334
+= -1.7000000000000000000000000000000002
+fI[1] = #bfffb333 33333333 33333333 33333333
+= -1.7
+fI[1] == strtod
+
+
+Input: 1.8
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fffcccc cccccccc cccccccc cccccccd
+printf("%.35Lg") gives 1.8
+g_Qfmt(0) gives 3 bytes: "1.8"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fffcccc cccccccc cccccccc cccccccc
+= 1.7999999999999999999999999999999998
+fI[1] = #3fffcccc cccccccc cccccccc cccccccd
+= 1.8
+fI[1] == strtod
+
+
+Input: -1.8
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfffcccc cccccccc cccccccc cccccccd
+printf("%.35Lg") gives -1.8
+g_Qfmt(0) gives 4 bytes: "-1.8"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfffcccc cccccccc cccccccc cccccccd
+= -1.8
+fI[1] = #bfffcccc cccccccc cccccccc cccccccc
+= -1.7999999999999999999999999999999998
+fI[0] == strtod
+
+
+Input: 1.9
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffe666 66666666 66666666 66666666
+printf("%.35Lg") gives 1.8999999999999999999999999999999999
+g_Qfmt(0) gives 3 bytes: "1.9"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffe666 66666666 66666666 66666666
+= 1.8999999999999999999999999999999999
+fI[1] = #3fffe666 66666666 66666666 66666667
+= 1.9000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.9
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffe666 66666666 66666666 66666666
+printf("%.35Lg") gives -1.8999999999999999999999999999999999
+g_Qfmt(0) gives 4 bytes: "-1.9"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffe666 66666666 66666666 66666667
+= -1.9000000000000000000000000000000001
+fI[1] = #bfffe666 66666666 66666666 66666666
+= -1.8999999999999999999999999999999999
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff1999 99999999 99999999 9999999a
+printf("%.35Lg") gives 1.1000000000000000000000000000000001
+g_Qfmt(0) gives 3 bytes: "1.1"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff1999 99999999 99999999 99999999
+= 1.0999999999999999999999999999999999
+fI[1] = #3fff1999 99999999 99999999 9999999a
+= 1.1000000000000000000000000000000001
+fI[1] == strtod
+
+
+Input: -1.1
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff1999 99999999 99999999 99999999
+printf("%.35Lg") gives -1.0999999999999999999999999999999999
+g_Qfmt(0) gives 37 bytes: "-1.0999999999999999999999999999999999"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff1999 99999999 99999999 9999999a
+= -1.1000000000000000000000000000000001
+fI[1] = #bfff1999 99999999 99999999 99999999
+= -1.0999999999999999999999999999999999
+fI[1] == strtod
+
+
+Input: 1.2
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff3333 33333333 33333333 33333334
+printf("%.35Lg") gives 1.2000000000000000000000000000000002
+g_Qfmt(0) gives 36 bytes: "1.2000000000000000000000000000000002"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff3333 33333333 33333333 33333333
+= 1.2
+fI[1] = #3fff3333 33333333 33333333 33333334
+= 1.2000000000000000000000000000000002
+fI[1] == strtod
+
+
+Input: -1.2
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff3333 33333333 33333333 33333333
+printf("%.35Lg") gives -1.2
+g_Qfmt(0) gives 4 bytes: "-1.2"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff3333 33333333 33333333 33333334
+= -1.2000000000000000000000000000000002
+fI[1] = #bfff3333 33333333 33333333 33333333
+= -1.2
+fI[1] == strtod
+
+
+Input: 1.3
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff4ccc cccccccc cccccccc cccccccd
+printf("%.35Lg") gives 1.3
+g_Qfmt(0) gives 3 bytes: "1.3"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff4ccc cccccccc cccccccc cccccccc
+= 1.2999999999999999999999999999999998
+fI[1] = #3fff4ccc cccccccc cccccccc cccccccd
+= 1.3
+fI[1] == strtod
+
+
+Input: -1.3
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff4ccc cccccccc cccccccc cccccccc
+printf("%.35Lg") gives -1.2999999999999999999999999999999998
+g_Qfmt(0) gives 37 bytes: "-1.2999999999999999999999999999999998"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff4ccc cccccccc cccccccc cccccccd
+= -1.3
+fI[1] = #bfff4ccc cccccccc cccccccc cccccccc
+= -1.2999999999999999999999999999999998
+fI[1] == strtod
+
+
+Input: 1.4
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff6666 66666666 66666666 66666667
+printf("%.35Lg") gives 1.4000000000000000000000000000000001
+g_Qfmt(0) gives 36 bytes: "1.4000000000000000000000000000000001"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff6666 66666666 66666666 66666666
+= 1.3999999999999999999999999999999999
+fI[1] = #3fff6666 66666666 66666666 66666667
+= 1.4000000000000000000000000000000001
+fI[1] == strtod
+
+
+Input: -1.4
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff6666 66666666 66666666 66666666
+printf("%.35Lg") gives -1.3999999999999999999999999999999999
+g_Qfmt(0) gives 4 bytes: "-1.4"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff6666 66666666 66666666 66666667
+= -1.4000000000000000000000000000000001
+fI[1] = #bfff6666 66666666 66666666 66666666
+= -1.3999999999999999999999999999999999
+fI[1] == strtod
+
+
+Input: 1.5
+
+strtoQ consumes 3 bytes and returns 1
+with bits = #3fff8000 0 0 0
+printf("%.35Lg") gives 1.5
+g_Qfmt(0) gives 3 bytes: "1.5"
+
+strtoIQ returns 1, consuming 3 bytes.
+fI[0] == fI[1] = #3fff8000 0 0 0
+= 1.5
+
+
+Input: -1.5
+
+strtoQ consumes 4 bytes and returns 9
+with bits = #bfff8000 0 0 0
+printf("%.35Lg") gives -1.5
+g_Qfmt(0) gives 4 bytes: "-1.5"
+
+strtoIQ returns 9, consuming 4 bytes.
+fI[0] == fI[1] = #bfff8000 0 0 0
+= -1.5
+
+
+Input: 1.6
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fff9999 99999999 99999999 9999999a
+printf("%.35Lg") gives 1.6000000000000000000000000000000001
+g_Qfmt(0) gives 3 bytes: "1.6"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff9999 99999999 99999999 99999999
+= 1.5999999999999999999999999999999999
+fI[1] = #3fff9999 99999999 99999999 9999999a
+= 1.6000000000000000000000000000000001
+fI[1] == strtod
+
+
+Input: -1.6
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfff9999 99999999 99999999 99999999
+printf("%.35Lg") gives -1.5999999999999999999999999999999999
+g_Qfmt(0) gives 37 bytes: "-1.5999999999999999999999999999999999"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff9999 99999999 99999999 9999999a
+= -1.6000000000000000000000000000000001
+fI[1] = #bfff9999 99999999 99999999 99999999
+= -1.5999999999999999999999999999999999
+fI[1] == strtod
+
+
+Input: 1.7
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fffb333 33333333 33333333 33333334
+printf("%.35Lg") gives 1.7000000000000000000000000000000002
+g_Qfmt(0) gives 36 bytes: "1.7000000000000000000000000000000002"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffb333 33333333 33333333 33333333
+= 1.7
+fI[1] = #3fffb333 33333333 33333333 33333334
+= 1.7000000000000000000000000000000002
+fI[1] == strtod
+
+
+Input: -1.7
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffb333 33333333 33333333 33333333
+printf("%.35Lg") gives -1.7
+g_Qfmt(0) gives 4 bytes: "-1.7"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffb333 33333333 33333333 33333334
+= -1.7000000000000000000000000000000002
+fI[1] = #bfffb333 33333333 33333333 33333333
+= -1.7
+fI[1] == strtod
+
+
+Input: 1.8
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fffcccc cccccccc cccccccc cccccccd
+printf("%.35Lg") gives 1.8
+g_Qfmt(0) gives 3 bytes: "1.8"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fffcccc cccccccc cccccccc cccccccc
+= 1.7999999999999999999999999999999998
+fI[1] = #3fffcccc cccccccc cccccccc cccccccd
+= 1.8
+fI[1] == strtod
+
+
+Input: -1.8
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffcccc cccccccc cccccccc cccccccc
+printf("%.35Lg") gives -1.7999999999999999999999999999999998
+g_Qfmt(0) gives 37 bytes: "-1.7999999999999999999999999999999998"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfffcccc cccccccc cccccccc cccccccd
+= -1.8
+fI[1] = #bfffcccc cccccccc cccccccc cccccccc
+= -1.7999999999999999999999999999999998
+fI[1] == strtod
+
+
+Input: 1.9
+
+strtoQ consumes 3 bytes and returns 33
+with bits = #3fffe666 66666666 66666666 66666667
+printf("%.35Lg") gives 1.9000000000000000000000000000000001
+g_Qfmt(0) gives 36 bytes: "1.9000000000000000000000000000000001"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffe666 66666666 66666666 66666666
+= 1.8999999999999999999999999999999999
+fI[1] = #3fffe666 66666666 66666666 66666667
+= 1.9000000000000000000000000000000001
+fI[1] == strtod
+
+
+Input: -1.9
+
+strtoQ consumes 4 bytes and returns 25
+with bits = #bfffe666 66666666 66666666 66666666
+printf("%.35Lg") gives -1.8999999999999999999999999999999999
+g_Qfmt(0) gives 4 bytes: "-1.9"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffe666 66666666 66666666 66666667
+= -1.9000000000000000000000000000000001
+fI[1] = #bfffe666 66666666 66666666 66666666
+= -1.8999999999999999999999999999999999
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff1999 99999999 99999999 99999999
+printf("%.35Lg") gives 1.0999999999999999999999999999999999
+g_Qfmt(0) gives 36 bytes: "1.0999999999999999999999999999999999"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff1999 99999999 99999999 99999999
+= 1.0999999999999999999999999999999999
+fI[1] = #3fff1999 99999999 99999999 9999999a
+= 1.1000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.1
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff1999 99999999 99999999 9999999a
+printf("%.35Lg") gives -1.1000000000000000000000000000000001
+g_Qfmt(0) gives 4 bytes: "-1.1"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff1999 99999999 99999999 9999999a
+= -1.1000000000000000000000000000000001
+fI[1] = #bfff1999 99999999 99999999 99999999
+= -1.0999999999999999999999999999999999
+fI[0] == strtod
+
+
+Input: 1.2
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff3333 33333333 33333333 33333333
+printf("%.35Lg") gives 1.2
+g_Qfmt(0) gives 3 bytes: "1.2"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff3333 33333333 33333333 33333333
+= 1.2
+fI[1] = #3fff3333 33333333 33333333 33333334
+= 1.2000000000000000000000000000000002
+fI[0] == strtod
+
+
+Input: -1.2
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff3333 33333333 33333333 33333334
+printf("%.35Lg") gives -1.2000000000000000000000000000000002
+g_Qfmt(0) gives 37 bytes: "-1.2000000000000000000000000000000002"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff3333 33333333 33333333 33333334
+= -1.2000000000000000000000000000000002
+fI[1] = #bfff3333 33333333 33333333 33333333
+= -1.2
+fI[0] == strtod
+
+
+Input: 1.3
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff4ccc cccccccc cccccccc cccccccc
+printf("%.35Lg") gives 1.2999999999999999999999999999999998
+g_Qfmt(0) gives 36 bytes: "1.2999999999999999999999999999999998"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff4ccc cccccccc cccccccc cccccccc
+= 1.2999999999999999999999999999999998
+fI[1] = #3fff4ccc cccccccc cccccccc cccccccd
+= 1.3
+fI[0] == strtod
+
+
+Input: -1.3
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff4ccc cccccccc cccccccc cccccccd
+printf("%.35Lg") gives -1.3
+g_Qfmt(0) gives 4 bytes: "-1.3"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff4ccc cccccccc cccccccc cccccccd
+= -1.3
+fI[1] = #bfff4ccc cccccccc cccccccc cccccccc
+= -1.2999999999999999999999999999999998
+fI[0] == strtod
+
+
+Input: 1.4
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff6666 66666666 66666666 66666666
+printf("%.35Lg") gives 1.3999999999999999999999999999999999
+g_Qfmt(0) gives 3 bytes: "1.4"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fff6666 66666666 66666666 66666666
+= 1.3999999999999999999999999999999999
+fI[1] = #3fff6666 66666666 66666666 66666667
+= 1.4000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.4
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff6666 66666666 66666666 66666667
+printf("%.35Lg") gives -1.4000000000000000000000000000000001
+g_Qfmt(0) gives 37 bytes: "-1.4000000000000000000000000000000001"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfff6666 66666666 66666666 66666667
+= -1.4000000000000000000000000000000001
+fI[1] = #bfff6666 66666666 66666666 66666666
+= -1.3999999999999999999999999999999999
+fI[0] == strtod
+
+
+Input: 1.5
+
+strtoQ consumes 3 bytes and returns 1
+with bits = #3fff8000 0 0 0
+printf("%.35Lg") gives 1.5
+g_Qfmt(0) gives 3 bytes: "1.5"
+
+strtoIQ returns 1, consuming 3 bytes.
+fI[0] == fI[1] = #3fff8000 0 0 0
+= 1.5
+
+
+Input: -1.5
+
+strtoQ consumes 4 bytes and returns 9
+with bits = #bfff8000 0 0 0
+printf("%.35Lg") gives -1.5
+g_Qfmt(0) gives 4 bytes: "-1.5"
+
+strtoIQ returns 9, consuming 4 bytes.
+fI[0] == fI[1] = #bfff8000 0 0 0
+= -1.5
+
+
+Input: 1.6
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fff9999 99999999 99999999 99999999
+printf("%.35Lg") gives 1.5999999999999999999999999999999999
+g_Qfmt(0) gives 36 bytes: "1.5999999999999999999999999999999999"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fff9999 99999999 99999999 99999999
+= 1.5999999999999999999999999999999999
+fI[1] = #3fff9999 99999999 99999999 9999999a
+= 1.6000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.6
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfff9999 99999999 99999999 9999999a
+printf("%.35Lg") gives -1.6000000000000000000000000000000001
+g_Qfmt(0) gives 4 bytes: "-1.6"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfff9999 99999999 99999999 9999999a
+= -1.6000000000000000000000000000000001
+fI[1] = #bfff9999 99999999 99999999 99999999
+= -1.5999999999999999999999999999999999
+fI[0] == strtod
+
+
+Input: 1.7
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffb333 33333333 33333333 33333333
+printf("%.35Lg") gives 1.7
+g_Qfmt(0) gives 3 bytes: "1.7"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffb333 33333333 33333333 33333333
+= 1.7
+fI[1] = #3fffb333 33333333 33333333 33333334
+= 1.7000000000000000000000000000000002
+fI[0] == strtod
+
+
+Input: -1.7
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfffb333 33333333 33333333 33333334
+printf("%.35Lg") gives -1.7000000000000000000000000000000002
+g_Qfmt(0) gives 37 bytes: "-1.7000000000000000000000000000000002"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffb333 33333333 33333333 33333334
+= -1.7000000000000000000000000000000002
+fI[1] = #bfffb333 33333333 33333333 33333333
+= -1.7
+fI[0] == strtod
+
+
+Input: 1.8
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffcccc cccccccc cccccccc cccccccc
+printf("%.35Lg") gives 1.7999999999999999999999999999999998
+g_Qfmt(0) gives 36 bytes: "1.7999999999999999999999999999999998"
+
+strtoIQ returns 33, consuming 3 bytes.
+fI[0] = #3fffcccc cccccccc cccccccc cccccccc
+= 1.7999999999999999999999999999999998
+fI[1] = #3fffcccc cccccccc cccccccc cccccccd
+= 1.8
+fI[0] == strtod
+
+
+Input: -1.8
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfffcccc cccccccc cccccccc cccccccd
+printf("%.35Lg") gives -1.8
+g_Qfmt(0) gives 4 bytes: "-1.8"
+
+strtoIQ returns 41, consuming 4 bytes.
+fI[0] = #bfffcccc cccccccc cccccccc cccccccd
+= -1.8
+fI[1] = #bfffcccc cccccccc cccccccc cccccccc
+= -1.7999999999999999999999999999999998
+fI[0] == strtod
+
+
+Input: 1.9
+
+strtoQ consumes 3 bytes and returns 17
+with bits = #3fffe666 66666666 66666666 66666666
+printf("%.35Lg") gives 1.8999999999999999999999999999999999
+g_Qfmt(0) gives 3 bytes: "1.9"
+
+strtoIQ returns 17, consuming 3 bytes.
+fI[0] = #3fffe666 66666666 66666666 66666666
+= 1.8999999999999999999999999999999999
+fI[1] = #3fffe666 66666666 66666666 66666667
+= 1.9000000000000000000000000000000001
+fI[0] == strtod
+
+
+Input: -1.9
+
+strtoQ consumes 4 bytes and returns 41
+with bits = #bfffe666 66666666 66666666 66666667
+printf("%.35Lg") gives -1.9000000000000000000000000000000001
+g_Qfmt(0) gives 37 bytes: "-1.9000000000000000000000000000000001"
+
+strtoIQ returns 25, consuming 4 bytes.
+fI[0] = #bfffe666 66666666 66666666 66666667
+= -1.9000000000000000000000000000000001
+fI[1] = #bfffe666 66666666 66666666 66666666
+= -1.8999999999999999999999999999999999
+fI[0] == strtod
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/Qtest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/Qtest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/Qtest.c	(revision 2404)
@@ -0,0 +1,170 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* Test program for g_Qfmt, strtoIQ, strtopQ, and strtorQ.
+ *
+ * Inputs (on stdin):
+ *		r rounding_mode
+ *		n ndig
+ *		number
+ *		#hex0 hex1 hex2 hex3
+ *
+ *	rounding_mode values:
+ *		0 = toward zero
+ *		1 = nearest
+ *		2 = toward +Infinity
+ *		3 = toward -Infinity
+ *
+ * where number is a decimal floating-point number,
+ * hex0 is a string of <= 8 Hex digits for the most significant
+ * word of the number, hex1 is a similar string for the next
+ * word, etc., and ndig is a parameters to g_Qfmt.
+ */
+
+#include "gdtoa.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+ extern int getround ANSI((int,char*));
+
+ static char ibuf[2048], obuf[2048];
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#define _3 3
+#endif
+#ifdef IEEE_8087
+#define _0 3
+#define _1 2
+#define _2 1
+#define _3 0
+#endif
+
+#define U (unsigned long)
+
+ int
+main(Void)
+{
+	char *s, *se, *se1;
+	int i, dItry, ndig = 0, r = 1;
+	union { long double d; ULong bits[4]; } u, v[2];
+
+	while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) {
+		while(*s <= ' ')
+			if (!*s++)
+				continue;
+		dItry = 0;
+		switch(*s) {
+		  case 'r':
+			r = getround(r, s);
+			continue;
+		  case 'n':
+			i = s[1];
+			if (i <= ' ' || i >= '0' && i <= '9') {
+				ndig = atoi(s+1);
+				continue;
+				}
+			break; /* nan? */
+		  case '#':
+			sscanf(s+1, "%lx %lx %lx %lx", &u.bits[_0],
+				&u.bits[_1], &u.bits[_2], &u.bits[_3]);
+			printf("\nInput: %s", ibuf);
+			printf(" --> f = #%lx %lx %lx %lx\n", u.bits[_0],
+				u.bits[_1], u.bits[_2], u.bits[_3]);
+			goto fmt_test;
+			}
+		dItry = 1;
+		printf("\nInput: %s", ibuf);
+		i = strtorQ(ibuf, &se, r, u.bits);
+		if (r == 1 && (strtopQ(ibuf,&se1,v[0].bits) != i
+		 || se != se1 || memcmp(u.bits, v[0].bits, 16)))
+			printf("***strtoQ and strtorQ disagree!!\n:");
+		printf("\nstrtoQ consumes %d bytes and returns %d\n",
+				(int)(se-ibuf), i);
+		printf("with bits = #%lx %lx %lx %lx\n",
+			U u.bits[_0], U u.bits[_1], U u.bits[_2], U u.bits[_3]);
+ fmt_test:
+		if (sizeof(long double) == 16)
+			printf("printf(\"%%.35Lg\") gives %.35Lg\n", u.d);
+		se = g_Qfmt(obuf, u.bits, ndig, sizeof(obuf));
+		printf("g_Qfmt(%d) gives %d bytes: \"%s\"\n\n", ndig,
+			(int)(se-obuf), se ? obuf : "<null>");
+		if (!dItry)
+			continue;
+		printf("strtoIQ returns %d,",
+			strtoIQ(ibuf, &se, v[0].bits, v[1].bits));
+		printf(" consuming %d bytes.\n", (int)(se-ibuf));
+		if (!memcmp(v[0].bits, v[1].bits, 16)) {
+			if (!memcpy(u.bits, v[0].bits, 16))
+				printf("fI[0] == fI[1] == strtoQ\n");
+			else {
+				printf("fI[0] == fI[1] = #%lx %lx %lx %lx\n",
+					U v[0].bits[_0], U v[0].bits[_1],
+					U v[0].bits[_2], U v[0].bits[_3]);
+				if (sizeof(long double) == 16)
+				    printf("= %.35Lg\n", v[0].d);
+				}
+			}
+		else {
+			printf("fI[0] = #%lx %lx %lx %lx\n",
+					U v[0].bits[_0], U v[0].bits[_1],
+					U v[0].bits[_2], U v[0].bits[_3]);
+			if (sizeof(long double) == 16)
+				printf("= %.35Lg\n", v[0].d);
+			printf("fI[1] = #%lx %lx %lx %lx\n",
+					U v[1].bits[_0], U v[1].bits[_1],
+					U v[1].bits[_2], U v[1].bits[_3]);
+			if (sizeof(long double) == 16)
+				printf("= %.35Lg\n", v[1].d);
+			if (!memcmp(v[0].bits, u.bits, 16))
+				printf("fI[0] == strtod\n");
+			else if (!memcmp(v[1].bits, u.bits, 16))
+				printf("fI[1] == strtod\n");
+			else
+				printf("**** Both differ from strtod ****\n");
+			}
+		printf("\n");
+		}
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/README
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/README	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/README	(revision 2404)
@@ -0,0 +1,61 @@
+This directory contains source for several test programs:
+
+dt is for conversion to/from double; it permits input of pairs of
+32-bit hex integers as #hhhhhhhh hhhhhhhh (i.e., the initial '#'
+indicates hex input).  No initial # ==> decimal input.
+After the input number is an optional : mode ndigits
+(colon, and decimal integers for parameters "mode" and "ndigits"
+to gdtoa).
+
+Qtest, ddtest, dtest, ftest, xLtest and xtest are for conversion to/from
+
+	f	IEEE single precision
+	d	IEEE double precision
+	xL	IEEE extended precision, as on Motorola 680x0 chips
+	x	IEEE extended precision, as on Intel 80x87 chips or
+			software emulation of Motorola 680x0 chips
+	Q	quad precision, as on Sun Sparc chips
+	dd	double double, pairs of IEEE double numbers
+		whose sum is the desired value
+
+They're all similar, except for the precision.  They test both
+directed roundings and interval input (the strtoI* routines).
+Lines that begin with "r" specify or interrogate the desired rounding
+direction:
+
+	0 = toward 0
+	1 = nearest (default)
+	2 = toward +Infinity
+	3 = toward -Infinity
+
+These are the FPI_Round_* values in gdota.h.  The "r" value is sticky:
+it stays in effect til changed.  To change the value, give a line that
+starts with r followed by 0, 1, 2, or 3.  To check the value, give "r"
+by itself.
+
+Lines that begin with n followed by a number specify the ndig
+argument for subsequent calls to the relevant g_*fmt routine.
+
+Lines that start with # followed by the appropriate number of
+hexadecimal strings (see the comments) give the big-endian
+internal representation of the desired number.
+
+When routines Qtest, xLtest, and xtest are used on machines whose
+long double is of type "quad" (for Qtest) or "extended" (for x*test),
+they try to print with %Lg as another way to show binary values.
+
+Program ddtest also accepts (white-space separated) pairs of decimal
+input numbers; it converts both with strtod and feeds the result
+to g_ddfmt.
+
+Program dItest exercises strtodI and strtoId.
+
+Programs dItestsi and ddtestsi are for testing the sudden-underflow
+logic (on double and double-double conversions).
+
+Program strtodt tests strtod on some hard cases (in file testnos3)
+posted by Fred Tydeman to comp.arch.arithmetic on 26 Feb. 1996.
+
+These are simple test programs, not meant for exhaustive testing,
+but for manually testing "interesting" cases.  Paxson's testbase
+is good for more exhaustive testing, in part with random inputs.
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/d.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/d.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/d.out	(revision 2404)
@@ -0,0 +1,986 @@
+
+Input: 1.23
+strtod consumes 4 bytes and returns 17 with f = 1.23 = #3ff3ae14 7ae147ae
+g_dfmt(0) gives 4 bytes: "1.23"
+
+strtoId returns 17, consuming 4 bytes.
+fI[0] = #3ff3ae14 7ae147ae = 1.23
+fI[1] = #3ff3ae14 7ae147af = 1.2300000000000002
+fI[0] == strtod
+
+
+Input: 1.23e+20
+strtod consumes 8 bytes and returns 1 with f = 1.23e+20 = #441aabdf 2145b430
+g_dfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoId returns 1, consuming 8 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: 1.23e-20
+strtod consumes 8 bytes and returns 33 with f = 1.2300000000000001e-20 = #3bcd0ae4 cf767531
+g_dfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoId returns 33, consuming 8 bytes.
+fI[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20
+fI[1] = #3bcd0ae4 cf767531 = 1.2300000000000001e-20
+fI[1] == strtod
+
+
+Input: 1.23456789
+strtod consumes 10 bytes and returns 17 with f = 1.2345678899999999 = #3ff3c0ca 4283de1b
+g_dfmt(0) gives 10 bytes: "1.23456789"
+
+strtoId returns 17, consuming 10 bytes.
+fI[0] = #3ff3c0ca 4283de1b = 1.2345678899999999
+fI[1] = #3ff3c0ca 4283de1c = 1.2345678900000001
+fI[0] == strtod
+
+
+Input: 1.23456589e+20
+strtod consumes 14 bytes and returns 17 with f = 1.23456589e+20 = #441ac537 a660b997
+g_dfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoId returns 17, consuming 14 bytes.
+fI[0] = #441ac537 a660b997 = 1.23456589e+20
+fI[1] = #441ac537 a660b998 = 1.2345658900000001e+20
+fI[0] == strtod
+
+
+Input: 1.23e+30
+strtod consumes 8 bytes and returns 17 with f = 1.23e+30 = #462f0cb0 4e8fb790
+g_dfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoId returns 17, consuming 8 bytes.
+fI[0] = #462f0cb0 4e8fb790 = 1.23e+30
+fI[1] = #462f0cb0 4e8fb791 = 1.2300000000000001e+30
+fI[0] == strtod
+
+
+Input: 1.23e-30
+strtod consumes 8 bytes and returns 33 with f = 1.2300000000000001e-30 = #39b8f286 6f5010ab
+g_dfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoId returns 33, consuming 8 bytes.
+fI[0] = #39b8f286 6f5010aa = 1.2299999999999999e-30
+fI[1] = #39b8f286 6f5010ab = 1.2300000000000001e-30
+fI[1] == strtod
+
+
+Input: 1.23456789e-20
+strtod consumes 14 bytes and returns 17 with f = 1.2345678899999999e-20 = #3bcd2681 471e7ada
+g_dfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoId returns 17, consuming 14 bytes.
+fI[0] = #3bcd2681 471e7ada = 1.2345678899999999e-20
+fI[1] = #3bcd2681 471e7adb = 1.2345678900000001e-20
+fI[0] == strtod
+
+
+Input: 1.23456789e-30
+strtod consumes 14 bytes and returns 17 with f = 1.23456789e-30 = #39b90a3e 33bbd995
+g_dfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoId returns 17, consuming 14 bytes.
+fI[0] = #39b90a3e 33bbd995 = 1.23456789e-30
+fI[1] = #39b90a3e 33bbd996 = 1.2345678900000002e-30
+fI[0] == strtod
+
+
+Input: 1.234567890123456789
+strtod consumes 20 bytes and returns 17 with f = 1.2345678901234567 = #3ff3c0ca 428c59fb
+g_dfmt(0) gives 18 bytes: "1.2345678901234567"
+
+strtoId returns 17, consuming 20 bytes.
+fI[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+fI[1] = #3ff3c0ca 428c59fc = 1.2345678901234569
+fI[0] == strtod
+
+
+Input: 1.23456789012345678901234567890123456789
+strtod consumes 40 bytes and returns 17 with f = 1.2345678901234567 = #3ff3c0ca 428c59fb
+g_dfmt(0) gives 18 bytes: "1.2345678901234567"
+
+strtoId returns 17, consuming 40 bytes.
+fI[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+fI[1] = #3ff3c0ca 428c59fc = 1.2345678901234569
+fI[0] == strtod
+
+
+Input: 1.23e306
+strtod consumes 8 bytes and returns 33 with f = 1.23e+306 = #7f7c0676 cd1c61f5
+g_dfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoId returns 33, consuming 8 bytes.
+fI[0] = #7f7c0676 cd1c61f4 = 1.2299999999999999e+306
+fI[1] = #7f7c0676 cd1c61f5 = 1.23e+306
+fI[1] == strtod
+
+
+Input: 1.23e-306
+strtod consumes 9 bytes and returns 33 with f = 1.23e-306 = #6ba3b8 5da396e8
+g_dfmt(0) gives 9 bytes: "1.23e-306"
+
+strtoId returns 33, consuming 9 bytes.
+fI[0] = #6ba3b8 5da396e7 = 1.2299999999999999e-306
+fI[1] = #6ba3b8 5da396e8 = 1.23e-306
+fI[1] == strtod
+
+
+Input: 1.23e-320
+strtod consumes 9 bytes and returns 98 with f = 1.2302234581447039e-320 = #0 9ba
+g_dfmt(0) gives 9 bytes: "1.23e-320"
+
+strtoId returns 98, consuming 9 bytes.
+fI[0] = #0 9b9 = 1.2297293924988626e-320
+fI[1] = #0 9ba = 1.2302234581447039e-320
+fI[1] == strtod
+
+
+Input: 1.23e-20
+strtod consumes 8 bytes and returns 33 with f = 1.2300000000000001e-20 = #3bcd0ae4 cf767531
+g_dfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoId returns 33, consuming 8 bytes.
+fI[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20
+fI[1] = #3bcd0ae4 cf767531 = 1.2300000000000001e-20
+fI[1] == strtod
+
+
+Input: 1.23456789e307
+strtod consumes 14 bytes and returns 33 with f = 1.23456789e+307 = #7fb194b1 4bdaecdc
+g_dfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoId returns 33, consuming 14 bytes.
+fI[0] = #7fb194b1 4bdaecdb = 1.2345678899999998e+307
+fI[1] = #7fb194b1 4bdaecdc = 1.23456789e+307
+fI[1] == strtod
+
+
+Input: 1.23456589e-307
+strtod consumes 15 bytes and returns 17 with f = 1.2345658899999999e-307 = #363196 bb9845fa
+g_dfmt(0) gives 15 bytes: "1.23456589e-307"
+
+strtoId returns 17, consuming 15 bytes.
+fI[0] = #363196 bb9845fa = 1.2345658899999999e-307
+fI[1] = #363196 bb9845fb = 1.2345658900000001e-307
+fI[0] == strtod
+
+
+Input: 1.234567890123456789
+strtod consumes 20 bytes and returns 17 with f = 1.2345678901234567 = #3ff3c0ca 428c59fb
+g_dfmt(0) gives 18 bytes: "1.2345678901234567"
+
+strtoId returns 17, consuming 20 bytes.
+fI[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+fI[1] = #3ff3c0ca 428c59fc = 1.2345678901234569
+fI[0] == strtod
+
+
+Input: 1.234567890123456789e301
+strtod consumes 24 bytes and returns 17 with f = 1.2345678901234568e+301 = #7e726f51 75f56413
+g_dfmt(0) gives 23 bytes: "1.2345678901234568e+301"
+
+strtoId returns 17, consuming 24 bytes.
+fI[0] = #7e726f51 75f56413 = 1.2345678901234568e+301
+fI[1] = #7e726f51 75f56414 = 1.234567890123457e+301
+fI[0] == strtod
+
+
+Input: 1.234567890123456789e-301
+strtod consumes 25 bytes and returns 17 with f = 1.2345678901234567e-301 = #1752a64 e34ba0d3
+g_dfmt(0) gives 23 bytes: "1.2345678901234567e-301"
+
+strtoId returns 17, consuming 25 bytes.
+fI[0] = #1752a64 e34ba0d3 = 1.2345678901234567e-301
+fI[1] = #1752a64 e34ba0d4 = 1.2345678901234569e-301
+fI[0] == strtod
+
+
+Input: 1.234567890123456789e-321
+strtod consumes 25 bytes and returns 98 with f = 1.2351641146031164e-321 = #0 fa
+g_dfmt(0) gives 10 bytes: "1.235e-321"
+
+strtoId returns 98, consuming 25 bytes.
+fI[0] = #0 f9 = 1.2302234581447039e-321
+fI[1] = #0 fa = 1.2351641146031164e-321
+fI[1] == strtod
+
+
+Input: 1e23
+strtod consumes 4 bytes and returns 17 with f = 9.9999999999999992e+22 = #44b52d02 c7e14af6
+g_dfmt(0) gives 5 bytes: "1e+23"
+
+strtoId returns 17, consuming 4 bytes.
+fI[0] = #44b52d02 c7e14af6 = 9.9999999999999992e+22
+fI[1] = #44b52d02 c7e14af7 = 1.0000000000000001e+23
+fI[0] == strtod
+
+
+Input: 1e310
+strtod consumes 5 bytes and returns 163 with f = Infinity = #7ff00000 0
+g_dfmt(0) gives 8 bytes: "Infinity"
+
+strtoId returns 163, consuming 5 bytes.
+fI[0] = #7fefffff ffffffff = 1.7976931348623157e+308
+fI[1] = #7ff00000 0 = Infinity
+fI[1] == strtod
+
+
+Input: 9.0259718793241475e-277
+strtod consumes 23 bytes and returns 33 with f = 9.0259718793241479e-277 = #6a00000 0
+g_dfmt(0) gives 22 bytes: "9.025971879324148e-277"
+
+strtoId returns 33, consuming 23 bytes.
+fI[0] = #69fffff ffffffff = 9.0259718793241469e-277
+fI[1] = #6a00000 0 = 9.0259718793241479e-277
+fI[1] == strtod
+
+
+Input: 9.025971879324147880346310405869e-277
+strtod consumes 37 bytes and returns 17 with f = 9.0259718793241479e-277 = #6a00000 0
+g_dfmt(0) gives 22 bytes: "9.025971879324148e-277"
+
+strtoId returns 17, consuming 37 bytes.
+fI[0] = #6a00000 0 = 9.0259718793241479e-277
+fI[1] = #6a00000 1 = 9.0259718793241499e-277
+fI[0] == strtod
+
+
+Input: 9.025971879324147880346310405868e-277
+strtod consumes 37 bytes and returns 33 with f = 9.0259718793241479e-277 = #6a00000 0
+g_dfmt(0) gives 22 bytes: "9.025971879324148e-277"
+
+strtoId returns 33, consuming 37 bytes.
+fI[0] = #69fffff ffffffff = 9.0259718793241469e-277
+fI[1] = #6a00000 0 = 9.0259718793241479e-277
+fI[1] == strtod
+
+
+Input: 2.2250738585072014e-308
+strtod consumes 23 bytes and returns 17 with f = 2.2250738585072014e-308 = #100000 0
+g_dfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoId returns 17, consuming 23 bytes.
+fI[0] = #100000 0 = 2.2250738585072014e-308
+fI[1] = #100000 1 = 2.2250738585072019e-308
+fI[0] == strtod
+
+
+Input: 2.2250738585072013e-308
+strtod consumes 23 bytes and returns 33 with f = 2.2250738585072014e-308 = #100000 0
+g_dfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoId returns 33, consuming 23 bytes.
+fI[0] = #fffff ffffffff = 2.2250738585072009e-308
+fI[1] = #100000 0 = 2.2250738585072014e-308
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+strtod consumes 3 bytes and returns 17 with f = 1.0999999999999999 = #3ff19999 99999999
+g_dfmt(0) gives 18 bytes: "1.0999999999999999"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff19999 99999999 = 1.0999999999999999
+fI[1] = #3ff19999 9999999a = 1.1000000000000001
+fI[0] == strtod
+
+
+Input: -1.1
+strtod consumes 4 bytes and returns 25 with f = -1.0999999999999999 = #bff19999 99999999
+g_dfmt(0) gives 19 bytes: "-1.0999999999999999"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff19999 9999999a = -1.1000000000000001
+fI[1] = #bff19999 99999999 = -1.0999999999999999
+fI[1] == strtod
+
+
+Input: 1.2
+strtod consumes 3 bytes and returns 17 with f = 1.2 = #3ff33333 33333333
+g_dfmt(0) gives 3 bytes: "1.2"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ff33333 33333333 = 1.2
+fI[1] = #3ff33333 33333334 = 1.2000000000000002
+fI[0] == strtod
+
+
+Input: -1.2
+strtod consumes 4 bytes and returns 25 with f = -1.2 = #bff33333 33333333
+g_dfmt(0) gives 4 bytes: "-1.2"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bff33333 33333334 = -1.2000000000000002
+fI[1] = #bff33333 33333333 = -1.2
+fI[1] == strtod
+
+
+Input: 1.3
+strtod consumes 3 bytes and returns 17 with f = 1.2999999999999998 = #3ff4cccc cccccccc
+g_dfmt(0) gives 18 bytes: "1.2999999999999998"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff4cccc cccccccc = 1.2999999999999998
+fI[1] = #3ff4cccc cccccccd = 1.3
+fI[0] == strtod
+
+
+Input: -1.3
+strtod consumes 4 bytes and returns 25 with f = -1.2999999999999998 = #bff4cccc cccccccc
+g_dfmt(0) gives 19 bytes: "-1.2999999999999998"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff4cccc cccccccd = -1.3
+fI[1] = #bff4cccc cccccccc = -1.2999999999999998
+fI[1] == strtod
+
+
+Input: 1.4
+strtod consumes 3 bytes and returns 17 with f = 1.3999999999999999 = #3ff66666 66666666
+g_dfmt(0) gives 3 bytes: "1.4"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ff66666 66666666 = 1.3999999999999999
+fI[1] = #3ff66666 66666667 = 1.4000000000000001
+fI[0] == strtod
+
+
+Input: -1.4
+strtod consumes 4 bytes and returns 25 with f = -1.3999999999999999 = #bff66666 66666666
+g_dfmt(0) gives 4 bytes: "-1.4"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bff66666 66666667 = -1.4000000000000001
+fI[1] = #bff66666 66666666 = -1.3999999999999999
+fI[1] == strtod
+
+
+Input: 1.5
+strtod consumes 3 bytes and returns 1 with f = 1.5 = #3ff80000 0
+g_dfmt(0) gives 3 bytes: "1.5"
+
+strtoId returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: -1.5
+strtod consumes 4 bytes and returns 9 with f = -1.5 = #bff80000 0
+g_dfmt(0) gives 4 bytes: "-1.5"
+
+strtoId returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: 1.6
+strtod consumes 3 bytes and returns 17 with f = 1.5999999999999999 = #3ff99999 99999999
+g_dfmt(0) gives 18 bytes: "1.5999999999999999"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff99999 99999999 = 1.5999999999999999
+fI[1] = #3ff99999 9999999a = 1.6000000000000001
+fI[0] == strtod
+
+
+Input: -1.6
+strtod consumes 4 bytes and returns 25 with f = -1.5999999999999999 = #bff99999 99999999
+g_dfmt(0) gives 19 bytes: "-1.5999999999999999"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff99999 9999999a = -1.6000000000000001
+fI[1] = #bff99999 99999999 = -1.5999999999999999
+fI[1] == strtod
+
+
+Input: 1.7
+strtod consumes 3 bytes and returns 17 with f = 1.7 = #3ffb3333 33333333
+g_dfmt(0) gives 3 bytes: "1.7"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ffb3333 33333333 = 1.7
+fI[1] = #3ffb3333 33333334 = 1.7000000000000002
+fI[0] == strtod
+
+
+Input: -1.7
+strtod consumes 4 bytes and returns 25 with f = -1.7 = #bffb3333 33333333
+g_dfmt(0) gives 4 bytes: "-1.7"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bffb3333 33333334 = -1.7000000000000002
+fI[1] = #bffb3333 33333333 = -1.7
+fI[1] == strtod
+
+
+Input: 1.8
+strtod consumes 3 bytes and returns 17 with f = 1.7999999999999998 = #3ffccccc cccccccc
+g_dfmt(0) gives 18 bytes: "1.7999999999999998"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ffccccc cccccccc = 1.7999999999999998
+fI[1] = #3ffccccc cccccccd = 1.8
+fI[0] == strtod
+
+
+Input: -1.8
+strtod consumes 4 bytes and returns 25 with f = -1.7999999999999998 = #bffccccc cccccccc
+g_dfmt(0) gives 19 bytes: "-1.7999999999999998"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bffccccc cccccccd = -1.8
+fI[1] = #bffccccc cccccccc = -1.7999999999999998
+fI[1] == strtod
+
+
+Input: 1.9
+strtod consumes 3 bytes and returns 17 with f = 1.8999999999999999 = #3ffe6666 66666666
+g_dfmt(0) gives 3 bytes: "1.9"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ffe6666 66666666 = 1.8999999999999999
+fI[1] = #3ffe6666 66666667 = 1.9000000000000001
+fI[0] == strtod
+
+
+Input: -1.9
+strtod consumes 4 bytes and returns 25 with f = -1.8999999999999999 = #bffe6666 66666666
+g_dfmt(0) gives 4 bytes: "-1.9"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bffe6666 66666667 = -1.9000000000000001
+fI[1] = #bffe6666 66666666 = -1.8999999999999999
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+strtod consumes 3 bytes and returns 33 with f = 1.1000000000000001 = #3ff19999 9999999a
+g_dfmt(0) gives 3 bytes: "1.1"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff19999 99999999 = 1.0999999999999999
+fI[1] = #3ff19999 9999999a = 1.1000000000000001
+fI[1] == strtod
+
+
+Input: -1.1
+strtod consumes 4 bytes and returns 41 with f = -1.1000000000000001 = #bff19999 9999999a
+g_dfmt(0) gives 4 bytes: "-1.1"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff19999 9999999a = -1.1000000000000001
+fI[1] = #bff19999 99999999 = -1.0999999999999999
+fI[0] == strtod
+
+
+Input: 1.2
+strtod consumes 3 bytes and returns 17 with f = 1.2 = #3ff33333 33333333
+g_dfmt(0) gives 3 bytes: "1.2"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ff33333 33333333 = 1.2
+fI[1] = #3ff33333 33333334 = 1.2000000000000002
+fI[0] == strtod
+
+
+Input: -1.2
+strtod consumes 4 bytes and returns 25 with f = -1.2 = #bff33333 33333333
+g_dfmt(0) gives 4 bytes: "-1.2"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bff33333 33333334 = -1.2000000000000002
+fI[1] = #bff33333 33333333 = -1.2
+fI[1] == strtod
+
+
+Input: 1.3
+strtod consumes 3 bytes and returns 33 with f = 1.3 = #3ff4cccc cccccccd
+g_dfmt(0) gives 3 bytes: "1.3"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff4cccc cccccccc = 1.2999999999999998
+fI[1] = #3ff4cccc cccccccd = 1.3
+fI[1] == strtod
+
+
+Input: -1.3
+strtod consumes 4 bytes and returns 41 with f = -1.3 = #bff4cccc cccccccd
+g_dfmt(0) gives 4 bytes: "-1.3"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff4cccc cccccccd = -1.3
+fI[1] = #bff4cccc cccccccc = -1.2999999999999998
+fI[0] == strtod
+
+
+Input: 1.4
+strtod consumes 3 bytes and returns 17 with f = 1.3999999999999999 = #3ff66666 66666666
+g_dfmt(0) gives 3 bytes: "1.4"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ff66666 66666666 = 1.3999999999999999
+fI[1] = #3ff66666 66666667 = 1.4000000000000001
+fI[0] == strtod
+
+
+Input: -1.4
+strtod consumes 4 bytes and returns 25 with f = -1.3999999999999999 = #bff66666 66666666
+g_dfmt(0) gives 4 bytes: "-1.4"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bff66666 66666667 = -1.4000000000000001
+fI[1] = #bff66666 66666666 = -1.3999999999999999
+fI[1] == strtod
+
+
+Input: 1.5
+strtod consumes 3 bytes and returns 1 with f = 1.5 = #3ff80000 0
+g_dfmt(0) gives 3 bytes: "1.5"
+
+strtoId returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: -1.5
+strtod consumes 4 bytes and returns 9 with f = -1.5 = #bff80000 0
+g_dfmt(0) gives 4 bytes: "-1.5"
+
+strtoId returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: 1.6
+strtod consumes 3 bytes and returns 33 with f = 1.6000000000000001 = #3ff99999 9999999a
+g_dfmt(0) gives 3 bytes: "1.6"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff99999 99999999 = 1.5999999999999999
+fI[1] = #3ff99999 9999999a = 1.6000000000000001
+fI[1] == strtod
+
+
+Input: -1.6
+strtod consumes 4 bytes and returns 41 with f = -1.6000000000000001 = #bff99999 9999999a
+g_dfmt(0) gives 4 bytes: "-1.6"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff99999 9999999a = -1.6000000000000001
+fI[1] = #bff99999 99999999 = -1.5999999999999999
+fI[0] == strtod
+
+
+Input: 1.7
+strtod consumes 3 bytes and returns 17 with f = 1.7 = #3ffb3333 33333333
+g_dfmt(0) gives 3 bytes: "1.7"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ffb3333 33333333 = 1.7
+fI[1] = #3ffb3333 33333334 = 1.7000000000000002
+fI[0] == strtod
+
+
+Input: -1.7
+strtod consumes 4 bytes and returns 25 with f = -1.7 = #bffb3333 33333333
+g_dfmt(0) gives 4 bytes: "-1.7"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bffb3333 33333334 = -1.7000000000000002
+fI[1] = #bffb3333 33333333 = -1.7
+fI[1] == strtod
+
+
+Input: 1.8
+strtod consumes 3 bytes and returns 33 with f = 1.8 = #3ffccccc cccccccd
+g_dfmt(0) gives 3 bytes: "1.8"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ffccccc cccccccc = 1.7999999999999998
+fI[1] = #3ffccccc cccccccd = 1.8
+fI[1] == strtod
+
+
+Input: -1.8
+strtod consumes 4 bytes and returns 41 with f = -1.8 = #bffccccc cccccccd
+g_dfmt(0) gives 4 bytes: "-1.8"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bffccccc cccccccd = -1.8
+fI[1] = #bffccccc cccccccc = -1.7999999999999998
+fI[0] == strtod
+
+
+Input: 1.9
+strtod consumes 3 bytes and returns 17 with f = 1.8999999999999999 = #3ffe6666 66666666
+g_dfmt(0) gives 3 bytes: "1.9"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ffe6666 66666666 = 1.8999999999999999
+fI[1] = #3ffe6666 66666667 = 1.9000000000000001
+fI[0] == strtod
+
+
+Input: -1.9
+strtod consumes 4 bytes and returns 25 with f = -1.8999999999999999 = #bffe6666 66666666
+g_dfmt(0) gives 4 bytes: "-1.9"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bffe6666 66666667 = -1.9000000000000001
+fI[1] = #bffe6666 66666666 = -1.8999999999999999
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+strtod consumes 3 bytes and returns 33 with f = 1.1000000000000001 = #3ff19999 9999999a
+g_dfmt(0) gives 3 bytes: "1.1"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff19999 99999999 = 1.0999999999999999
+fI[1] = #3ff19999 9999999a = 1.1000000000000001
+fI[1] == strtod
+
+
+Input: -1.1
+strtod consumes 4 bytes and returns 25 with f = -1.0999999999999999 = #bff19999 99999999
+g_dfmt(0) gives 19 bytes: "-1.0999999999999999"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff19999 9999999a = -1.1000000000000001
+fI[1] = #bff19999 99999999 = -1.0999999999999999
+fI[1] == strtod
+
+
+Input: 1.2
+strtod consumes 3 bytes and returns 33 with f = 1.2000000000000002 = #3ff33333 33333334
+g_dfmt(0) gives 18 bytes: "1.2000000000000002"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ff33333 33333333 = 1.2
+fI[1] = #3ff33333 33333334 = 1.2000000000000002
+fI[1] == strtod
+
+
+Input: -1.2
+strtod consumes 4 bytes and returns 25 with f = -1.2 = #bff33333 33333333
+g_dfmt(0) gives 4 bytes: "-1.2"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bff33333 33333334 = -1.2000000000000002
+fI[1] = #bff33333 33333333 = -1.2
+fI[1] == strtod
+
+
+Input: 1.3
+strtod consumes 3 bytes and returns 33 with f = 1.3 = #3ff4cccc cccccccd
+g_dfmt(0) gives 3 bytes: "1.3"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff4cccc cccccccc = 1.2999999999999998
+fI[1] = #3ff4cccc cccccccd = 1.3
+fI[1] == strtod
+
+
+Input: -1.3
+strtod consumes 4 bytes and returns 25 with f = -1.2999999999999998 = #bff4cccc cccccccc
+g_dfmt(0) gives 19 bytes: "-1.2999999999999998"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff4cccc cccccccd = -1.3
+fI[1] = #bff4cccc cccccccc = -1.2999999999999998
+fI[1] == strtod
+
+
+Input: 1.4
+strtod consumes 3 bytes and returns 33 with f = 1.4000000000000001 = #3ff66666 66666667
+g_dfmt(0) gives 18 bytes: "1.4000000000000001"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ff66666 66666666 = 1.3999999999999999
+fI[1] = #3ff66666 66666667 = 1.4000000000000001
+fI[1] == strtod
+
+
+Input: -1.4
+strtod consumes 4 bytes and returns 25 with f = -1.3999999999999999 = #bff66666 66666666
+g_dfmt(0) gives 4 bytes: "-1.4"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bff66666 66666667 = -1.4000000000000001
+fI[1] = #bff66666 66666666 = -1.3999999999999999
+fI[1] == strtod
+
+
+Input: 1.5
+strtod consumes 3 bytes and returns 1 with f = 1.5 = #3ff80000 0
+g_dfmt(0) gives 3 bytes: "1.5"
+
+strtoId returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: -1.5
+strtod consumes 4 bytes and returns 9 with f = -1.5 = #bff80000 0
+g_dfmt(0) gives 4 bytes: "-1.5"
+
+strtoId returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: 1.6
+strtod consumes 3 bytes and returns 33 with f = 1.6000000000000001 = #3ff99999 9999999a
+g_dfmt(0) gives 3 bytes: "1.6"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff99999 99999999 = 1.5999999999999999
+fI[1] = #3ff99999 9999999a = 1.6000000000000001
+fI[1] == strtod
+
+
+Input: -1.6
+strtod consumes 4 bytes and returns 25 with f = -1.5999999999999999 = #bff99999 99999999
+g_dfmt(0) gives 19 bytes: "-1.5999999999999999"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff99999 9999999a = -1.6000000000000001
+fI[1] = #bff99999 99999999 = -1.5999999999999999
+fI[1] == strtod
+
+
+Input: 1.7
+strtod consumes 3 bytes and returns 33 with f = 1.7000000000000002 = #3ffb3333 33333334
+g_dfmt(0) gives 18 bytes: "1.7000000000000002"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ffb3333 33333333 = 1.7
+fI[1] = #3ffb3333 33333334 = 1.7000000000000002
+fI[1] == strtod
+
+
+Input: -1.7
+strtod consumes 4 bytes and returns 25 with f = -1.7 = #bffb3333 33333333
+g_dfmt(0) gives 4 bytes: "-1.7"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bffb3333 33333334 = -1.7000000000000002
+fI[1] = #bffb3333 33333333 = -1.7
+fI[1] == strtod
+
+
+Input: 1.8
+strtod consumes 3 bytes and returns 33 with f = 1.8 = #3ffccccc cccccccd
+g_dfmt(0) gives 3 bytes: "1.8"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ffccccc cccccccc = 1.7999999999999998
+fI[1] = #3ffccccc cccccccd = 1.8
+fI[1] == strtod
+
+
+Input: -1.8
+strtod consumes 4 bytes and returns 25 with f = -1.7999999999999998 = #bffccccc cccccccc
+g_dfmt(0) gives 19 bytes: "-1.7999999999999998"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bffccccc cccccccd = -1.8
+fI[1] = #bffccccc cccccccc = -1.7999999999999998
+fI[1] == strtod
+
+
+Input: 1.9
+strtod consumes 3 bytes and returns 33 with f = 1.9000000000000001 = #3ffe6666 66666667
+g_dfmt(0) gives 18 bytes: "1.9000000000000001"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ffe6666 66666666 = 1.8999999999999999
+fI[1] = #3ffe6666 66666667 = 1.9000000000000001
+fI[1] == strtod
+
+
+Input: -1.9
+strtod consumes 4 bytes and returns 25 with f = -1.8999999999999999 = #bffe6666 66666666
+g_dfmt(0) gives 4 bytes: "-1.9"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bffe6666 66666667 = -1.9000000000000001
+fI[1] = #bffe6666 66666666 = -1.8999999999999999
+fI[1] == strtod
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+strtod consumes 3 bytes and returns 17 with f = 1.0999999999999999 = #3ff19999 99999999
+g_dfmt(0) gives 18 bytes: "1.0999999999999999"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff19999 99999999 = 1.0999999999999999
+fI[1] = #3ff19999 9999999a = 1.1000000000000001
+fI[0] == strtod
+
+
+Input: -1.1
+strtod consumes 4 bytes and returns 41 with f = -1.1000000000000001 = #bff19999 9999999a
+g_dfmt(0) gives 4 bytes: "-1.1"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff19999 9999999a = -1.1000000000000001
+fI[1] = #bff19999 99999999 = -1.0999999999999999
+fI[0] == strtod
+
+
+Input: 1.2
+strtod consumes 3 bytes and returns 17 with f = 1.2 = #3ff33333 33333333
+g_dfmt(0) gives 3 bytes: "1.2"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ff33333 33333333 = 1.2
+fI[1] = #3ff33333 33333334 = 1.2000000000000002
+fI[0] == strtod
+
+
+Input: -1.2
+strtod consumes 4 bytes and returns 41 with f = -1.2000000000000002 = #bff33333 33333334
+g_dfmt(0) gives 19 bytes: "-1.2000000000000002"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bff33333 33333334 = -1.2000000000000002
+fI[1] = #bff33333 33333333 = -1.2
+fI[0] == strtod
+
+
+Input: 1.3
+strtod consumes 3 bytes and returns 17 with f = 1.2999999999999998 = #3ff4cccc cccccccc
+g_dfmt(0) gives 18 bytes: "1.2999999999999998"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff4cccc cccccccc = 1.2999999999999998
+fI[1] = #3ff4cccc cccccccd = 1.3
+fI[0] == strtod
+
+
+Input: -1.3
+strtod consumes 4 bytes and returns 41 with f = -1.3 = #bff4cccc cccccccd
+g_dfmt(0) gives 4 bytes: "-1.3"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff4cccc cccccccd = -1.3
+fI[1] = #bff4cccc cccccccc = -1.2999999999999998
+fI[0] == strtod
+
+
+Input: 1.4
+strtod consumes 3 bytes and returns 17 with f = 1.3999999999999999 = #3ff66666 66666666
+g_dfmt(0) gives 3 bytes: "1.4"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ff66666 66666666 = 1.3999999999999999
+fI[1] = #3ff66666 66666667 = 1.4000000000000001
+fI[0] == strtod
+
+
+Input: -1.4
+strtod consumes 4 bytes and returns 41 with f = -1.4000000000000001 = #bff66666 66666667
+g_dfmt(0) gives 19 bytes: "-1.4000000000000001"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bff66666 66666667 = -1.4000000000000001
+fI[1] = #bff66666 66666666 = -1.3999999999999999
+fI[0] == strtod
+
+
+Input: 1.5
+strtod consumes 3 bytes and returns 1 with f = 1.5 = #3ff80000 0
+g_dfmt(0) gives 3 bytes: "1.5"
+
+strtoId returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: -1.5
+strtod consumes 4 bytes and returns 9 with f = -1.5 = #bff80000 0
+g_dfmt(0) gives 4 bytes: "-1.5"
+
+strtoId returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtod
+
+
+Input: 1.6
+strtod consumes 3 bytes and returns 17 with f = 1.5999999999999999 = #3ff99999 99999999
+g_dfmt(0) gives 18 bytes: "1.5999999999999999"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ff99999 99999999 = 1.5999999999999999
+fI[1] = #3ff99999 9999999a = 1.6000000000000001
+fI[0] == strtod
+
+
+Input: -1.6
+strtod consumes 4 bytes and returns 41 with f = -1.6000000000000001 = #bff99999 9999999a
+g_dfmt(0) gives 4 bytes: "-1.6"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bff99999 9999999a = -1.6000000000000001
+fI[1] = #bff99999 99999999 = -1.5999999999999999
+fI[0] == strtod
+
+
+Input: 1.7
+strtod consumes 3 bytes and returns 17 with f = 1.7 = #3ffb3333 33333333
+g_dfmt(0) gives 3 bytes: "1.7"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ffb3333 33333333 = 1.7
+fI[1] = #3ffb3333 33333334 = 1.7000000000000002
+fI[0] == strtod
+
+
+Input: -1.7
+strtod consumes 4 bytes and returns 41 with f = -1.7000000000000002 = #bffb3333 33333334
+g_dfmt(0) gives 19 bytes: "-1.7000000000000002"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bffb3333 33333334 = -1.7000000000000002
+fI[1] = #bffb3333 33333333 = -1.7
+fI[0] == strtod
+
+
+Input: 1.8
+strtod consumes 3 bytes and returns 17 with f = 1.7999999999999998 = #3ffccccc cccccccc
+g_dfmt(0) gives 18 bytes: "1.7999999999999998"
+
+strtoId returns 33, consuming 3 bytes.
+fI[0] = #3ffccccc cccccccc = 1.7999999999999998
+fI[1] = #3ffccccc cccccccd = 1.8
+fI[0] == strtod
+
+
+Input: -1.8
+strtod consumes 4 bytes and returns 41 with f = -1.8 = #bffccccc cccccccd
+g_dfmt(0) gives 4 bytes: "-1.8"
+
+strtoId returns 41, consuming 4 bytes.
+fI[0] = #bffccccc cccccccd = -1.8
+fI[1] = #bffccccc cccccccc = -1.7999999999999998
+fI[0] == strtod
+
+
+Input: 1.9
+strtod consumes 3 bytes and returns 17 with f = 1.8999999999999999 = #3ffe6666 66666666
+g_dfmt(0) gives 3 bytes: "1.9"
+
+strtoId returns 17, consuming 3 bytes.
+fI[0] = #3ffe6666 66666666 = 1.8999999999999999
+fI[1] = #3ffe6666 66666667 = 1.9000000000000001
+fI[0] == strtod
+
+
+Input: -1.9
+strtod consumes 4 bytes and returns 41 with f = -1.9000000000000001 = #bffe6666 66666667
+g_dfmt(0) gives 19 bytes: "-1.9000000000000001"
+
+strtoId returns 25, consuming 4 bytes.
+fI[0] = #bffe6666 66666667 = -1.9000000000000001
+fI[1] = #bffe6666 66666666 = -1.8999999999999999
+fI[0] == strtod
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/dI.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/dI.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/dI.out	(revision 2404)
@@ -0,0 +1,168 @@
+
+Input: 1.23
+strtodI consumes 4 bytes and returns 17
+dd[0] = #3ff3ae14 7ae147ae = 1.23
+dd[1] = #3ff3ae14 7ae147af = 1.2300000000000002
+
+
+Input: 1.23e+20
+strtodI consumes 8 bytes and returns 1
+dd[0] = #441aabdf 2145b430 = 1.23e+20
+dd[1] = #441aabdf 2145b430 = 1.23e+20
+
+
+Input: 1.23e-20
+strtodI consumes 8 bytes and returns 33
+dd[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20
+dd[1] = #3bcd0ae4 cf767531 = 1.23e-20
+
+
+Input: 1.23456789
+strtodI consumes 10 bytes and returns 17
+dd[0] = #3ff3c0ca 4283de1b = 1.23456789
+dd[1] = #3ff3c0ca 4283de1c = 1.2345678900000001
+
+
+Input: 1.23456589e+20
+strtodI consumes 14 bytes and returns 17
+dd[0] = #441ac537 a660b997 = 1.23456589e+20
+dd[1] = #441ac537 a660b998 = 123456589000000010000
+
+
+Input: 1.23e+30
+strtodI consumes 8 bytes and returns 17
+dd[0] = #462f0cb0 4e8fb790 = 1.23e+30
+dd[1] = #462f0cb0 4e8fb791 = 1.2300000000000001e+30
+
+
+Input: 1.23e-30
+strtodI consumes 8 bytes and returns 33
+dd[0] = #39b8f286 6f5010aa = 1.2299999999999999e-30
+dd[1] = #39b8f286 6f5010ab = 1.23e-30
+
+
+Input: 1.23456789e-20
+strtodI consumes 14 bytes and returns 17
+dd[0] = #3bcd2681 471e7ada = 1.23456789e-20
+dd[1] = #3bcd2681 471e7adb = 1.2345678900000001e-20
+
+
+Input: 1.23456789e-30
+strtodI consumes 14 bytes and returns 17
+dd[0] = #39b90a3e 33bbd995 = 1.23456789e-30
+dd[1] = #39b90a3e 33bbd996 = 1.2345678900000002e-30
+
+
+Input: 1.234567890123456789
+strtodI consumes 20 bytes and returns 17
+dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457
+
+
+Input: 1.23456789012345678901234567890123456789
+strtodI consumes 40 bytes and returns 17
+dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457
+
+
+Input: 1.23e306
+strtodI consumes 8 bytes and returns 33
+dd[0] = #7f7c0676 cd1c61f4 = 1.2299999999999999e+306
+dd[1] = #7f7c0676 cd1c61f5 = 1.23e+306
+
+
+Input: 1.23e-306
+strtodI consumes 9 bytes and returns 33
+dd[0] = #6ba3b8 5da396e7 = 1.2299999999999999e-306
+dd[1] = #6ba3b8 5da396e8 = 1.23e-306
+
+
+Input: 1.23e-320
+strtodI consumes 9 bytes and returns 98
+dd[0] = #0 9b9 = 1.2297e-320
+dd[1] = #0 9ba = 1.23e-320
+
+
+Input: 1.23e-20
+strtodI consumes 8 bytes and returns 33
+dd[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20
+dd[1] = #3bcd0ae4 cf767531 = 1.23e-20
+
+
+Input: 1.23456789e307
+strtodI consumes 14 bytes and returns 33
+dd[0] = #7fb194b1 4bdaecdb = 1.2345678899999998e+307
+dd[1] = #7fb194b1 4bdaecdc = 1.23456789e+307
+
+
+Input: 1.23456589e-307
+strtodI consumes 15 bytes and returns 17
+dd[0] = #363196 bb9845fa = 1.23456589e-307
+dd[1] = #363196 bb9845fb = 1.2345658900000001e-307
+
+
+Input: 1.234567890123456789
+strtodI consumes 20 bytes and returns 17
+dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457
+
+
+Input: 1.234567890123456789e301
+strtodI consumes 24 bytes and returns 17
+dd[0] = #7e726f51 75f56413 = 1.2345678901234568e+301
+dd[1] = #7e726f51 75f56414 = 1.234567890123457e+301
+
+
+Input: 1.234567890123456789e-301
+strtodI consumes 25 bytes and returns 17
+dd[0] = #1752a64 e34ba0d3 = 1.2345678901234567e-301
+dd[1] = #1752a64 e34ba0d4 = 1.234567890123457e-301
+
+
+Input: 1.234567890123456789e-321
+strtodI consumes 25 bytes and returns 98
+dd[0] = #0 f9 = 1.23e-321
+dd[1] = #0 fa = 1.235e-321
+
+
+Input: 1e23
+strtodI consumes 4 bytes and returns 17
+dd[0] = #44b52d02 c7e14af6 = 1e+23
+dd[1] = #44b52d02 c7e14af7 = 1.0000000000000001e+23
+
+
+Input: 1e310
+strtodI consumes 5 bytes and returns 163
+dd[0] = #7fefffff ffffffff = 1.7976931348623157e+308
+dd[1] = #7ff00000 0 = Infinity
+
+
+Input: 9.0259718793241475e-277
+strtodI consumes 23 bytes and returns 33
+dd[0] = #69fffff ffffffff = 9.025971879324147e-277
+dd[1] = #6a00000 0 = 9.025971879324148e-277
+
+
+Input: 9.025971879324147880346310405869e-277
+strtodI consumes 37 bytes and returns 17
+dd[0] = #6a00000 0 = 9.025971879324148e-277
+dd[1] = #6a00000 1 = 9.02597187932415e-277
+
+
+Input: 9.025971879324147880346310405868e-277
+strtodI consumes 37 bytes and returns 33
+dd[0] = #69fffff ffffffff = 9.025971879324147e-277
+dd[1] = #6a00000 0 = 9.025971879324148e-277
+
+
+Input: 2.2250738585072014e-308
+strtodI consumes 23 bytes and returns 17
+dd[0] = #100000 0 = 2.2250738585072014e-308
+dd[1] = #100000 1 = 2.225073858507202e-308
+
+
+Input: 2.2250738585072013e-308
+strtodI consumes 23 bytes and returns 33
+dd[0] = #fffff ffffffff = 2.225073858507201e-308
+dd[1] = #100000 0 = 2.2250738585072014e-308
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/dIsi.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/dIsi.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/dIsi.out	(revision 2404)
@@ -0,0 +1,168 @@
+
+Input: 1.23
+strtodI consumes 4 bytes and returns 17
+dd[0] = #3ff3ae14 7ae147ae = 1.23
+dd[1] = #3ff3ae14 7ae147af = 1.2300000000000002
+
+
+Input: 1.23e+20
+strtodI consumes 8 bytes and returns 1
+dd[0] = #441aabdf 2145b430 = 1.23e+20
+dd[1] = #441aabdf 2145b430 = 1.23e+20
+
+
+Input: 1.23e-20
+strtodI consumes 8 bytes and returns 33
+dd[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20
+dd[1] = #3bcd0ae4 cf767531 = 1.23e-20
+
+
+Input: 1.23456789
+strtodI consumes 10 bytes and returns 17
+dd[0] = #3ff3c0ca 4283de1b = 1.23456789
+dd[1] = #3ff3c0ca 4283de1c = 1.2345678900000001
+
+
+Input: 1.23456589e+20
+strtodI consumes 14 bytes and returns 17
+dd[0] = #441ac537 a660b997 = 1.23456589e+20
+dd[1] = #441ac537 a660b998 = 123456589000000010000
+
+
+Input: 1.23e+30
+strtodI consumes 8 bytes and returns 17
+dd[0] = #462f0cb0 4e8fb790 = 1.23e+30
+dd[1] = #462f0cb0 4e8fb791 = 1.2300000000000001e+30
+
+
+Input: 1.23e-30
+strtodI consumes 8 bytes and returns 33
+dd[0] = #39b8f286 6f5010aa = 1.2299999999999999e-30
+dd[1] = #39b8f286 6f5010ab = 1.23e-30
+
+
+Input: 1.23456789e-20
+strtodI consumes 14 bytes and returns 17
+dd[0] = #3bcd2681 471e7ada = 1.23456789e-20
+dd[1] = #3bcd2681 471e7adb = 1.2345678900000001e-20
+
+
+Input: 1.23456789e-30
+strtodI consumes 14 bytes and returns 17
+dd[0] = #39b90a3e 33bbd995 = 1.23456789e-30
+dd[1] = #39b90a3e 33bbd996 = 1.2345678900000002e-30
+
+
+Input: 1.234567890123456789
+strtodI consumes 20 bytes and returns 17
+dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457
+
+
+Input: 1.23456789012345678901234567890123456789
+strtodI consumes 40 bytes and returns 17
+dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457
+
+
+Input: 1.23e306
+strtodI consumes 8 bytes and returns 33
+dd[0] = #7f7c0676 cd1c61f4 = 1.2299999999999999e+306
+dd[1] = #7f7c0676 cd1c61f5 = 1.23e+306
+
+
+Input: 1.23e-306
+strtodI consumes 9 bytes and returns 33
+dd[0] = #6ba3b8 5da396e7 = 1.2299999999999999e-306
+dd[1] = #6ba3b8 5da396e8 = 1.23e-306
+
+
+Input: 1.23e-320
+strtodI consumes 9 bytes and returns 80
+dd[0] = #0 0 = 0
+dd[1] = #100000 0 = 2.2250738585072014e-308
+
+
+Input: 1.23e-20
+strtodI consumes 8 bytes and returns 33
+dd[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20
+dd[1] = #3bcd0ae4 cf767531 = 1.23e-20
+
+
+Input: 1.23456789e307
+strtodI consumes 14 bytes and returns 33
+dd[0] = #7fb194b1 4bdaecdb = 1.2345678899999998e+307
+dd[1] = #7fb194b1 4bdaecdc = 1.23456789e+307
+
+
+Input: 1.23456589e-307
+strtodI consumes 15 bytes and returns 17
+dd[0] = #363196 bb9845fa = 1.23456589e-307
+dd[1] = #363196 bb9845fb = 1.2345658900000001e-307
+
+
+Input: 1.234567890123456789
+strtodI consumes 20 bytes and returns 17
+dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567
+dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457
+
+
+Input: 1.234567890123456789e301
+strtodI consumes 24 bytes and returns 17
+dd[0] = #7e726f51 75f56413 = 1.2345678901234568e+301
+dd[1] = #7e726f51 75f56414 = 1.234567890123457e+301
+
+
+Input: 1.234567890123456789e-301
+strtodI consumes 25 bytes and returns 17
+dd[0] = #1752a64 e34ba0d3 = 1.2345678901234567e-301
+dd[1] = #1752a64 e34ba0d4 = 1.234567890123457e-301
+
+
+Input: 1.234567890123456789e-321
+strtodI consumes 25 bytes and returns 80
+dd[0] = #0 0 = 0
+dd[1] = #100000 0 = 2.2250738585072014e-308
+
+
+Input: 1e23
+strtodI consumes 4 bytes and returns 17
+dd[0] = #44b52d02 c7e14af6 = 1e+23
+dd[1] = #44b52d02 c7e14af7 = 1.0000000000000001e+23
+
+
+Input: 1e310
+strtodI consumes 5 bytes and returns 163
+dd[0] = #7fefffff ffffffff = 1.7976931348623157e+308
+dd[1] = #7ff00000 0 = Infinity
+
+
+Input: 9.0259718793241475e-277
+strtodI consumes 23 bytes and returns 33
+dd[0] = #69fffff ffffffff = 9.025971879324147e-277
+dd[1] = #6a00000 0 = 9.025971879324148e-277
+
+
+Input: 9.025971879324147880346310405869e-277
+strtodI consumes 37 bytes and returns 17
+dd[0] = #6a00000 0 = 9.025971879324148e-277
+dd[1] = #6a00000 1 = 9.02597187932415e-277
+
+
+Input: 9.025971879324147880346310405868e-277
+strtodI consumes 37 bytes and returns 33
+dd[0] = #69fffff ffffffff = 9.025971879324147e-277
+dd[1] = #6a00000 0 = 9.025971879324148e-277
+
+
+Input: 2.2250738585072014e-308
+strtodI consumes 23 bytes and returns 17
+dd[0] = #100000 0 = 2.2250738585072014e-308
+dd[1] = #100000 1 = 2.225073858507202e-308
+
+
+Input: 2.2250738585072013e-308
+strtodI consumes 23 bytes and returns 33
+dd[0] = #0 0 = 0
+dd[1] = #100000 0 = 2.2250738585072014e-308
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/dItest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/dItest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/dItest.c	(revision 2404)
@@ -0,0 +1,88 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+ static char ibuf[2048];
+
+#define U (unsigned long)
+
+ static void
+#ifdef KR_headers
+dshow(what, d) char *what; double d;
+#else
+dshow(char *what, double d)
+#endif
+{
+	char buf[32];
+	g_dfmt(buf, &d, 0, sizeof(buf));
+	printf("%s = #%lx %lx = %s\n", what,
+		U ((ULong*)&d)[_0], U ((ULong*)&d)[_1], buf);
+	}
+
+ int
+main(Void)
+{
+	/* Input: one number per line */
+
+	char *s, *se, *se1;
+	int i, j;
+	double dd[2], dd1, dd2;
+	static char cfmt[] = "%s consumes %d bytes and returns %d\n";
+
+	while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) {
+		while(*s <= ' ')
+			if (!*s++)
+				continue;
+		printf("\nInput: %s", ibuf);
+		i = strtodI(ibuf, &se, dd);
+		printf(cfmt, "strtodI", (int)(se-ibuf), i);
+		dshow("dd[0]", dd[0]);
+		dshow("dd[1]", dd[1]);
+		printf("\n");
+		j = strtoId(ibuf, &se1, &dd1, &dd2);
+		if (j != i || se != se1
+		 || dd[0] != dd1 || dd[1] != dd2) {
+			printf(cfmt, "**** strtoId", (int)(se-ibuf), j);
+			dshow("dd1", dd1);
+			dshow("dd2", dd2);
+			}
+		}
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/dd.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/dd.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/dd.out	(revision 2404)
@@ -0,0 +1,1356 @@
+
+Input: 1.23
+strtopdd consumes 4 bytes and returns 17
+dd[0] = 1.23 = #3ff3ae14 7ae147ae
+dd[1] = 1.7763568394002496e-17 = #3c747ae1 47ae1478
+g_ddfmt(0) gives 4 bytes: "1.23"
+
+strtoIdd returns 17, consuming 4 bytes.
+ddI[0] = #3ff3ae14 7ae147ae + 3c747ae1 47ae1478
+= 1.23 + 1.7763568394002496e-17
+ddI[1] = #3ff3ae14 7ae147ae + 3c747ae1 47ae1480
+= 1.23 + 1.776356839400252e-17
+ddI[0] == strtod
+
+
+Input: 1.23e+20
+strtopdd consumes 8 bytes and returns 1
+dd[0] = 1.23e+20 = #441aabdf 2145b430
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIdd returns 1, consuming 8 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.23e-20
+strtopdd consumes 8 bytes and returns 33
+dd[0] = 1.2299999999999999e-20 = #3bcd0ae4 cf767530
+dd[1] = 9.304023318521521e-37 = #3873c997 955b2691
+g_ddfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIdd returns 33, consuming 8 bytes.
+ddI[0] = #3bcd0ae4 cf767530 + 3873c997 955b2690
+= 1.2299999999999999e-20 + 9.3040233185215194e-37
+ddI[1] = #3bcd0ae4 cf767530 + 3873c997 955b2691
+= 1.2299999999999999e-20 + 9.3040233185215211e-37
+ddI[1] == strtod
+
+
+Input: 1.23456789
+strtopdd consumes 10 bytes and returns 17
+dd[0] = 1.23456789 = #3ff3c0ca 4283de1b
+dd[1] = 1.0990618193318369e-16 = #3c9fada5 144c1252
+g_ddfmt(0) gives 10 bytes: "1.23456789"
+
+strtoIdd returns 17, consuming 10 bytes.
+ddI[0] = #3ff3c0ca 4283de1b + 3c9fada5 144c1252
+= 1.2345678899999999 + 1.0990618193318369e-16
+ddI[1] = #3ff3c0ca 4283de1b + 3c9fada5 144c1254
+= 1.2345678899999999 + 1.0990618193318371e-16
+ddI[0] == strtod
+
+
+Input: 1.23456589e+20
+strtopdd consumes 14 bytes and returns 1
+dd[0] = 1.23456589e+20 = #441ac537 a660b997
+dd[1] = 4096 = #40b00000 0
+g_ddfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoIdd returns 1, consuming 14 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.23e+30
+strtopdd consumes 8 bytes and returns 1
+dd[0] = 1.23e+30 = #462f0cb0 4e8fb790
+dd[1] = 40281156091904 = #42c25158 0
+g_ddfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIdd returns 1, consuming 8 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.23e-30
+strtopdd consumes 8 bytes and returns 17
+dd[0] = 1.2299999999999999e-30 = #39b8f286 6f5010aa
+dd[1] = 1.076909723013918e-46 = #3663ac7f 3dafd174
+g_ddfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIdd returns 17, consuming 8 bytes.
+ddI[0] = #39b8f286 6f5010aa + 3663ac7f 3dafd174
+= 1.2299999999999999e-30 + 1.076909723013918e-46
+ddI[1] = #39b8f286 6f5010aa + 3663ac7f 3dafd175
+= 1.2299999999999999e-30 + 1.0769097230139181e-46
+ddI[0] == strtod
+
+
+Input: 1.23456789e-20
+strtopdd consumes 14 bytes and returns 17
+dd[0] = 1.23456789e-20 = #3bcd2681 471e7ada
+dd[1] = 6.247111971663133e-37 = #386a9280 a761b07e
+g_ddfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoIdd returns 17, consuming 14 bytes.
+ddI[0] = #3bcd2681 471e7ada + 386a9280 a761b07e
+= 1.2345678899999999e-20 + 6.2471119716631328e-37
+ddI[1] = #3bcd2681 471e7ada + 386a9280 a761b080
+= 1.2345678899999999e-20 + 6.2471119716631345e-37
+ddI[0] == strtod
+
+
+Input: 1.23456789e-30
+strtopdd consumes 14 bytes and returns 33
+dd[0] = 1.23456789e-30 = #39b90a3e 33bbd995
+dd[1] = 2.1567930523648577e-47 = #363f8585 55a6b1a0
+g_ddfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoIdd returns 33, consuming 14 bytes.
+ddI[0] = #39b90a3e 33bbd995 + 363f8585 55a6b198
+= 1.23456789e-30 + 2.1567930523648558e-47
+ddI[1] = #39b90a3e 33bbd995 + 363f8585 55a6b1a0
+= 1.23456789e-30 + 2.1567930523648577e-47
+ddI[1] == strtod
+
+
+Input: 1.234567890123456789
+strtopdd consumes 20 bytes and returns 33
+dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb
+dd[1] = 9.856786452588859e-17 = #3c9c6906 51a3745e
+g_ddfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIdd returns 33, consuming 20 bytes.
+ddI[0] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745c
+= 1.2345678901234567 + 9.8567864525888563e-17
+ddI[1] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745e
+= 1.2345678901234567 + 9.8567864525888588e-17
+ddI[1] == strtod
+
+
+Input: 1.23456789012345678901234567890123456789
+strtopdd consumes 40 bytes and returns 33
+dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb
+dd[1] = 9.858021020478982e-17 = #3c9c69ef 85adadb6
+g_ddfmt(0) gives 34 bytes: "1.23456789012345678901234567890124"
+
+strtoIdd returns 33, consuming 40 bytes.
+ddI[0] = #3ff3c0ca 428c59fb + 3c9c69ef 85adadb4
+= 1.2345678901234567 + 9.8580210204789798e-17
+ddI[1] = #3ff3c0ca 428c59fb + 3c9c69ef 85adadb6
+= 1.2345678901234567 + 9.8580210204789823e-17
+ddI[1] == strtod
+
+
+Input: 1.23e306
+strtopdd consumes 8 bytes and returns 33
+dd[0] = 1.2299999999999999e+306 = #7f7c0676 cd1c61f4
+dd[1] = 1.3319001448659015e+290 = #7c2b558b e3d3f477
+g_ddfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoIdd returns 33, consuming 8 bytes.
+ddI[0] = #7f7c0676 cd1c61f4 + 7c2b558b e3d3f476
+= 1.2299999999999999e+306 + 1.3319001448659013e+290
+ddI[1] = #7f7c0676 cd1c61f4 + 7c2b558b e3d3f477
+= 1.2299999999999999e+306 + 1.3319001448659015e+290
+ddI[1] == strtod
+
+
+Input: 1.23e-306
+strtopdd consumes 9 bytes and returns 98
+dd[0] = 1.2299999999999999e-306 = #6ba3b8 5da396e7
+dd[1] = 1.43e-322 = #0 1d
+g_ddfmt(0) gives 9 bytes: "1.23e-306"
+
+strtoIdd returns 98, consuming 9 bytes.
+ddI[0] = #6ba3b8 5da396e7 + 0 1c
+= 1.2299999999999999e-306 + 1.3833838083554903e-322
+ddI[1] = #6ba3b8 5da396e7 + 0 1d
+= 1.2299999999999999e-306 + 1.432790372939615e-322
+ddI[1] == strtod
+
+
+Input: 1.23e-320
+strtopdd consumes 9 bytes and returns 98
+dd[0] = 1.23e-320 = #0 9ba
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 9 bytes: "1.23e-320"
+
+strtoIdd returns 98, consuming 9 bytes.
+ddI[0] = #0 9b9 + 0 0
+= 1.2297293924988626e-320 + 0
+ddI[1] = #0 9ba + 0 0
+= 1.2302234581447039e-320 + 0
+ddI[1] == strtod
+
+
+Input: 1.23e-20
+strtopdd consumes 8 bytes and returns 33
+dd[0] = 1.2299999999999999e-20 = #3bcd0ae4 cf767530
+dd[1] = 9.304023318521521e-37 = #3873c997 955b2691
+g_ddfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIdd returns 33, consuming 8 bytes.
+ddI[0] = #3bcd0ae4 cf767530 + 3873c997 955b2690
+= 1.2299999999999999e-20 + 9.3040233185215194e-37
+ddI[1] = #3bcd0ae4 cf767530 + 3873c997 955b2691
+= 1.2299999999999999e-20 + 9.3040233185215211e-37
+ddI[1] == strtod
+
+
+Input: 1.23456789e307
+strtopdd consumes 14 bytes and returns 33
+dd[0] = 1.2345678899999998e+307 = #7fb194b1 4bdaecdb
+dd[1] = 2.0137933598720243e+291 = #7c69d48d 192048ca
+g_ddfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoIdd returns 33, consuming 14 bytes.
+ddI[0] = #7fb194b1 4bdaecdb + 7c69d48d 192048c9
+= 1.2345678899999998e+307 + 2.013793359872024e+291
+ddI[1] = #7fb194b1 4bdaecdb + 7c69d48d 192048ca
+= 1.2345678899999998e+307 + 2.0137933598720243e+291
+ddI[1] == strtod
+
+
+Input: 1.23456589e-307
+strtopdd consumes 15 bytes and returns 98
+dd[0] = 1.23456589e-307 = #363196 bb9845fa
+dd[1] = 1e-323 = #0 2
+g_ddfmt(0) gives 15 bytes: "1.23456589e-307"
+
+strtoIdd returns 98, consuming 15 bytes.
+ddI[0] = #363196 bb9845fa + 0 1
+= 1.2345658899999999e-307 + 4.9406564584124654e-324
+ddI[1] = #363196 bb9845fa + 0 2
+= 1.2345658899999999e-307 + 9.8813129168249309e-324
+ddI[1] == strtod
+
+
+Input: 1.234567890123456789
+strtopdd consumes 20 bytes and returns 33
+dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb
+dd[1] = 9.856786452588859e-17 = #3c9c6906 51a3745e
+g_ddfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIdd returns 33, consuming 20 bytes.
+ddI[0] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745c
+= 1.2345678901234567 + 9.8567864525888563e-17
+ddI[1] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745e
+= 1.2345678901234567 + 9.8567864525888588e-17
+ddI[1] == strtod
+
+
+Input: 1.234567890123456789e301
+strtopdd consumes 24 bytes and returns 33
+dd[0] = 1.2345678901234568e+301 = #7e726f51 75f56413
+dd[1] = 1.3892003943918827e+283 = #7ab7ea80 76399100
+g_ddfmt(0) gives 25 bytes: "1.234567890123456789e+301"
+
+strtoIdd returns 33, consuming 24 bytes.
+ddI[0] = #7e726f51 75f56413 + 7ab7ea80 76399080
+= 1.2345678901234568e+301 + 1.3892003943918563e+283
+ddI[1] = #7e726f51 75f56413 + 7ab7ea80 76399100
+= 1.2345678901234568e+301 + 1.3892003943918827e+283
+ddI[1] == strtod
+
+
+Input: 1.234567890123456789e-301
+strtopdd consumes 25 bytes and returns 82
+dd[0] = 1.2345678901234567e-301 = #1752a64 e34ba0d3
+dd[1] = 7.374365e-318 = #0 16c66c
+g_ddfmt(0) gives 25 bytes: "1.234567890123456789e-301"
+
+strtoIdd returns 82, consuming 25 bytes.
+ddI[0] = #1752a64 e34ba0d3 + 0 16c66c
+= 1.2345678901234567e-301 + 7.374364541948945e-318
+ddI[1] = #1752a64 e34ba0d3 + 0 16c66d
+= 1.2345678901234567e-301 + 7.3743694826054034e-318
+ddI[0] == strtod
+
+
+Input: 1.234567890123456789e-321
+strtopdd consumes 25 bytes and returns 98
+dd[0] = 1.235e-321 = #0 fa
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 10 bytes: "1.235e-321"
+
+strtoIdd returns 98, consuming 25 bytes.
+ddI[0] = #0 f9 + 0 0
+= 1.2302234581447039e-321 + 0
+ddI[1] = #0 fa + 0 0
+= 1.2351641146031164e-321 + 0
+ddI[1] == strtod
+
+
+Input: 1e23
+strtopdd consumes 4 bytes and returns 1
+dd[0] = 1e+23 = #44b52d02 c7e14af6
+dd[1] = 8388608 = #41600000 0
+g_ddfmt(0) gives 5 bytes: "1e+23"
+
+strtoIdd returns 1, consuming 4 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1e310
+strtopdd consumes 5 bytes and returns 163
+dd[0] = Infinity = #7ff00000 0
+dd[1] = Infinity = #7ff00000 0
+g_ddfmt(0) gives 8 bytes: "Infinity"
+
+strtoIdd returns 163, consuming 5 bytes.
+ddI[0] = #7fefffff ffffffff + 7c9fffff ffffffff
+= 1.7976931348623157e+308 + 1.9958403095347196e+292
+ddI[1] = #7ff00000 0 + 7ff00000 0
+= Infinity + Infinity
+ddI[1] == strtod
+
+
+Input: 9.0259718793241475e-277
+strtopdd consumes 23 bytes and returns 33
+dd[0] = 9.025971879324147e-277 = #69fffff ffffffff
+dd[1] = 6.217378695986177e-293 = #343daae f3582320
+g_ddfmt(0) gives 23 bytes: "9.0259718793241475e-277"
+
+strtoIdd returns 33, consuming 23 bytes.
+ddI[0] = #69fffff ffffffff + 343daae f358231f
+= 9.0259718793241469e-277 + 6.2173786959861757e-293
+ddI[1] = #69fffff ffffffff + 343daae f3582320
+= 9.0259718793241469e-277 + 6.2173786959861768e-293
+ddI[1] == strtod
+
+
+Input: 9.025971879324147880346310405869e-277
+strtopdd consumes 37 bytes and returns 17
+dd[0] = 9.025971879324148e-277 = #6a00000 0
+dd[1] = 2.2250738585072014e-308 = #100000 0
+g_ddfmt(0) gives 37 bytes: "9.025971879324147880346310405869e-277"
+
+strtoIdd returns 17, consuming 37 bytes.
+ddI[0] = #6a00000 0 + 100000 0
+= 9.0259718793241479e-277 + 2.2250738585072014e-308
+ddI[1] = #6a00000 0 + 200000 0
+= 9.0259718793241479e-277 + 4.4501477170144028e-308
+ddI[0] == strtod
+
+
+Input: 9.025971879324147880346310405868e-277
+strtopdd consumes 37 bytes and returns 17
+dd[0] = 9.025971879324147e-277 = #69fffff ffffffff
+dd[1] = 1.0020841800044856e-292 = #34fffff fffffff9
+g_ddfmt(0) gives 37 bytes: "9.025971879324147880346310405868e-277"
+
+strtoIdd returns 17, consuming 37 bytes.
+ddI[0] = #69fffff ffffffff + 34fffff fffffff9
+= 9.0259718793241469e-277 + 1.0020841800044856e-292
+ddI[1] = #69fffff ffffffff + 34fffff fffffffa
+= 9.0259718793241469e-277 + 1.0020841800044857e-292
+ddI[0] == strtod
+
+
+Input: 2.2250738585072014e-308
+strtopdd consumes 23 bytes and returns 82
+dd[0] = 2.2250738585072014e-308 = #100000 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoIdd returns 82, consuming 23 bytes.
+ddI[0] = #100000 0 + 0 0
+= 2.2250738585072014e-308 + 0
+ddI[1] = #100000 1 + 0 0
+= 2.2250738585072019e-308 + 0
+ddI[0] == strtod
+
+
+Input: 2.2250738585072013e-308
+strtopdd consumes 23 bytes and returns 98
+dd[0] = 2.2250738585072014e-308 = #100000 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoIdd returns 98, consuming 23 bytes.
+ddI[0] = #fffff ffffffff + 0 0
+= 2.2250738585072009e-308 + 0
+ddI[1] = #100000 0 + 0 0
+= 2.2250738585072014e-308 + 0
+ddI[1] == strtod
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.0999999999999999 = #3ff19999 99999999
+dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333
+g_ddfmt(0) gives 3 bytes: "1.1"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff19999 99999999 + 3ca33333 33333333
+= 1.0999999999999999 + 1.3322676295501878e-16
+ddI[1] = #3ff19999 99999999 + 3ca33333 33333334
+= 1.0999999999999999 + 1.332267629550188e-16
+ddI[0] == strtod
+
+
+Input: -1.1
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.0999999999999999 = #bff19999 99999999
+dd[1] = -1.3322676295501878e-16 = #bca33333 33333333
+g_ddfmt(0) gives 4 bytes: "-1.1"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff19999 99999999 + bca33333 33333334
+= -1.0999999999999999 + -1.332267629550188e-16
+ddI[1] = #bff19999 99999999 + bca33333 33333333
+= -1.0999999999999999 + -1.3322676295501878e-16
+ddI[1] == strtod
+
+
+Input: 1.2
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.2 = #3ff33333 33333333
+dd[1] = 4.440892098500625e-17 = #3c899999 99999998
+g_ddfmt(0) gives 3 bytes: "1.2"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff33333 33333333 + 3c899999 99999998
+= 1.2 + 4.4408920985006252e-17
+ddI[1] = #3ff33333 33333333 + 3c899999 9999999c
+= 1.2 + 4.4408920985006276e-17
+ddI[0] == strtod
+
+
+Input: -1.2
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.2 = #bff33333 33333333
+dd[1] = -4.440892098500625e-17 = #bc899999 99999998
+g_ddfmt(0) gives 4 bytes: "-1.2"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff33333 33333333 + bc899999 9999999c
+= -1.2 + -4.4408920985006276e-17
+ddI[1] = #bff33333 33333333 + bc899999 99999998
+= -1.2 + -4.4408920985006252e-17
+ddI[1] == strtod
+
+
+Input: 1.3
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.2999999999999998 = #3ff4cccc cccccccc
+dd[1] = 1.7763568394002503e-16 = #3ca99999 99999999
+g_ddfmt(0) gives 34 bytes: "1.29999999999999999999999999999999"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ff4cccc cccccccc + 3ca99999 99999999
+= 1.2999999999999998 + 1.7763568394002503e-16
+ddI[1] = #3ff4cccc cccccccc + 3ca99999 9999999a
+= 1.2999999999999998 + 1.7763568394002506e-16
+ddI[0] == strtod
+
+
+Input: -1.3
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.2999999999999998 = #bff4cccc cccccccc
+dd[1] = -1.7763568394002503e-16 = #bca99999 99999999
+g_ddfmt(0) gives 35 bytes: "-1.29999999999999999999999999999999"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bff4cccc cccccccc + bca99999 9999999a
+= -1.2999999999999998 + -1.7763568394002506e-16
+ddI[1] = #bff4cccc cccccccc + bca99999 99999999
+= -1.2999999999999998 + -1.7763568394002503e-16
+ddI[1] == strtod
+
+
+Input: 1.4
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.4 = #3ff66666 66666666
+dd[1] = 8.88178419700125e-17 = #3c999999 99999998
+g_ddfmt(0) gives 34 bytes: "1.39999999999999999999999999999998"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ff66666 66666666 + 3c999999 99999998
+= 1.3999999999999999 + 8.8817841970012504e-17
+ddI[1] = #3ff66666 66666666 + 3c999999 9999999a
+= 1.3999999999999999 + 8.8817841970012528e-17
+ddI[0] == strtod
+
+
+Input: -1.4
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.4 = #bff66666 66666666
+dd[1] = -8.88178419700125e-17 = #bc999999 99999998
+g_ddfmt(0) gives 35 bytes: "-1.39999999999999999999999999999998"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bff66666 66666666 + bc999999 9999999a
+= -1.3999999999999999 + -8.8817841970012528e-17
+ddI[1] = #bff66666 66666666 + bc999999 99999998
+= -1.3999999999999999 + -8.8817841970012504e-17
+ddI[1] == strtod
+
+
+Input: 1.5
+strtopdd consumes 3 bytes and returns 1
+dd[0] = 1.5 = #3ff80000 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 3 bytes: "1.5"
+
+strtoIdd returns 1, consuming 3 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: -1.5
+strtopdd consumes 4 bytes and returns 9
+dd[0] = -1.5 = #bff80000 0
+dd[1] = -0 = #80000000 0
+g_ddfmt(0) gives 3 bytes: "1.5"
+
+strtoIdd returns 9, consuming 4 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.6
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.5999999999999999 = #3ff99999 99999999
+dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333
+g_ddfmt(0) gives 3 bytes: "1.6"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff99999 99999999 + 3ca33333 33333333
+= 1.5999999999999999 + 1.3322676295501878e-16
+ddI[1] = #3ff99999 99999999 + 3ca33333 33333334
+= 1.5999999999999999 + 1.332267629550188e-16
+ddI[0] == strtod
+
+
+Input: -1.6
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.5999999999999999 = #bff99999 99999999
+dd[1] = -1.3322676295501878e-16 = #bca33333 33333333
+g_ddfmt(0) gives 4 bytes: "-1.6"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff99999 99999999 + bca33333 33333334
+= -1.5999999999999999 + -1.332267629550188e-16
+ddI[1] = #bff99999 99999999 + bca33333 33333333
+= -1.5999999999999999 + -1.3322676295501878e-16
+ddI[1] == strtod
+
+
+Input: 1.7
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.7 = #3ffb3333 33333333
+dd[1] = 4.440892098500625e-17 = #3c899999 99999998
+g_ddfmt(0) gives 3 bytes: "1.7"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ffb3333 33333333 + 3c899999 99999998
+= 1.7 + 4.4408920985006252e-17
+ddI[1] = #3ffb3333 33333333 + 3c899999 9999999c
+= 1.7 + 4.4408920985006276e-17
+ddI[0] == strtod
+
+
+Input: -1.7
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.7 = #bffb3333 33333333
+dd[1] = -4.440892098500625e-17 = #bc899999 99999998
+g_ddfmt(0) gives 4 bytes: "-1.7"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bffb3333 33333333 + bc899999 9999999c
+= -1.7 + -4.4408920985006276e-17
+ddI[1] = #bffb3333 33333333 + bc899999 99999998
+= -1.7 + -4.4408920985006252e-17
+ddI[1] == strtod
+
+
+Input: 1.8
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.7999999999999998 = #3ffccccc cccccccc
+dd[1] = 1.7763568394002503e-16 = #3ca99999 99999999
+g_ddfmt(0) gives 34 bytes: "1.79999999999999999999999999999999"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ffccccc cccccccc + 3ca99999 99999999
+= 1.7999999999999998 + 1.7763568394002503e-16
+ddI[1] = #3ffccccc cccccccc + 3ca99999 9999999a
+= 1.7999999999999998 + 1.7763568394002506e-16
+ddI[0] == strtod
+
+
+Input: -1.8
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.7999999999999998 = #bffccccc cccccccc
+dd[1] = -1.7763568394002503e-16 = #bca99999 99999999
+g_ddfmt(0) gives 35 bytes: "-1.79999999999999999999999999999999"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bffccccc cccccccc + bca99999 9999999a
+= -1.7999999999999998 + -1.7763568394002506e-16
+ddI[1] = #bffccccc cccccccc + bca99999 99999999
+= -1.7999999999999998 + -1.7763568394002503e-16
+ddI[1] == strtod
+
+
+Input: 1.9
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.9 = #3ffe6666 66666666
+dd[1] = 8.88178419700125e-17 = #3c999999 99999998
+g_ddfmt(0) gives 34 bytes: "1.89999999999999999999999999999998"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ffe6666 66666666 + 3c999999 99999998
+= 1.8999999999999999 + 8.8817841970012504e-17
+ddI[1] = #3ffe6666 66666666 + 3c999999 9999999a
+= 1.8999999999999999 + 8.8817841970012528e-17
+ddI[0] == strtod
+
+
+Input: -1.9
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.9 = #bffe6666 66666666
+dd[1] = -8.88178419700125e-17 = #bc999999 99999998
+g_ddfmt(0) gives 35 bytes: "-1.89999999999999999999999999999998"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bffe6666 66666666 + bc999999 9999999a
+= -1.8999999999999999 + -8.8817841970012528e-17
+ddI[1] = #bffe6666 66666666 + bc999999 99999998
+= -1.8999999999999999 + -8.8817841970012504e-17
+ddI[1] == strtod
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.0999999999999999 = #3ff19999 99999999
+dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333
+g_ddfmt(0) gives 3 bytes: "1.1"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff19999 99999999 + 3ca33333 33333333
+= 1.0999999999999999 + 1.3322676295501878e-16
+ddI[1] = #3ff19999 99999999 + 3ca33333 33333334
+= 1.0999999999999999 + 1.332267629550188e-16
+ddI[0] == strtod
+
+
+Input: -1.1
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.0999999999999999 = #bff19999 99999999
+dd[1] = -1.3322676295501878e-16 = #bca33333 33333333
+g_ddfmt(0) gives 4 bytes: "-1.1"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff19999 99999999 + bca33333 33333334
+= -1.0999999999999999 + -1.332267629550188e-16
+ddI[1] = #bff19999 99999999 + bca33333 33333333
+= -1.0999999999999999 + -1.3322676295501878e-16
+ddI[1] == strtod
+
+
+Input: 1.2
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.2 = #3ff33333 33333333
+dd[1] = 4.440892098500625e-17 = #3c899999 99999998
+g_ddfmt(0) gives 3 bytes: "1.2"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff33333 33333333 + 3c899999 99999998
+= 1.2 + 4.4408920985006252e-17
+ddI[1] = #3ff33333 33333333 + 3c899999 9999999c
+= 1.2 + 4.4408920985006276e-17
+ddI[0] == strtod
+
+
+Input: -1.2
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.2 = #bff33333 33333333
+dd[1] = -4.440892098500625e-17 = #bc899999 99999998
+g_ddfmt(0) gives 4 bytes: "-1.2"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff33333 33333333 + bc899999 9999999c
+= -1.2 + -4.4408920985006276e-17
+ddI[1] = #bff33333 33333333 + bc899999 99999998
+= -1.2 + -4.4408920985006252e-17
+ddI[1] == strtod
+
+
+Input: 1.3
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.2999999999999998 = #3ff4cccc cccccccc
+dd[1] = 1.7763568394002506e-16 = #3ca99999 9999999a
+g_ddfmt(0) gives 3 bytes: "1.3"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ff4cccc cccccccc + 3ca99999 99999999
+= 1.2999999999999998 + 1.7763568394002503e-16
+ddI[1] = #3ff4cccc cccccccc + 3ca99999 9999999a
+= 1.2999999999999998 + 1.7763568394002506e-16
+ddI[1] == strtod
+
+
+Input: -1.3
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.2999999999999998 = #bff4cccc cccccccc
+dd[1] = -1.7763568394002506e-16 = #bca99999 9999999a
+g_ddfmt(0) gives 4 bytes: "-1.3"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bff4cccc cccccccc + bca99999 9999999a
+= -1.2999999999999998 + -1.7763568394002506e-16
+ddI[1] = #bff4cccc cccccccc + bca99999 99999999
+= -1.2999999999999998 + -1.7763568394002503e-16
+ddI[0] == strtod
+
+
+Input: 1.4
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.4 = #3ff66666 66666666
+dd[1] = 8.881784197001253e-17 = #3c999999 9999999a
+g_ddfmt(0) gives 3 bytes: "1.4"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ff66666 66666666 + 3c999999 99999998
+= 1.3999999999999999 + 8.8817841970012504e-17
+ddI[1] = #3ff66666 66666666 + 3c999999 9999999a
+= 1.3999999999999999 + 8.8817841970012528e-17
+ddI[1] == strtod
+
+
+Input: -1.4
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.4 = #bff66666 66666666
+dd[1] = -8.881784197001253e-17 = #bc999999 9999999a
+g_ddfmt(0) gives 4 bytes: "-1.4"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bff66666 66666666 + bc999999 9999999a
+= -1.3999999999999999 + -8.8817841970012528e-17
+ddI[1] = #bff66666 66666666 + bc999999 99999998
+= -1.3999999999999999 + -8.8817841970012504e-17
+ddI[0] == strtod
+
+
+Input: 1.5
+strtopdd consumes 3 bytes and returns 1
+dd[0] = 1.5 = #3ff80000 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 3 bytes: "1.5"
+
+strtoIdd returns 1, consuming 3 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: -1.5
+strtopdd consumes 4 bytes and returns 9
+dd[0] = -1.5 = #bff80000 0
+dd[1] = -0 = #80000000 0
+g_ddfmt(0) gives 3 bytes: "1.5"
+
+strtoIdd returns 9, consuming 4 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.6
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.5999999999999999 = #3ff99999 99999999
+dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333
+g_ddfmt(0) gives 3 bytes: "1.6"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff99999 99999999 + 3ca33333 33333333
+= 1.5999999999999999 + 1.3322676295501878e-16
+ddI[1] = #3ff99999 99999999 + 3ca33333 33333334
+= 1.5999999999999999 + 1.332267629550188e-16
+ddI[0] == strtod
+
+
+Input: -1.6
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.5999999999999999 = #bff99999 99999999
+dd[1] = -1.3322676295501878e-16 = #bca33333 33333333
+g_ddfmt(0) gives 4 bytes: "-1.6"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff99999 99999999 + bca33333 33333334
+= -1.5999999999999999 + -1.332267629550188e-16
+ddI[1] = #bff99999 99999999 + bca33333 33333333
+= -1.5999999999999999 + -1.3322676295501878e-16
+ddI[1] == strtod
+
+
+Input: 1.7
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.7 = #3ffb3333 33333333
+dd[1] = 4.440892098500625e-17 = #3c899999 99999998
+g_ddfmt(0) gives 3 bytes: "1.7"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ffb3333 33333333 + 3c899999 99999998
+= 1.7 + 4.4408920985006252e-17
+ddI[1] = #3ffb3333 33333333 + 3c899999 9999999c
+= 1.7 + 4.4408920985006276e-17
+ddI[0] == strtod
+
+
+Input: -1.7
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.7 = #bffb3333 33333333
+dd[1] = -4.440892098500625e-17 = #bc899999 99999998
+g_ddfmt(0) gives 4 bytes: "-1.7"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bffb3333 33333333 + bc899999 9999999c
+= -1.7 + -4.4408920985006276e-17
+ddI[1] = #bffb3333 33333333 + bc899999 99999998
+= -1.7 + -4.4408920985006252e-17
+ddI[1] == strtod
+
+
+Input: 1.8
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.7999999999999998 = #3ffccccc cccccccc
+dd[1] = 1.7763568394002506e-16 = #3ca99999 9999999a
+g_ddfmt(0) gives 3 bytes: "1.8"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ffccccc cccccccc + 3ca99999 99999999
+= 1.7999999999999998 + 1.7763568394002503e-16
+ddI[1] = #3ffccccc cccccccc + 3ca99999 9999999a
+= 1.7999999999999998 + 1.7763568394002506e-16
+ddI[1] == strtod
+
+
+Input: -1.8
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.7999999999999998 = #bffccccc cccccccc
+dd[1] = -1.7763568394002506e-16 = #bca99999 9999999a
+g_ddfmt(0) gives 4 bytes: "-1.8"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bffccccc cccccccc + bca99999 9999999a
+= -1.7999999999999998 + -1.7763568394002506e-16
+ddI[1] = #bffccccc cccccccc + bca99999 99999999
+= -1.7999999999999998 + -1.7763568394002503e-16
+ddI[0] == strtod
+
+
+Input: 1.9
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.9 = #3ffe6666 66666666
+dd[1] = 8.881784197001253e-17 = #3c999999 9999999a
+g_ddfmt(0) gives 3 bytes: "1.9"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ffe6666 66666666 + 3c999999 99999998
+= 1.8999999999999999 + 8.8817841970012504e-17
+ddI[1] = #3ffe6666 66666666 + 3c999999 9999999a
+= 1.8999999999999999 + 8.8817841970012528e-17
+ddI[1] == strtod
+
+
+Input: -1.9
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.9 = #bffe6666 66666666
+dd[1] = -8.881784197001253e-17 = #bc999999 9999999a
+g_ddfmt(0) gives 4 bytes: "-1.9"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bffe6666 66666666 + bc999999 9999999a
+= -1.8999999999999999 + -8.8817841970012528e-17
+ddI[1] = #bffe6666 66666666 + bc999999 99999998
+= -1.8999999999999999 + -8.8817841970012504e-17
+ddI[0] == strtod
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.0999999999999999 = #3ff19999 99999999
+dd[1] = 1.332267629550188e-16 = #3ca33333 33333334
+g_ddfmt(0) gives 34 bytes: "1.10000000000000000000000000000002"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff19999 99999999 + 3ca33333 33333333
+= 1.0999999999999999 + 1.3322676295501878e-16
+ddI[1] = #3ff19999 99999999 + 3ca33333 33333334
+= 1.0999999999999999 + 1.332267629550188e-16
+ddI[1] == strtod
+
+
+Input: -1.1
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.0999999999999999 = #bff19999 99999999
+dd[1] = -1.3322676295501878e-16 = #bca33333 33333333
+g_ddfmt(0) gives 4 bytes: "-1.1"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff19999 99999999 + bca33333 33333334
+= -1.0999999999999999 + -1.332267629550188e-16
+ddI[1] = #bff19999 99999999 + bca33333 33333333
+= -1.0999999999999999 + -1.3322676295501878e-16
+ddI[1] == strtod
+
+
+Input: 1.2
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.2 = #3ff33333 33333333
+dd[1] = 4.4408920985006276e-17 = #3c899999 9999999c
+g_ddfmt(0) gives 34 bytes: "1.20000000000000000000000000000001"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff33333 33333333 + 3c899999 99999998
+= 1.2 + 4.4408920985006252e-17
+ddI[1] = #3ff33333 33333333 + 3c899999 9999999c
+= 1.2 + 4.4408920985006276e-17
+ddI[1] == strtod
+
+
+Input: -1.2
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.2 = #bff33333 33333333
+dd[1] = -4.440892098500625e-17 = #bc899999 99999998
+g_ddfmt(0) gives 4 bytes: "-1.2"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff33333 33333333 + bc899999 9999999c
+= -1.2 + -4.4408920985006276e-17
+ddI[1] = #bff33333 33333333 + bc899999 99999998
+= -1.2 + -4.4408920985006252e-17
+ddI[1] == strtod
+
+
+Input: 1.3
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.2999999999999998 = #3ff4cccc cccccccc
+dd[1] = 1.7763568394002506e-16 = #3ca99999 9999999a
+g_ddfmt(0) gives 3 bytes: "1.3"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ff4cccc cccccccc + 3ca99999 99999999
+= 1.2999999999999998 + 1.7763568394002503e-16
+ddI[1] = #3ff4cccc cccccccc + 3ca99999 9999999a
+= 1.2999999999999998 + 1.7763568394002506e-16
+ddI[1] == strtod
+
+
+Input: -1.3
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.2999999999999998 = #bff4cccc cccccccc
+dd[1] = -1.7763568394002503e-16 = #bca99999 99999999
+g_ddfmt(0) gives 35 bytes: "-1.29999999999999999999999999999999"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bff4cccc cccccccc + bca99999 9999999a
+= -1.2999999999999998 + -1.7763568394002506e-16
+ddI[1] = #bff4cccc cccccccc + bca99999 99999999
+= -1.2999999999999998 + -1.7763568394002503e-16
+ddI[1] == strtod
+
+
+Input: 1.4
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.4 = #3ff66666 66666666
+dd[1] = 8.881784197001253e-17 = #3c999999 9999999a
+g_ddfmt(0) gives 3 bytes: "1.4"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ff66666 66666666 + 3c999999 99999998
+= 1.3999999999999999 + 8.8817841970012504e-17
+ddI[1] = #3ff66666 66666666 + 3c999999 9999999a
+= 1.3999999999999999 + 8.8817841970012528e-17
+ddI[1] == strtod
+
+
+Input: -1.4
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.4 = #bff66666 66666666
+dd[1] = -8.88178419700125e-17 = #bc999999 99999998
+g_ddfmt(0) gives 35 bytes: "-1.39999999999999999999999999999998"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bff66666 66666666 + bc999999 9999999a
+= -1.3999999999999999 + -8.8817841970012528e-17
+ddI[1] = #bff66666 66666666 + bc999999 99999998
+= -1.3999999999999999 + -8.8817841970012504e-17
+ddI[1] == strtod
+
+
+Input: 1.5
+strtopdd consumes 3 bytes and returns 1
+dd[0] = 1.5 = #3ff80000 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 3 bytes: "1.5"
+
+strtoIdd returns 1, consuming 3 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: -1.5
+strtopdd consumes 4 bytes and returns 9
+dd[0] = -1.5 = #bff80000 0
+dd[1] = -0 = #80000000 0
+g_ddfmt(0) gives 3 bytes: "1.5"
+
+strtoIdd returns 9, consuming 4 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.6
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.5999999999999999 = #3ff99999 99999999
+dd[1] = 1.332267629550188e-16 = #3ca33333 33333334
+g_ddfmt(0) gives 34 bytes: "1.60000000000000000000000000000002"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff99999 99999999 + 3ca33333 33333333
+= 1.5999999999999999 + 1.3322676295501878e-16
+ddI[1] = #3ff99999 99999999 + 3ca33333 33333334
+= 1.5999999999999999 + 1.332267629550188e-16
+ddI[1] == strtod
+
+
+Input: -1.6
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.5999999999999999 = #bff99999 99999999
+dd[1] = -1.3322676295501878e-16 = #bca33333 33333333
+g_ddfmt(0) gives 4 bytes: "-1.6"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff99999 99999999 + bca33333 33333334
+= -1.5999999999999999 + -1.332267629550188e-16
+ddI[1] = #bff99999 99999999 + bca33333 33333333
+= -1.5999999999999999 + -1.3322676295501878e-16
+ddI[1] == strtod
+
+
+Input: 1.7
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.7 = #3ffb3333 33333333
+dd[1] = 4.4408920985006276e-17 = #3c899999 9999999c
+g_ddfmt(0) gives 34 bytes: "1.70000000000000000000000000000001"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ffb3333 33333333 + 3c899999 99999998
+= 1.7 + 4.4408920985006252e-17
+ddI[1] = #3ffb3333 33333333 + 3c899999 9999999c
+= 1.7 + 4.4408920985006276e-17
+ddI[1] == strtod
+
+
+Input: -1.7
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.7 = #bffb3333 33333333
+dd[1] = -4.440892098500625e-17 = #bc899999 99999998
+g_ddfmt(0) gives 4 bytes: "-1.7"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bffb3333 33333333 + bc899999 9999999c
+= -1.7 + -4.4408920985006276e-17
+ddI[1] = #bffb3333 33333333 + bc899999 99999998
+= -1.7 + -4.4408920985006252e-17
+ddI[1] == strtod
+
+
+Input: 1.8
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.7999999999999998 = #3ffccccc cccccccc
+dd[1] = 1.7763568394002506e-16 = #3ca99999 9999999a
+g_ddfmt(0) gives 3 bytes: "1.8"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ffccccc cccccccc + 3ca99999 99999999
+= 1.7999999999999998 + 1.7763568394002503e-16
+ddI[1] = #3ffccccc cccccccc + 3ca99999 9999999a
+= 1.7999999999999998 + 1.7763568394002506e-16
+ddI[1] == strtod
+
+
+Input: -1.8
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.7999999999999998 = #bffccccc cccccccc
+dd[1] = -1.7763568394002503e-16 = #bca99999 99999999
+g_ddfmt(0) gives 35 bytes: "-1.79999999999999999999999999999999"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bffccccc cccccccc + bca99999 9999999a
+= -1.7999999999999998 + -1.7763568394002506e-16
+ddI[1] = #bffccccc cccccccc + bca99999 99999999
+= -1.7999999999999998 + -1.7763568394002503e-16
+ddI[1] == strtod
+
+
+Input: 1.9
+strtopdd consumes 3 bytes and returns 33
+dd[0] = 1.9 = #3ffe6666 66666666
+dd[1] = 8.881784197001253e-17 = #3c999999 9999999a
+g_ddfmt(0) gives 3 bytes: "1.9"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ffe6666 66666666 + 3c999999 99999998
+= 1.8999999999999999 + 8.8817841970012504e-17
+ddI[1] = #3ffe6666 66666666 + 3c999999 9999999a
+= 1.8999999999999999 + 8.8817841970012528e-17
+ddI[1] == strtod
+
+
+Input: -1.9
+strtopdd consumes 4 bytes and returns 25
+dd[0] = -1.9 = #bffe6666 66666666
+dd[1] = -8.88178419700125e-17 = #bc999999 99999998
+g_ddfmt(0) gives 35 bytes: "-1.89999999999999999999999999999998"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bffe6666 66666666 + bc999999 9999999a
+= -1.8999999999999999 + -8.8817841970012528e-17
+ddI[1] = #bffe6666 66666666 + bc999999 99999998
+= -1.8999999999999999 + -8.8817841970012504e-17
+ddI[1] == strtod
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.0999999999999999 = #3ff19999 99999999
+dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333
+g_ddfmt(0) gives 3 bytes: "1.1"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff19999 99999999 + 3ca33333 33333333
+= 1.0999999999999999 + 1.3322676295501878e-16
+ddI[1] = #3ff19999 99999999 + 3ca33333 33333334
+= 1.0999999999999999 + 1.332267629550188e-16
+ddI[0] == strtod
+
+
+Input: -1.1
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.0999999999999999 = #bff19999 99999999
+dd[1] = -1.332267629550188e-16 = #bca33333 33333334
+g_ddfmt(0) gives 35 bytes: "-1.10000000000000000000000000000002"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff19999 99999999 + bca33333 33333334
+= -1.0999999999999999 + -1.332267629550188e-16
+ddI[1] = #bff19999 99999999 + bca33333 33333333
+= -1.0999999999999999 + -1.3322676295501878e-16
+ddI[0] == strtod
+
+
+Input: 1.2
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.2 = #3ff33333 33333333
+dd[1] = 4.440892098500625e-17 = #3c899999 99999998
+g_ddfmt(0) gives 3 bytes: "1.2"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff33333 33333333 + 3c899999 99999998
+= 1.2 + 4.4408920985006252e-17
+ddI[1] = #3ff33333 33333333 + 3c899999 9999999c
+= 1.2 + 4.4408920985006276e-17
+ddI[0] == strtod
+
+
+Input: -1.2
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.2 = #bff33333 33333333
+dd[1] = -4.4408920985006276e-17 = #bc899999 9999999c
+g_ddfmt(0) gives 35 bytes: "-1.20000000000000000000000000000001"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff33333 33333333 + bc899999 9999999c
+= -1.2 + -4.4408920985006276e-17
+ddI[1] = #bff33333 33333333 + bc899999 99999998
+= -1.2 + -4.4408920985006252e-17
+ddI[0] == strtod
+
+
+Input: 1.3
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.2999999999999998 = #3ff4cccc cccccccc
+dd[1] = 1.7763568394002503e-16 = #3ca99999 99999999
+g_ddfmt(0) gives 34 bytes: "1.29999999999999999999999999999999"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ff4cccc cccccccc + 3ca99999 99999999
+= 1.2999999999999998 + 1.7763568394002503e-16
+ddI[1] = #3ff4cccc cccccccc + 3ca99999 9999999a
+= 1.2999999999999998 + 1.7763568394002506e-16
+ddI[0] == strtod
+
+
+Input: -1.3
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.2999999999999998 = #bff4cccc cccccccc
+dd[1] = -1.7763568394002506e-16 = #bca99999 9999999a
+g_ddfmt(0) gives 4 bytes: "-1.3"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bff4cccc cccccccc + bca99999 9999999a
+= -1.2999999999999998 + -1.7763568394002506e-16
+ddI[1] = #bff4cccc cccccccc + bca99999 99999999
+= -1.2999999999999998 + -1.7763568394002503e-16
+ddI[0] == strtod
+
+
+Input: 1.4
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.4 = #3ff66666 66666666
+dd[1] = 8.88178419700125e-17 = #3c999999 99999998
+g_ddfmt(0) gives 34 bytes: "1.39999999999999999999999999999998"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ff66666 66666666 + 3c999999 99999998
+= 1.3999999999999999 + 8.8817841970012504e-17
+ddI[1] = #3ff66666 66666666 + 3c999999 9999999a
+= 1.3999999999999999 + 8.8817841970012528e-17
+ddI[0] == strtod
+
+
+Input: -1.4
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.4 = #bff66666 66666666
+dd[1] = -8.881784197001253e-17 = #bc999999 9999999a
+g_ddfmt(0) gives 4 bytes: "-1.4"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bff66666 66666666 + bc999999 9999999a
+= -1.3999999999999999 + -8.8817841970012528e-17
+ddI[1] = #bff66666 66666666 + bc999999 99999998
+= -1.3999999999999999 + -8.8817841970012504e-17
+ddI[0] == strtod
+
+
+Input: 1.5
+strtopdd consumes 3 bytes and returns 1
+dd[0] = 1.5 = #3ff80000 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 3 bytes: "1.5"
+
+strtoIdd returns 1, consuming 3 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: -1.5
+strtopdd consumes 4 bytes and returns 9
+dd[0] = -1.5 = #bff80000 0
+dd[1] = -0 = #80000000 0
+g_ddfmt(0) gives 3 bytes: "1.5"
+
+strtoIdd returns 9, consuming 4 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.6
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.5999999999999999 = #3ff99999 99999999
+dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333
+g_ddfmt(0) gives 3 bytes: "1.6"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ff99999 99999999 + 3ca33333 33333333
+= 1.5999999999999999 + 1.3322676295501878e-16
+ddI[1] = #3ff99999 99999999 + 3ca33333 33333334
+= 1.5999999999999999 + 1.332267629550188e-16
+ddI[0] == strtod
+
+
+Input: -1.6
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.5999999999999999 = #bff99999 99999999
+dd[1] = -1.332267629550188e-16 = #bca33333 33333334
+g_ddfmt(0) gives 35 bytes: "-1.60000000000000000000000000000002"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bff99999 99999999 + bca33333 33333334
+= -1.5999999999999999 + -1.332267629550188e-16
+ddI[1] = #bff99999 99999999 + bca33333 33333333
+= -1.5999999999999999 + -1.3322676295501878e-16
+ddI[0] == strtod
+
+
+Input: 1.7
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.7 = #3ffb3333 33333333
+dd[1] = 4.440892098500625e-17 = #3c899999 99999998
+g_ddfmt(0) gives 3 bytes: "1.7"
+
+strtoIdd returns 17, consuming 3 bytes.
+ddI[0] = #3ffb3333 33333333 + 3c899999 99999998
+= 1.7 + 4.4408920985006252e-17
+ddI[1] = #3ffb3333 33333333 + 3c899999 9999999c
+= 1.7 + 4.4408920985006276e-17
+ddI[0] == strtod
+
+
+Input: -1.7
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.7 = #bffb3333 33333333
+dd[1] = -4.4408920985006276e-17 = #bc899999 9999999c
+g_ddfmt(0) gives 35 bytes: "-1.70000000000000000000000000000001"
+
+strtoIdd returns 25, consuming 4 bytes.
+ddI[0] = #bffb3333 33333333 + bc899999 9999999c
+= -1.7 + -4.4408920985006276e-17
+ddI[1] = #bffb3333 33333333 + bc899999 99999998
+= -1.7 + -4.4408920985006252e-17
+ddI[0] == strtod
+
+
+Input: 1.8
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.7999999999999998 = #3ffccccc cccccccc
+dd[1] = 1.7763568394002503e-16 = #3ca99999 99999999
+g_ddfmt(0) gives 34 bytes: "1.79999999999999999999999999999999"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ffccccc cccccccc + 3ca99999 99999999
+= 1.7999999999999998 + 1.7763568394002503e-16
+ddI[1] = #3ffccccc cccccccc + 3ca99999 9999999a
+= 1.7999999999999998 + 1.7763568394002506e-16
+ddI[0] == strtod
+
+
+Input: -1.8
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.7999999999999998 = #bffccccc cccccccc
+dd[1] = -1.7763568394002506e-16 = #bca99999 9999999a
+g_ddfmt(0) gives 4 bytes: "-1.8"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bffccccc cccccccc + bca99999 9999999a
+= -1.7999999999999998 + -1.7763568394002506e-16
+ddI[1] = #bffccccc cccccccc + bca99999 99999999
+= -1.7999999999999998 + -1.7763568394002503e-16
+ddI[0] == strtod
+
+
+Input: 1.9
+strtopdd consumes 3 bytes and returns 17
+dd[0] = 1.9 = #3ffe6666 66666666
+dd[1] = 8.88178419700125e-17 = #3c999999 99999998
+g_ddfmt(0) gives 34 bytes: "1.89999999999999999999999999999998"
+
+strtoIdd returns 33, consuming 3 bytes.
+ddI[0] = #3ffe6666 66666666 + 3c999999 99999998
+= 1.8999999999999999 + 8.8817841970012504e-17
+ddI[1] = #3ffe6666 66666666 + 3c999999 9999999a
+= 1.8999999999999999 + 8.8817841970012528e-17
+ddI[0] == strtod
+
+
+Input: -1.9
+strtopdd consumes 4 bytes and returns 41
+dd[0] = -1.9 = #bffe6666 66666666
+dd[1] = -8.881784197001253e-17 = #bc999999 9999999a
+g_ddfmt(0) gives 4 bytes: "-1.9"
+
+strtoIdd returns 41, consuming 4 bytes.
+ddI[0] = #bffe6666 66666666 + bc999999 9999999a
+= -1.8999999999999999 + -8.8817841970012528e-17
+ddI[1] = #bffe6666 66666666 + bc999999 99999998
+= -1.8999999999999999 + -8.8817841970012504e-17
+ddI[0] == strtod
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/ddsi.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/ddsi.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/ddsi.out	(revision 2404)
@@ -0,0 +1,376 @@
+
+Input: 1.23
+strtopdd consumes 4 bytes and returns 17
+dd[0] = 1.23 = #3ff3ae14 7ae147ae
+dd[1] = 1.7763568394002496e-17 = #3c747ae1 47ae1478
+g_ddfmt(0) gives 4 bytes: "1.23"
+
+strtoIdd returns 17, consuming 4 bytes.
+ddI[0] = #3ff3ae14 7ae147ae + 3c747ae1 47ae1478
+= 1.23 + 1.7763568394002496e-17
+ddI[1] = #3ff3ae14 7ae147ae + 3c747ae1 47ae1480
+= 1.23 + 1.776356839400252e-17
+ddI[0] == strtod
+
+
+Input: 1.23e+20
+strtopdd consumes 8 bytes and returns 1
+dd[0] = 1.23e+20 = #441aabdf 2145b430
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIdd returns 1, consuming 8 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.23e-20
+strtopdd consumes 8 bytes and returns 33
+dd[0] = 1.2299999999999999e-20 = #3bcd0ae4 cf767530
+dd[1] = 9.304023318521521e-37 = #3873c997 955b2691
+g_ddfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIdd returns 33, consuming 8 bytes.
+ddI[0] = #3bcd0ae4 cf767530 + 3873c997 955b2690
+= 1.2299999999999999e-20 + 9.3040233185215194e-37
+ddI[1] = #3bcd0ae4 cf767530 + 3873c997 955b2691
+= 1.2299999999999999e-20 + 9.3040233185215211e-37
+ddI[1] == strtod
+
+
+Input: 1.23456789
+strtopdd consumes 10 bytes and returns 17
+dd[0] = 1.23456789 = #3ff3c0ca 4283de1b
+dd[1] = 1.0990618193318369e-16 = #3c9fada5 144c1252
+g_ddfmt(0) gives 10 bytes: "1.23456789"
+
+strtoIdd returns 17, consuming 10 bytes.
+ddI[0] = #3ff3c0ca 4283de1b + 3c9fada5 144c1252
+= 1.2345678899999999 + 1.0990618193318369e-16
+ddI[1] = #3ff3c0ca 4283de1b + 3c9fada5 144c1254
+= 1.2345678899999999 + 1.0990618193318371e-16
+ddI[0] == strtod
+
+
+Input: 1.23456589e+20
+strtopdd consumes 14 bytes and returns 1
+dd[0] = 1.23456589e+20 = #441ac537 a660b997
+dd[1] = 4096 = #40b00000 0
+g_ddfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoIdd returns 1, consuming 14 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.23e+30
+strtopdd consumes 8 bytes and returns 1
+dd[0] = 1.23e+30 = #462f0cb0 4e8fb790
+dd[1] = 40281156091904 = #42c25158 0
+g_ddfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIdd returns 1, consuming 8 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1.23e-30
+strtopdd consumes 8 bytes and returns 17
+dd[0] = 1.2299999999999999e-30 = #39b8f286 6f5010aa
+dd[1] = 1.076909723013918e-46 = #3663ac7f 3dafd174
+g_ddfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIdd returns 17, consuming 8 bytes.
+ddI[0] = #39b8f286 6f5010aa + 3663ac7f 3dafd174
+= 1.2299999999999999e-30 + 1.076909723013918e-46
+ddI[1] = #39b8f286 6f5010aa + 3663ac7f 3dafd175
+= 1.2299999999999999e-30 + 1.0769097230139181e-46
+ddI[0] == strtod
+
+
+Input: 1.23456789e-20
+strtopdd consumes 14 bytes and returns 17
+dd[0] = 1.23456789e-20 = #3bcd2681 471e7ada
+dd[1] = 6.247111971663133e-37 = #386a9280 a761b07e
+g_ddfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoIdd returns 17, consuming 14 bytes.
+ddI[0] = #3bcd2681 471e7ada + 386a9280 a761b07e
+= 1.2345678899999999e-20 + 6.2471119716631328e-37
+ddI[1] = #3bcd2681 471e7ada + 386a9280 a761b080
+= 1.2345678899999999e-20 + 6.2471119716631345e-37
+ddI[0] == strtod
+
+
+Input: 1.23456789e-30
+strtopdd consumes 14 bytes and returns 33
+dd[0] = 1.23456789e-30 = #39b90a3e 33bbd995
+dd[1] = 2.1567930523648577e-47 = #363f8585 55a6b1a0
+g_ddfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoIdd returns 33, consuming 14 bytes.
+ddI[0] = #39b90a3e 33bbd995 + 363f8585 55a6b198
+= 1.23456789e-30 + 2.1567930523648558e-47
+ddI[1] = #39b90a3e 33bbd995 + 363f8585 55a6b1a0
+= 1.23456789e-30 + 2.1567930523648577e-47
+ddI[1] == strtod
+
+
+Input: 1.234567890123456789
+strtopdd consumes 20 bytes and returns 33
+dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb
+dd[1] = 9.856786452588859e-17 = #3c9c6906 51a3745e
+g_ddfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIdd returns 33, consuming 20 bytes.
+ddI[0] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745c
+= 1.2345678901234567 + 9.8567864525888563e-17
+ddI[1] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745e
+= 1.2345678901234567 + 9.8567864525888588e-17
+ddI[1] == strtod
+
+
+Input: 1.23456789012345678901234567890123456789
+strtopdd consumes 40 bytes and returns 33
+dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb
+dd[1] = 9.858021020478982e-17 = #3c9c69ef 85adadb6
+g_ddfmt(0) gives 34 bytes: "1.23456789012345678901234567890124"
+
+strtoIdd returns 33, consuming 40 bytes.
+ddI[0] = #3ff3c0ca 428c59fb + 3c9c69ef 85adadb4
+= 1.2345678901234567 + 9.8580210204789798e-17
+ddI[1] = #3ff3c0ca 428c59fb + 3c9c69ef 85adadb6
+= 1.2345678901234567 + 9.8580210204789823e-17
+ddI[1] == strtod
+
+
+Input: 1.23e306
+strtopdd consumes 8 bytes and returns 33
+dd[0] = 1.2299999999999999e+306 = #7f7c0676 cd1c61f4
+dd[1] = 1.3319001448659015e+290 = #7c2b558b e3d3f477
+g_ddfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoIdd returns 33, consuming 8 bytes.
+ddI[0] = #7f7c0676 cd1c61f4 + 7c2b558b e3d3f476
+= 1.2299999999999999e+306 + 1.3319001448659013e+290
+ddI[1] = #7f7c0676 cd1c61f4 + 7c2b558b e3d3f477
+= 1.2299999999999999e+306 + 1.3319001448659015e+290
+ddI[1] == strtod
+
+
+Input: 1.23e-306
+strtopdd consumes 9 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 9 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
+
+Input: 1.23e-320
+strtopdd consumes 9 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 9 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
+
+Input: 1.23e-20
+strtopdd consumes 8 bytes and returns 33
+dd[0] = 1.2299999999999999e-20 = #3bcd0ae4 cf767530
+dd[1] = 9.304023318521521e-37 = #3873c997 955b2691
+g_ddfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIdd returns 33, consuming 8 bytes.
+ddI[0] = #3bcd0ae4 cf767530 + 3873c997 955b2690
+= 1.2299999999999999e-20 + 9.3040233185215194e-37
+ddI[1] = #3bcd0ae4 cf767530 + 3873c997 955b2691
+= 1.2299999999999999e-20 + 9.3040233185215211e-37
+ddI[1] == strtod
+
+
+Input: 1.23456789e307
+strtopdd consumes 14 bytes and returns 33
+dd[0] = 1.2345678899999998e+307 = #7fb194b1 4bdaecdb
+dd[1] = 2.0137933598720243e+291 = #7c69d48d 192048ca
+g_ddfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoIdd returns 33, consuming 14 bytes.
+ddI[0] = #7fb194b1 4bdaecdb + 7c69d48d 192048c9
+= 1.2345678899999998e+307 + 2.013793359872024e+291
+ddI[1] = #7fb194b1 4bdaecdb + 7c69d48d 192048ca
+= 1.2345678899999998e+307 + 2.0137933598720243e+291
+ddI[1] == strtod
+
+
+Input: 1.23456589e-307
+strtopdd consumes 15 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 15 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
+
+Input: 1.234567890123456789
+strtopdd consumes 20 bytes and returns 33
+dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb
+dd[1] = 9.856786452588859e-17 = #3c9c6906 51a3745e
+g_ddfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIdd returns 33, consuming 20 bytes.
+ddI[0] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745c
+= 1.2345678901234567 + 9.8567864525888563e-17
+ddI[1] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745e
+= 1.2345678901234567 + 9.8567864525888588e-17
+ddI[1] == strtod
+
+
+Input: 1.234567890123456789e301
+strtopdd consumes 24 bytes and returns 33
+dd[0] = 1.2345678901234568e+301 = #7e726f51 75f56413
+dd[1] = 1.3892003943918827e+283 = #7ab7ea80 76399100
+g_ddfmt(0) gives 25 bytes: "1.234567890123456789e+301"
+
+strtoIdd returns 33, consuming 24 bytes.
+ddI[0] = #7e726f51 75f56413 + 7ab7ea80 76399080
+= 1.2345678901234568e+301 + 1.3892003943918563e+283
+ddI[1] = #7e726f51 75f56413 + 7ab7ea80 76399100
+= 1.2345678901234568e+301 + 1.3892003943918827e+283
+ddI[1] == strtod
+
+
+Input: 1.234567890123456789e-301
+strtopdd consumes 25 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 25 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
+
+Input: 1.234567890123456789e-321
+strtopdd consumes 25 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 25 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
+
+Input: 1e23
+strtopdd consumes 4 bytes and returns 1
+dd[0] = 1e+23 = #44b52d02 c7e14af6
+dd[1] = 8388608 = #41600000 0
+g_ddfmt(0) gives 5 bytes: "1e+23"
+
+strtoIdd returns 1, consuming 4 bytes.
+ddI[0] == ddI[1] == strtopdd
+
+
+Input: 1e310
+strtopdd consumes 5 bytes and returns 163
+dd[0] = Infinity = #7ff00000 0
+dd[1] = Infinity = #7ff00000 0
+g_ddfmt(0) gives 8 bytes: "Infinity"
+
+strtoIdd returns 163, consuming 5 bytes.
+ddI[0] = #7fefffff ffffffff + 7c9fffff ffffffff
+= 1.7976931348623157e+308 + 1.9958403095347196e+292
+ddI[1] = #7ff00000 0 + 7ff00000 0
+= Infinity + Infinity
+ddI[1] == strtod
+
+
+Input: 9.0259718793241475e-277
+strtopdd consumes 23 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 23 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
+
+Input: 9.025971879324147880346310405869e-277
+strtopdd consumes 37 bytes and returns 17
+dd[0] = 9.025971879324148e-277 = #6a00000 0
+dd[1] = 2.2250738585072014e-308 = #100000 0
+g_ddfmt(0) gives 37 bytes: "9.025971879324147880346310405869e-277"
+
+strtoIdd returns 17, consuming 37 bytes.
+ddI[0] = #6a00000 0 + 100000 0
+= 9.0259718793241479e-277 + 2.2250738585072014e-308
+ddI[1] = #6a00000 0 + 200000 0
+= 9.0259718793241479e-277 + 4.4501477170144028e-308
+ddI[0] == strtod
+
+
+Input: 9.025971879324147880346310405868e-277
+strtopdd consumes 37 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 37 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
+
+Input: 2.2250738585072014e-308
+strtopdd consumes 23 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 23 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
+
+Input: 2.2250738585072013e-308
+strtopdd consumes 23 bytes and returns 80
+dd[0] = 0 = #0 0
+dd[1] = 0 = #0 0
+g_ddfmt(0) gives 1 bytes: "0"
+
+strtoIdd returns 80, consuming 23 bytes.
+ddI[0] = #0 0 + 0 0
+= 0 + 0
+ddI[1] = #6a00000 0 + 0 0
+= 9.0259718793241479e-277 + 0
+ddI[0] == strtod
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/ddtest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/ddtest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/ddtest.c	(revision 2404)
@@ -0,0 +1,183 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* Test program for g_ddfmt, strtoIdd, strtopdd, and strtordd.
+ *
+ * Inputs (on stdin):
+ *		r rounding_mode
+ *		n ndig
+ *		number
+ *		#hex0 hex1 hex2 hex3
+ *
+ *	rounding_mode values:
+ *		0 = toward zero
+ *		1 = nearest
+ *		2 = toward +Infinity
+ *		3 = toward -Infinity
+ *
+ * where number is a decimal floating-point number,
+ * hex0 is a string of <= 8 Hex digits for the most significant
+ * word of the number, hex1 is a similar string for the next
+ * word, etc., and ndig is a parameters to g_ddfmt.
+ */
+
+#include "gdtoaimp.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+ extern int getround ANSI((int,char*));
+
+ static char ibuf[2048], obuf[1024];
+
+#define U (unsigned long)
+
+ static void
+#ifdef KR_headers
+dprint(what, d) char *what; double d;
+#else
+dprint(char *what, double d)
+#endif
+{
+	char buf[32];
+	ULong *L = (ULong*)&d;
+
+	g_dfmt(buf,&d,0,sizeof(buf));
+	printf("%s = %s = #%lx %lx\n", what, buf, U L[_0], U L[_1]);
+	}
+
+ int
+main(Void)
+{
+	ULong *L;
+	char *s, *s1, *se, *se1;
+	int dItry, i, j, r = 1, ndig = 0;
+	double dd[2], ddI[4];
+	long LL[4];
+
+	L = (ULong*)&dd[0];
+	while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) {
+		while(*s <= ' ')
+			if (!*s++)
+				continue;
+		dItry = 0;
+		switch(*s) {
+		  case 'r':
+			r = getround(r, s);
+			continue;
+		  case 'n':
+			i = s[1];
+			if (i <= ' ' || i >= '0' && i <= '9') {
+				ndig = atoi(s+1);
+				continue;
+				}
+			break; /* nan? */
+		  case '#':
+			LL[0] = L[_0];
+			LL[1] = L[_1];
+			LL[2] = L[2+_0];
+			LL[3] = L[2+_1];
+			sscanf(s+1, "%lx %lx %lx %lx", &LL[0], &LL[1],
+				&LL[2], &LL[3]);
+			L[_0] = LL[0];
+			L[_1] = LL[1];
+			L[2+_0] = LL[2];
+			L[2+_1] = LL[3];
+			printf("\nInput: %s", ibuf);
+			printf(" --> f = #%lx %lx %lx %lx\n",
+				LL[0],LL[1],LL[2],LL[3]);
+			goto fmt_test;
+			}
+		printf("\nInput: %s", ibuf);
+		for(s1 = s; *s1 > ' '; s1++){};
+		while(*s1 <= ' ' && *s1) s1++;
+		if (!*s1) {
+			dItry = 1;
+			i = strtordd(ibuf, &se, r, dd);
+			if (r == 1) {
+				j = strtopdd(ibuf, &se1, ddI);
+				if (i != j || dd[0] != ddI[0]
+				 || dd[1] != ddI[1] || se != se1)
+					printf("***strtopdd and strtordd disagree!!\n:");
+				}
+			printf("strtopdd consumes %d bytes and returns %d\n",
+				(int)(se-ibuf), i);
+			}
+		else {
+			dd[0] = strtod(s, &se);
+			dd[1] = strtod(se, &se);
+			}
+ fmt_test:
+		dprint("dd[0]", dd[0]);
+		dprint("dd[1]", dd[1]);
+		se = g_ddfmt(obuf, dd, ndig, sizeof(obuf));
+		printf("g_ddfmt(%d) gives %d bytes: \"%s\"\n\n",
+			ndig, (int)(se-obuf), se ? obuf : "<null>");
+		if (!dItry)
+			continue;
+		printf("strtoIdd returns %d,", strtoIdd(ibuf, &se, ddI,&ddI[2]));
+		printf(" consuming %d bytes.\n", (int)(se-ibuf));
+		if (ddI[0] == ddI[2] && ddI[1] == ddI[3]) {
+			if (ddI[0] == dd[0] && ddI[1] == dd[1])
+				printf("ddI[0] == ddI[1] == strtopdd\n");
+			else
+				printf("ddI[0] == ddI[1] = #%lx %lx + %lx %lx\n= %.17g + %17.g\n",
+					U ((ULong*)ddI)[_0],
+					U ((ULong*)ddI)[_1],
+					U ((ULong*)ddI)[2+_0],
+					U ((ULong*)ddI)[2+_1],
+					ddI[0], ddI[1]);
+			}
+		else {
+			printf("ddI[0] = #%lx %lx + %lx %lx\n= %.17g + %.17g\n",
+				U ((ULong*)ddI)[_0], U ((ULong*)ddI)[_1],
+				U ((ULong*)ddI)[2+_0], U ((ULong*)ddI)[2+_1],
+				ddI[0], ddI[1]);
+			printf("ddI[1] = #%lx %lx + %lx %lx\n= %.17g + %.17g\n",
+				U ((ULong*)ddI)[4+_0], U ((ULong*)ddI)[4+_1],
+				U ((ULong*)ddI)[6+_0], U ((ULong*)ddI)[6+_1],
+				ddI[2], ddI[3]);
+			if (ddI[0] == dd[0] && ddI[1] == dd[1])
+				printf("ddI[0] == strtod\n");
+			else if (ddI[2] == dd[0] && ddI[3] == dd[1])
+				printf("ddI[1] == strtod\n");
+			else
+				printf("**** Both differ from strtopdd ****\n");
+			}
+		printf("\n");
+		}
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/dt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/dt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/dt.c	(revision 2404)
@@ -0,0 +1,275 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* Test program for strtod and dtoa.
+ *
+ * Inputs (on stdin):
+ *		number[: mode [ndigits]]
+ * or
+ *		#hex0 hex1[: mode [ndigits]]
+ * where number is a decimal floating-point number,
+ * hex0 is a string of Hex digits for the most significant
+ * word of the number, hex1 is a similar string for the other
+ * (least significant) word, and mode and ndigits are
+ * parameters to dtoa.
+ */
+
+#include <stdio.h>
+#include "gdtoa.h"
+#ifdef KR_headers
+#define Void /*void*/
+#else
+#define Void void
+#endif
+
+#ifdef __STDC__
+#include <stdlib.h>
+#else
+#ifdef __cplusplus
+extern "C" double atof(const char*);
+#else
+extern double atof ANSI((char*));
+#endif
+#endif
+#ifdef IEEE_8087
+#define word0(x) ((ULong *)&x)[1]
+#define word1(x) ((ULong *)&x)[0]
+#else
+#define word0(x) ((ULong *)&x)[0]
+#define word1(x) ((ULong *)&x)[1]
+#endif
+#include "errno.h"
+
+#ifdef __cplusplus
+extern "C" char *dtoa(double, int, int, int*, int*, char **);
+#else
+extern char *dtoa ANSI((double, int, int, int*, int*, char **));
+#endif
+
+ static void
+#ifdef KR_headers
+g_fmt(b, x) char *b; double x;
+#else
+g_fmt(char *b, double x)
+#endif
+{
+	char *s, *se;
+	int decpt, i, j, k, sign;
+
+	if (!x) {
+		*b++ = '0';
+		*b = 0;
+		return;
+		}
+	s = dtoa(x, 0, 0, &decpt, &sign, &se);
+	if (sign)
+		*b++ = '-';
+	if (decpt == 9999) /* Infinity or Nan */ {
+		while(*b++ = *s++);
+		return;
+		}
+	if (decpt <= -4 || decpt > se - s + 5) {
+		*b++ = *s++;
+		if (*s) {
+			*b++ = '.';
+			while(*b = *s++)
+				b++;
+			}
+		*b++ = 'e';
+		/* sprintf(b, "%+.2d", decpt - 1); */
+		if (--decpt < 0) {
+			*b++ = '-';
+			decpt = -decpt;
+			}
+		else
+			*b++ = '+';
+		for(j = 2, k = 10; 10*k <= decpt; j++, k *= 10){};
+		for(;;) {
+			i = decpt / k;
+			*b++ = i + '0';
+			if (--j <= 0)
+				break;
+			decpt -= i*k;
+			decpt *= 10;
+			}
+		*b = 0;
+		}
+	else if (decpt <= 0) {
+		*b++ = '.';
+		for(; decpt < 0; decpt++)
+			*b++ = '0';
+		while(*b++ = *s++);
+		}
+	else {
+		while(*b = *s++) {
+			b++;
+			if (--decpt == 0 && *s)
+				*b++ = '.';
+			}
+		for(; decpt > 0; decpt--)
+			*b++ = '0';
+		*b = 0;
+		}
+	}
+
+ static void
+baderrno(Void)
+{
+	fflush(stdout);
+	perror("\nerrno strtod");
+	fflush(stderr);
+	}
+
+#define U (unsigned long)
+
+ static void
+#ifdef KR_headers
+check(d) double d;
+#else
+check(double d)
+#endif
+{
+	char buf[64];
+	int decpt, sign;
+	char *s, *se;
+	double d1;
+
+	s = dtoa(d, 0, 0, &decpt, &sign, &se);
+	sprintf(buf, "%s.%se%d", sign ? "-" : "", s, decpt);
+	errno = 0;
+	d1 = strtod(buf, (char **)0);
+	if (errno)
+		baderrno();
+	if (d != d1) {
+		printf("sent d = %.17g = 0x%lx %lx, buf = %s\n",
+			d, U word0(d), U word1(d), buf);
+		printf("got d1 = %.17g = 0x%lx %lx\n",
+			d1, U word0(d1), U word1(d1));
+		}
+	}
+
+main(Void){
+	char buf[2048], buf1[32];
+	char *fmt, *s, *se;
+	double d, d1;
+	int decpt, sign;
+	int mode = 0, ndigits = 17;
+	ULong x, y;
+#ifdef VAX
+	ULong z;
+#endif
+
+	while(fgets(buf, sizeof(buf), stdin)) {
+		if (*buf == '*') {
+			printf("%s", buf);
+			continue;
+			}
+		printf("Input: %s", buf);
+		if (*buf == '#') {
+			x = word0(d);
+			y = word1(d);
+			sscanf(buf+1, "%lx %lx:%d %d", &x, &y, &mode, &ndigits);
+			word0(d) = x;
+			word1(d) = y;
+			fmt = "Output: d =\n%.17g = 0x%lx %lx\n";
+			}
+		else {
+			errno = 0;
+			d = strtod(buf,&se);
+			if (*se == ':')
+				sscanf(se+1,"%d %d", &mode, &ndigits);
+			d1 = atof(buf);
+			fmt = "Output: d =\n%.17g = 0x%lx %lx, se = %s";
+			if (errno)
+				baderrno();
+			}
+		printf(fmt, d, U word0(d), U word1(d), se);
+		g_fmt(buf1, d);
+		printf("\tg_fmt gives \"%s\"\n", buf1);
+		if (*buf != '#' && d != d1)
+			printf("atof gives\n\
+	d1 = %.17g = 0x%lx %lx\nversus\n\
+	d  = %.17g = 0x%lx %lx\n", d1, U word0(d1), U word1(d1),
+				d, U word0(d), U word1(d));
+		check(d);
+		s = dtoa(d, mode, ndigits, &decpt, &sign, &se);
+		printf("\tdtoa(mode = %d, ndigits = %d):\n", mode, ndigits);
+		printf("\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n",
+			sign, decpt, se-s, s);
+		x = word1(d);
+		if (x != 0xffffffff
+		 && (word0(d) & 0x7ff00000) != 0x7ff00000) {
+#ifdef VAX
+			z = x << 16 | x >> 16;
+			z++;
+			z = z << 16 | z >> 16;
+			word1(d) = z;
+#else
+			word1(d) = x + 1;
+#endif
+			printf("\tnextafter(d,+Inf) = %.17g = 0x%lx %lx:\n",
+				d, U word0(d), U word1(d));
+			g_fmt(buf1, d);
+			printf("\tg_fmt gives \"%s\"\n", buf1);
+			s = dtoa(d, mode, ndigits, &decpt, &sign, &se);
+			printf(
+		"\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n",
+				sign, decpt, se-s, s);
+			check(d);
+			}
+		if (x) {
+#ifdef VAX
+			z = x << 16 | x >> 16;
+			z--;
+			z = z << 16 | z >> 16;
+			word1(d) = z;
+#else
+			word1(d) = x - 1;
+#endif
+			printf("\tnextafter(d,-Inf) = %.17g = 0x%lx %lx:\n",
+				d, U word0(d), U word1(d));
+			g_fmt(buf1, d);
+			printf("\tg_fmt gives \"%s\"\n", buf1);
+			s = dtoa(d, mode, ndigits, &decpt, &sign, &se);
+			printf(
+		"\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n",
+				sign, decpt, se-s, s);
+			check(d);
+			}
+		}
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/dtest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/dtest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/dtest.c	(revision 2404)
@@ -0,0 +1,146 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* Test program for g_dfmt, strtoId, strtod, strtopd, and strtord.
+ *
+ * Inputs (on stdin):
+ *		r rounding_mode
+ *		n ndig
+ *		number
+ *		#hex0 hex1
+ *
+ *	rounding_mode values:
+ *		0 = toward zero
+ *		1 = nearest
+ *		2 = toward +Infinity
+ *		3 = toward -Infinity
+ *
+ * where number is a decimal floating-point number,
+ * hex0 is a string of Hex <= 8 digits for the most significant
+ * word of the number, hex1 is a similar string for the other
+ * (least significant) word, and ndig is a parameters to g_dfmt.
+ */
+
+#include "gdtoaimp.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+ extern int getround ANSI((int,char*));
+
+ static char ibuf[2048], obuf[1024];
+
+#define U (unsigned long)
+
+ int
+main(Void)
+{
+	ULong *L;
+	char *s, *se, *se1;
+	double f, f1, fI[2];
+	int i, i1, ndig = 0, r = 1;
+	long LL[2];
+
+	L = (ULong*)&f;
+	while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) {
+		while(*s <= ' ')
+			if (!*s++)
+				continue;
+		switch(*s) {
+		  case 'r':
+			r = getround(r, s);
+			continue;
+		  case 'n':
+			i = s[1];
+			if (i <= ' ' || i >= '0' && i <= '9') {
+				ndig = atoi(s+1);
+				continue;
+				}
+			break; /* nan? */
+		  case '#':
+			LL[0] = L[_0];
+			LL[1] = L[_1];
+			sscanf(s+1, "%lx %lx", &LL[0], &LL[1]);
+			L[_0] = LL[0];
+			L[_1] = LL[1];
+			printf("\nInput: %s", ibuf);
+			printf("--> f = #%lx %lx\n", (long)L[_0], (long)L[_1]);
+			goto fmt_test;
+			}
+		printf("\nInput: %s", ibuf);
+		i = strtord(ibuf, &se, r, &f);
+		if (r == 1) {
+			if ((f != strtod(ibuf, &se1) || se1 != se))
+				printf("***strtod and strtord disagree!!\n");
+			i1 = strtopd(ibuf, &se, &f1);
+			if (i != i1 || f != f1 || se != se1)
+				printf("***strtord and strtopd disagree!!\n");
+			}
+		printf("strtod consumes %d bytes and returns %d with f = %.17g = #%lx %lx\n",
+				(int)(se-ibuf), i, f, U L[_0], U L[_1]);
+ fmt_test:
+		se = g_dfmt(obuf, &f, ndig, sizeof(obuf));
+		printf("g_dfmt(%d) gives %d bytes: \"%s\"\n\n",
+			ndig, (int)(se-obuf), se ? obuf : "<null>");
+		if (*s == '#')
+			continue;
+		printf("strtoId returns %d,", strtoId(ibuf, &se, fI, &fI[1]));
+		printf(" consuming %d bytes.\n", (int)(se-ibuf));
+		if (fI[0] == fI[1]) {
+			if (fI[0] == f)
+				printf("fI[0] == fI[1] == strtod\n");
+			else
+				printf("fI[0] == fI[1] = #%lx %lx = %.17g\n",
+					U ((ULong*)fI)[_0], U ((ULong*)fI)[_1],
+					fI[0]);
+			}
+		else {
+			printf("fI[0] = #%lx %lx = %.17g\n",
+				U ((ULong*)fI)[_0], U ((ULong*)fI)[_1], fI[0]);
+			printf("fI[1] = #%lx %lx = %.17g\n",
+				U ((ULong*)&fI[1])[_0], U ((ULong*)&fI[1])[_1],
+				fI[1]);
+			if (fI[0] == f)
+				printf("fI[0] == strtod\n");
+			else if (fI[1] == f)
+				printf("fI[1] == strtod\n");
+			else
+				printf("**** Both differ from strtod ****\n");
+			}
+		printf("\n");
+		}
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/dtst.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/dtst.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/dtst.out	(revision 2404)
@@ -0,0 +1,686 @@
+Input: 1.23
+Output: d =
+1.23 = 0x3ff3ae14 7ae147ae, se = 
+	g_fmt gives "1.23"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 1, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002 = 0x3ff3ae14 7ae147af:
+	g_fmt gives "1.2300000000000002"
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12300000000000002
+	nextafter(d,-Inf) = 1.2299999999999998 = 0x3ff3ae14 7ae147ad:
+	g_fmt gives "1.2299999999999998"
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12299999999999998
+Input: 1.23e+20
+Output: d =
+1.23e+20 = 0x441aabdf 2145b430, se = 
+	g_fmt gives "1.23e+20"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 21, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e+20 = 0x441aabdf 2145b431:
+	g_fmt gives "123000000000000020000"
+	dtoa returns sign = 0, decpt = 21, 17 digits:
+12300000000000002
+	nextafter(d,-Inf) = 1.2299999999999998e+20 = 0x441aabdf 2145b42f:
+	g_fmt gives "122999999999999980000"
+	dtoa returns sign = 0, decpt = 21, 17 digits:
+12299999999999998
+Input: 1.23e-20
+Output: d =
+1.2300000000000001e-20 = 0x3bcd0ae4 cf767531, se = 
+	g_fmt gives "1.23e-20"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -19, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e-20 = 0x3bcd0ae4 cf767532:
+	g_fmt gives "1.2300000000000002e-20"
+	dtoa returns sign = 0, decpt = -19, 17 digits:
+12300000000000002
+	nextafter(d,-Inf) = 1.2299999999999999e-20 = 0x3bcd0ae4 cf767530:
+	g_fmt gives "1.2299999999999999e-20"
+	dtoa returns sign = 0, decpt = -19, 17 digits:
+12299999999999999
+Input: 1.23456789
+Output: d =
+1.2345678899999999 = 0x3ff3c0ca 4283de1b, se = 
+	g_fmt gives "1.23456789"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 1, 9 digits:
+123456789
+	nextafter(d,+Inf) = 1.2345678900000001 = 0x3ff3c0ca 4283de1c:
+	g_fmt gives "1.2345678900000001"
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12345678900000001
+	nextafter(d,-Inf) = 1.2345678899999997 = 0x3ff3c0ca 4283de1a:
+	g_fmt gives "1.2345678899999997"
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12345678899999997
+Input: 1.23456589e+20
+Output: d =
+1.23456589e+20 = 0x441ac537 a660b997, se = 
+	g_fmt gives "1.23456589e+20"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 21, 9 digits:
+123456589
+	nextafter(d,+Inf) = 1.2345658900000001e+20 = 0x441ac537 a660b998:
+	g_fmt gives "123456589000000010000"
+	dtoa returns sign = 0, decpt = 21, 17 digits:
+12345658900000001
+	nextafter(d,-Inf) = 1.2345658899999998e+20 = 0x441ac537 a660b996:
+	g_fmt gives "123456588999999980000"
+	dtoa returns sign = 0, decpt = 21, 17 digits:
+12345658899999998
+Input: 1.23e+30
+Output: d =
+1.23e+30 = 0x462f0cb0 4e8fb790, se = 
+	g_fmt gives "1.23e+30"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 31, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000001e+30 = 0x462f0cb0 4e8fb791:
+	g_fmt gives "1.2300000000000001e+30"
+	dtoa returns sign = 0, decpt = 31, 17 digits:
+12300000000000001
+	nextafter(d,-Inf) = 1.2299999999999998e+30 = 0x462f0cb0 4e8fb78f:
+	g_fmt gives "1.2299999999999998e+30"
+	dtoa returns sign = 0, decpt = 31, 17 digits:
+12299999999999998
+Input: 1.23e-30
+Output: d =
+1.2300000000000001e-30 = 0x39b8f286 6f5010ab, se = 
+	g_fmt gives "1.23e-30"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -29, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e-30 = 0x39b8f286 6f5010ac:
+	g_fmt gives "1.2300000000000002e-30"
+	dtoa returns sign = 0, decpt = -29, 17 digits:
+12300000000000002
+	nextafter(d,-Inf) = 1.2299999999999999e-30 = 0x39b8f286 6f5010aa:
+	g_fmt gives "1.2299999999999999e-30"
+	dtoa returns sign = 0, decpt = -29, 17 digits:
+12299999999999999
+Input: 1.23456789e-20
+Output: d =
+1.2345678899999999e-20 = 0x3bcd2681 471e7ada, se = 
+	g_fmt gives "1.23456789e-20"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -19, 9 digits:
+123456789
+	nextafter(d,+Inf) = 1.2345678900000001e-20 = 0x3bcd2681 471e7adb:
+	g_fmt gives "1.2345678900000001e-20"
+	dtoa returns sign = 0, decpt = -19, 17 digits:
+12345678900000001
+	nextafter(d,-Inf) = 1.2345678899999998e-20 = 0x3bcd2681 471e7ad9:
+	g_fmt gives "1.2345678899999998e-20"
+	dtoa returns sign = 0, decpt = -19, 17 digits:
+12345678899999998
+Input: 1.23456789e-30
+Output: d =
+1.23456789e-30 = 0x39b90a3e 33bbd995, se = 
+	g_fmt gives "1.23456789e-30"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -29, 9 digits:
+123456789
+	nextafter(d,+Inf) = 1.2345678900000002e-30 = 0x39b90a3e 33bbd996:
+	g_fmt gives "1.2345678900000002e-30"
+	dtoa returns sign = 0, decpt = -29, 17 digits:
+12345678900000002
+	nextafter(d,-Inf) = 1.2345678899999998e-30 = 0x39b90a3e 33bbd994:
+	g_fmt gives "1.2345678899999998e-30"
+	dtoa returns sign = 0, decpt = -29, 17 digits:
+12345678899999998
+Input: 1.234567890123456789
+Output: d =
+1.2345678901234567 = 0x3ff3c0ca 428c59fb, se = 
+	g_fmt gives "1.2345678901234567"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12345678901234567
+	nextafter(d,+Inf) = 1.2345678901234569 = 0x3ff3c0ca 428c59fc:
+	g_fmt gives "1.234567890123457"
+	dtoa returns sign = 0, decpt = 1, 16 digits:
+1234567890123457
+	nextafter(d,-Inf) = 1.2345678901234565 = 0x3ff3c0ca 428c59fa:
+	g_fmt gives "1.2345678901234565"
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12345678901234565
+Input: 1.23456789012345678901234567890123456789
+Output: d =
+1.2345678901234567 = 0x3ff3c0ca 428c59fb, se = 
+	g_fmt gives "1.2345678901234567"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12345678901234567
+	nextafter(d,+Inf) = 1.2345678901234569 = 0x3ff3c0ca 428c59fc:
+	g_fmt gives "1.234567890123457"
+	dtoa returns sign = 0, decpt = 1, 16 digits:
+1234567890123457
+	nextafter(d,-Inf) = 1.2345678901234565 = 0x3ff3c0ca 428c59fa:
+	g_fmt gives "1.2345678901234565"
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12345678901234565
+Input: 1.23e306
+Output: d =
+1.23e+306 = 0x7f7c0676 cd1c61f5, se = 
+	g_fmt gives "1.23e+306"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 307, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e+306 = 0x7f7c0676 cd1c61f6:
+	g_fmt gives "1.2300000000000002e+306"
+	dtoa returns sign = 0, decpt = 307, 17 digits:
+12300000000000002
+	nextafter(d,-Inf) = 1.2299999999999999e+306 = 0x7f7c0676 cd1c61f4:
+	g_fmt gives "1.2299999999999999e+306"
+	dtoa returns sign = 0, decpt = 307, 17 digits:
+12299999999999999
+Input: 1.23e-306
+Output: d =
+1.23e-306 = 0x6ba3b8 5da396e8, se = 
+	g_fmt gives "1.23e-306"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -305, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e-306 = 0x6ba3b8 5da396e9:
+	g_fmt gives "1.2300000000000002e-306"
+	dtoa returns sign = 0, decpt = -305, 17 digits:
+12300000000000002
+	nextafter(d,-Inf) = 1.2299999999999999e-306 = 0x6ba3b8 5da396e7:
+	g_fmt gives "1.2299999999999999e-306"
+	dtoa returns sign = 0, decpt = -305, 17 digits:
+12299999999999999
+Input: 1.23e-320
+Output: d =
+1.2302234581447039e-320 = 0x0 9ba, se = 
+	g_fmt gives "1.23e-320"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -319, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2307175237905451e-320 = 0x0 9bb:
+	g_fmt gives "1.2307e-320"
+	dtoa returns sign = 0, decpt = -319, 5 digits:
+12307
+	nextafter(d,-Inf) = 1.2297293924988626e-320 = 0x0 9b9:
+	g_fmt gives "1.2297e-320"
+	dtoa returns sign = 0, decpt = -319, 5 digits:
+12297
+Input: 1.23e-20
+Output: d =
+1.2300000000000001e-20 = 0x3bcd0ae4 cf767531, se = 
+	g_fmt gives "1.23e-20"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -19, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e-20 = 0x3bcd0ae4 cf767532:
+	g_fmt gives "1.2300000000000002e-20"
+	dtoa returns sign = 0, decpt = -19, 17 digits:
+12300000000000002
+	nextafter(d,-Inf) = 1.2299999999999999e-20 = 0x3bcd0ae4 cf767530:
+	g_fmt gives "1.2299999999999999e-20"
+	dtoa returns sign = 0, decpt = -19, 17 digits:
+12299999999999999
+Input: 1.23456789e307
+Output: d =
+1.23456789e+307 = 0x7fb194b1 4bdaecdc, se = 
+	g_fmt gives "1.23456789e+307"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 308, 9 digits:
+123456789
+	nextafter(d,+Inf) = 1.2345678900000003e+307 = 0x7fb194b1 4bdaecdd:
+	g_fmt gives "1.2345678900000003e+307"
+	dtoa returns sign = 0, decpt = 308, 17 digits:
+12345678900000003
+	nextafter(d,-Inf) = 1.2345678899999998e+307 = 0x7fb194b1 4bdaecdb:
+	g_fmt gives "1.2345678899999998e+307"
+	dtoa returns sign = 0, decpt = 308, 17 digits:
+12345678899999998
+Input: 1.23456589e-307
+Output: d =
+1.2345658899999999e-307 = 0x363196 bb9845fa, se = 
+	g_fmt gives "1.23456589e-307"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -306, 9 digits:
+123456589
+	nextafter(d,+Inf) = 1.2345658900000001e-307 = 0x363196 bb9845fb:
+	g_fmt gives "1.2345658900000001e-307"
+	dtoa returns sign = 0, decpt = -306, 17 digits:
+12345658900000001
+	nextafter(d,-Inf) = 1.2345658899999997e-307 = 0x363196 bb9845f9:
+	g_fmt gives "1.2345658899999997e-307"
+	dtoa returns sign = 0, decpt = -306, 17 digits:
+12345658899999997
+Input: 1.234567890123456789
+Output: d =
+1.2345678901234567 = 0x3ff3c0ca 428c59fb, se = 
+	g_fmt gives "1.2345678901234567"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12345678901234567
+	nextafter(d,+Inf) = 1.2345678901234569 = 0x3ff3c0ca 428c59fc:
+	g_fmt gives "1.234567890123457"
+	dtoa returns sign = 0, decpt = 1, 16 digits:
+1234567890123457
+	nextafter(d,-Inf) = 1.2345678901234565 = 0x3ff3c0ca 428c59fa:
+	g_fmt gives "1.2345678901234565"
+	dtoa returns sign = 0, decpt = 1, 17 digits:
+12345678901234565
+Input: 1.234567890123456789e301
+Output: d =
+1.2345678901234568e+301 = 0x7e726f51 75f56413, se = 
+	g_fmt gives "1.2345678901234568e+301"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 302, 17 digits:
+12345678901234568
+	nextafter(d,+Inf) = 1.234567890123457e+301 = 0x7e726f51 75f56414:
+	g_fmt gives "1.234567890123457e+301"
+	dtoa returns sign = 0, decpt = 302, 16 digits:
+1234567890123457
+	nextafter(d,-Inf) = 1.2345678901234565e+301 = 0x7e726f51 75f56412:
+	g_fmt gives "1.2345678901234565e+301"
+	dtoa returns sign = 0, decpt = 302, 17 digits:
+12345678901234565
+Input: 1.234567890123456789e-301
+Output: d =
+1.2345678901234567e-301 = 0x1752a64 e34ba0d3, se = 
+	g_fmt gives "1.2345678901234567e-301"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -300, 17 digits:
+12345678901234567
+	nextafter(d,+Inf) = 1.2345678901234569e-301 = 0x1752a64 e34ba0d4:
+	g_fmt gives "1.234567890123457e-301"
+	dtoa returns sign = 0, decpt = -300, 16 digits:
+1234567890123457
+	nextafter(d,-Inf) = 1.2345678901234565e-301 = 0x1752a64 e34ba0d2:
+	g_fmt gives "1.2345678901234565e-301"
+	dtoa returns sign = 0, decpt = -300, 17 digits:
+12345678901234565
+Input: 1.234567890123456789e-321
+Output: d =
+1.2351641146031164e-321 = 0x0 fa, se = 
+	g_fmt gives "1.235e-321"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -320, 4 digits:
+1235
+	nextafter(d,+Inf) = 1.2401047710615288e-321 = 0x0 fb:
+	g_fmt gives "1.24e-321"
+	dtoa returns sign = 0, decpt = -320, 3 digits:
+124
+	nextafter(d,-Inf) = 1.2302234581447039e-321 = 0x0 f9:
+	g_fmt gives "1.23e-321"
+	dtoa returns sign = 0, decpt = -320, 3 digits:
+123
+Input: 1e23
+Output: d =
+9.9999999999999992e+22 = 0x44b52d02 c7e14af6, se = 
+	g_fmt gives "1e+23"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 24, 1 digits:
+1
+	nextafter(d,+Inf) = 1.0000000000000001e+23 = 0x44b52d02 c7e14af7:
+	g_fmt gives "1.0000000000000001e+23"
+	dtoa returns sign = 0, decpt = 24, 17 digits:
+10000000000000001
+	nextafter(d,-Inf) = 9.9999999999999975e+22 = 0x44b52d02 c7e14af5:
+	g_fmt gives "9.999999999999997e+22"
+	dtoa returns sign = 0, decpt = 23, 16 digits:
+9999999999999997
+Input: 1e310
+
+errno strtod: Result too large
+Output: d =
+Infinity = 0x7ff00000 0, se = 
+	g_fmt gives "Infinity"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = 9999, 8 digits:
+Infinity
+Input: 9.0259718793241475e-277
+Output: d =
+9.0259718793241479e-277 = 0x6a00000 0, se = 
+	g_fmt gives "9.025971879324148e-277"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -276, 16 digits:
+9025971879324148
+	nextafter(d,+Inf) = 9.0259718793241499e-277 = 0x6a00000 1:
+	g_fmt gives "9.02597187932415e-277"
+	dtoa returns sign = 0, decpt = -276, 15 digits:
+902597187932415
+Input: 9.025971879324147880346310405869e-277
+Output: d =
+9.0259718793241479e-277 = 0x6a00000 0, se = 
+	g_fmt gives "9.025971879324148e-277"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -276, 16 digits:
+9025971879324148
+	nextafter(d,+Inf) = 9.0259718793241499e-277 = 0x6a00000 1:
+	g_fmt gives "9.02597187932415e-277"
+	dtoa returns sign = 0, decpt = -276, 15 digits:
+902597187932415
+Input: 9.025971879324147880346310405868e-277
+Output: d =
+9.0259718793241479e-277 = 0x6a00000 0, se = 
+	g_fmt gives "9.025971879324148e-277"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -276, 16 digits:
+9025971879324148
+	nextafter(d,+Inf) = 9.0259718793241499e-277 = 0x6a00000 1:
+	g_fmt gives "9.02597187932415e-277"
+	dtoa returns sign = 0, decpt = -276, 15 digits:
+902597187932415
+Input: 2.2250738585072014e-308
+Output: d =
+2.2250738585072014e-308 = 0x100000 0, se = 
+	g_fmt gives "2.2250738585072014e-308"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -307, 17 digits:
+22250738585072014
+	nextafter(d,+Inf) = 2.2250738585072019e-308 = 0x100000 1:
+	g_fmt gives "2.225073858507202e-308"
+	dtoa returns sign = 0, decpt = -307, 16 digits:
+2225073858507202
+Input: 2.2250738585072013e-308
+Output: d =
+2.2250738585072014e-308 = 0x100000 0, se = 
+	g_fmt gives "2.2250738585072014e-308"
+	dtoa(mode = 0, ndigits = 17):
+	dtoa returns sign = 0, decpt = -307, 17 digits:
+22250738585072014
+	nextafter(d,+Inf) = 2.2250738585072019e-308 = 0x100000 1:
+	g_fmt gives "2.225073858507202e-308"
+	dtoa returns sign = 0, decpt = -307, 16 digits:
+2225073858507202
+Input: 1.23:2 6
+Output: d =
+1.23 = 0x3ff3ae14 7ae147ae, se = :2 6
+	g_fmt gives "1.23"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = 1, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002 = 0x3ff3ae14 7ae147af:
+	g_fmt gives "1.2300000000000002"
+	dtoa returns sign = 0, decpt = 1, 3 digits:
+123
+	nextafter(d,-Inf) = 1.2299999999999998 = 0x3ff3ae14 7ae147ad:
+	g_fmt gives "1.2299999999999998"
+	dtoa returns sign = 0, decpt = 1, 3 digits:
+123
+Input: 1.23:4 6
+Output: d =
+1.23 = 0x3ff3ae14 7ae147ae, se = :4 6
+	g_fmt gives "1.23"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = 1, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002 = 0x3ff3ae14 7ae147af:
+	g_fmt gives "1.2300000000000002"
+	dtoa returns sign = 0, decpt = 1, 3 digits:
+123
+	nextafter(d,-Inf) = 1.2299999999999998 = 0x3ff3ae14 7ae147ad:
+	g_fmt gives "1.2299999999999998"
+	dtoa returns sign = 0, decpt = 1, 3 digits:
+123
+Input: 1.23e+20:2 6
+Output: d =
+1.23e+20 = 0x441aabdf 2145b430, se = :2 6
+	g_fmt gives "1.23e+20"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = 21, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e+20 = 0x441aabdf 2145b431:
+	g_fmt gives "123000000000000020000"
+	dtoa returns sign = 0, decpt = 21, 3 digits:
+123
+	nextafter(d,-Inf) = 1.2299999999999998e+20 = 0x441aabdf 2145b42f:
+	g_fmt gives "122999999999999980000"
+	dtoa returns sign = 0, decpt = 21, 3 digits:
+123
+Input: 1.23e+20:4 6
+Output: d =
+1.23e+20 = 0x441aabdf 2145b430, se = :4 6
+	g_fmt gives "1.23e+20"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = 21, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e+20 = 0x441aabdf 2145b431:
+	g_fmt gives "123000000000000020000"
+	dtoa returns sign = 0, decpt = 21, 3 digits:
+123
+	nextafter(d,-Inf) = 1.2299999999999998e+20 = 0x441aabdf 2145b42f:
+	g_fmt gives "122999999999999980000"
+	dtoa returns sign = 0, decpt = 21, 3 digits:
+123
+Input: 1.23e-20:2 6
+Output: d =
+1.2300000000000001e-20 = 0x3bcd0ae4 cf767531, se = :2 6
+	g_fmt gives "1.23e-20"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = -19, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e-20 = 0x3bcd0ae4 cf767532:
+	g_fmt gives "1.2300000000000002e-20"
+	dtoa returns sign = 0, decpt = -19, 3 digits:
+123
+	nextafter(d,-Inf) = 1.2299999999999999e-20 = 0x3bcd0ae4 cf767530:
+	g_fmt gives "1.2299999999999999e-20"
+	dtoa returns sign = 0, decpt = -19, 3 digits:
+123
+Input: 1.23e-20:4 6
+Output: d =
+1.2300000000000001e-20 = 0x3bcd0ae4 cf767531, se = :4 6
+	g_fmt gives "1.23e-20"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = -19, 3 digits:
+123
+	nextafter(d,+Inf) = 1.2300000000000002e-20 = 0x3bcd0ae4 cf767532:
+	g_fmt gives "1.2300000000000002e-20"
+	dtoa returns sign = 0, decpt = -19, 3 digits:
+123
+	nextafter(d,-Inf) = 1.2299999999999999e-20 = 0x3bcd0ae4 cf767530:
+	g_fmt gives "1.2299999999999999e-20"
+	dtoa returns sign = 0, decpt = -19, 3 digits:
+123
+Input: 1.23456789:2 6
+Output: d =
+1.2345678899999999 = 0x3ff3c0ca 4283de1b, se = :2 6
+	g_fmt gives "1.23456789"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123457
+	nextafter(d,+Inf) = 1.2345678900000001 = 0x3ff3c0ca 4283de1c:
+	g_fmt gives "1.2345678900000001"
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345678899999997 = 0x3ff3c0ca 4283de1a:
+	g_fmt gives "1.2345678899999997"
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123457
+Input: 1.23456789:4 6
+Output: d =
+1.2345678899999999 = 0x3ff3c0ca 4283de1b, se = :4 6
+	g_fmt gives "1.23456789"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123457
+	nextafter(d,+Inf) = 1.2345678900000001 = 0x3ff3c0ca 4283de1c:
+	g_fmt gives "1.2345678900000001"
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345678899999997 = 0x3ff3c0ca 4283de1a:
+	g_fmt gives "1.2345678899999997"
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123457
+Input: 1.23456589e+20:2 6
+Output: d =
+1.23456589e+20 = 0x441ac537 a660b997, se = :2 6
+	g_fmt gives "1.23456589e+20"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123457
+	nextafter(d,+Inf) = 1.2345658900000001e+20 = 0x441ac537 a660b998:
+	g_fmt gives "123456589000000010000"
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345658899999998e+20 = 0x441ac537 a660b996:
+	g_fmt gives "123456588999999980000"
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123457
+Input: 1.23456589e+20:4 6
+Output: d =
+1.23456589e+20 = 0x441ac537 a660b997, se = :4 6
+	g_fmt gives "1.23456589e+20"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123457
+	nextafter(d,+Inf) = 1.2345658900000001e+20 = 0x441ac537 a660b998:
+	g_fmt gives "123456589000000010000"
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345658899999998e+20 = 0x441ac537 a660b996:
+	g_fmt gives "123456588999999980000"
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123457
+Input: 1.23456789e-20:2 6
+Output: d =
+1.2345678899999999e-20 = 0x3bcd2681 471e7ada, se = :2 6
+	g_fmt gives "1.23456789e-20"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123457
+	nextafter(d,+Inf) = 1.2345678900000001e-20 = 0x3bcd2681 471e7adb:
+	g_fmt gives "1.2345678900000001e-20"
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345678899999998e-20 = 0x3bcd2681 471e7ad9:
+	g_fmt gives "1.2345678899999998e-20"
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123457
+Input: 1.23456789e-20:4 6
+Output: d =
+1.2345678899999999e-20 = 0x3bcd2681 471e7ada, se = :4 6
+	g_fmt gives "1.23456789e-20"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123457
+	nextafter(d,+Inf) = 1.2345678900000001e-20 = 0x3bcd2681 471e7adb:
+	g_fmt gives "1.2345678900000001e-20"
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345678899999998e-20 = 0x3bcd2681 471e7ad9:
+	g_fmt gives "1.2345678899999998e-20"
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123457
+Input: 1234565:2 6
+Output: d =
+1234565 = 0x4132d685 0, se = :2 6
+	g_fmt gives "1234565"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = 7, 6 digits:
+123456
+	nextafter(d,+Inf) = 1234565.0000000002 = 0x4132d685 1:
+	g_fmt gives "1234565.0000000002"
+	dtoa returns sign = 0, decpt = 7, 6 digits:
+123457
+Input: 1234565:4 6
+Output: d =
+1234565 = 0x4132d685 0, se = :4 6
+	g_fmt gives "1234565"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = 7, 6 digits:
+123456
+	nextafter(d,+Inf) = 1234565.0000000002 = 0x4132d685 1:
+	g_fmt gives "1234565.0000000002"
+	dtoa returns sign = 0, decpt = 7, 6 digits:
+123457
+Input: 1.234565:2 6
+Output: d =
+1.2345649999999999 = 0x3ff3c0c7 3abc9470, se = :2 6
+	g_fmt gives "1.234565"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123456
+	nextafter(d,+Inf) = 1.2345650000000001 = 0x3ff3c0c7 3abc9471:
+	g_fmt gives "1.2345650000000001"
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345649999999997 = 0x3ff3c0c7 3abc946f:
+	g_fmt gives "1.2345649999999997"
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123456
+Input: 1.234565:4 6
+Output: d =
+1.2345649999999999 = 0x3ff3c0c7 3abc9470, se = :4 6
+	g_fmt gives "1.234565"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123456
+	nextafter(d,+Inf) = 1.2345650000000001 = 0x3ff3c0c7 3abc9471:
+	g_fmt gives "1.2345650000000001"
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345649999999997 = 0x3ff3c0c7 3abc946f:
+	g_fmt gives "1.2345649999999997"
+	dtoa returns sign = 0, decpt = 1, 6 digits:
+123456
+Input: 1.234565e+20:2 6
+Output: d =
+1.234565e+20 = 0x441ac536 6299040d, se = :2 6
+	g_fmt gives "1.234565e+20"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123456
+	nextafter(d,+Inf) = 1.2345650000000002e+20 = 0x441ac536 6299040e:
+	g_fmt gives "123456500000000020000"
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345649999999998e+20 = 0x441ac536 6299040c:
+	g_fmt gives "123456499999999980000"
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123456
+Input: 1.234565e+20:4 6
+Output: d =
+1.234565e+20 = 0x441ac536 6299040d, se = :4 6
+	g_fmt gives "1.234565e+20"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123456
+	nextafter(d,+Inf) = 1.2345650000000002e+20 = 0x441ac536 6299040e:
+	g_fmt gives "123456500000000020000"
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345649999999998e+20 = 0x441ac536 6299040c:
+	g_fmt gives "123456499999999980000"
+	dtoa returns sign = 0, decpt = 21, 6 digits:
+123456
+Input: 1.234565e-20:2 6
+Output: d =
+1.234565e-20 = 0x3bcd267c ce45a93f, se = :2 6
+	g_fmt gives "1.234565e-20"
+	dtoa(mode = 2, ndigits = 6):
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123456
+	nextafter(d,+Inf) = 1.2345650000000001e-20 = 0x3bcd267c ce45a940:
+	g_fmt gives "1.2345650000000001e-20"
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345649999999998e-20 = 0x3bcd267c ce45a93e:
+	g_fmt gives "1.2345649999999998e-20"
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123456
+Input: 1.234565e-20:4 6
+Output: d =
+1.234565e-20 = 0x3bcd267c ce45a93f, se = :4 6
+	g_fmt gives "1.234565e-20"
+	dtoa(mode = 4, ndigits = 6):
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123456
+	nextafter(d,+Inf) = 1.2345650000000001e-20 = 0x3bcd267c ce45a940:
+	g_fmt gives "1.2345650000000001e-20"
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123457
+	nextafter(d,-Inf) = 1.2345649999999998e-20 = 0x3bcd267c ce45a93e:
+	g_fmt gives "1.2345649999999998e-20"
+	dtoa returns sign = 0, decpt = -19, 6 digits:
+123456
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/f.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/f.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/f.out	(revision 2404)
@@ -0,0 +1,968 @@
+
+Input: 1.23
+strtof consumes 4 bytes and returns 1.23 = #3f9d70a4
+g_ffmt(0) gives 4 bytes: "1.23"
+
+strtoIf returns 33, consuming 4 bytes.
+fI[0] = #3f9d70a3 = 1.2299999
+fI[1] = #3f9d70a4 = 1.23
+fI[1] == strtof
+
+
+Input: 1.23e+20
+strtof consumes 8 bytes and returns 1.23e+20 = #60d55ef9
+g_ffmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIf returns 17, consuming 8 bytes.
+fI[0] = #60d55ef9 = 1.23e+20
+fI[1] = #60d55efa = 1.2300001e+20
+fI[0] == strtof
+
+
+Input: 1.23e-20
+strtof consumes 8 bytes and returns 1.23e-20 = #1e685726
+g_ffmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIf returns 17, consuming 8 bytes.
+fI[0] = #1e685726 = 1.23e-20
+fI[1] = #1e685727 = 1.23e-20
+fI[0] == strtof
+
+
+Input: 1.23456789
+strtof consumes 10 bytes and returns 1.2345679 = #3f9e0652
+g_ffmt(0) gives 9 bytes: "1.2345679"
+
+strtoIf returns 17, consuming 10 bytes.
+fI[0] = #3f9e0652 = 1.2345679
+fI[1] = #3f9e0653 = 1.234568
+fI[0] == strtof
+
+
+Input: 1.23456589e+20
+strtof consumes 14 bytes and returns 1.2345659e+20 = #60d629bd
+g_ffmt(0) gives 13 bytes: "1.2345659e+20"
+
+strtoIf returns 17, consuming 14 bytes.
+fI[0] = #60d629bd = 1.2345659e+20
+fI[1] = #60d629be = 1.234566e+20
+fI[0] == strtof
+
+
+Input: 1.23e+30
+strtof consumes 8 bytes and returns 1.23e+30 = #71786582
+g_ffmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIf returns 17, consuming 8 bytes.
+fI[0] = #71786582 = 1.23e+30
+fI[1] = #71786583 = 1.23e+30
+fI[0] == strtof
+
+
+Input: 1.23e-30
+strtof consumes 8 bytes and returns 1.23e-30 = #dc79433
+g_ffmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIf returns 17, consuming 8 bytes.
+fI[0] = #dc79433 = 1.23e-30
+fI[1] = #dc79434 = 1.23e-30
+fI[0] == strtof
+
+
+Input: 1.23456789e-20
+strtof consumes 14 bytes and returns 1.2345679e-20 = #1e69340a
+g_ffmt(0) gives 13 bytes: "1.2345679e-20"
+
+strtoIf returns 17, consuming 14 bytes.
+fI[0] = #1e69340a = 1.2345679e-20
+fI[1] = #1e69340b = 1.234568e-20
+fI[0] == strtof
+
+
+Input: 1.23456789e-30
+strtof consumes 14 bytes and returns 1.2345679e-30 = #dc851f2
+g_ffmt(0) gives 13 bytes: "1.2345679e-30"
+
+strtoIf returns 33, consuming 14 bytes.
+fI[0] = #dc851f1 = 1.2345678e-30
+fI[1] = #dc851f2 = 1.2345679e-30
+fI[1] == strtof
+
+
+Input: 1.234567890123456789
+strtof consumes 20 bytes and returns 1.2345679 = #3f9e0652
+g_ffmt(0) gives 9 bytes: "1.2345679"
+
+strtoIf returns 17, consuming 20 bytes.
+fI[0] = #3f9e0652 = 1.2345679
+fI[1] = #3f9e0653 = 1.234568
+fI[0] == strtof
+
+
+Input: 1.23456789012345678901234567890123456789
+strtof consumes 40 bytes and returns 1.2345679 = #3f9e0652
+g_ffmt(0) gives 9 bytes: "1.2345679"
+
+strtoIf returns 17, consuming 40 bytes.
+fI[0] = #3f9e0652 = 1.2345679
+fI[1] = #3f9e0653 = 1.234568
+fI[0] == strtof
+
+
+Input: 1.23e306
+strtof consumes 8 bytes and returns Infinity = #7f800000
+g_ffmt(0) gives 8 bytes: "Infinity"
+
+strtoIf returns 163, consuming 8 bytes.
+fI[0] = #7f7fffff = 3.4028235e+38
+fI[1] = #7f800000 = Infinity
+fI[1] == strtof
+
+
+Input: 1.23e-306
+strtof consumes 9 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 9 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1.23e-320
+strtof consumes 9 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 9 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1.23e-20
+strtof consumes 8 bytes and returns 1.23e-20 = #1e685726
+g_ffmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIf returns 17, consuming 8 bytes.
+fI[0] = #1e685726 = 1.23e-20
+fI[1] = #1e685727 = 1.23e-20
+fI[0] == strtof
+
+
+Input: 1.23456789e307
+strtof consumes 14 bytes and returns Infinity = #7f800000
+g_ffmt(0) gives 8 bytes: "Infinity"
+
+strtoIf returns 163, consuming 14 bytes.
+fI[0] = #7f7fffff = 3.4028235e+38
+fI[1] = #7f800000 = Infinity
+fI[1] == strtof
+
+
+Input: 1.23456589e-307
+strtof consumes 15 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 15 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1.234567890123456789
+strtof consumes 20 bytes and returns 1.2345679 = #3f9e0652
+g_ffmt(0) gives 9 bytes: "1.2345679"
+
+strtoIf returns 17, consuming 20 bytes.
+fI[0] = #3f9e0652 = 1.2345679
+fI[1] = #3f9e0653 = 1.234568
+fI[0] == strtof
+
+
+Input: 1.234567890123456789e301
+strtof consumes 24 bytes and returns Infinity = #7f800000
+g_ffmt(0) gives 8 bytes: "Infinity"
+
+strtoIf returns 163, consuming 24 bytes.
+fI[0] = #7f7fffff = 3.4028235e+38
+fI[1] = #7f800000 = Infinity
+fI[1] == strtof
+
+
+Input: 1.234567890123456789e-301
+strtof consumes 25 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 25 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1.234567890123456789e-321
+strtof consumes 25 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 25 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1e23
+strtof consumes 4 bytes and returns 9.9999998e+22 = #65a96816
+g_ffmt(0) gives 5 bytes: "1e+23"
+
+strtoIf returns 17, consuming 4 bytes.
+fI[0] = #65a96816 = 9.9999998e+22
+fI[1] = #65a96817 = 1.0000001e+23
+fI[0] == strtof
+
+
+Input: 1e310
+strtof consumes 5 bytes and returns Infinity = #7f800000
+g_ffmt(0) gives 8 bytes: "Infinity"
+
+strtoIf returns 163, consuming 5 bytes.
+fI[0] = #7f7fffff = 3.4028235e+38
+fI[1] = #7f800000 = Infinity
+fI[1] == strtof
+
+
+Input: 9.0259718793241475e-277
+strtof consumes 23 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 23 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 9.025971879324147880346310405869e-277
+strtof consumes 37 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 37 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 9.025971879324147880346310405868e-277
+strtof consumes 37 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 37 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 2.2250738585072014e-308
+strtof consumes 23 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 23 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 2.2250738585072013e-308
+strtof consumes 23 bytes and returns 0 = #0
+g_ffmt(0) gives 1 bytes: "0"
+
+strtoIf returns 80, consuming 23 bytes.
+fI[0] == fI[1] == strtof
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+strtof consumes 3 bytes and returns 1.0999999 = #3f8ccccc
+g_ffmt(0) gives 9 bytes: "1.0999999"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3f8ccccc = 1.0999999
+fI[1] = #3f8ccccd = 1.1
+fI[0] == strtof
+
+
+Input: -1.1
+strtof consumes 4 bytes and returns -1.0999999 = #bf8ccccc
+g_ffmt(0) gives 10 bytes: "-1.0999999"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bf8ccccd = -1.1
+fI[1] = #bf8ccccc = -1.0999999
+fI[1] == strtof
+
+
+Input: 1.2
+strtof consumes 3 bytes and returns 1.1999999 = #3f999999
+g_ffmt(0) gives 9 bytes: "1.1999999"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3f999999 = 1.1999999
+fI[1] = #3f99999a = 1.2
+fI[0] == strtof
+
+
+Input: -1.2
+strtof consumes 4 bytes and returns -1.1999999 = #bf999999
+g_ffmt(0) gives 10 bytes: "-1.1999999"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bf99999a = -1.2
+fI[1] = #bf999999 = -1.1999999
+fI[1] == strtof
+
+
+Input: 1.3
+strtof consumes 3 bytes and returns 1.3 = #3fa66666
+g_ffmt(0) gives 3 bytes: "1.3"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fa66666 = 1.3
+fI[1] = #3fa66667 = 1.3000001
+fI[0] == strtof
+
+
+Input: -1.3
+strtof consumes 4 bytes and returns -1.3 = #bfa66666
+g_ffmt(0) gives 4 bytes: "-1.3"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfa66667 = -1.3000001
+fI[1] = #bfa66666 = -1.3
+fI[1] == strtof
+
+
+Input: 1.4
+strtof consumes 3 bytes and returns 1.4 = #3fb33333
+g_ffmt(0) gives 3 bytes: "1.4"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fb33333 = 1.4
+fI[1] = #3fb33334 = 1.4000001
+fI[0] == strtof
+
+
+Input: -1.4
+strtof consumes 4 bytes and returns -1.4 = #bfb33333
+g_ffmt(0) gives 4 bytes: "-1.4"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfb33334 = -1.4000001
+fI[1] = #bfb33333 = -1.4
+fI[1] == strtof
+
+
+Input: 1.5
+strtof consumes 3 bytes and returns 1.5 = #3fc00000
+g_ffmt(0) gives 3 bytes: "1.5"
+
+strtoIf returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: -1.5
+strtof consumes 4 bytes and returns -1.5 = #bfc00000
+g_ffmt(0) gives 4 bytes: "-1.5"
+
+strtoIf returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1.6
+strtof consumes 3 bytes and returns 1.5999999 = #3fcccccc
+g_ffmt(0) gives 9 bytes: "1.5999999"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3fcccccc = 1.5999999
+fI[1] = #3fcccccd = 1.6
+fI[0] == strtof
+
+
+Input: -1.6
+strtof consumes 4 bytes and returns -1.5999999 = #bfcccccc
+g_ffmt(0) gives 10 bytes: "-1.5999999"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bfcccccd = -1.6
+fI[1] = #bfcccccc = -1.5999999
+fI[1] == strtof
+
+
+Input: 1.7
+strtof consumes 3 bytes and returns 1.6999999 = #3fd99999
+g_ffmt(0) gives 9 bytes: "1.6999999"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3fd99999 = 1.6999999
+fI[1] = #3fd9999a = 1.7
+fI[0] == strtof
+
+
+Input: -1.7
+strtof consumes 4 bytes and returns -1.6999999 = #bfd99999
+g_ffmt(0) gives 10 bytes: "-1.6999999"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bfd9999a = -1.7
+fI[1] = #bfd99999 = -1.6999999
+fI[1] == strtof
+
+
+Input: 1.8
+strtof consumes 3 bytes and returns 1.8 = #3fe66666
+g_ffmt(0) gives 3 bytes: "1.8"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fe66666 = 1.8
+fI[1] = #3fe66667 = 1.8000001
+fI[0] == strtof
+
+
+Input: -1.8
+strtof consumes 4 bytes and returns -1.8 = #bfe66666
+g_ffmt(0) gives 4 bytes: "-1.8"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfe66667 = -1.8000001
+fI[1] = #bfe66666 = -1.8
+fI[1] == strtof
+
+
+Input: 1.9
+strtof consumes 3 bytes and returns 1.9 = #3ff33333
+g_ffmt(0) gives 3 bytes: "1.9"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3ff33333 = 1.9
+fI[1] = #3ff33334 = 1.9000001
+fI[0] == strtof
+
+
+Input: -1.9
+strtof consumes 4 bytes and returns -1.9 = #bff33333
+g_ffmt(0) gives 4 bytes: "-1.9"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bff33334 = -1.9000001
+fI[1] = #bff33333 = -1.9
+fI[1] == strtof
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+strtof consumes 3 bytes and returns 1.1 = #3f8ccccd
+g_ffmt(0) gives 3 bytes: "1.1"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3f8ccccc = 1.0999999
+fI[1] = #3f8ccccd = 1.1
+fI[1] == strtof
+
+
+Input: -1.1
+strtof consumes 4 bytes and returns -1.1 = #bf8ccccd
+g_ffmt(0) gives 4 bytes: "-1.1"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bf8ccccd = -1.1
+fI[1] = #bf8ccccc = -1.0999999
+fI[0] == strtof
+
+
+Input: 1.2
+strtof consumes 3 bytes and returns 1.2 = #3f99999a
+g_ffmt(0) gives 3 bytes: "1.2"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3f999999 = 1.1999999
+fI[1] = #3f99999a = 1.2
+fI[1] == strtof
+
+
+Input: -1.2
+strtof consumes 4 bytes and returns -1.2 = #bf99999a
+g_ffmt(0) gives 4 bytes: "-1.2"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bf99999a = -1.2
+fI[1] = #bf999999 = -1.1999999
+fI[0] == strtof
+
+
+Input: 1.3
+strtof consumes 3 bytes and returns 1.3 = #3fa66666
+g_ffmt(0) gives 3 bytes: "1.3"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fa66666 = 1.3
+fI[1] = #3fa66667 = 1.3000001
+fI[0] == strtof
+
+
+Input: -1.3
+strtof consumes 4 bytes and returns -1.3 = #bfa66666
+g_ffmt(0) gives 4 bytes: "-1.3"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfa66667 = -1.3000001
+fI[1] = #bfa66666 = -1.3
+fI[1] == strtof
+
+
+Input: 1.4
+strtof consumes 3 bytes and returns 1.4 = #3fb33333
+g_ffmt(0) gives 3 bytes: "1.4"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fb33333 = 1.4
+fI[1] = #3fb33334 = 1.4000001
+fI[0] == strtof
+
+
+Input: -1.4
+strtof consumes 4 bytes and returns -1.4 = #bfb33333
+g_ffmt(0) gives 4 bytes: "-1.4"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfb33334 = -1.4000001
+fI[1] = #bfb33333 = -1.4
+fI[1] == strtof
+
+
+Input: 1.5
+strtof consumes 3 bytes and returns 1.5 = #3fc00000
+g_ffmt(0) gives 3 bytes: "1.5"
+
+strtoIf returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: -1.5
+strtof consumes 4 bytes and returns -1.5 = #bfc00000
+g_ffmt(0) gives 4 bytes: "-1.5"
+
+strtoIf returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1.6
+strtof consumes 3 bytes and returns 1.6 = #3fcccccd
+g_ffmt(0) gives 3 bytes: "1.6"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3fcccccc = 1.5999999
+fI[1] = #3fcccccd = 1.6
+fI[1] == strtof
+
+
+Input: -1.6
+strtof consumes 4 bytes and returns -1.6 = #bfcccccd
+g_ffmt(0) gives 4 bytes: "-1.6"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bfcccccd = -1.6
+fI[1] = #bfcccccc = -1.5999999
+fI[0] == strtof
+
+
+Input: 1.7
+strtof consumes 3 bytes and returns 1.7 = #3fd9999a
+g_ffmt(0) gives 3 bytes: "1.7"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3fd99999 = 1.6999999
+fI[1] = #3fd9999a = 1.7
+fI[1] == strtof
+
+
+Input: -1.7
+strtof consumes 4 bytes and returns -1.7 = #bfd9999a
+g_ffmt(0) gives 4 bytes: "-1.7"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bfd9999a = -1.7
+fI[1] = #bfd99999 = -1.6999999
+fI[0] == strtof
+
+
+Input: 1.8
+strtof consumes 3 bytes and returns 1.8 = #3fe66666
+g_ffmt(0) gives 3 bytes: "1.8"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fe66666 = 1.8
+fI[1] = #3fe66667 = 1.8000001
+fI[0] == strtof
+
+
+Input: -1.8
+strtof consumes 4 bytes and returns -1.8 = #bfe66666
+g_ffmt(0) gives 4 bytes: "-1.8"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfe66667 = -1.8000001
+fI[1] = #bfe66666 = -1.8
+fI[1] == strtof
+
+
+Input: 1.9
+strtof consumes 3 bytes and returns 1.9 = #3ff33333
+g_ffmt(0) gives 3 bytes: "1.9"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3ff33333 = 1.9
+fI[1] = #3ff33334 = 1.9000001
+fI[0] == strtof
+
+
+Input: -1.9
+strtof consumes 4 bytes and returns -1.9 = #bff33333
+g_ffmt(0) gives 4 bytes: "-1.9"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bff33334 = -1.9000001
+fI[1] = #bff33333 = -1.9
+fI[1] == strtof
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+strtof consumes 3 bytes and returns 1.1 = #3f8ccccd
+g_ffmt(0) gives 3 bytes: "1.1"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3f8ccccc = 1.0999999
+fI[1] = #3f8ccccd = 1.1
+fI[1] == strtof
+
+
+Input: -1.1
+strtof consumes 4 bytes and returns -1.0999999 = #bf8ccccc
+g_ffmt(0) gives 10 bytes: "-1.0999999"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bf8ccccd = -1.1
+fI[1] = #bf8ccccc = -1.0999999
+fI[1] == strtof
+
+
+Input: 1.2
+strtof consumes 3 bytes and returns 1.2 = #3f99999a
+g_ffmt(0) gives 3 bytes: "1.2"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3f999999 = 1.1999999
+fI[1] = #3f99999a = 1.2
+fI[1] == strtof
+
+
+Input: -1.2
+strtof consumes 4 bytes and returns -1.1999999 = #bf999999
+g_ffmt(0) gives 10 bytes: "-1.1999999"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bf99999a = -1.2
+fI[1] = #bf999999 = -1.1999999
+fI[1] == strtof
+
+
+Input: 1.3
+strtof consumes 3 bytes and returns 1.3000001 = #3fa66667
+g_ffmt(0) gives 9 bytes: "1.3000001"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fa66666 = 1.3
+fI[1] = #3fa66667 = 1.3000001
+fI[1] == strtof
+
+
+Input: -1.3
+strtof consumes 4 bytes and returns -1.3 = #bfa66666
+g_ffmt(0) gives 4 bytes: "-1.3"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfa66667 = -1.3000001
+fI[1] = #bfa66666 = -1.3
+fI[1] == strtof
+
+
+Input: 1.4
+strtof consumes 3 bytes and returns 1.4000001 = #3fb33334
+g_ffmt(0) gives 9 bytes: "1.4000001"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fb33333 = 1.4
+fI[1] = #3fb33334 = 1.4000001
+fI[1] == strtof
+
+
+Input: -1.4
+strtof consumes 4 bytes and returns -1.4 = #bfb33333
+g_ffmt(0) gives 4 bytes: "-1.4"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfb33334 = -1.4000001
+fI[1] = #bfb33333 = -1.4
+fI[1] == strtof
+
+
+Input: 1.5
+strtof consumes 3 bytes and returns 1.5 = #3fc00000
+g_ffmt(0) gives 3 bytes: "1.5"
+
+strtoIf returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: -1.5
+strtof consumes 4 bytes and returns -1.5 = #bfc00000
+g_ffmt(0) gives 4 bytes: "-1.5"
+
+strtoIf returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1.6
+strtof consumes 3 bytes and returns 1.6 = #3fcccccd
+g_ffmt(0) gives 3 bytes: "1.6"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3fcccccc = 1.5999999
+fI[1] = #3fcccccd = 1.6
+fI[1] == strtof
+
+
+Input: -1.6
+strtof consumes 4 bytes and returns -1.5999999 = #bfcccccc
+g_ffmt(0) gives 10 bytes: "-1.5999999"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bfcccccd = -1.6
+fI[1] = #bfcccccc = -1.5999999
+fI[1] == strtof
+
+
+Input: 1.7
+strtof consumes 3 bytes and returns 1.7 = #3fd9999a
+g_ffmt(0) gives 3 bytes: "1.7"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3fd99999 = 1.6999999
+fI[1] = #3fd9999a = 1.7
+fI[1] == strtof
+
+
+Input: -1.7
+strtof consumes 4 bytes and returns -1.6999999 = #bfd99999
+g_ffmt(0) gives 10 bytes: "-1.6999999"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bfd9999a = -1.7
+fI[1] = #bfd99999 = -1.6999999
+fI[1] == strtof
+
+
+Input: 1.8
+strtof consumes 3 bytes and returns 1.8000001 = #3fe66667
+g_ffmt(0) gives 9 bytes: "1.8000001"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fe66666 = 1.8
+fI[1] = #3fe66667 = 1.8000001
+fI[1] == strtof
+
+
+Input: -1.8
+strtof consumes 4 bytes and returns -1.8 = #bfe66666
+g_ffmt(0) gives 4 bytes: "-1.8"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfe66667 = -1.8000001
+fI[1] = #bfe66666 = -1.8
+fI[1] == strtof
+
+
+Input: 1.9
+strtof consumes 3 bytes and returns 1.9000001 = #3ff33334
+g_ffmt(0) gives 9 bytes: "1.9000001"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3ff33333 = 1.9
+fI[1] = #3ff33334 = 1.9000001
+fI[1] == strtof
+
+
+Input: -1.9
+strtof consumes 4 bytes and returns -1.9 = #bff33333
+g_ffmt(0) gives 4 bytes: "-1.9"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bff33334 = -1.9000001
+fI[1] = #bff33333 = -1.9
+fI[1] == strtof
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+strtof consumes 3 bytes and returns 1.0999999 = #3f8ccccc
+g_ffmt(0) gives 9 bytes: "1.0999999"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3f8ccccc = 1.0999999
+fI[1] = #3f8ccccd = 1.1
+fI[0] == strtof
+
+
+Input: -1.1
+strtof consumes 4 bytes and returns -1.1 = #bf8ccccd
+g_ffmt(0) gives 4 bytes: "-1.1"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bf8ccccd = -1.1
+fI[1] = #bf8ccccc = -1.0999999
+fI[0] == strtof
+
+
+Input: 1.2
+strtof consumes 3 bytes and returns 1.1999999 = #3f999999
+g_ffmt(0) gives 9 bytes: "1.1999999"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3f999999 = 1.1999999
+fI[1] = #3f99999a = 1.2
+fI[0] == strtof
+
+
+Input: -1.2
+strtof consumes 4 bytes and returns -1.2 = #bf99999a
+g_ffmt(0) gives 4 bytes: "-1.2"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bf99999a = -1.2
+fI[1] = #bf999999 = -1.1999999
+fI[0] == strtof
+
+
+Input: 1.3
+strtof consumes 3 bytes and returns 1.3 = #3fa66666
+g_ffmt(0) gives 3 bytes: "1.3"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fa66666 = 1.3
+fI[1] = #3fa66667 = 1.3000001
+fI[0] == strtof
+
+
+Input: -1.3
+strtof consumes 4 bytes and returns -1.3000001 = #bfa66667
+g_ffmt(0) gives 10 bytes: "-1.3000001"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfa66667 = -1.3000001
+fI[1] = #bfa66666 = -1.3
+fI[0] == strtof
+
+
+Input: 1.4
+strtof consumes 3 bytes and returns 1.4 = #3fb33333
+g_ffmt(0) gives 3 bytes: "1.4"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fb33333 = 1.4
+fI[1] = #3fb33334 = 1.4000001
+fI[0] == strtof
+
+
+Input: -1.4
+strtof consumes 4 bytes and returns -1.4000001 = #bfb33334
+g_ffmt(0) gives 10 bytes: "-1.4000001"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfb33334 = -1.4000001
+fI[1] = #bfb33333 = -1.4
+fI[0] == strtof
+
+
+Input: 1.5
+strtof consumes 3 bytes and returns 1.5 = #3fc00000
+g_ffmt(0) gives 3 bytes: "1.5"
+
+strtoIf returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: -1.5
+strtof consumes 4 bytes and returns -1.5 = #bfc00000
+g_ffmt(0) gives 4 bytes: "-1.5"
+
+strtoIf returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtof
+
+
+Input: 1.6
+strtof consumes 3 bytes and returns 1.5999999 = #3fcccccc
+g_ffmt(0) gives 9 bytes: "1.5999999"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3fcccccc = 1.5999999
+fI[1] = #3fcccccd = 1.6
+fI[0] == strtof
+
+
+Input: -1.6
+strtof consumes 4 bytes and returns -1.6 = #bfcccccd
+g_ffmt(0) gives 4 bytes: "-1.6"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bfcccccd = -1.6
+fI[1] = #bfcccccc = -1.5999999
+fI[0] == strtof
+
+
+Input: 1.7
+strtof consumes 3 bytes and returns 1.6999999 = #3fd99999
+g_ffmt(0) gives 9 bytes: "1.6999999"
+
+strtoIf returns 33, consuming 3 bytes.
+fI[0] = #3fd99999 = 1.6999999
+fI[1] = #3fd9999a = 1.7
+fI[0] == strtof
+
+
+Input: -1.7
+strtof consumes 4 bytes and returns -1.7 = #bfd9999a
+g_ffmt(0) gives 4 bytes: "-1.7"
+
+strtoIf returns 41, consuming 4 bytes.
+fI[0] = #bfd9999a = -1.7
+fI[1] = #bfd99999 = -1.6999999
+fI[0] == strtof
+
+
+Input: 1.8
+strtof consumes 3 bytes and returns 1.8 = #3fe66666
+g_ffmt(0) gives 3 bytes: "1.8"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3fe66666 = 1.8
+fI[1] = #3fe66667 = 1.8000001
+fI[0] == strtof
+
+
+Input: -1.8
+strtof consumes 4 bytes and returns -1.8000001 = #bfe66667
+g_ffmt(0) gives 10 bytes: "-1.8000001"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bfe66667 = -1.8000001
+fI[1] = #bfe66666 = -1.8
+fI[0] == strtof
+
+
+Input: 1.9
+strtof consumes 3 bytes and returns 1.9 = #3ff33333
+g_ffmt(0) gives 3 bytes: "1.9"
+
+strtoIf returns 17, consuming 3 bytes.
+fI[0] = #3ff33333 = 1.9
+fI[1] = #3ff33334 = 1.9000001
+fI[0] == strtof
+
+
+Input: -1.9
+strtof consumes 4 bytes and returns -1.9000001 = #bff33334
+g_ffmt(0) gives 10 bytes: "-1.9000001"
+
+strtoIf returns 25, consuming 4 bytes.
+fI[0] = #bff33334 = -1.9000001
+fI[1] = #bff33333 = -1.9
+fI[0] == strtof
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/ftest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/ftest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/ftest.c	(revision 2404)
@@ -0,0 +1,146 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* Test program for g_ffmt, strtof, strtoIf, strtopf, and strtorf.
+ *
+ * Inputs (on stdin):
+ *		r rounding_mode
+ *		n ndig
+ *		number
+ *		#hex
+ *
+ *	rounding_mode values:
+ *		0 = toward zero
+ *		1 = nearest
+ *		2 = toward +Infinity
+ *		3 = toward -Infinity
+ *
+ * where number is a decimal floating-point number,
+ * hex is a string of <= 8 Hex digits for the internal representation
+ * of the number, and ndig is a parameters to g_ffmt.
+ */
+
+#include "gdtoa.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+ extern int getround ANSI((int,char*));
+
+ static char ibuf[2048], obuf[1024];
+
+#define U (unsigned long)
+
+ int
+main(Void)
+{
+	ULong *L;
+	char *s, *se, *se1;
+	int dItry, i, i1, ndig = 0, r = 1;
+	float f, f1, fI[2];
+
+	L = (ULong*)&f;
+	while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) {
+		while(*s <= ' ')
+			if (!*s++)
+				continue;
+		dItry = 0;
+		switch(*s) {
+		  case 'r':
+			r = getround(r, s);
+			continue;
+		  case 'n':
+			i = s[1];
+			if (i <= ' ' || i >= '0' && i <= '9') {
+				ndig = atoi(s+1);
+				continue;
+				}
+			break; /* nan? */
+		  case '#':
+			sscanf(s+1, "%lx", &L[0]);
+			printf("\nInput: %s", ibuf);
+			printf(" --> f = #%lx\n", L[0]);
+			goto fmt_test;
+			}
+		dItry = 1;
+		printf("\nInput: %s", ibuf);
+		i = strtorf(ibuf, &se, r, &f);
+		if (r == 1) {
+		    if (f != (i1 = strtopf(ibuf, &se1, &f1), f1)
+				 || se != se1 || i != i1) {
+			printf("***strtopf and strtorf disagree!!\n");
+			if (f != f1)
+				printf("\tf1 = %g\n", (double)f1);
+			if (i != i1)
+				printf("\ti = %d but i1 = %d\n", i, i1);
+			if (se != se1)
+				printf("se - se1 = %d\n", (int)(se-se1));
+			}
+		    if (f != strtof(ibuf, &se1) || se != se1)
+			printf("***strtof and strtorf disagree!\n");
+		    }
+		printf("strtof consumes %d bytes and returns %.8g = #%lx\n",
+				(int)(se-ibuf), f, U *(ULong*)&f);
+ fmt_test:
+		se = g_ffmt(obuf, &f, ndig, sizeof(obuf));
+		printf("g_ffmt(%d) gives %d bytes: \"%s\"\n\n",
+			ndig, (int)(se-obuf), se ? obuf : "<null>");
+		if (!dItry)
+			continue;
+		printf("strtoIf returns %d,", strtoIf(ibuf, &se, fI, &fI[1]));
+		printf(" consuming %d bytes.\n", (int)(se-ibuf));
+		if (fI[0] == fI[1]) {
+			if (fI[0] == f)
+				printf("fI[0] == fI[1] == strtof\n");
+			else
+				printf("fI[0] == fI[1] = #%lx = %.8g\n",
+					U *(ULong*)fI, fI[0]);
+			}
+		else {
+			printf("fI[0] = #%lx = %.8g\nfI[1] = #%lx = %.8g\n",
+				U *(ULong*)fI, fI[0],
+				U *(ULong*)&fI[1], fI[1]);
+			if (fI[0] == f)
+				printf("fI[0] == strtof\n");
+			else if (fI[1] == f)
+				printf("fI[1] == strtof\n");
+			else
+				printf("**** Both differ from strtof ****\n");
+			}
+		printf("\n");
+		}
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/getround.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/getround.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/getround.c	(revision 2404)
@@ -0,0 +1,68 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static char *dir[4] = { "toward zero", "nearest", "toward +Infinity",
+			"toward -Infinity" };
+
+ int
+#ifdef KR_headers
+getround(r, s) int r; char *s;
+#else
+getround(int r, char *s)
+#endif
+{
+	int i;
+
+	i = atoi(s+1);
+	if (i >= 0 && i < 4) {
+		printf("Rounding mode for strtor... ");
+		if (i == r)
+			printf("was and is %d (%s)\n", i, dir[i]);
+		else
+			printf("changed from %d (%s) to %d (%s)\n",
+				r, dir[r], i, dir[i]);
+		return i;
+		}
+	printf("Bad rounding direction %d: choose among\n", i);
+	for(i = 0; i < 4; i++)
+		printf("\t%d (%s)\n", i, dir[i]);
+	printf("Leaving rounding mode for strtor... at %d (%s)\n", r, dir[r]);
+	return r;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/makefile
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/makefile	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/makefile	(revision 2404)
@@ -0,0 +1,135 @@
+# /****************************************************************
+# Copyright (C) 1998, 2000 by Lucent Technologies
+# All Rights Reserved
+#
+# Permission to use, copy, modify, and distribute this software and
+# its documentation for any purpose and without fee is hereby
+# granted, provided that the above copyright notice appear in all
+# copies and that both that the copyright notice and this
+# permission notice and warranty disclaimer appear in supporting
+# documentation, and that the name of Lucent or any of its entities
+# not be used in advertising or publicity pertaining to
+# distribution of the software without specific, written prior
+# permission.
+#
+# LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+# IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+# THIS SOFTWARE.
+#
+# ****************************************************************/
+
+.SUFFIXES: .c .o
+CC = cc
+CFLAGS = -g -I..
+A = ../gdtoa.a
+
+.c.o:
+	$(CC) -c $(CFLAGS) $*.c
+
+all: dt dItest ddtest dtest ftest Qtest xLtest xtest ddtestsi dItestsi tests
+
+dt = dt.o $A
+dt: $(dt)
+	$(CC) -o dt $(dt)
+
+dItest = dItest.o getround.o $A
+dItest: $(dItest)
+	$(CC) -o dItest $(dItest)
+
+ddtest = ddtest.o getround.o $A
+ddtest: $(ddtest)
+	$(CC) -o ddtest $(ddtest)
+
+dtest = dtest.o getround.o $A
+dtest: $(dtest)
+	$(CC) -o dtest $(dtest)
+
+ftest = ftest.o getround.o $A
+ftest: $(ftest)
+	$(CC) -o ftest $(ftest)
+
+Qtest = Qtest.o getround.o $A
+Qtest: $(Qtest)
+	$(CC) -o Qtest $(Qtest)
+
+xtest = xtest.o getround.o $A
+xtest: $(xtest)
+	$(CC) -o xtest $(xtest)
+
+xLtest = xLtest.o getround.o $A
+xLtest: $(xLtest)
+	$(CC) -o xLtest $(xLtest)
+
+strtopddSI.o: strtopddSI.c ../strtopdd.c
+
+strtorddSI.o: strtorddSI.c ../strtordd.c
+
+strtodISI.o: strtodISI.c ../strtodI.c
+
+strtoIddSI.o: strtoIddSI.c ../strtoIdd.c
+
+strtoIdSI.o: strtoIdSI.c ../strtoId.c
+
+ddtestsi = ddtest.o strtopddSI.o strtorddSI.o strtoIddSI.o getround.o $A
+ddtestsi: $(ddtestsi)
+	$(CC) -o ddtestsi $(ddtestsi)
+
+dItestsi = dItest.o strtodISI.o strtoIdSI.o getround.o $A
+dItestsi: $(dItestsi)
+	$(CC) -o dItestsi $(dItestsi)
+
+strtodt = strtodt.o $A
+strtodt: $(strtodt)
+	$(CC) -o strtodt $(strtodt)
+
+# xQtest generates cp commands that depend on sizeof(long double).
+# See the source for details.  If you know better, create Q.out,
+# x.out and xL.out by copying the relevant *.ou0 or *.ou1 files
+# to the corresponding .out files.  In short, the *.ou0 files are
+# for long double == double; x.ou1 and xL.ou1 are for
+# long double == extended (a la 80x87 and MC680x0), and Q.ou1 is
+# for long double == quad.
+
+Q.out x.out xL.out:
+	$(CC) -o xQtest xQtest.c
+	./xQtest | sh
+	rm -f xQtest xQtest.o
+
+## The rmdir below will fail if any test results differ.
+
+tests: Q.out x.out xL.out dt dItest ddtest dtest ftest Qtest xLtest xtest ddtestsi dItestsi strtodt
+	mkdir bad
+	cat testnos testnos1 | ./dt >zap 2>&1
+	cmp dtst.out zap || mv zap bad/dtst.out
+	./dItest <testnos >zap 2>&1
+	cmp dI.out zap || mv zap bad/dI.out
+	./dItestsi <testnos >zap 2>&1
+	cmp dIsi.out zap || mv zap bad/dIsi.out
+	./ddtestsi <testnos >zap 2>&1
+	cmp ddsi.out zap || mv zap bad/ddsi.out
+	for i in dd d f x xL Q; do cat testnos rtestnos | \
+	 ./"$$i"test >zap 2>&1;\
+	cmp $$i.out zap || mv zap bad/$$i.out; done
+	./strtodt testnos3 >bad/strtodt.out && rm bad/strtodt.out || \
+		cat bad/strtodt.out
+	rmdir bad
+	touch tests
+
+xs0 = README Qtest.c dItest.c ddtest.c dtest.c dt.c ftest.c getround.c \
+	strtoIdSI.c strtoIddSI.c strtodISI.c strtodt.c strtopddSI.c \
+	strtorddSI.c xLtest.c xQtest.c xtest.c rtestnos testnos testnos1 \
+	testnos3 dI.out dIsi.out ddsi.out dd.out dtst.out d.out f.out \
+	x.ou0 xL.ou0 x.ou1 xL.ou1 Q.ou0 Q.ou1 makefile
+
+xsum.out: xsum0.out $(xs0)
+	xsum $(xs0) >xsum1.out
+	cmp xsum0.out xsum1.out && mv xsum1.out xsum.out || diff xsum[01].out
+
+clean:
+	rm -f *.[ao] dt *test *testsi strtodt xsum.out xsum1.out tests zap x.out xL.out Q.out
+	rm -rf bad
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/rtestnos
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/rtestnos	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/rtestnos	(revision 2404)
@@ -0,0 +1,76 @@
+r0
+1.1
+-1.1
+1.2
+-1.2
+1.3
+-1.3
+1.4
+-1.4
+1.5
+-1.5
+1.6
+-1.6
+1.7
+-1.7
+1.8
+-1.8
+1.9
+-1.9
+r1
+1.1
+-1.1
+1.2
+-1.2
+1.3
+-1.3
+1.4
+-1.4
+1.5
+-1.5
+1.6
+-1.6
+1.7
+-1.7
+1.8
+-1.8
+1.9
+-1.9
+r2
+1.1
+-1.1
+1.2
+-1.2
+1.3
+-1.3
+1.4
+-1.4
+1.5
+-1.5
+1.6
+-1.6
+1.7
+-1.7
+1.8
+-1.8
+1.9
+-1.9
+r3
+1.1
+-1.1
+1.2
+-1.2
+1.3
+-1.3
+1.4
+-1.4
+1.5
+-1.5
+1.6
+-1.6
+1.7
+-1.7
+1.8
+-1.8
+1.9
+-1.9
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/strtoIdSI.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/strtoIdSI.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/strtoIdSI.c	(revision 2404)
@@ -0,0 +1,2 @@
+#define Sudden_Underflow
+#include "../strtoId.c"
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/strtoIddSI.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/strtoIddSI.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/strtoIddSI.c	(revision 2404)
@@ -0,0 +1,2 @@
+#define Sudden_Underflow
+#include "../strtoIdd.c"
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/strtodISI.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/strtodISI.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/strtodISI.c	(revision 2404)
@@ -0,0 +1,2 @@
+#define Sudden_Underflow
+#include "../strtodI.c"
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/strtodt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/strtodt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/strtodt.c	(revision 2404)
@@ -0,0 +1,140 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* Test strtod.  */
+
+/* On stdin, read triples: d x y:
+ *	d = decimal string
+ *	x = high-order Hex value expected from strtod
+ *	y = low-order Hex value
+ * Complain about errors.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+ static int W0, W1;
+ typedef union {
+		double d;
+		long L[2];
+		} U;
+
+ static int
+process(char *fname, FILE *f)
+{
+	U a, b;
+	char buf[2048];
+	double d;
+	char *s;
+	int line, n;
+
+	line = n = 0;
+
+ top:
+	while(fgets(s = buf, sizeof(buf), f)) {
+		line++;
+		while(*s <= ' ')
+			if (!*s++)
+				goto top; /* break 2 */
+		if (*s == '#')
+			continue;
+		while(*s > ' ')
+			s++;
+		if (sscanf(s,"\t%lx\t%lx", &a.L[0], &a.L[1]) != 2) {
+			printf("Badly formatted line %d of %s\n",
+				line, fname);
+			n++;
+			continue;
+			}
+		b.d = strtod(buf,0);
+		if (b.L[W0] != a.L[0] || b.L[W1] != a.L[1]) {
+			n++;
+			printf("Line %d of %s: got %lx %lx; expected %lx %lx\n",
+				line, fname, b.L[W0], b.L[W1], a.L[0], a.L[1]);
+			}
+		}
+	return n;
+	}
+
+ int
+main(int argc, char **argv)
+{
+	FILE *f;
+	char *prog, *s;
+	int n, rc;
+	U u;
+
+	prog = argv[0];
+	if (argc == 2 && !strcmp(argv[1],"-?")) {
+		fprintf(stderr, "Usage: %s [file [file...]]\n"
+			"\tto read data file(s) of tab-separated triples d x y with\n"
+			"\t\td decimal string\n"
+			"\t\tx = high-order Hex value expected from strtod\n"
+			"\t\ty = low-order Hex value\n"
+			"\tComplain about errors by strtod.\n"
+			"\tIf no files, read triples from stdin.\n",
+			prog);
+		return 0;
+		}
+
+	/* determine endian-ness */
+
+	u.d = 1.;
+	W0 = u.L[0] == 0;
+	W1 = 1 - W0;
+
+	/* test */
+
+	n = rc = 0;
+	if (argc <= 1)
+		n = process("<stdin>", stdin);
+	else
+		while(s = *++argv)
+			if (f = fopen(s,"r")) {
+				n += process(s, f);
+				fclose(f);
+				}
+			else {
+				rc = 2;
+				fprintf(stderr, "Cannot open %s\n", s);
+				}
+	printf("%d bad conversions\n", n);
+	if (n)
+		rc |= 1;
+	return rc;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/strtopddSI.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/strtopddSI.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/strtopddSI.c	(revision 2404)
@@ -0,0 +1,2 @@
+#define Sudden_Underflow
+#include "../strtopdd.c"
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/strtorddSI.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/strtorddSI.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/strtorddSI.c	(revision 2404)
@@ -0,0 +1,2 @@
+#define Sudden_Underflow
+#include "../strtordd.c"
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos	(revision 2404)
@@ -0,0 +1,28 @@
+1.23
+1.23e+20
+1.23e-20
+1.23456789
+1.23456589e+20
+1.23e+30
+1.23e-30
+1.23456789e-20
+1.23456789e-30
+1.234567890123456789
+1.23456789012345678901234567890123456789
+1.23e306
+1.23e-306
+1.23e-320
+1.23e-20
+1.23456789e307
+1.23456589e-307
+1.234567890123456789
+1.234567890123456789e301
+1.234567890123456789e-301
+1.234567890123456789e-321
+1e23
+1e310
+9.0259718793241475e-277
+9.025971879324147880346310405869e-277
+9.025971879324147880346310405868e-277
+2.2250738585072014e-308
+2.2250738585072013e-308
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos1
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos1	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos1	(revision 2404)
@@ -0,0 +1,20 @@
+1.23:2 6
+1.23:4 6
+1.23e+20:2 6
+1.23e+20:4 6
+1.23e-20:2 6
+1.23e-20:4 6
+1.23456789:2 6
+1.23456789:4 6
+1.23456589e+20:2 6
+1.23456589e+20:4 6
+1.23456789e-20:2 6
+1.23456789e-20:4 6
+1234565:2 6
+1234565:4 6
+1.234565:2 6
+1.234565:4 6
+1.234565e+20:2 6
+1.234565e+20:4 6
+1.234565e-20:2 6
+1.234565e-20:4 6
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos3
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos3	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/testnos3	(revision 2404)
@@ -0,0 +1,328 @@
+# Test triples for strtodt, derived from Fred Tydeman's posting
+# of 26 February 1996 to comp.arch.arithmetic.
+
+9e0306	7fa9a202	8368022e
+4e-079	2fa7b6d7	1d20b96c
+7e-261	9eb8d7e	32be6396
+6e-025	3ae7361c	b863de62
+7e-161	1eaf7e0d	b3799aa3
+7e0289	7c1cbb54	7777a285
+5e0079	507afcef	51f0fb5f
+1e0080	508afcef	51f0fb5f
+7e-303	1333391	31c46f8b
+5e0152	5fa317e5	ef3ab327
+5e0125	5a07a2ec	c414a03f
+2e0126	5a27a2ec	c414a03f
+7e-141	22d5570f	59bd178c
+4e-192	18323ff0	6eea847a
+9e0043	49102498	ea6df0c4
+1e0303	7ed754e3	1cd072da
+95e-089	2dde3cbc	9907fdc8
+85e0194	689d1c26	db7d0dae
+69e0267	77c0b7cb	60c994da
+97e-019	3c665dde	8e688ba6
+37e0046	49d033d7	eca0adef
+74e0046	49e033d7	eca0adef
+61e-099	2bc0ad83	6f269a17
+53e-208	151b39ae	1909c31b
+93e-234	fc27b2e	4f210075
+79e-095	2c9a5db8	12948281
+87e-274	772d36c	f48e7abd
+83e0025	4585747a	b143e353
+17e-036	38b698cc	dc60015a
+53e0033	47246a34	18629ef6
+51e-074	30ecd5be	e57763e6
+63e-022	3bbdc03b	8fd7016a
+839e0143	5e3ae03f	245703e2
+749e-182	1abf1472	7744c63e
+999e-026	3b282782	afe1869e
+345e0266	77b0b7cb	60c994da
+914e-102	2b5ffc81	bc29f02b
+829e0102	55b7221a	79cdd1d9
+307e0090	5322d6b1	83fe4b55
+859e0182	6654374d	8b87ac63
+283e0085	5216c309	24bab4b
+589e0187	675526be	9c22eb17
+302e0176	64fdcf7d	f8f573b7
+604e0176	650dcf7d	f8f573b7
+761e-244	de03cea	3586452e
+647e0230	7044d64d	4079150c
+755e0174	64a7d931	93f78fc6
+255e-075	30dcd5be	e57763e6
+3391e0055	4c159bd3	ad46e346
+4147e-015	3d923d1b	5eb1d778
+3996e-026	3b482782	afe1869e
+1998e-026	3b382782	afe1869e
+3338e-296	335519a	c5142aab
+1669e-296	325519a	c5142aab
+8699e-276	772d2df	246ecd2d
+5311e0243	73284e91	f4aa0fdb
+7903e-096	2cd07c2d	27a5b989
+7611e-226	11d19b87	44033457
+3257e0058	4cb444b3	4a6fb3eb
+6514e0058	4cc444b3	4a6fb3eb
+3571e0263	77462644	c61d41aa
+7142e0263	77562644	c61d41aa
+5311e0242	72f3720e	5d54d97c
+1617e-063	3384c98f	ce16152e
+51881e0037	4897d295	dc76da4
+31441e-118	285ef890	f5de4c86
+30179e0079	5143e272	a77478e8
+60358e0079	5153e272	a77478e8
+63876e-020	3cc70385	6844bdbf
+31938e-020	3cb70385	6844bdbf
+46073e-032	3a42405b	773fbdf3
+32941e0051	4b757eb8	ad52a5c9
+82081e0041	49770105	df3d47cb
+38701e-215	1440492a	4a8a37fd
+62745e0047	4ab0c52f	e6dc6a1b
+12549e0048	4ac0c52f	e6dc6a1b
+64009e-183	1af099b3	93b84832
+89275e0261	77262644	c61d41aa
+75859e0025	46232645	e1ba93f0
+57533e0287	7c8272ed	2307f56a
+584169e0229	70ad6570	59dc79aa
+940189e-112	29eb99d6	240c1a28
+416121e0197	6a00fd07	ed297f80
+832242e0197	6a10fd07	ed297f80
+584738e0076	50e8a85e	b277e645
+933587e-140	241b2487	28b9c117
+252601e0121	5a2dda59	2e398dd7
+358423e0274	79f9463b	59b8f2bd
+892771e-213	14f25818	c7294f27
+410405e0040	49670105	df3d47cb
+928609e-261	afbe2dd	66200bef
+302276e-254	c55a462	d91c6ab3
+920657e-023	3c653a99	85dbde6c
+609019e-025	3bf1f99e	11ea0a24
+252601e0120	59f7e1e0	f1c7a4ac
+654839e-060	34b00e7d	b3b3f242
+8823691e0130	5c5e597c	b94b7ae
+2920845e0228	709d6570	59dc79aa
+9210917e0080	51fda232	347e6032
+5800419e-303	26e58ff	a48f4fce
+6119898e-243	ee3ecf2	2ea07863
+3059949e-243	ed3ecf2	2ea07863
+2572231e0223	6f90f73b	e1dff9ad
+5444097e-021	3cf8849d	d33c95af
+5783893e-127	26f7e590	2ce0e151
+3865421e-225	1295d4fe	53afec65
+4590831e0156	61b4689b	4a5fa201
+9181662e0156	61c4689b	4a5fa201
+5906361e-027	3bbbe45a	312d08a0
+7315057e0235	7225f0d4	8362a72
+9088115e0106	5762e51a	84a3c6a0
+1817623e0107	5772e51a	84a3c6a0
+44118455e0129	5c4e597c	b94b7ae
+35282041e0293	7e5512d5	273e62e8
+31279898e-291	5129b01	b6885d36
+15639949e-291	5029b01	b6885d36
+27966061e0145	5f955bcf	72fd10f9
+55932122e0145	5fa55bcf	72fd10f9
+70176353e-053	36900683	a21de855
+40277543e-032	3adf29ca	ff893b1
+50609263e0157	622193af	f1f1c8e3
+66094077e0077	518b37c4	b7928317
+84863171e0114	59406e98	f5ec8f37
+89396333e0264	786526f0	61ca9053
+87575437e-309	16e0732	602056c
+78693511e-044	3870bc7b	7603a2ca
+90285923e-206	16d14700	83f89d48
+30155207e-030	3b423a4a	d20748a2
+245540327e0121	5acc569e	968e0944
+263125459e0287	7d44997a	298b2f2e
+566446538e-257	c64472b	a9550e86
+283223269e-257	c54472b	a9550e86
+245540327e0122	5b01b623	1e18c5cb
+491080654e0122	5b11b623	1e18c5cb
+971212611e-126	27a397d3	c9745d2f
+229058583e0052	4c76ce94	febdc7a5
+325270231e0039	49cc7ccf	90c9f8ab
+989648089e-035	3a8880a3	d515e849
+653777767e0273	7a720223	f2b3a881
+923091487e0209	6d30bc60	e6896717
+526250918e0288	7d89bfd8	b3edfafa
+350301748e-309	18e0732	602056c
+741111169e-203	17a14fe7	daf8f3ae
+667284113e-240	ff09355	f8050c02
+1227701635e0120	5abc569e	968e0944
+9981396317e-182	1c38afe1	a2a66aa
+5232604057e-298	41465b8	96c24520
+5572170023e-088	2fb08478	22f765b2
+1964322616e0122	5b31b623	1e18c5cb
+3928645232e0122	5b41b623	1e18c5cb
+8715380633e-058	35f4614c	3219891f
+4856063055e-127	279397d3	c9745d2f
+8336960483e-153	223a06a1	24b95e1
+1007046393e-155	21a01891	fc4717fd
+5378822089e-176	1d695fd4	c88d4b1b
+5981342308e-190	1a83db11	ac608107
+7214782613e-086	3020b552	d2edcdea
+5458466829e0142	5f70acde	6a98eb4c
+9078555839e-109	2b5fc575	867314ee
+6418488827e0079	526021f1	4ed7b3fa
+65325840981e0069	5081a151	ddbd3c4a
+49573485983e0089	54a221bd	871d2cf4
+46275205733e0074	51830e6c	7d4e3480
+92550411466e0074	51930e6c	7d4e3480
+41129842097e-202	1832c3e7	2d179607
+93227267727e-049	380960fe	8d5847f
+41297294357e0185	688c4943	7fccfadb
+41534892987e-067	343a1266	6477886d
+42333842451e0201	6be0189a	26df575f
+78564021519e-227	13115551	5fd37265
+53587107423e-061	35800a19	a3ffd981
+53827010643e-200	18a32fa6	9a69bd6d
+83356057653e0193	6a4544e6	daee2a18
+45256834646e-118	29a541ec	dfd48694
+45392779195e-110	2b4fc575	867314ee
+23934638219e0291	7e81deaf	40ead9a0
+995779191233e0113	59e2d44e	dcc51304
+997422852243e-265	b676688	faee99bc
+653532977297e-123	28d925a0	aabcdc68
+938885684947e0147	60f11894	b202e9f4
+619534293513e0124	5c210c20	303fe0f1
+539879452414e-042	39a5e66d	c3d6bdb5
+742522891517e0259	782c1c35	2fc3c309
+254901016865e-022	3dbc06d3	66394441
+685763015669e0280	7c85fd7a	a44d9477
+384865004907e-285	72aa65b	58639e69
+286556458711e0081	5321958b	36c5102b
+573112917422e0081	5331958b	36c5102b
+769525178383e-150	234253ec	e161420
+416780288265e0192	6a3544e6	daee2a18
+226963895975e-111	2b3fc575	867314ee
+665592809339e0063	4f778b65	16c2b478
+3891901811465e0217	6f99ab82	61990292
+4764593340755e0069	50e4177a	9915fbf8
+6336156586177e0269	7a7173f7	6c63b792
+8233559360849e0095	56566fee	5649a7a
+3662265515198e-107	2c538e6e	dd48f2a3
+1831132757599e-107	2c438e6e	dd48f2a3
+7812878489261e-179	1d726dae	7bbeda75
+6363857920591e0145	60b28a61	cf9483b7
+8811915538555e0082	53a51f50	8b287ae7
+9997878507563e-195	1a253db2	fea1ea31
+9224786422069e-291	634ee5d	56b32957
+6284426329974e-294	58d3409	dfbca26f
+9199302046091e-062	35c13597	2630774c
+6070482281213e-122	29423fa9	e6fcf47e
+2780161250963e-301	405acc2	53064c2
+8233559360849e0094	5621f324	d11d4862
+72027097041701e0206	6d946778	12d3a606
+97297545286625e0215	6f79ab82	61990292
+99021992302453e-025	3da5c671	4def374c
+54104687080198e-022	3e373cdf	8db7a7bc
+33519685743233e0089	5537f203	339c9629
+67039371486466e0089	5547f203	339c9629
+39064392446305e-180	1d626dae	7bbeda75
+17796979903653e0261	78e072f3	819c1321
+28921916763211e0038	4a9eebab	e0957af3
+87605699161665e0155	6302920f	96e7f9ef
+41921560615349e-067	34d9b2a5	c4041e4b
+80527976643809e0061	4f7c7c5a	ea080a49
+72335858886654e-159	21cce77c	2b3328fc
+52656615219377e0102	57f561de	f4a9ee32
+15400733123779e-072	33b8bf7e	7fa6f02a
+77003665618895e-073	33a8bf7e	7fa6f02a
+475603213226859e-042	3a42d730	88f4050a
+972708181182949e0116	5b218a7f	36172332
+246411729980464e-071	342eef5e	1f90ac34
+123205864990232e-071	341eef5e	1f90ac34
+609610927149051e-255	e104273	b18918b1
+475603213226859e-041	3a778cfc	ab31064d
+672574798934795e0065	508226c6	84c87261
+134514959786959e0066	509226c6	84c87261
+294897574603217e-151	2395f2df	5e675a0f
+723047919080275e0036	4a7eebab	e0957af3
+660191429952702e-088	30bddc7e	975c5045
+330095714976351e-088	30addc7e	975c5045
+578686871093232e-159	21fce77c	2b3328fc
+144671717773308e-159	21dce77c	2b3328fc
+385018328094475e-074	3398bf7e	7fa6f02a
+330095714976351e-089	3077e398	7916a69e
+2215901545757777e-212	171a80a6	e566428c
+1702061899637397e-276	9cacc46	749dccfe
+1864950924021923e0213	6f53ae60	753af6ca
+3729901848043846e0213	6f63ae60	753af6ca
+7487252720986826e-165	20f8823a	57adbef9
+3743626360493413e-165	20e8823a	57adbef9
+4988915232824583e0119	5be5f6de	9d5d6b5b
+3771476185376383e0277	7cae3c14	d6916ce9
+6182410494241627e-119	2a81b964	58445d07
+2572981889477453e0142	609dfc11	fbf46087
+7793560217139653e0051	4dd28046	1b856ec5
+9163942927285259e-202	194fe601	457dce4d
+6353227084707473e0155	63650aff	653ffe8a
+4431803091515554e-211	17609068	4f5fe998
+9324754620109615e0211	6f0f7d67	21f7f144
+8870461176410409e0263	79d90529	a37b7e22
+90372559027740405e0143	612491da	ad0ba280
+18074511805548081e0146	61a011f2	d73116f4
+54897030182071313e0029	496ec556	66d8f9ec
+76232626624829156e-032	3ccb7738	11e75fe
+59898021767894608e-165	2128823a	57adbef9
+29949010883947304e-165	2118823a	57adbef9
+26153245263757307e0049	4d83de00	5bd620df
+27176258005319167e-261	d27c074	7bd76fa1
+18074511805548081e0147	61d4166f	8cfd5cb1
+24691002732654881e-115	2b759a27	83ce70ab
+58483921078398283e0057	4f408ce4	99519ce3
+64409240769861689e-159	22692238	f7987779
+94080055902682397e-242	11364981	e39e66ca
+31766135423537365e0154	63550aff	653ffe8a
+68985865317742005e0164	657a999d	dec72aca
+13797173063548401e0165	658a999d	dec72aca
+902042358290366539e-281	9522dc0	1ca1cb8c
+238296178309629163e0272	7c038fd9	3f1f5342
+783308178698887621e0226	72925ae6	2cb346d8
+439176241456570504e0029	499ec556	66d8f9ec
+899810892172646163e0283	7e6adf51	fa055e03
+926145344610700019e-225	14f307a6	7f1f69ff
+653831131593932675e0047	4d63de00	5bd620df
+130766226318786535e0048	4d73de00	5bd620df
+557035730189854663e-294	693bfac	6bc4767b
+902042358290366539e-280	986b930	23ca3e6f
+272104041512242479e0200	6d13bbb4	bf05f087
+544208083024484958e0200	6d23bbb4	bf05f087
+680429695511221511e0192	6b808ebc	116f8a20
+308975121073410857e0236	7490db75	cc001072
+792644927852378159e0078	53d7bff3	36d8ff06
+783308178698887621e0223	71f2cbac	35f71140
+8396094300569779681e-252	f8ab223	efcee35a
+3507665085003296281e-074	346b85c0	26a264e4
+7322325862592278999e0074	5336775b	6caa5ae0
+6014546754280072926e0209	6f396397	b06732a4
+7120190517612959703e0120	5cc3220d	cd5899fd
+3507665085003296281e-073	34a13398	18257f0f
+4345544743100783551e-218	168a9c42	e5b6d89f
+9778613303868468131e-090	313146fe	1075e1ef
+7539204280836061195e-082	32d3d969	e3dbe723
+7862637540082247119e-202	19eaba32	62ee707b
+2176832332097939832e0200	6d43bbb4	bf05f087
+8643988913946659879e0115	5bbe71ec	1ed0a4f9
+5529436763613147623e0138	6079c677	be6f236e
+6764958008109694533e-173	1fed0669	2e6f5ef6
+6802601037806061975e0197	6cbf92ba	cb3cb40c
+1360520207561212395e0198	6ccf92ba	cb3cb40c
+62259110684423957791e0047	4dcd8f2c	fc20d6e8
+88800290202542652011e-226	1526cec5	1a43f41a
+41010852717673354694e-221	16201295	4b6aabba
+20505426358836677347e-221	16101295	4b6aabba
+66102447903809911604e0055	4f776206	8a24fd55
+35600952588064798515e0119	5cb3220d	cd5899fd
+14371240869903838702e0205	6e78d92d	2bcc7a81
+57500690832492901689e0043	4cf65d3e	2acd616b
+23432630639573022093e-107	2dbdd54c	40a2f25f
+62259110684423957791e0048	4e02797c	1d948651
+35620497849450218807e-306	475b220	82529425
+69658634627134074624e0200	6d93bbb4	bf05f087
+99440755792436956989e-062	37362d10	462a26f4
+55277197169490210673e0081	54d945bf	a911e32a
+36992084760177624177e-318	1f8c5f9	551c2f9a
+30888265282878466443e-111	2cf01b8e	f28251fc
+
+# examples of bugs introduced 20001113, fixed 20010207
+# first is 2^-1075 (half the smallest denormal)
+2.4703282292062327208828439643411068618252990130716238221279284125033775363510437593264991818081799618989828234772285886546332835517796989819938739800539093906315035659515570226392290858392449105184435931802849936536152500319370457678249219365623669863658480757001585769269903706311928279558551332927834338409351978015531246597263579574622766465272827220056374006485499977096599470454020828166226237857393450736339007967761930577506740176324673600968951340535537458516661134223766678604162159680461914467291840300530057530849048765391711386591646239524912623653881879636239373280423891018672348497668235089863388587925628302755995657524455507255189313690836254779186948667994968324049705821028513185451396213837722826145437693412532098591327667236328125e-324	0	0
+2.47032822920623272e-324	0	0
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/x.ou0
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/x.ou0	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/x.ou0	(revision 2404)
@@ -0,0 +1,1182 @@
+
+Input: 1.23
+
+strtox consumes 4 bytes and returns 33
+with bits = #3fff 9d70 a3d7 a3d 70a4
+g_xfmt(0) gives 4 bytes: "1.23"
+
+strtoIx returns 33, consuming 4 bytes.
+fI[0] = #3fff 9d70 a3d7 a3d 70a3
+fI[1] = #3fff 9d70 a3d7 a3d 70a3
+fI[1] == strtox
+
+
+Input: 1.23e+20
+
+strtox consumes 8 bytes and returns 1
+with bits = #4041 d55e f90a 2da1 8000
+g_xfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIx returns 1, consuming 8 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.23e-20
+
+strtox consumes 8 bytes and returns 17
+with bits = #3fbc e857 267b b3a9 84f2
+g_xfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #3fbc e857 267b b3a9 84f2
+fI[1] = #3fbc e857 267b b3a9 84f2
+fI[0] == strtox
+
+
+Input: 1.23456789
+
+strtox consumes 10 bytes and returns 33
+with bits = #3fff 9e06 5214 1ef0 dbf6
+g_xfmt(0) gives 10 bytes: "1.23456789"
+
+strtoIx returns 33, consuming 10 bytes.
+fI[0] = #3fff 9e06 5214 1ef0 dbf5
+fI[1] = #3fff 9e06 5214 1ef0 dbf5
+fI[1] == strtox
+
+
+Input: 1.23456589e+20
+
+strtox consumes 14 bytes and returns 1
+with bits = #4041 d629 bd33 5cc ba00
+g_xfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoIx returns 1, consuming 14 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.23e+30
+
+strtox consumes 8 bytes and returns 17
+with bits = #4062 f865 8274 7dbc 824a
+g_xfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #4062 f865 8274 7dbc 824a
+fI[1] = #4062 f865 8274 7dbc 824a
+fI[0] == strtox
+
+
+Input: 1.23e-30
+
+strtox consumes 8 bytes and returns 17
+with bits = #3f9b c794 337a 8085 54eb
+g_xfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #3f9b c794 337a 8085 54eb
+fI[1] = #3f9b c794 337a 8085 54eb
+fI[0] == strtox
+
+
+Input: 1.23456789e-20
+
+strtox consumes 14 bytes and returns 17
+with bits = #3fbc e934 a38 f3d6 d352
+g_xfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoIx returns 17, consuming 14 bytes.
+fI[0] = #3fbc e934 a38 f3d6 d352
+fI[1] = #3fbc e934 a38 f3d6 d352
+fI[0] == strtox
+
+
+Input: 1.23456789e-30
+
+strtox consumes 14 bytes and returns 17
+with bits = #3f9b c851 f19d decc a8fc
+g_xfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoIx returns 17, consuming 14 bytes.
+fI[0] = #3f9b c851 f19d decc a8fc
+fI[1] = #3f9b c851 f19d decc a8fc
+fI[0] == strtox
+
+
+Input: 1.234567890123456789
+
+strtox consumes 20 bytes and returns 17
+with bits = #3fff 9e06 5214 62cf db8d
+g_xfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIx returns 17, consuming 20 bytes.
+fI[0] = #3fff 9e06 5214 62cf db8d
+fI[1] = #3fff 9e06 5214 62cf db8d
+fI[0] == strtox
+
+
+Input: 1.23456789012345678901234567890123456789
+
+strtox consumes 40 bytes and returns 17
+with bits = #3fff 9e06 5214 62cf db8d
+g_xfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIx returns 17, consuming 40 bytes.
+fI[0] = #3fff 9e06 5214 62cf db8d
+fI[1] = #3fff 9e06 5214 62cf db8d
+fI[0] == strtox
+
+
+Input: 1.23e306
+
+strtox consumes 8 bytes and returns 17
+with bits = #43f7 e033 b668 e30f a6d5
+g_xfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #43f7 e033 b668 e30f a6d5
+fI[1] = #43f7 e033 b668 e30f a6d5
+fI[0] == strtox
+
+
+Input: 1.23e-306
+
+strtox consumes 9 bytes and returns 33
+with bits = #3c06 dd1d c2ed 1cb7 3f25
+g_xfmt(0) gives 9 bytes: "1.23e-306"
+
+strtoIx returns 33, consuming 9 bytes.
+fI[0] = #3c06 dd1d c2ed 1cb7 3f24
+fI[1] = #3c06 dd1d c2ed 1cb7 3f24
+fI[1] == strtox
+
+
+Input: 1.23e-320
+
+strtox consumes 9 bytes and returns 33
+with bits = #3bd8 9b98 c371 844c 3f1a
+g_xfmt(0) gives 9 bytes: "1.23e-320"
+
+strtoIx returns 33, consuming 9 bytes.
+fI[0] = #3bd8 9b98 c371 844c 3f19
+fI[1] = #3bd8 9b98 c371 844c 3f19
+fI[1] == strtox
+
+
+Input: 1.23e-20
+
+strtox consumes 8 bytes and returns 17
+with bits = #3fbc e857 267b b3a9 84f2
+g_xfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #3fbc e857 267b b3a9 84f2
+fI[1] = #3fbc e857 267b b3a9 84f2
+fI[0] == strtox
+
+
+Input: 1.23456789e307
+
+strtox consumes 14 bytes and returns 17
+with bits = #43fb 8ca5 8a5e d766 de75
+g_xfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoIx returns 17, consuming 14 bytes.
+fI[0] = #43fb 8ca5 8a5e d766 de75
+fI[1] = #43fb 8ca5 8a5e d766 de75
+fI[0] == strtox
+
+
+Input: 1.23456589e-307
+
+strtox consumes 15 bytes and returns 17
+with bits = #3c03 b18c b5dc c22f d369
+g_xfmt(0) gives 15 bytes: "1.23456589e-307"
+
+strtoIx returns 17, consuming 15 bytes.
+fI[0] = #3c03 b18c b5dc c22f d369
+fI[1] = #3c03 b18c b5dc c22f d369
+fI[0] == strtox
+
+
+Input: 1.234567890123456789
+
+strtox consumes 20 bytes and returns 17
+with bits = #3fff 9e06 5214 62cf db8d
+g_xfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIx returns 17, consuming 20 bytes.
+fI[0] = #3fff 9e06 5214 62cf db8d
+fI[1] = #3fff 9e06 5214 62cf db8d
+fI[0] == strtox
+
+
+Input: 1.234567890123456789e301
+
+strtox consumes 24 bytes and returns 33
+with bits = #43e7 937a 8baf ab20 980c
+g_xfmt(0) gives 25 bytes: "1.234567890123456789e+301"
+
+strtoIx returns 33, consuming 24 bytes.
+fI[0] = #43e7 937a 8baf ab20 980b
+fI[1] = #43e7 937a 8baf ab20 980b
+fI[1] == strtox
+
+
+Input: 1.234567890123456789e-301
+
+strtox consumes 25 bytes and returns 33
+with bits = #3c17 a953 271a 5d06 9ad9
+g_xfmt(0) gives 25 bytes: "1.234567890123456789e-301"
+
+strtoIx returns 33, consuming 25 bytes.
+fI[0] = #3c17 a953 271a 5d06 9ad8
+fI[1] = #3c17 a953 271a 5d06 9ad8
+fI[1] == strtox
+
+
+Input: 1.234567890123456789e-321
+
+strtox consumes 25 bytes and returns 33
+with bits = #3bd4 f9e1 1b4c ea6d cce9
+g_xfmt(0) gives 25 bytes: "1.234567890123456789e-321"
+
+strtoIx returns 33, consuming 25 bytes.
+fI[0] = #3bd4 f9e1 1b4c ea6d cce8
+fI[1] = #3bd4 f9e1 1b4c ea6d cce8
+fI[1] == strtox
+
+
+Input: 1e23
+
+strtox consumes 4 bytes and returns 1
+with bits = #404b a968 163f a57 b400
+g_xfmt(0) gives 5 bytes: "1e+23"
+
+strtoIx returns 1, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1e310
+
+strtox consumes 5 bytes and returns 33
+with bits = #4404 de81 e40a 34b cf50
+g_xfmt(0) gives 6 bytes: "1e+310"
+
+strtoIx returns 33, consuming 5 bytes.
+fI[0] = #4404 de81 e40a 34b cf4f
+fI[1] = #4404 de81 e40a 34b cf4f
+fI[1] == strtox
+
+
+Input: 9.0259718793241475e-277
+
+strtox consumes 23 bytes and returns 33
+with bits = #3c69 ffff ffff ffff fcf7
+g_xfmt(0) gives 23 bytes: "9.0259718793241475e-277"
+
+strtoIx returns 33, consuming 23 bytes.
+fI[0] = #3c69 ffff ffff ffff fcf6
+fI[1] = #3c69 ffff ffff ffff fcf6
+fI[1] == strtox
+
+
+Input: 9.025971879324147880346310405869e-277
+
+strtox consumes 37 bytes and returns 17
+with bits = #3c6a 8000 0 0 0
+g_xfmt(0) gives 26 bytes: "9.0259718793241478803e-277"
+
+strtoIx returns 17, consuming 37 bytes.
+fI[0] = #3c6a 8000 0 0 0
+fI[1] = #3c6a 8000 0 0 0
+fI[0] == strtox
+
+
+Input: 9.025971879324147880346310405868e-277
+
+strtox consumes 37 bytes and returns 33
+with bits = #3c6a 8000 0 0 0
+g_xfmt(0) gives 26 bytes: "9.0259718793241478803e-277"
+
+strtoIx returns 33, consuming 37 bytes.
+fI[0] = #3c69 ffff ffff ffff ffff
+fI[1] = #3c6a 8000 0 ffff ffff
+fI[1] == strtox
+
+
+Input: 2.2250738585072014e-308
+
+strtox consumes 23 bytes and returns 17
+with bits = #3c01 8000 0 0 46
+g_xfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoIx returns 17, consuming 23 bytes.
+fI[0] = #3c01 8000 0 0 46
+fI[1] = #3c01 8000 0 0 46
+fI[0] == strtox
+
+
+Input: 2.2250738585072013e-308
+
+strtox consumes 23 bytes and returns 17
+with bits = #3c00 ffff ffff ffff fd4f
+g_xfmt(0) gives 23 bytes: "2.2250738585072013e-308"
+
+strtoIx returns 17, consuming 23 bytes.
+fI[0] = #3c00 ffff ffff ffff fd4f
+fI[1] = #3c00 ffff ffff ffff fd4f
+fI[0] == strtox
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff 8ccc cccc cccc cccc
+g_xfmt(0) gives 21 bytes: "1.0999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 8ccc cccc cccc cccc
+fI[1] = #3fff 8ccc cccc cccc cccc
+fI[0] == strtox
+
+
+Input: -1.1
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff 8ccc cccc cccc cccc
+g_xfmt(0) gives 22 bytes: "-1.0999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 8ccc cccc cccc cccd
+fI[1] = #bfff 8ccc cccc cccc cccd
+fI[1] == strtox
+
+
+Input: 1.2
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff 9999 9999 9999 9999
+g_xfmt(0) gives 21 bytes: "1.1999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 9999 9999 9999 9999
+fI[1] = #3fff 9999 9999 9999 9999
+fI[0] == strtox
+
+
+Input: -1.2
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff 9999 9999 9999 9999
+g_xfmt(0) gives 22 bytes: "-1.1999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 9999 9999 9999 999a
+fI[1] = #bfff 9999 9999 9999 999a
+fI[1] == strtox
+
+
+Input: 1.3
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff a666 6666 6666 6666
+g_xfmt(0) gives 3 bytes: "1.3"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff a666 6666 6666 6666
+fI[1] = #3fff a666 6666 6666 6666
+fI[0] == strtox
+
+
+Input: -1.3
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff a666 6666 6666 6666
+g_xfmt(0) gives 4 bytes: "-1.3"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff a666 6666 6666 6667
+fI[1] = #bfff a666 6666 6666 6667
+fI[1] == strtox
+
+
+Input: 1.4
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff b333 3333 3333 3333
+g_xfmt(0) gives 3 bytes: "1.4"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff b333 3333 3333 3333
+fI[1] = #3fff b333 3333 3333 3333
+fI[0] == strtox
+
+
+Input: -1.4
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff b333 3333 3333 3333
+g_xfmt(0) gives 4 bytes: "-1.4"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff b333 3333 3333 3334
+fI[1] = #bfff b333 3333 3333 3334
+fI[1] == strtox
+
+
+Input: 1.5
+
+strtox consumes 3 bytes and returns 1
+with bits = #3fff c000 0 0 0
+g_xfmt(0) gives 3 bytes: "1.5"
+
+strtoIx returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: -1.5
+
+strtox consumes 4 bytes and returns 9
+with bits = #bfff c000 0 0 0
+g_xfmt(0) gives 4 bytes: "-1.5"
+
+strtoIx returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.6
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff cccc cccc cccc cccc
+g_xfmt(0) gives 21 bytes: "1.5999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff cccc cccc cccc cccc
+fI[1] = #3fff cccc cccc cccc cccc
+fI[0] == strtox
+
+
+Input: -1.6
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff cccc cccc cccc cccc
+g_xfmt(0) gives 22 bytes: "-1.5999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff cccc cccc cccc cccd
+fI[1] = #bfff cccc cccc cccc cccd
+fI[1] == strtox
+
+
+Input: 1.7
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff d999 9999 9999 9999
+g_xfmt(0) gives 21 bytes: "1.6999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff d999 9999 9999 9999
+fI[1] = #3fff d999 9999 9999 9999
+fI[0] == strtox
+
+
+Input: -1.7
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff d999 9999 9999 9999
+g_xfmt(0) gives 22 bytes: "-1.6999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff d999 9999 9999 999a
+fI[1] = #bfff d999 9999 9999 999a
+fI[1] == strtox
+
+
+Input: 1.8
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff e666 6666 6666 6666
+g_xfmt(0) gives 3 bytes: "1.8"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff e666 6666 6666 6666
+fI[1] = #3fff e666 6666 6666 6666
+fI[0] == strtox
+
+
+Input: -1.8
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff e666 6666 6666 6666
+g_xfmt(0) gives 4 bytes: "-1.8"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff e666 6666 6666 6667
+fI[1] = #bfff e666 6666 6666 6667
+fI[1] == strtox
+
+
+Input: 1.9
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff f333 3333 3333 3333
+g_xfmt(0) gives 3 bytes: "1.9"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff f333 3333 3333 3333
+fI[1] = #3fff f333 3333 3333 3333
+fI[0] == strtox
+
+
+Input: -1.9
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff f333 3333 3333 3333
+g_xfmt(0) gives 4 bytes: "-1.9"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff f333 3333 3333 3334
+fI[1] = #bfff f333 3333 3333 3334
+fI[1] == strtox
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff 8ccc cccc cccc cccd
+g_xfmt(0) gives 3 bytes: "1.1"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 8ccc cccc cccc cccc
+fI[1] = #3fff 8ccc cccc cccc cccc
+fI[1] == strtox
+
+
+Input: -1.1
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff 8ccc cccc cccc cccd
+g_xfmt(0) gives 4 bytes: "-1.1"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 8ccc cccc cccc cccd
+fI[1] = #bfff 8ccc cccc cccc cccd
+fI[0] == strtox
+
+
+Input: 1.2
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff 9999 9999 9999 999a
+g_xfmt(0) gives 3 bytes: "1.2"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 9999 9999 9999 9999
+fI[1] = #3fff 9999 9999 9999 9999
+fI[1] == strtox
+
+
+Input: -1.2
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff 9999 9999 9999 999a
+g_xfmt(0) gives 4 bytes: "-1.2"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 9999 9999 9999 999a
+fI[1] = #bfff 9999 9999 9999 999a
+fI[0] == strtox
+
+
+Input: 1.3
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff a666 6666 6666 6666
+g_xfmt(0) gives 3 bytes: "1.3"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff a666 6666 6666 6666
+fI[1] = #3fff a666 6666 6666 6666
+fI[0] == strtox
+
+
+Input: -1.3
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff a666 6666 6666 6666
+g_xfmt(0) gives 4 bytes: "-1.3"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff a666 6666 6666 6667
+fI[1] = #bfff a666 6666 6666 6667
+fI[1] == strtox
+
+
+Input: 1.4
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff b333 3333 3333 3333
+g_xfmt(0) gives 3 bytes: "1.4"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff b333 3333 3333 3333
+fI[1] = #3fff b333 3333 3333 3333
+fI[0] == strtox
+
+
+Input: -1.4
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff b333 3333 3333 3333
+g_xfmt(0) gives 4 bytes: "-1.4"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff b333 3333 3333 3334
+fI[1] = #bfff b333 3333 3333 3334
+fI[1] == strtox
+
+
+Input: 1.5
+
+strtox consumes 3 bytes and returns 1
+with bits = #3fff c000 0 0 0
+g_xfmt(0) gives 3 bytes: "1.5"
+
+strtoIx returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: -1.5
+
+strtox consumes 4 bytes and returns 9
+with bits = #bfff c000 0 0 0
+g_xfmt(0) gives 4 bytes: "-1.5"
+
+strtoIx returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.6
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff cccc cccc cccc cccd
+g_xfmt(0) gives 3 bytes: "1.6"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff cccc cccc cccc cccc
+fI[1] = #3fff cccc cccc cccc cccc
+fI[1] == strtox
+
+
+Input: -1.6
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff cccc cccc cccc cccd
+g_xfmt(0) gives 4 bytes: "-1.6"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff cccc cccc cccc cccd
+fI[1] = #bfff cccc cccc cccc cccd
+fI[0] == strtox
+
+
+Input: 1.7
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff d999 9999 9999 999a
+g_xfmt(0) gives 3 bytes: "1.7"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff d999 9999 9999 9999
+fI[1] = #3fff d999 9999 9999 9999
+fI[1] == strtox
+
+
+Input: -1.7
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff d999 9999 9999 999a
+g_xfmt(0) gives 4 bytes: "-1.7"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff d999 9999 9999 999a
+fI[1] = #bfff d999 9999 9999 999a
+fI[0] == strtox
+
+
+Input: 1.8
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff e666 6666 6666 6666
+g_xfmt(0) gives 3 bytes: "1.8"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff e666 6666 6666 6666
+fI[1] = #3fff e666 6666 6666 6666
+fI[0] == strtox
+
+
+Input: -1.8
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff e666 6666 6666 6666
+g_xfmt(0) gives 4 bytes: "-1.8"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff e666 6666 6666 6667
+fI[1] = #bfff e666 6666 6666 6667
+fI[1] == strtox
+
+
+Input: 1.9
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff f333 3333 3333 3333
+g_xfmt(0) gives 3 bytes: "1.9"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff f333 3333 3333 3333
+fI[1] = #3fff f333 3333 3333 3333
+fI[0] == strtox
+
+
+Input: -1.9
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff f333 3333 3333 3333
+g_xfmt(0) gives 4 bytes: "-1.9"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff f333 3333 3333 3334
+fI[1] = #bfff f333 3333 3333 3334
+fI[1] == strtox
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff 8ccc cccc cccc cccd
+g_xfmt(0) gives 3 bytes: "1.1"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 8ccc cccc cccc cccc
+fI[1] = #3fff 8ccc cccc cccc cccc
+fI[1] == strtox
+
+
+Input: -1.1
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff 8ccc cccc cccc cccc
+g_xfmt(0) gives 22 bytes: "-1.0999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 8ccc cccc cccc cccd
+fI[1] = #bfff 8ccc cccc cccc cccd
+fI[1] == strtox
+
+
+Input: 1.2
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff 9999 9999 9999 999a
+g_xfmt(0) gives 3 bytes: "1.2"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 9999 9999 9999 9999
+fI[1] = #3fff 9999 9999 9999 9999
+fI[1] == strtox
+
+
+Input: -1.2
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff 9999 9999 9999 9999
+g_xfmt(0) gives 22 bytes: "-1.1999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 9999 9999 9999 999a
+fI[1] = #bfff 9999 9999 9999 999a
+fI[1] == strtox
+
+
+Input: 1.3
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff a666 6666 6666 6667
+g_xfmt(0) gives 21 bytes: "1.3000000000000000001"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff a666 6666 6666 6666
+fI[1] = #3fff a666 6666 6666 6666
+fI[1] == strtox
+
+
+Input: -1.3
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff a666 6666 6666 6666
+g_xfmt(0) gives 4 bytes: "-1.3"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff a666 6666 6666 6667
+fI[1] = #bfff a666 6666 6666 6667
+fI[1] == strtox
+
+
+Input: 1.4
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff b333 3333 3333 3334
+g_xfmt(0) gives 21 bytes: "1.4000000000000000001"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff b333 3333 3333 3333
+fI[1] = #3fff b333 3333 3333 3333
+fI[1] == strtox
+
+
+Input: -1.4
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff b333 3333 3333 3333
+g_xfmt(0) gives 4 bytes: "-1.4"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff b333 3333 3333 3334
+fI[1] = #bfff b333 3333 3333 3334
+fI[1] == strtox
+
+
+Input: 1.5
+
+strtox consumes 3 bytes and returns 1
+with bits = #3fff c000 0 0 0
+g_xfmt(0) gives 3 bytes: "1.5"
+
+strtoIx returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: -1.5
+
+strtox consumes 4 bytes and returns 9
+with bits = #bfff c000 0 0 0
+g_xfmt(0) gives 4 bytes: "-1.5"
+
+strtoIx returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.6
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff cccc cccc cccc cccd
+g_xfmt(0) gives 3 bytes: "1.6"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff cccc cccc cccc cccc
+fI[1] = #3fff cccc cccc cccc cccc
+fI[1] == strtox
+
+
+Input: -1.6
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff cccc cccc cccc cccc
+g_xfmt(0) gives 22 bytes: "-1.5999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff cccc cccc cccc cccd
+fI[1] = #bfff cccc cccc cccc cccd
+fI[1] == strtox
+
+
+Input: 1.7
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff d999 9999 9999 999a
+g_xfmt(0) gives 3 bytes: "1.7"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff d999 9999 9999 9999
+fI[1] = #3fff d999 9999 9999 9999
+fI[1] == strtox
+
+
+Input: -1.7
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff d999 9999 9999 9999
+g_xfmt(0) gives 22 bytes: "-1.6999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff d999 9999 9999 999a
+fI[1] = #bfff d999 9999 9999 999a
+fI[1] == strtox
+
+
+Input: 1.8
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff e666 6666 6666 6667
+g_xfmt(0) gives 21 bytes: "1.8000000000000000001"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff e666 6666 6666 6666
+fI[1] = #3fff e666 6666 6666 6666
+fI[1] == strtox
+
+
+Input: -1.8
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff e666 6666 6666 6666
+g_xfmt(0) gives 4 bytes: "-1.8"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff e666 6666 6666 6667
+fI[1] = #bfff e666 6666 6666 6667
+fI[1] == strtox
+
+
+Input: 1.9
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff f333 3333 3333 3334
+g_xfmt(0) gives 21 bytes: "1.9000000000000000001"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff f333 3333 3333 3333
+fI[1] = #3fff f333 3333 3333 3333
+fI[1] == strtox
+
+
+Input: -1.9
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff f333 3333 3333 3333
+g_xfmt(0) gives 4 bytes: "-1.9"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff f333 3333 3333 3334
+fI[1] = #bfff f333 3333 3333 3334
+fI[1] == strtox
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff 8ccc cccc cccc cccc
+g_xfmt(0) gives 21 bytes: "1.0999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 8ccc cccc cccc cccc
+fI[1] = #3fff 8ccc cccc cccc cccc
+fI[0] == strtox
+
+
+Input: -1.1
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff 8ccc cccc cccc cccd
+g_xfmt(0) gives 4 bytes: "-1.1"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 8ccc cccc cccc cccd
+fI[1] = #bfff 8ccc cccc cccc cccd
+fI[0] == strtox
+
+
+Input: 1.2
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff 9999 9999 9999 9999
+g_xfmt(0) gives 21 bytes: "1.1999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 9999 9999 9999 9999
+fI[1] = #3fff 9999 9999 9999 9999
+fI[0] == strtox
+
+
+Input: -1.2
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff 9999 9999 9999 999a
+g_xfmt(0) gives 4 bytes: "-1.2"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 9999 9999 9999 999a
+fI[1] = #bfff 9999 9999 9999 999a
+fI[0] == strtox
+
+
+Input: 1.3
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff a666 6666 6666 6666
+g_xfmt(0) gives 3 bytes: "1.3"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff a666 6666 6666 6666
+fI[1] = #3fff a666 6666 6666 6666
+fI[0] == strtox
+
+
+Input: -1.3
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff a666 6666 6666 6667
+g_xfmt(0) gives 22 bytes: "-1.3000000000000000001"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff a666 6666 6666 6667
+fI[1] = #bfff a666 6666 6666 6667
+fI[0] == strtox
+
+
+Input: 1.4
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff b333 3333 3333 3333
+g_xfmt(0) gives 3 bytes: "1.4"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff b333 3333 3333 3333
+fI[1] = #3fff b333 3333 3333 3333
+fI[0] == strtox
+
+
+Input: -1.4
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff b333 3333 3333 3334
+g_xfmt(0) gives 22 bytes: "-1.4000000000000000001"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff b333 3333 3333 3334
+fI[1] = #bfff b333 3333 3333 3334
+fI[0] == strtox
+
+
+Input: 1.5
+
+strtox consumes 3 bytes and returns 1
+with bits = #3fff c000 0 0 0
+g_xfmt(0) gives 3 bytes: "1.5"
+
+strtoIx returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: -1.5
+
+strtox consumes 4 bytes and returns 9
+with bits = #bfff c000 0 0 0
+g_xfmt(0) gives 4 bytes: "-1.5"
+
+strtoIx returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.6
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff cccc cccc cccc cccc
+g_xfmt(0) gives 21 bytes: "1.5999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff cccc cccc cccc cccc
+fI[1] = #3fff cccc cccc cccc cccc
+fI[0] == strtox
+
+
+Input: -1.6
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff cccc cccc cccc cccd
+g_xfmt(0) gives 4 bytes: "-1.6"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff cccc cccc cccc cccd
+fI[1] = #bfff cccc cccc cccc cccd
+fI[0] == strtox
+
+
+Input: 1.7
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff d999 9999 9999 9999
+g_xfmt(0) gives 21 bytes: "1.6999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff d999 9999 9999 9999
+fI[1] = #3fff d999 9999 9999 9999
+fI[0] == strtox
+
+
+Input: -1.7
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff d999 9999 9999 999a
+g_xfmt(0) gives 4 bytes: "-1.7"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff d999 9999 9999 999a
+fI[1] = #bfff d999 9999 9999 999a
+fI[0] == strtox
+
+
+Input: 1.8
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff e666 6666 6666 6666
+g_xfmt(0) gives 3 bytes: "1.8"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff e666 6666 6666 6666
+fI[1] = #3fff e666 6666 6666 6666
+fI[0] == strtox
+
+
+Input: -1.8
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff e666 6666 6666 6667
+g_xfmt(0) gives 22 bytes: "-1.8000000000000000001"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff e666 6666 6666 6667
+fI[1] = #bfff e666 6666 6666 6667
+fI[0] == strtox
+
+
+Input: 1.9
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff f333 3333 3333 3333
+g_xfmt(0) gives 3 bytes: "1.9"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff f333 3333 3333 3333
+fI[1] = #3fff f333 3333 3333 3333
+fI[0] == strtox
+
+
+Input: -1.9
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff f333 3333 3333 3334
+g_xfmt(0) gives 22 bytes: "-1.9000000000000000001"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff f333 3333 3333 3334
+fI[1] = #bfff f333 3333 3333 3334
+fI[0] == strtox
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/x.ou1
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/x.ou1	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/x.ou1	(revision 2404)
@@ -0,0 +1,1460 @@
+
+Input: 1.23
+
+strtox consumes 4 bytes and returns 33
+with bits = #3fff 9d70 a3d7 a3d 70a4
+printf("%.21Lg") gives 1.23000000000000000002
+g_xfmt(0) gives 4 bytes: "1.23"
+
+strtoIx returns 33, consuming 4 bytes.
+fI[0] = #3fff 9d70 a3d7 a3d 70a3
+= 1.22999999999999999991
+fI[1] = #3fff 9d70 a3d7 a3d 70a3
+= 1.23000000000000000002
+fI[1] == strtox
+
+
+Input: 1.23e+20
+
+strtox consumes 8 bytes and returns 1
+with bits = #4041 d55e f90a 2da1 8000
+printf("%.21Lg") gives 123000000000000000000
+g_xfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIx returns 1, consuming 8 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.23e-20
+
+strtox consumes 8 bytes and returns 17
+with bits = #3fbc e857 267b b3a9 84f2
+printf("%.21Lg") gives 1.22999999999999999997e-20
+g_xfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #3fbc e857 267b b3a9 84f2
+= 1.22999999999999999997e-20
+fI[1] = #3fbc e857 267b b3a9 84f2
+= 1.23000000000000000004e-20
+fI[0] == strtox
+
+
+Input: 1.23456789
+
+strtox consumes 10 bytes and returns 33
+with bits = #3fff 9e06 5214 1ef0 dbf6
+printf("%.21Lg") gives 1.23456789000000000003
+g_xfmt(0) gives 10 bytes: "1.23456789"
+
+strtoIx returns 33, consuming 10 bytes.
+fI[0] = #3fff 9e06 5214 1ef0 dbf5
+= 1.23456788999999999992
+fI[1] = #3fff 9e06 5214 1ef0 dbf5
+= 1.23456789000000000003
+fI[1] == strtox
+
+
+Input: 1.23456589e+20
+
+strtox consumes 14 bytes and returns 1
+with bits = #4041 d629 bd33 5cc ba00
+printf("%.21Lg") gives 123456589000000000000
+g_xfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoIx returns 1, consuming 14 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.23e+30
+
+strtox consumes 8 bytes and returns 17
+with bits = #4062 f865 8274 7dbc 824a
+printf("%.21Lg") gives 1.22999999999999999999e+30
+g_xfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #4062 f865 8274 7dbc 824a
+= 1.22999999999999999999e+30
+fI[1] = #4062 f865 8274 7dbc 824a
+= 1.23000000000000000006e+30
+fI[0] == strtox
+
+
+Input: 1.23e-30
+
+strtox consumes 8 bytes and returns 17
+with bits = #3f9b c794 337a 8085 54eb
+printf("%.21Lg") gives 1.22999999999999999999e-30
+g_xfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #3f9b c794 337a 8085 54eb
+= 1.22999999999999999999e-30
+fI[1] = #3f9b c794 337a 8085 54eb
+= 1.23000000000000000007e-30
+fI[0] == strtox
+
+
+Input: 1.23456789e-20
+
+strtox consumes 14 bytes and returns 17
+with bits = #3fbc e934 a38 f3d6 d352
+printf("%.21Lg") gives 1.23456788999999999998e-20
+g_xfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoIx returns 17, consuming 14 bytes.
+fI[0] = #3fbc e934 a38 f3d6 d352
+= 1.23456788999999999998e-20
+fI[1] = #3fbc e934 a38 f3d6 d352
+= 1.23456789000000000005e-20
+fI[0] == strtox
+
+
+Input: 1.23456789e-30
+
+strtox consumes 14 bytes and returns 17
+with bits = #3f9b c851 f19d decc a8fc
+printf("%.21Lg") gives 1.23456788999999999999e-30
+g_xfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoIx returns 17, consuming 14 bytes.
+fI[0] = #3f9b c851 f19d decc a8fc
+= 1.23456788999999999999e-30
+fI[1] = #3f9b c851 f19d decc a8fc
+= 1.23456789000000000007e-30
+fI[0] == strtox
+
+
+Input: 1.234567890123456789
+
+strtox consumes 20 bytes and returns 17
+with bits = #3fff 9e06 5214 62cf db8d
+printf("%.21Lg") gives 1.23456789012345678899
+g_xfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIx returns 17, consuming 20 bytes.
+fI[0] = #3fff 9e06 5214 62cf db8d
+= 1.23456789012345678899
+fI[1] = #3fff 9e06 5214 62cf db8d
+= 1.23456789012345678909
+fI[0] == strtox
+
+
+Input: 1.23456789012345678901234567890123456789
+
+strtox consumes 40 bytes and returns 17
+with bits = #3fff 9e06 5214 62cf db8d
+printf("%.21Lg") gives 1.23456789012345678899
+g_xfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIx returns 17, consuming 40 bytes.
+fI[0] = #3fff 9e06 5214 62cf db8d
+= 1.23456789012345678899
+fI[1] = #3fff 9e06 5214 62cf db8d
+= 1.23456789012345678909
+fI[0] == strtox
+
+
+Input: 1.23e306
+
+strtox consumes 8 bytes and returns 17
+with bits = #43f7 e033 b668 e30f a6d5
+printf("%.21Lg") gives 1.22999999999999999997e+306
+g_xfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #43f7 e033 b668 e30f a6d5
+= 1.22999999999999999997e+306
+fI[1] = #43f7 e033 b668 e30f a6d5
+= 1.23000000000000000005e+306
+fI[0] == strtox
+
+
+Input: 1.23e-306
+
+strtox consumes 9 bytes and returns 33
+with bits = #3c06 dd1d c2ed 1cb7 3f25
+printf("%.21Lg") gives 1.23000000000000000002e-306
+g_xfmt(0) gives 9 bytes: "1.23e-306"
+
+strtoIx returns 33, consuming 9 bytes.
+fI[0] = #3c06 dd1d c2ed 1cb7 3f24
+= 1.22999999999999999995e-306
+fI[1] = #3c06 dd1d c2ed 1cb7 3f24
+= 1.23000000000000000002e-306
+fI[1] == strtox
+
+
+Input: 1.23e-320
+
+strtox consumes 9 bytes and returns 33
+with bits = #3bd8 9b98 c371 844c 3f1a
+printf("%.21Lg") gives 1.23000000000000000002e-320
+g_xfmt(0) gives 9 bytes: "1.23e-320"
+
+strtoIx returns 33, consuming 9 bytes.
+fI[0] = #3bd8 9b98 c371 844c 3f19
+= 1.22999999999999999991e-320
+fI[1] = #3bd8 9b98 c371 844c 3f19
+= 1.23000000000000000002e-320
+fI[1] == strtox
+
+
+Input: 1.23e-20
+
+strtox consumes 8 bytes and returns 17
+with bits = #3fbc e857 267b b3a9 84f2
+printf("%.21Lg") gives 1.22999999999999999997e-20
+g_xfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIx returns 17, consuming 8 bytes.
+fI[0] = #3fbc e857 267b b3a9 84f2
+= 1.22999999999999999997e-20
+fI[1] = #3fbc e857 267b b3a9 84f2
+= 1.23000000000000000004e-20
+fI[0] == strtox
+
+
+Input: 1.23456789e307
+
+strtox consumes 14 bytes and returns 17
+with bits = #43fb 8ca5 8a5e d766 de75
+printf("%.21Lg") gives 1.23456788999999999998e+307
+g_xfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoIx returns 17, consuming 14 bytes.
+fI[0] = #43fb 8ca5 8a5e d766 de75
+= 1.23456788999999999998e+307
+fI[1] = #43fb 8ca5 8a5e d766 de75
+= 1.23456789000000000011e+307
+fI[0] == strtox
+
+
+Input: 1.23456589e-307
+
+strtox consumes 15 bytes and returns 17
+with bits = #3c03 b18c b5dc c22f d369
+printf("%.21Lg") gives 1.23456588999999999999e-307
+g_xfmt(0) gives 15 bytes: "1.23456589e-307"
+
+strtoIx returns 17, consuming 15 bytes.
+fI[0] = #3c03 b18c b5dc c22f d369
+= 1.23456588999999999999e-307
+fI[1] = #3c03 b18c b5dc c22f d369
+= 1.23456589000000000009e-307
+fI[0] == strtox
+
+
+Input: 1.234567890123456789
+
+strtox consumes 20 bytes and returns 17
+with bits = #3fff 9e06 5214 62cf db8d
+printf("%.21Lg") gives 1.23456789012345678899
+g_xfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIx returns 17, consuming 20 bytes.
+fI[0] = #3fff 9e06 5214 62cf db8d
+= 1.23456789012345678899
+fI[1] = #3fff 9e06 5214 62cf db8d
+= 1.23456789012345678909
+fI[0] == strtox
+
+
+Input: 1.234567890123456789e301
+
+strtox consumes 24 bytes and returns 33
+with bits = #43e7 937a 8baf ab20 980c
+printf("%.21Lg") gives 1.234567890123456789e+301
+g_xfmt(0) gives 25 bytes: "1.234567890123456789e+301"
+
+strtoIx returns 33, consuming 24 bytes.
+fI[0] = #43e7 937a 8baf ab20 980b
+= 1.23456789012345678889e+301
+fI[1] = #43e7 937a 8baf ab20 980b
+= 1.234567890123456789e+301
+fI[1] == strtox
+
+
+Input: 1.234567890123456789e-301
+
+strtox consumes 25 bytes and returns 33
+with bits = #3c17 a953 271a 5d06 9ad9
+printf("%.21Lg") gives 1.23456789012345678902e-301
+g_xfmt(0) gives 25 bytes: "1.234567890123456789e-301"
+
+strtoIx returns 33, consuming 25 bytes.
+fI[0] = #3c17 a953 271a 5d06 9ad8
+= 1.23456789012345678892e-301
+fI[1] = #3c17 a953 271a 5d06 9ad8
+= 1.23456789012345678902e-301
+fI[1] == strtox
+
+
+Input: 1.234567890123456789e-321
+
+strtox consumes 25 bytes and returns 33
+with bits = #3bd4 f9e1 1b4c ea6d cce9
+printf("%.21Lg") gives 1.234567890123456789e-321
+g_xfmt(0) gives 25 bytes: "1.234567890123456789e-321"
+
+strtoIx returns 33, consuming 25 bytes.
+fI[0] = #3bd4 f9e1 1b4c ea6d cce8
+= 1.23456789012345678893e-321
+fI[1] = #3bd4 f9e1 1b4c ea6d cce8
+= 1.234567890123456789e-321
+fI[1] == strtox
+
+
+Input: 1e23
+
+strtox consumes 4 bytes and returns 1
+with bits = #404b a968 163f a57 b400
+printf("%.21Lg") gives 1e+23
+g_xfmt(0) gives 5 bytes: "1e+23"
+
+strtoIx returns 1, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1e310
+
+strtox consumes 5 bytes and returns 33
+with bits = #4404 de81 e40a 34b cf50
+printf("%.21Lg") gives 1e+310
+g_xfmt(0) gives 6 bytes: "1e+310"
+
+strtoIx returns 33, consuming 5 bytes.
+fI[0] = #4404 de81 e40a 34b cf4f
+= 9.9999999999999999994e+309
+fI[1] = #4404 de81 e40a 34b cf4f
+= 1e+310
+fI[1] == strtox
+
+
+Input: 9.0259718793241475e-277
+
+strtox consumes 23 bytes and returns 33
+with bits = #3c69 ffff ffff ffff fcf7
+printf("%.21Lg") gives 9.02597187932414750016e-277
+g_xfmt(0) gives 23 bytes: "9.0259718793241475e-277"
+
+strtoIx returns 33, consuming 23 bytes.
+fI[0] = #3c69 ffff ffff ffff fcf6
+= 9.02597187932414749967e-277
+fI[1] = #3c69 ffff ffff ffff fcf6
+= 9.02597187932414750016e-277
+fI[1] == strtox
+
+
+Input: 9.025971879324147880346310405869e-277
+
+strtox consumes 37 bytes and returns 17
+with bits = #3c6a 8000 0 0 0
+printf("%.21Lg") gives 9.02597187932414788035e-277
+g_xfmt(0) gives 26 bytes: "9.0259718793241478803e-277"
+
+strtoIx returns 17, consuming 37 bytes.
+fI[0] = #3c6a 8000 0 0 0
+= 9.02597187932414788035e-277
+fI[1] = #3c6a 8000 0 0 0
+= 9.02597187932414788132e-277
+fI[0] == strtox
+
+
+Input: 9.025971879324147880346310405868e-277
+
+strtox consumes 37 bytes and returns 33
+with bits = #3c6a 8000 0 0 0
+printf("%.21Lg") gives 9.02597187932414788035e-277
+g_xfmt(0) gives 26 bytes: "9.0259718793241478803e-277"
+
+strtoIx returns 33, consuming 37 bytes.
+fI[0] = #3c69 ffff ffff ffff ffff
+= 9.02597187932414787986e-277
+fI[1] = #3c6a 8000 0 ffff ffff
+= 9.02597187932414788035e-277
+fI[1] == strtox
+
+
+Input: 2.2250738585072014e-308
+
+strtox consumes 23 bytes and returns 17
+with bits = #3c01 8000 0 0 46
+printf("%.21Lg") gives 2.22507385850720139998e-308
+g_xfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoIx returns 17, consuming 23 bytes.
+fI[0] = #3c01 8000 0 0 46
+= 2.22507385850720139998e-308
+fI[1] = #3c01 8000 0 0 46
+= 2.22507385850720140022e-308
+fI[0] == strtox
+
+
+Input: 2.2250738585072013e-308
+
+strtox consumes 23 bytes and returns 17
+with bits = #3c00 ffff ffff ffff fd4f
+printf("%.21Lg") gives 2.22507385850720129998e-308
+g_xfmt(0) gives 23 bytes: "2.2250738585072013e-308"
+
+strtoIx returns 17, consuming 23 bytes.
+fI[0] = #3c00 ffff ffff ffff fd4f
+= 2.22507385850720129998e-308
+fI[1] = #3c00 ffff ffff ffff fd4f
+= 2.2250738585072013001e-308
+fI[0] == strtox
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff 8ccc cccc cccc cccc
+printf("%.21Lg") gives 1.09999999999999999991
+g_xfmt(0) gives 21 bytes: "1.0999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 8ccc cccc cccc cccc
+= 1.09999999999999999991
+fI[1] = #3fff 8ccc cccc cccc cccc
+= 1.10000000000000000002
+fI[0] == strtox
+
+
+Input: -1.1
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff 8ccc cccc cccc cccc
+printf("%.21Lg") gives -1.09999999999999999991
+g_xfmt(0) gives 22 bytes: "-1.0999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 8ccc cccc cccc cccd
+= -1.10000000000000000002
+fI[1] = #bfff 8ccc cccc cccc cccd
+= -1.09999999999999999991
+fI[1] == strtox
+
+
+Input: 1.2
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff 9999 9999 9999 9999
+printf("%.21Lg") gives 1.19999999999999999993
+g_xfmt(0) gives 21 bytes: "1.1999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 9999 9999 9999 9999
+= 1.19999999999999999993
+fI[1] = #3fff 9999 9999 9999 9999
+= 1.20000000000000000004
+fI[0] == strtox
+
+
+Input: -1.2
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff 9999 9999 9999 9999
+printf("%.21Lg") gives -1.19999999999999999993
+g_xfmt(0) gives 22 bytes: "-1.1999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 9999 9999 9999 999a
+= -1.20000000000000000004
+fI[1] = #bfff 9999 9999 9999 999a
+= -1.19999999999999999993
+fI[1] == strtox
+
+
+Input: 1.3
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff a666 6666 6666 6666
+printf("%.21Lg") gives 1.29999999999999999996
+g_xfmt(0) gives 3 bytes: "1.3"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff a666 6666 6666 6666
+= 1.29999999999999999996
+fI[1] = #3fff a666 6666 6666 6666
+= 1.30000000000000000007
+fI[0] == strtox
+
+
+Input: -1.3
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff a666 6666 6666 6666
+printf("%.21Lg") gives -1.29999999999999999996
+g_xfmt(0) gives 4 bytes: "-1.3"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff a666 6666 6666 6667
+= -1.30000000000000000007
+fI[1] = #bfff a666 6666 6666 6667
+= -1.29999999999999999996
+fI[1] == strtox
+
+
+Input: 1.4
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff b333 3333 3333 3333
+printf("%.21Lg") gives 1.39999999999999999998
+g_xfmt(0) gives 3 bytes: "1.4"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff b333 3333 3333 3333
+= 1.39999999999999999998
+fI[1] = #3fff b333 3333 3333 3333
+= 1.40000000000000000009
+fI[0] == strtox
+
+
+Input: -1.4
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff b333 3333 3333 3333
+printf("%.21Lg") gives -1.39999999999999999998
+g_xfmt(0) gives 4 bytes: "-1.4"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff b333 3333 3333 3334
+= -1.40000000000000000009
+fI[1] = #bfff b333 3333 3333 3334
+= -1.39999999999999999998
+fI[1] == strtox
+
+
+Input: 1.5
+
+strtox consumes 3 bytes and returns 1
+with bits = #3fff c000 0 0 0
+printf("%.21Lg") gives 1.5
+g_xfmt(0) gives 3 bytes: "1.5"
+
+strtoIx returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: -1.5
+
+strtox consumes 4 bytes and returns 9
+with bits = #bfff c000 0 0 0
+printf("%.21Lg") gives -1.5
+g_xfmt(0) gives 4 bytes: "-1.5"
+
+strtoIx returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.6
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff cccc cccc cccc cccc
+printf("%.21Lg") gives 1.59999999999999999991
+g_xfmt(0) gives 21 bytes: "1.5999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff cccc cccc cccc cccc
+= 1.59999999999999999991
+fI[1] = #3fff cccc cccc cccc cccc
+= 1.60000000000000000002
+fI[0] == strtox
+
+
+Input: -1.6
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff cccc cccc cccc cccc
+printf("%.21Lg") gives -1.59999999999999999991
+g_xfmt(0) gives 22 bytes: "-1.5999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff cccc cccc cccc cccd
+= -1.60000000000000000002
+fI[1] = #bfff cccc cccc cccc cccd
+= -1.59999999999999999991
+fI[1] == strtox
+
+
+Input: 1.7
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff d999 9999 9999 9999
+printf("%.21Lg") gives 1.69999999999999999993
+g_xfmt(0) gives 21 bytes: "1.6999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff d999 9999 9999 9999
+= 1.69999999999999999993
+fI[1] = #3fff d999 9999 9999 9999
+= 1.70000000000000000004
+fI[0] == strtox
+
+
+Input: -1.7
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff d999 9999 9999 9999
+printf("%.21Lg") gives -1.69999999999999999993
+g_xfmt(0) gives 22 bytes: "-1.6999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff d999 9999 9999 999a
+= -1.70000000000000000004
+fI[1] = #bfff d999 9999 9999 999a
+= -1.69999999999999999993
+fI[1] == strtox
+
+
+Input: 1.8
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff e666 6666 6666 6666
+printf("%.21Lg") gives 1.79999999999999999996
+g_xfmt(0) gives 3 bytes: "1.8"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff e666 6666 6666 6666
+= 1.79999999999999999996
+fI[1] = #3fff e666 6666 6666 6666
+= 1.80000000000000000007
+fI[0] == strtox
+
+
+Input: -1.8
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff e666 6666 6666 6666
+printf("%.21Lg") gives -1.79999999999999999996
+g_xfmt(0) gives 4 bytes: "-1.8"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff e666 6666 6666 6667
+= -1.80000000000000000007
+fI[1] = #bfff e666 6666 6666 6667
+= -1.79999999999999999996
+fI[1] == strtox
+
+
+Input: 1.9
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff f333 3333 3333 3333
+printf("%.21Lg") gives 1.89999999999999999998
+g_xfmt(0) gives 3 bytes: "1.9"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff f333 3333 3333 3333
+= 1.89999999999999999998
+fI[1] = #3fff f333 3333 3333 3333
+= 1.90000000000000000009
+fI[0] == strtox
+
+
+Input: -1.9
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff f333 3333 3333 3333
+printf("%.21Lg") gives -1.89999999999999999998
+g_xfmt(0) gives 4 bytes: "-1.9"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff f333 3333 3333 3334
+= -1.90000000000000000009
+fI[1] = #bfff f333 3333 3333 3334
+= -1.89999999999999999998
+fI[1] == strtox
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff 8ccc cccc cccc cccd
+printf("%.21Lg") gives 1.10000000000000000002
+g_xfmt(0) gives 3 bytes: "1.1"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 8ccc cccc cccc cccc
+= 1.09999999999999999991
+fI[1] = #3fff 8ccc cccc cccc cccc
+= 1.10000000000000000002
+fI[1] == strtox
+
+
+Input: -1.1
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff 8ccc cccc cccc cccd
+printf("%.21Lg") gives -1.10000000000000000002
+g_xfmt(0) gives 4 bytes: "-1.1"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 8ccc cccc cccc cccd
+= -1.10000000000000000002
+fI[1] = #bfff 8ccc cccc cccc cccd
+= -1.09999999999999999991
+fI[0] == strtox
+
+
+Input: 1.2
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff 9999 9999 9999 999a
+printf("%.21Lg") gives 1.20000000000000000004
+g_xfmt(0) gives 3 bytes: "1.2"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 9999 9999 9999 9999
+= 1.19999999999999999993
+fI[1] = #3fff 9999 9999 9999 9999
+= 1.20000000000000000004
+fI[1] == strtox
+
+
+Input: -1.2
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff 9999 9999 9999 999a
+printf("%.21Lg") gives -1.20000000000000000004
+g_xfmt(0) gives 4 bytes: "-1.2"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 9999 9999 9999 999a
+= -1.20000000000000000004
+fI[1] = #bfff 9999 9999 9999 999a
+= -1.19999999999999999993
+fI[0] == strtox
+
+
+Input: 1.3
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff a666 6666 6666 6666
+printf("%.21Lg") gives 1.29999999999999999996
+g_xfmt(0) gives 3 bytes: "1.3"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff a666 6666 6666 6666
+= 1.29999999999999999996
+fI[1] = #3fff a666 6666 6666 6666
+= 1.30000000000000000007
+fI[0] == strtox
+
+
+Input: -1.3
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff a666 6666 6666 6666
+printf("%.21Lg") gives -1.29999999999999999996
+g_xfmt(0) gives 4 bytes: "-1.3"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff a666 6666 6666 6667
+= -1.30000000000000000007
+fI[1] = #bfff a666 6666 6666 6667
+= -1.29999999999999999996
+fI[1] == strtox
+
+
+Input: 1.4
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff b333 3333 3333 3333
+printf("%.21Lg") gives 1.39999999999999999998
+g_xfmt(0) gives 3 bytes: "1.4"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff b333 3333 3333 3333
+= 1.39999999999999999998
+fI[1] = #3fff b333 3333 3333 3333
+= 1.40000000000000000009
+fI[0] == strtox
+
+
+Input: -1.4
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff b333 3333 3333 3333
+printf("%.21Lg") gives -1.39999999999999999998
+g_xfmt(0) gives 4 bytes: "-1.4"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff b333 3333 3333 3334
+= -1.40000000000000000009
+fI[1] = #bfff b333 3333 3333 3334
+= -1.39999999999999999998
+fI[1] == strtox
+
+
+Input: 1.5
+
+strtox consumes 3 bytes and returns 1
+with bits = #3fff c000 0 0 0
+printf("%.21Lg") gives 1.5
+g_xfmt(0) gives 3 bytes: "1.5"
+
+strtoIx returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: -1.5
+
+strtox consumes 4 bytes and returns 9
+with bits = #bfff c000 0 0 0
+printf("%.21Lg") gives -1.5
+g_xfmt(0) gives 4 bytes: "-1.5"
+
+strtoIx returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.6
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff cccc cccc cccc cccd
+printf("%.21Lg") gives 1.60000000000000000002
+g_xfmt(0) gives 3 bytes: "1.6"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff cccc cccc cccc cccc
+= 1.59999999999999999991
+fI[1] = #3fff cccc cccc cccc cccc
+= 1.60000000000000000002
+fI[1] == strtox
+
+
+Input: -1.6
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff cccc cccc cccc cccd
+printf("%.21Lg") gives -1.60000000000000000002
+g_xfmt(0) gives 4 bytes: "-1.6"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff cccc cccc cccc cccd
+= -1.60000000000000000002
+fI[1] = #bfff cccc cccc cccc cccd
+= -1.59999999999999999991
+fI[0] == strtox
+
+
+Input: 1.7
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff d999 9999 9999 999a
+printf("%.21Lg") gives 1.70000000000000000004
+g_xfmt(0) gives 3 bytes: "1.7"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff d999 9999 9999 9999
+= 1.69999999999999999993
+fI[1] = #3fff d999 9999 9999 9999
+= 1.70000000000000000004
+fI[1] == strtox
+
+
+Input: -1.7
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff d999 9999 9999 999a
+printf("%.21Lg") gives -1.70000000000000000004
+g_xfmt(0) gives 4 bytes: "-1.7"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff d999 9999 9999 999a
+= -1.70000000000000000004
+fI[1] = #bfff d999 9999 9999 999a
+= -1.69999999999999999993
+fI[0] == strtox
+
+
+Input: 1.8
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff e666 6666 6666 6666
+printf("%.21Lg") gives 1.79999999999999999996
+g_xfmt(0) gives 3 bytes: "1.8"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff e666 6666 6666 6666
+= 1.79999999999999999996
+fI[1] = #3fff e666 6666 6666 6666
+= 1.80000000000000000007
+fI[0] == strtox
+
+
+Input: -1.8
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff e666 6666 6666 6666
+printf("%.21Lg") gives -1.79999999999999999996
+g_xfmt(0) gives 4 bytes: "-1.8"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff e666 6666 6666 6667
+= -1.80000000000000000007
+fI[1] = #bfff e666 6666 6666 6667
+= -1.79999999999999999996
+fI[1] == strtox
+
+
+Input: 1.9
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff f333 3333 3333 3333
+printf("%.21Lg") gives 1.89999999999999999998
+g_xfmt(0) gives 3 bytes: "1.9"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff f333 3333 3333 3333
+= 1.89999999999999999998
+fI[1] = #3fff f333 3333 3333 3333
+= 1.90000000000000000009
+fI[0] == strtox
+
+
+Input: -1.9
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff f333 3333 3333 3333
+printf("%.21Lg") gives -1.89999999999999999998
+g_xfmt(0) gives 4 bytes: "-1.9"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff f333 3333 3333 3334
+= -1.90000000000000000009
+fI[1] = #bfff f333 3333 3333 3334
+= -1.89999999999999999998
+fI[1] == strtox
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff 8ccc cccc cccc cccd
+printf("%.21Lg") gives 1.10000000000000000002
+g_xfmt(0) gives 3 bytes: "1.1"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 8ccc cccc cccc cccc
+= 1.09999999999999999991
+fI[1] = #3fff 8ccc cccc cccc cccc
+= 1.10000000000000000002
+fI[1] == strtox
+
+
+Input: -1.1
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff 8ccc cccc cccc cccc
+printf("%.21Lg") gives -1.09999999999999999991
+g_xfmt(0) gives 22 bytes: "-1.0999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 8ccc cccc cccc cccd
+= -1.10000000000000000002
+fI[1] = #bfff 8ccc cccc cccc cccd
+= -1.09999999999999999991
+fI[1] == strtox
+
+
+Input: 1.2
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff 9999 9999 9999 999a
+printf("%.21Lg") gives 1.20000000000000000004
+g_xfmt(0) gives 3 bytes: "1.2"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 9999 9999 9999 9999
+= 1.19999999999999999993
+fI[1] = #3fff 9999 9999 9999 9999
+= 1.20000000000000000004
+fI[1] == strtox
+
+
+Input: -1.2
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff 9999 9999 9999 9999
+printf("%.21Lg") gives -1.19999999999999999993
+g_xfmt(0) gives 22 bytes: "-1.1999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 9999 9999 9999 999a
+= -1.20000000000000000004
+fI[1] = #bfff 9999 9999 9999 999a
+= -1.19999999999999999993
+fI[1] == strtox
+
+
+Input: 1.3
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff a666 6666 6666 6667
+printf("%.21Lg") gives 1.30000000000000000007
+g_xfmt(0) gives 21 bytes: "1.3000000000000000001"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff a666 6666 6666 6666
+= 1.29999999999999999996
+fI[1] = #3fff a666 6666 6666 6666
+= 1.30000000000000000007
+fI[1] == strtox
+
+
+Input: -1.3
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff a666 6666 6666 6666
+printf("%.21Lg") gives -1.29999999999999999996
+g_xfmt(0) gives 4 bytes: "-1.3"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff a666 6666 6666 6667
+= -1.30000000000000000007
+fI[1] = #bfff a666 6666 6666 6667
+= -1.29999999999999999996
+fI[1] == strtox
+
+
+Input: 1.4
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff b333 3333 3333 3334
+printf("%.21Lg") gives 1.40000000000000000009
+g_xfmt(0) gives 21 bytes: "1.4000000000000000001"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff b333 3333 3333 3333
+= 1.39999999999999999998
+fI[1] = #3fff b333 3333 3333 3333
+= 1.40000000000000000009
+fI[1] == strtox
+
+
+Input: -1.4
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff b333 3333 3333 3333
+printf("%.21Lg") gives -1.39999999999999999998
+g_xfmt(0) gives 4 bytes: "-1.4"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff b333 3333 3333 3334
+= -1.40000000000000000009
+fI[1] = #bfff b333 3333 3333 3334
+= -1.39999999999999999998
+fI[1] == strtox
+
+
+Input: 1.5
+
+strtox consumes 3 bytes and returns 1
+with bits = #3fff c000 0 0 0
+printf("%.21Lg") gives 1.5
+g_xfmt(0) gives 3 bytes: "1.5"
+
+strtoIx returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: -1.5
+
+strtox consumes 4 bytes and returns 9
+with bits = #bfff c000 0 0 0
+printf("%.21Lg") gives -1.5
+g_xfmt(0) gives 4 bytes: "-1.5"
+
+strtoIx returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.6
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff cccc cccc cccc cccd
+printf("%.21Lg") gives 1.60000000000000000002
+g_xfmt(0) gives 3 bytes: "1.6"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff cccc cccc cccc cccc
+= 1.59999999999999999991
+fI[1] = #3fff cccc cccc cccc cccc
+= 1.60000000000000000002
+fI[1] == strtox
+
+
+Input: -1.6
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff cccc cccc cccc cccc
+printf("%.21Lg") gives -1.59999999999999999991
+g_xfmt(0) gives 22 bytes: "-1.5999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff cccc cccc cccc cccd
+= -1.60000000000000000002
+fI[1] = #bfff cccc cccc cccc cccd
+= -1.59999999999999999991
+fI[1] == strtox
+
+
+Input: 1.7
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff d999 9999 9999 999a
+printf("%.21Lg") gives 1.70000000000000000004
+g_xfmt(0) gives 3 bytes: "1.7"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff d999 9999 9999 9999
+= 1.69999999999999999993
+fI[1] = #3fff d999 9999 9999 9999
+= 1.70000000000000000004
+fI[1] == strtox
+
+
+Input: -1.7
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff d999 9999 9999 9999
+printf("%.21Lg") gives -1.69999999999999999993
+g_xfmt(0) gives 22 bytes: "-1.6999999999999999999"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff d999 9999 9999 999a
+= -1.70000000000000000004
+fI[1] = #bfff d999 9999 9999 999a
+= -1.69999999999999999993
+fI[1] == strtox
+
+
+Input: 1.8
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff e666 6666 6666 6667
+printf("%.21Lg") gives 1.80000000000000000007
+g_xfmt(0) gives 21 bytes: "1.8000000000000000001"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff e666 6666 6666 6666
+= 1.79999999999999999996
+fI[1] = #3fff e666 6666 6666 6666
+= 1.80000000000000000007
+fI[1] == strtox
+
+
+Input: -1.8
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff e666 6666 6666 6666
+printf("%.21Lg") gives -1.79999999999999999996
+g_xfmt(0) gives 4 bytes: "-1.8"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff e666 6666 6666 6667
+= -1.80000000000000000007
+fI[1] = #bfff e666 6666 6666 6667
+= -1.79999999999999999996
+fI[1] == strtox
+
+
+Input: 1.9
+
+strtox consumes 3 bytes and returns 33
+with bits = #3fff f333 3333 3333 3334
+printf("%.21Lg") gives 1.90000000000000000009
+g_xfmt(0) gives 21 bytes: "1.9000000000000000001"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff f333 3333 3333 3333
+= 1.89999999999999999998
+fI[1] = #3fff f333 3333 3333 3333
+= 1.90000000000000000009
+fI[1] == strtox
+
+
+Input: -1.9
+
+strtox consumes 4 bytes and returns 25
+with bits = #bfff f333 3333 3333 3333
+printf("%.21Lg") gives -1.89999999999999999998
+g_xfmt(0) gives 4 bytes: "-1.9"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff f333 3333 3333 3334
+= -1.90000000000000000009
+fI[1] = #bfff f333 3333 3333 3334
+= -1.89999999999999999998
+fI[1] == strtox
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff 8ccc cccc cccc cccc
+printf("%.21Lg") gives 1.09999999999999999991
+g_xfmt(0) gives 21 bytes: "1.0999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 8ccc cccc cccc cccc
+= 1.09999999999999999991
+fI[1] = #3fff 8ccc cccc cccc cccc
+= 1.10000000000000000002
+fI[0] == strtox
+
+
+Input: -1.1
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff 8ccc cccc cccc cccd
+printf("%.21Lg") gives -1.10000000000000000002
+g_xfmt(0) gives 4 bytes: "-1.1"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 8ccc cccc cccc cccd
+= -1.10000000000000000002
+fI[1] = #bfff 8ccc cccc cccc cccd
+= -1.09999999999999999991
+fI[0] == strtox
+
+
+Input: 1.2
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff 9999 9999 9999 9999
+printf("%.21Lg") gives 1.19999999999999999993
+g_xfmt(0) gives 21 bytes: "1.1999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff 9999 9999 9999 9999
+= 1.19999999999999999993
+fI[1] = #3fff 9999 9999 9999 9999
+= 1.20000000000000000004
+fI[0] == strtox
+
+
+Input: -1.2
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff 9999 9999 9999 999a
+printf("%.21Lg") gives -1.20000000000000000004
+g_xfmt(0) gives 4 bytes: "-1.2"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff 9999 9999 9999 999a
+= -1.20000000000000000004
+fI[1] = #bfff 9999 9999 9999 999a
+= -1.19999999999999999993
+fI[0] == strtox
+
+
+Input: 1.3
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff a666 6666 6666 6666
+printf("%.21Lg") gives 1.29999999999999999996
+g_xfmt(0) gives 3 bytes: "1.3"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff a666 6666 6666 6666
+= 1.29999999999999999996
+fI[1] = #3fff a666 6666 6666 6666
+= 1.30000000000000000007
+fI[0] == strtox
+
+
+Input: -1.3
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff a666 6666 6666 6667
+printf("%.21Lg") gives -1.30000000000000000007
+g_xfmt(0) gives 22 bytes: "-1.3000000000000000001"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff a666 6666 6666 6667
+= -1.30000000000000000007
+fI[1] = #bfff a666 6666 6666 6667
+= -1.29999999999999999996
+fI[0] == strtox
+
+
+Input: 1.4
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff b333 3333 3333 3333
+printf("%.21Lg") gives 1.39999999999999999998
+g_xfmt(0) gives 3 bytes: "1.4"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff b333 3333 3333 3333
+= 1.39999999999999999998
+fI[1] = #3fff b333 3333 3333 3333
+= 1.40000000000000000009
+fI[0] == strtox
+
+
+Input: -1.4
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff b333 3333 3333 3334
+printf("%.21Lg") gives -1.40000000000000000009
+g_xfmt(0) gives 22 bytes: "-1.4000000000000000001"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff b333 3333 3333 3334
+= -1.40000000000000000009
+fI[1] = #bfff b333 3333 3333 3334
+= -1.39999999999999999998
+fI[0] == strtox
+
+
+Input: 1.5
+
+strtox consumes 3 bytes and returns 1
+with bits = #3fff c000 0 0 0
+printf("%.21Lg") gives 1.5
+g_xfmt(0) gives 3 bytes: "1.5"
+
+strtoIx returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: -1.5
+
+strtox consumes 4 bytes and returns 9
+with bits = #bfff c000 0 0 0
+printf("%.21Lg") gives -1.5
+g_xfmt(0) gives 4 bytes: "-1.5"
+
+strtoIx returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtox
+
+
+Input: 1.6
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff cccc cccc cccc cccc
+printf("%.21Lg") gives 1.59999999999999999991
+g_xfmt(0) gives 21 bytes: "1.5999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff cccc cccc cccc cccc
+= 1.59999999999999999991
+fI[1] = #3fff cccc cccc cccc cccc
+= 1.60000000000000000002
+fI[0] == strtox
+
+
+Input: -1.6
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff cccc cccc cccc cccd
+printf("%.21Lg") gives -1.60000000000000000002
+g_xfmt(0) gives 4 bytes: "-1.6"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff cccc cccc cccc cccd
+= -1.60000000000000000002
+fI[1] = #bfff cccc cccc cccc cccd
+= -1.59999999999999999991
+fI[0] == strtox
+
+
+Input: 1.7
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff d999 9999 9999 9999
+printf("%.21Lg") gives 1.69999999999999999993
+g_xfmt(0) gives 21 bytes: "1.6999999999999999999"
+
+strtoIx returns 33, consuming 3 bytes.
+fI[0] = #3fff d999 9999 9999 9999
+= 1.69999999999999999993
+fI[1] = #3fff d999 9999 9999 9999
+= 1.70000000000000000004
+fI[0] == strtox
+
+
+Input: -1.7
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff d999 9999 9999 999a
+printf("%.21Lg") gives -1.70000000000000000004
+g_xfmt(0) gives 4 bytes: "-1.7"
+
+strtoIx returns 41, consuming 4 bytes.
+fI[0] = #bfff d999 9999 9999 999a
+= -1.70000000000000000004
+fI[1] = #bfff d999 9999 9999 999a
+= -1.69999999999999999993
+fI[0] == strtox
+
+
+Input: 1.8
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff e666 6666 6666 6666
+printf("%.21Lg") gives 1.79999999999999999996
+g_xfmt(0) gives 3 bytes: "1.8"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff e666 6666 6666 6666
+= 1.79999999999999999996
+fI[1] = #3fff e666 6666 6666 6666
+= 1.80000000000000000007
+fI[0] == strtox
+
+
+Input: -1.8
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff e666 6666 6666 6667
+printf("%.21Lg") gives -1.80000000000000000007
+g_xfmt(0) gives 22 bytes: "-1.8000000000000000001"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff e666 6666 6666 6667
+= -1.80000000000000000007
+fI[1] = #bfff e666 6666 6666 6667
+= -1.79999999999999999996
+fI[0] == strtox
+
+
+Input: 1.9
+
+strtox consumes 3 bytes and returns 17
+with bits = #3fff f333 3333 3333 3333
+printf("%.21Lg") gives 1.89999999999999999998
+g_xfmt(0) gives 3 bytes: "1.9"
+
+strtoIx returns 17, consuming 3 bytes.
+fI[0] = #3fff f333 3333 3333 3333
+= 1.89999999999999999998
+fI[1] = #3fff f333 3333 3333 3333
+= 1.90000000000000000009
+fI[0] == strtox
+
+
+Input: -1.9
+
+strtox consumes 4 bytes and returns 41
+with bits = #bfff f333 3333 3333 3334
+printf("%.21Lg") gives -1.90000000000000000009
+g_xfmt(0) gives 22 bytes: "-1.9000000000000000001"
+
+strtoIx returns 25, consuming 4 bytes.
+fI[0] = #bfff f333 3333 3333 3334
+= -1.90000000000000000009
+fI[1] = #bfff f333 3333 3333 3334
+= -1.89999999999999999998
+fI[0] == strtox
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/xL.ou0
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/xL.ou0	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/xL.ou0	(revision 2404)
@@ -0,0 +1,1182 @@
+
+Input: 1.23
+
+strtoxL consumes 4 bytes and returns 33
+with bits = #3fff0000 9d70a3d7 a3d70a4
+g_xLfmt(0) gives 4 bytes: "1.23"
+
+strtoIxL returns 33, consuming 4 bytes.
+fI[0] = #3fff0000 9d70a3d7 a3d70a3
+fI[1] = #3fff0000 9d70a3d7 a3d70a4
+fI[1] == strtoxL
+
+
+Input: 1.23e+20
+
+strtoxL consumes 8 bytes and returns 1
+with bits = #40410000 d55ef90a 2da18000
+g_xLfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIxL returns 1, consuming 8 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.23e-20
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #3fbc0000 e857267b b3a984f2
+g_xLfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #3fbc0000 e857267b b3a984f2
+fI[1] = #3fbc0000 e857267b b3a984f3
+fI[0] == strtoxL
+
+
+Input: 1.23456789
+
+strtoxL consumes 10 bytes and returns 33
+with bits = #3fff0000 9e065214 1ef0dbf6
+g_xLfmt(0) gives 10 bytes: "1.23456789"
+
+strtoIxL returns 33, consuming 10 bytes.
+fI[0] = #3fff0000 9e065214 1ef0dbf5
+fI[1] = #3fff0000 9e065214 1ef0dbf6
+fI[1] == strtoxL
+
+
+Input: 1.23456589e+20
+
+strtoxL consumes 14 bytes and returns 1
+with bits = #40410000 d629bd33 5ccba00
+g_xLfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoIxL returns 1, consuming 14 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.23e+30
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #40620000 f8658274 7dbc824a
+g_xLfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #40620000 f8658274 7dbc824a
+fI[1] = #40620000 f8658274 7dbc824b
+fI[0] == strtoxL
+
+
+Input: 1.23e-30
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #3f9b0000 c794337a 808554eb
+g_xLfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #3f9b0000 c794337a 808554eb
+fI[1] = #3f9b0000 c794337a 808554ec
+fI[0] == strtoxL
+
+
+Input: 1.23456789e-20
+
+strtoxL consumes 14 bytes and returns 17
+with bits = #3fbc0000 e9340a38 f3d6d352
+g_xLfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoIxL returns 17, consuming 14 bytes.
+fI[0] = #3fbc0000 e9340a38 f3d6d352
+fI[1] = #3fbc0000 e9340a38 f3d6d353
+fI[0] == strtoxL
+
+
+Input: 1.23456789e-30
+
+strtoxL consumes 14 bytes and returns 17
+with bits = #3f9b0000 c851f19d decca8fc
+g_xLfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoIxL returns 17, consuming 14 bytes.
+fI[0] = #3f9b0000 c851f19d decca8fc
+fI[1] = #3f9b0000 c851f19d decca8fd
+fI[0] == strtoxL
+
+
+Input: 1.234567890123456789
+
+strtoxL consumes 20 bytes and returns 17
+with bits = #3fff0000 9e065214 62cfdb8d
+g_xLfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIxL returns 17, consuming 20 bytes.
+fI[0] = #3fff0000 9e065214 62cfdb8d
+fI[1] = #3fff0000 9e065214 62cfdb8e
+fI[0] == strtoxL
+
+
+Input: 1.23456789012345678901234567890123456789
+
+strtoxL consumes 40 bytes and returns 17
+with bits = #3fff0000 9e065214 62cfdb8d
+g_xLfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIxL returns 17, consuming 40 bytes.
+fI[0] = #3fff0000 9e065214 62cfdb8d
+fI[1] = #3fff0000 9e065214 62cfdb8e
+fI[0] == strtoxL
+
+
+Input: 1.23e306
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #43f70000 e033b668 e30fa6d5
+g_xLfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #43f70000 e033b668 e30fa6d5
+fI[1] = #43f70000 e033b668 e30fa6d6
+fI[0] == strtoxL
+
+
+Input: 1.23e-306
+
+strtoxL consumes 9 bytes and returns 33
+with bits = #3c060000 dd1dc2ed 1cb73f25
+g_xLfmt(0) gives 9 bytes: "1.23e-306"
+
+strtoIxL returns 33, consuming 9 bytes.
+fI[0] = #3c060000 dd1dc2ed 1cb73f24
+fI[1] = #3c060000 dd1dc2ed 1cb73f25
+fI[1] == strtoxL
+
+
+Input: 1.23e-320
+
+strtoxL consumes 9 bytes and returns 33
+with bits = #3bd80000 9b98c371 844c3f1a
+g_xLfmt(0) gives 9 bytes: "1.23e-320"
+
+strtoIxL returns 33, consuming 9 bytes.
+fI[0] = #3bd80000 9b98c371 844c3f19
+fI[1] = #3bd80000 9b98c371 844c3f1a
+fI[1] == strtoxL
+
+
+Input: 1.23e-20
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #3fbc0000 e857267b b3a984f2
+g_xLfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #3fbc0000 e857267b b3a984f2
+fI[1] = #3fbc0000 e857267b b3a984f3
+fI[0] == strtoxL
+
+
+Input: 1.23456789e307
+
+strtoxL consumes 14 bytes and returns 17
+with bits = #43fb0000 8ca58a5e d766de75
+g_xLfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoIxL returns 17, consuming 14 bytes.
+fI[0] = #43fb0000 8ca58a5e d766de75
+fI[1] = #43fb0000 8ca58a5e d766de76
+fI[0] == strtoxL
+
+
+Input: 1.23456589e-307
+
+strtoxL consumes 15 bytes and returns 17
+with bits = #3c030000 b18cb5dc c22fd369
+g_xLfmt(0) gives 15 bytes: "1.23456589e-307"
+
+strtoIxL returns 17, consuming 15 bytes.
+fI[0] = #3c030000 b18cb5dc c22fd369
+fI[1] = #3c030000 b18cb5dc c22fd36a
+fI[0] == strtoxL
+
+
+Input: 1.234567890123456789
+
+strtoxL consumes 20 bytes and returns 17
+with bits = #3fff0000 9e065214 62cfdb8d
+g_xLfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIxL returns 17, consuming 20 bytes.
+fI[0] = #3fff0000 9e065214 62cfdb8d
+fI[1] = #3fff0000 9e065214 62cfdb8e
+fI[0] == strtoxL
+
+
+Input: 1.234567890123456789e301
+
+strtoxL consumes 24 bytes and returns 33
+with bits = #43e70000 937a8baf ab20980c
+g_xLfmt(0) gives 25 bytes: "1.234567890123456789e+301"
+
+strtoIxL returns 33, consuming 24 bytes.
+fI[0] = #43e70000 937a8baf ab20980b
+fI[1] = #43e70000 937a8baf ab20980c
+fI[1] == strtoxL
+
+
+Input: 1.234567890123456789e-301
+
+strtoxL consumes 25 bytes and returns 33
+with bits = #3c170000 a953271a 5d069ad9
+g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-301"
+
+strtoIxL returns 33, consuming 25 bytes.
+fI[0] = #3c170000 a953271a 5d069ad8
+fI[1] = #3c170000 a953271a 5d069ad9
+fI[1] == strtoxL
+
+
+Input: 1.234567890123456789e-321
+
+strtoxL consumes 25 bytes and returns 33
+with bits = #3bd40000 f9e11b4c ea6dcce9
+g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-321"
+
+strtoIxL returns 33, consuming 25 bytes.
+fI[0] = #3bd40000 f9e11b4c ea6dcce8
+fI[1] = #3bd40000 f9e11b4c ea6dcce9
+fI[1] == strtoxL
+
+
+Input: 1e23
+
+strtoxL consumes 4 bytes and returns 1
+with bits = #404b0000 a968163f a57b400
+g_xLfmt(0) gives 5 bytes: "1e+23"
+
+strtoIxL returns 1, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1e310
+
+strtoxL consumes 5 bytes and returns 33
+with bits = #44040000 de81e40a 34bcf50
+g_xLfmt(0) gives 6 bytes: "1e+310"
+
+strtoIxL returns 33, consuming 5 bytes.
+fI[0] = #44040000 de81e40a 34bcf4f
+fI[1] = #44040000 de81e40a 34bcf50
+fI[1] == strtoxL
+
+
+Input: 9.0259718793241475e-277
+
+strtoxL consumes 23 bytes and returns 33
+with bits = #3c690000 ffffffff fffffcf7
+g_xLfmt(0) gives 23 bytes: "9.0259718793241475e-277"
+
+strtoIxL returns 33, consuming 23 bytes.
+fI[0] = #3c690000 ffffffff fffffcf6
+fI[1] = #3c690000 ffffffff fffffcf7
+fI[1] == strtoxL
+
+
+Input: 9.025971879324147880346310405869e-277
+
+strtoxL consumes 37 bytes and returns 17
+with bits = #3c6a0000 80000000 0
+g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277"
+
+strtoIxL returns 17, consuming 37 bytes.
+fI[0] = #3c6a0000 80000000 0
+fI[1] = #3c6a0000 80000000 1
+fI[0] == strtoxL
+
+
+Input: 9.025971879324147880346310405868e-277
+
+strtoxL consumes 37 bytes and returns 33
+with bits = #3c6a0000 80000000 0
+g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277"
+
+strtoIxL returns 33, consuming 37 bytes.
+fI[0] = #3c690000 ffffffff ffffffff
+fI[1] = #3c6a0000 80000000 0
+fI[1] == strtoxL
+
+
+Input: 2.2250738585072014e-308
+
+strtoxL consumes 23 bytes and returns 17
+with bits = #3c010000 80000000 46
+g_xLfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoIxL returns 17, consuming 23 bytes.
+fI[0] = #3c010000 80000000 46
+fI[1] = #3c010000 80000000 47
+fI[0] == strtoxL
+
+
+Input: 2.2250738585072013e-308
+
+strtoxL consumes 23 bytes and returns 17
+with bits = #3c000000 ffffffff fffffd4f
+g_xLfmt(0) gives 23 bytes: "2.2250738585072013e-308"
+
+strtoIxL returns 17, consuming 23 bytes.
+fI[0] = #3c000000 ffffffff fffffd4f
+fI[1] = #3c000000 ffffffff fffffd50
+fI[0] == strtoxL
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 8ccccccc cccccccc
+g_xLfmt(0) gives 21 bytes: "1.0999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 8ccccccc cccccccc
+fI[1] = #3fff0000 8ccccccc cccccccd
+fI[0] == strtoxL
+
+
+Input: -1.1
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 8ccccccc cccccccc
+g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 8ccccccc cccccccd
+fI[1] = #bfff0000 8ccccccc cccccccc
+fI[1] == strtoxL
+
+
+Input: 1.2
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 99999999 99999999
+g_xLfmt(0) gives 21 bytes: "1.1999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 99999999 99999999
+fI[1] = #3fff0000 99999999 9999999a
+fI[0] == strtoxL
+
+
+Input: -1.2
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 99999999 99999999
+g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 99999999 9999999a
+fI[1] = #bfff0000 99999999 99999999
+fI[1] == strtoxL
+
+
+Input: 1.3
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 a6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.3"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 a6666666 66666666
+fI[1] = #3fff0000 a6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.3
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 a6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.3"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 a6666666 66666667
+fI[1] = #bfff0000 a6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.4
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 b3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.4"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 b3333333 33333333
+fI[1] = #3fff0000 b3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.4
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 b3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.4"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 b3333333 33333334
+fI[1] = #bfff0000 b3333333 33333333
+fI[1] == strtoxL
+
+
+Input: 1.5
+
+strtoxL consumes 3 bytes and returns 1
+with bits = #3fff0000 c0000000 0
+g_xLfmt(0) gives 3 bytes: "1.5"
+
+strtoIxL returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: -1.5
+
+strtoxL consumes 4 bytes and returns 9
+with bits = #bfff0000 c0000000 0
+g_xLfmt(0) gives 4 bytes: "-1.5"
+
+strtoIxL returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.6
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 cccccccc cccccccc
+g_xLfmt(0) gives 21 bytes: "1.5999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 cccccccc cccccccc
+fI[1] = #3fff0000 cccccccc cccccccd
+fI[0] == strtoxL
+
+
+Input: -1.6
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 cccccccc cccccccc
+g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 cccccccc cccccccd
+fI[1] = #bfff0000 cccccccc cccccccc
+fI[1] == strtoxL
+
+
+Input: 1.7
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 d9999999 99999999
+g_xLfmt(0) gives 21 bytes: "1.6999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 d9999999 99999999
+fI[1] = #3fff0000 d9999999 9999999a
+fI[0] == strtoxL
+
+
+Input: -1.7
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 d9999999 99999999
+g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 d9999999 9999999a
+fI[1] = #bfff0000 d9999999 99999999
+fI[1] == strtoxL
+
+
+Input: 1.8
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 e6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.8"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 e6666666 66666666
+fI[1] = #3fff0000 e6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.8
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 e6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.8"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 e6666666 66666667
+fI[1] = #bfff0000 e6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.9
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 f3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.9"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 f3333333 33333333
+fI[1] = #3fff0000 f3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.9
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 f3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.9"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 f3333333 33333334
+fI[1] = #bfff0000 f3333333 33333333
+fI[1] == strtoxL
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 8ccccccc cccccccd
+g_xLfmt(0) gives 3 bytes: "1.1"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 8ccccccc cccccccc
+fI[1] = #3fff0000 8ccccccc cccccccd
+fI[1] == strtoxL
+
+
+Input: -1.1
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 8ccccccc cccccccd
+g_xLfmt(0) gives 4 bytes: "-1.1"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 8ccccccc cccccccd
+fI[1] = #bfff0000 8ccccccc cccccccc
+fI[0] == strtoxL
+
+
+Input: 1.2
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 99999999 9999999a
+g_xLfmt(0) gives 3 bytes: "1.2"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 99999999 99999999
+fI[1] = #3fff0000 99999999 9999999a
+fI[1] == strtoxL
+
+
+Input: -1.2
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 99999999 9999999a
+g_xLfmt(0) gives 4 bytes: "-1.2"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 99999999 9999999a
+fI[1] = #bfff0000 99999999 99999999
+fI[0] == strtoxL
+
+
+Input: 1.3
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 a6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.3"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 a6666666 66666666
+fI[1] = #3fff0000 a6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.3
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 a6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.3"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 a6666666 66666667
+fI[1] = #bfff0000 a6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.4
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 b3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.4"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 b3333333 33333333
+fI[1] = #3fff0000 b3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.4
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 b3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.4"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 b3333333 33333334
+fI[1] = #bfff0000 b3333333 33333333
+fI[1] == strtoxL
+
+
+Input: 1.5
+
+strtoxL consumes 3 bytes and returns 1
+with bits = #3fff0000 c0000000 0
+g_xLfmt(0) gives 3 bytes: "1.5"
+
+strtoIxL returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: -1.5
+
+strtoxL consumes 4 bytes and returns 9
+with bits = #bfff0000 c0000000 0
+g_xLfmt(0) gives 4 bytes: "-1.5"
+
+strtoIxL returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.6
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 cccccccc cccccccd
+g_xLfmt(0) gives 3 bytes: "1.6"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 cccccccc cccccccc
+fI[1] = #3fff0000 cccccccc cccccccd
+fI[1] == strtoxL
+
+
+Input: -1.6
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 cccccccc cccccccd
+g_xLfmt(0) gives 4 bytes: "-1.6"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 cccccccc cccccccd
+fI[1] = #bfff0000 cccccccc cccccccc
+fI[0] == strtoxL
+
+
+Input: 1.7
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 d9999999 9999999a
+g_xLfmt(0) gives 3 bytes: "1.7"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 d9999999 99999999
+fI[1] = #3fff0000 d9999999 9999999a
+fI[1] == strtoxL
+
+
+Input: -1.7
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 d9999999 9999999a
+g_xLfmt(0) gives 4 bytes: "-1.7"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 d9999999 9999999a
+fI[1] = #bfff0000 d9999999 99999999
+fI[0] == strtoxL
+
+
+Input: 1.8
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 e6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.8"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 e6666666 66666666
+fI[1] = #3fff0000 e6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.8
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 e6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.8"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 e6666666 66666667
+fI[1] = #bfff0000 e6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.9
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 f3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.9"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 f3333333 33333333
+fI[1] = #3fff0000 f3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.9
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 f3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.9"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 f3333333 33333334
+fI[1] = #bfff0000 f3333333 33333333
+fI[1] == strtoxL
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 8ccccccc cccccccd
+g_xLfmt(0) gives 3 bytes: "1.1"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 8ccccccc cccccccc
+fI[1] = #3fff0000 8ccccccc cccccccd
+fI[1] == strtoxL
+
+
+Input: -1.1
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 8ccccccc cccccccc
+g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 8ccccccc cccccccd
+fI[1] = #bfff0000 8ccccccc cccccccc
+fI[1] == strtoxL
+
+
+Input: 1.2
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 99999999 9999999a
+g_xLfmt(0) gives 3 bytes: "1.2"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 99999999 99999999
+fI[1] = #3fff0000 99999999 9999999a
+fI[1] == strtoxL
+
+
+Input: -1.2
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 99999999 99999999
+g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 99999999 9999999a
+fI[1] = #bfff0000 99999999 99999999
+fI[1] == strtoxL
+
+
+Input: 1.3
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 a6666666 66666667
+g_xLfmt(0) gives 21 bytes: "1.3000000000000000001"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 a6666666 66666666
+fI[1] = #3fff0000 a6666666 66666667
+fI[1] == strtoxL
+
+
+Input: -1.3
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 a6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.3"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 a6666666 66666667
+fI[1] = #bfff0000 a6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.4
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 b3333333 33333334
+g_xLfmt(0) gives 21 bytes: "1.4000000000000000001"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 b3333333 33333333
+fI[1] = #3fff0000 b3333333 33333334
+fI[1] == strtoxL
+
+
+Input: -1.4
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 b3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.4"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 b3333333 33333334
+fI[1] = #bfff0000 b3333333 33333333
+fI[1] == strtoxL
+
+
+Input: 1.5
+
+strtoxL consumes 3 bytes and returns 1
+with bits = #3fff0000 c0000000 0
+g_xLfmt(0) gives 3 bytes: "1.5"
+
+strtoIxL returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: -1.5
+
+strtoxL consumes 4 bytes and returns 9
+with bits = #bfff0000 c0000000 0
+g_xLfmt(0) gives 4 bytes: "-1.5"
+
+strtoIxL returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.6
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 cccccccc cccccccd
+g_xLfmt(0) gives 3 bytes: "1.6"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 cccccccc cccccccc
+fI[1] = #3fff0000 cccccccc cccccccd
+fI[1] == strtoxL
+
+
+Input: -1.6
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 cccccccc cccccccc
+g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 cccccccc cccccccd
+fI[1] = #bfff0000 cccccccc cccccccc
+fI[1] == strtoxL
+
+
+Input: 1.7
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 d9999999 9999999a
+g_xLfmt(0) gives 3 bytes: "1.7"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 d9999999 99999999
+fI[1] = #3fff0000 d9999999 9999999a
+fI[1] == strtoxL
+
+
+Input: -1.7
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 d9999999 99999999
+g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 d9999999 9999999a
+fI[1] = #bfff0000 d9999999 99999999
+fI[1] == strtoxL
+
+
+Input: 1.8
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 e6666666 66666667
+g_xLfmt(0) gives 21 bytes: "1.8000000000000000001"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 e6666666 66666666
+fI[1] = #3fff0000 e6666666 66666667
+fI[1] == strtoxL
+
+
+Input: -1.8
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 e6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.8"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 e6666666 66666667
+fI[1] = #bfff0000 e6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.9
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 f3333333 33333334
+g_xLfmt(0) gives 21 bytes: "1.9000000000000000001"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 f3333333 33333333
+fI[1] = #3fff0000 f3333333 33333334
+fI[1] == strtoxL
+
+
+Input: -1.9
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 f3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.9"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 f3333333 33333334
+fI[1] = #bfff0000 f3333333 33333333
+fI[1] == strtoxL
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 8ccccccc cccccccc
+g_xLfmt(0) gives 21 bytes: "1.0999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 8ccccccc cccccccc
+fI[1] = #3fff0000 8ccccccc cccccccd
+fI[0] == strtoxL
+
+
+Input: -1.1
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 8ccccccc cccccccd
+g_xLfmt(0) gives 4 bytes: "-1.1"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 8ccccccc cccccccd
+fI[1] = #bfff0000 8ccccccc cccccccc
+fI[0] == strtoxL
+
+
+Input: 1.2
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 99999999 99999999
+g_xLfmt(0) gives 21 bytes: "1.1999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 99999999 99999999
+fI[1] = #3fff0000 99999999 9999999a
+fI[0] == strtoxL
+
+
+Input: -1.2
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 99999999 9999999a
+g_xLfmt(0) gives 4 bytes: "-1.2"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 99999999 9999999a
+fI[1] = #bfff0000 99999999 99999999
+fI[0] == strtoxL
+
+
+Input: 1.3
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 a6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.3"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 a6666666 66666666
+fI[1] = #3fff0000 a6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.3
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 a6666666 66666667
+g_xLfmt(0) gives 22 bytes: "-1.3000000000000000001"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 a6666666 66666667
+fI[1] = #bfff0000 a6666666 66666666
+fI[0] == strtoxL
+
+
+Input: 1.4
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 b3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.4"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 b3333333 33333333
+fI[1] = #3fff0000 b3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.4
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 b3333333 33333334
+g_xLfmt(0) gives 22 bytes: "-1.4000000000000000001"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 b3333333 33333334
+fI[1] = #bfff0000 b3333333 33333333
+fI[0] == strtoxL
+
+
+Input: 1.5
+
+strtoxL consumes 3 bytes and returns 1
+with bits = #3fff0000 c0000000 0
+g_xLfmt(0) gives 3 bytes: "1.5"
+
+strtoIxL returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: -1.5
+
+strtoxL consumes 4 bytes and returns 9
+with bits = #bfff0000 c0000000 0
+g_xLfmt(0) gives 4 bytes: "-1.5"
+
+strtoIxL returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.6
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 cccccccc cccccccc
+g_xLfmt(0) gives 21 bytes: "1.5999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 cccccccc cccccccc
+fI[1] = #3fff0000 cccccccc cccccccd
+fI[0] == strtoxL
+
+
+Input: -1.6
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 cccccccc cccccccd
+g_xLfmt(0) gives 4 bytes: "-1.6"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 cccccccc cccccccd
+fI[1] = #bfff0000 cccccccc cccccccc
+fI[0] == strtoxL
+
+
+Input: 1.7
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 d9999999 99999999
+g_xLfmt(0) gives 21 bytes: "1.6999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 d9999999 99999999
+fI[1] = #3fff0000 d9999999 9999999a
+fI[0] == strtoxL
+
+
+Input: -1.7
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 d9999999 9999999a
+g_xLfmt(0) gives 4 bytes: "-1.7"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 d9999999 9999999a
+fI[1] = #bfff0000 d9999999 99999999
+fI[0] == strtoxL
+
+
+Input: 1.8
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 e6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.8"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 e6666666 66666666
+fI[1] = #3fff0000 e6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.8
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 e6666666 66666667
+g_xLfmt(0) gives 22 bytes: "-1.8000000000000000001"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 e6666666 66666667
+fI[1] = #bfff0000 e6666666 66666666
+fI[0] == strtoxL
+
+
+Input: 1.9
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 f3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.9"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 f3333333 33333333
+fI[1] = #3fff0000 f3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.9
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 f3333333 33333334
+g_xLfmt(0) gives 22 bytes: "-1.9000000000000000001"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 f3333333 33333334
+fI[1] = #bfff0000 f3333333 33333333
+fI[0] == strtoxL
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/xL.ou1
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/xL.ou1	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/xL.ou1	(revision 2404)
@@ -0,0 +1,1183 @@
+***** This file is not right.  It needs to be generated on a
+***** system with a Motorla 68881 or the equivalent.
+Input: 1.23
+
+strtoxL consumes 4 bytes and returns 33
+with bits = #3fff0000 9d70a3d7 a3d70a4
+g_xLfmt(0) gives 4 bytes: "1.23"
+
+strtoIxL returns 33, consuming 4 bytes.
+fI[0] = #3fff0000 9d70a3d7 a3d70a3
+fI[1] = #3fff0000 9d70a3d7 a3d70a4
+fI[1] == strtoxL
+
+
+Input: 1.23e+20
+
+strtoxL consumes 8 bytes and returns 1
+with bits = #40410000 d55ef90a 2da18000
+g_xLfmt(0) gives 8 bytes: "1.23e+20"
+
+strtoIxL returns 1, consuming 8 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.23e-20
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #3fbc0000 e857267b b3a984f2
+g_xLfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #3fbc0000 e857267b b3a984f2
+fI[1] = #3fbc0000 e857267b b3a984f3
+fI[0] == strtoxL
+
+
+Input: 1.23456789
+
+strtoxL consumes 10 bytes and returns 33
+with bits = #3fff0000 9e065214 1ef0dbf6
+g_xLfmt(0) gives 10 bytes: "1.23456789"
+
+strtoIxL returns 33, consuming 10 bytes.
+fI[0] = #3fff0000 9e065214 1ef0dbf5
+fI[1] = #3fff0000 9e065214 1ef0dbf6
+fI[1] == strtoxL
+
+
+Input: 1.23456589e+20
+
+strtoxL consumes 14 bytes and returns 1
+with bits = #40410000 d629bd33 5ccba00
+g_xLfmt(0) gives 14 bytes: "1.23456589e+20"
+
+strtoIxL returns 1, consuming 14 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.23e+30
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #40620000 f8658274 7dbc824a
+g_xLfmt(0) gives 8 bytes: "1.23e+30"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #40620000 f8658274 7dbc824a
+fI[1] = #40620000 f8658274 7dbc824b
+fI[0] == strtoxL
+
+
+Input: 1.23e-30
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #3f9b0000 c794337a 808554eb
+g_xLfmt(0) gives 8 bytes: "1.23e-30"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #3f9b0000 c794337a 808554eb
+fI[1] = #3f9b0000 c794337a 808554ec
+fI[0] == strtoxL
+
+
+Input: 1.23456789e-20
+
+strtoxL consumes 14 bytes and returns 17
+with bits = #3fbc0000 e9340a38 f3d6d352
+g_xLfmt(0) gives 14 bytes: "1.23456789e-20"
+
+strtoIxL returns 17, consuming 14 bytes.
+fI[0] = #3fbc0000 e9340a38 f3d6d352
+fI[1] = #3fbc0000 e9340a38 f3d6d353
+fI[0] == strtoxL
+
+
+Input: 1.23456789e-30
+
+strtoxL consumes 14 bytes and returns 17
+with bits = #3f9b0000 c851f19d decca8fc
+g_xLfmt(0) gives 14 bytes: "1.23456789e-30"
+
+strtoIxL returns 17, consuming 14 bytes.
+fI[0] = #3f9b0000 c851f19d decca8fc
+fI[1] = #3f9b0000 c851f19d decca8fd
+fI[0] == strtoxL
+
+
+Input: 1.234567890123456789
+
+strtoxL consumes 20 bytes and returns 17
+with bits = #3fff0000 9e065214 62cfdb8d
+g_xLfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIxL returns 17, consuming 20 bytes.
+fI[0] = #3fff0000 9e065214 62cfdb8d
+fI[1] = #3fff0000 9e065214 62cfdb8e
+fI[0] == strtoxL
+
+
+Input: 1.23456789012345678901234567890123456789
+
+strtoxL consumes 40 bytes and returns 17
+with bits = #3fff0000 9e065214 62cfdb8d
+g_xLfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIxL returns 17, consuming 40 bytes.
+fI[0] = #3fff0000 9e065214 62cfdb8d
+fI[1] = #3fff0000 9e065214 62cfdb8e
+fI[0] == strtoxL
+
+
+Input: 1.23e306
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #43f70000 e033b668 e30fa6d5
+g_xLfmt(0) gives 9 bytes: "1.23e+306"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #43f70000 e033b668 e30fa6d5
+fI[1] = #43f70000 e033b668 e30fa6d6
+fI[0] == strtoxL
+
+
+Input: 1.23e-306
+
+strtoxL consumes 9 bytes and returns 33
+with bits = #3c060000 dd1dc2ed 1cb73f25
+g_xLfmt(0) gives 9 bytes: "1.23e-306"
+
+strtoIxL returns 33, consuming 9 bytes.
+fI[0] = #3c060000 dd1dc2ed 1cb73f24
+fI[1] = #3c060000 dd1dc2ed 1cb73f25
+fI[1] == strtoxL
+
+
+Input: 1.23e-320
+
+strtoxL consumes 9 bytes and returns 33
+with bits = #3bd80000 9b98c371 844c3f1a
+g_xLfmt(0) gives 9 bytes: "1.23e-320"
+
+strtoIxL returns 33, consuming 9 bytes.
+fI[0] = #3bd80000 9b98c371 844c3f19
+fI[1] = #3bd80000 9b98c371 844c3f1a
+fI[1] == strtoxL
+
+
+Input: 1.23e-20
+
+strtoxL consumes 8 bytes and returns 17
+with bits = #3fbc0000 e857267b b3a984f2
+g_xLfmt(0) gives 8 bytes: "1.23e-20"
+
+strtoIxL returns 17, consuming 8 bytes.
+fI[0] = #3fbc0000 e857267b b3a984f2
+fI[1] = #3fbc0000 e857267b b3a984f3
+fI[0] == strtoxL
+
+
+Input: 1.23456789e307
+
+strtoxL consumes 14 bytes and returns 17
+with bits = #43fb0000 8ca58a5e d766de75
+g_xLfmt(0) gives 15 bytes: "1.23456789e+307"
+
+strtoIxL returns 17, consuming 14 bytes.
+fI[0] = #43fb0000 8ca58a5e d766de75
+fI[1] = #43fb0000 8ca58a5e d766de76
+fI[0] == strtoxL
+
+
+Input: 1.23456589e-307
+
+strtoxL consumes 15 bytes and returns 17
+with bits = #3c030000 b18cb5dc c22fd369
+g_xLfmt(0) gives 15 bytes: "1.23456589e-307"
+
+strtoIxL returns 17, consuming 15 bytes.
+fI[0] = #3c030000 b18cb5dc c22fd369
+fI[1] = #3c030000 b18cb5dc c22fd36a
+fI[0] == strtoxL
+
+
+Input: 1.234567890123456789
+
+strtoxL consumes 20 bytes and returns 17
+with bits = #3fff0000 9e065214 62cfdb8d
+g_xLfmt(0) gives 20 bytes: "1.234567890123456789"
+
+strtoIxL returns 17, consuming 20 bytes.
+fI[0] = #3fff0000 9e065214 62cfdb8d
+fI[1] = #3fff0000 9e065214 62cfdb8e
+fI[0] == strtoxL
+
+
+Input: 1.234567890123456789e301
+
+strtoxL consumes 24 bytes and returns 33
+with bits = #43e70000 937a8baf ab20980c
+g_xLfmt(0) gives 25 bytes: "1.234567890123456789e+301"
+
+strtoIxL returns 33, consuming 24 bytes.
+fI[0] = #43e70000 937a8baf ab20980b
+fI[1] = #43e70000 937a8baf ab20980c
+fI[1] == strtoxL
+
+
+Input: 1.234567890123456789e-301
+
+strtoxL consumes 25 bytes and returns 33
+with bits = #3c170000 a953271a 5d069ad9
+g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-301"
+
+strtoIxL returns 33, consuming 25 bytes.
+fI[0] = #3c170000 a953271a 5d069ad8
+fI[1] = #3c170000 a953271a 5d069ad9
+fI[1] == strtoxL
+
+
+Input: 1.234567890123456789e-321
+
+strtoxL consumes 25 bytes and returns 33
+with bits = #3bd40000 f9e11b4c ea6dcce9
+g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-321"
+
+strtoIxL returns 33, consuming 25 bytes.
+fI[0] = #3bd40000 f9e11b4c ea6dcce8
+fI[1] = #3bd40000 f9e11b4c ea6dcce9
+fI[1] == strtoxL
+
+
+Input: 1e23
+
+strtoxL consumes 4 bytes and returns 1
+with bits = #404b0000 a968163f a57b400
+g_xLfmt(0) gives 5 bytes: "1e+23"
+
+strtoIxL returns 1, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1e310
+
+strtoxL consumes 5 bytes and returns 33
+with bits = #44040000 de81e40a 34bcf50
+g_xLfmt(0) gives 6 bytes: "1e+310"
+
+strtoIxL returns 33, consuming 5 bytes.
+fI[0] = #44040000 de81e40a 34bcf4f
+fI[1] = #44040000 de81e40a 34bcf50
+fI[1] == strtoxL
+
+
+Input: 9.0259718793241475e-277
+
+strtoxL consumes 23 bytes and returns 33
+with bits = #3c690000 ffffffff fffffcf7
+g_xLfmt(0) gives 23 bytes: "9.0259718793241475e-277"
+
+strtoIxL returns 33, consuming 23 bytes.
+fI[0] = #3c690000 ffffffff fffffcf6
+fI[1] = #3c690000 ffffffff fffffcf7
+fI[1] == strtoxL
+
+
+Input: 9.025971879324147880346310405869e-277
+
+strtoxL consumes 37 bytes and returns 17
+with bits = #3c6a0000 80000000 0
+g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277"
+
+strtoIxL returns 17, consuming 37 bytes.
+fI[0] = #3c6a0000 80000000 0
+fI[1] = #3c6a0000 80000000 1
+fI[0] == strtoxL
+
+
+Input: 9.025971879324147880346310405868e-277
+
+strtoxL consumes 37 bytes and returns 33
+with bits = #3c6a0000 80000000 0
+g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277"
+
+strtoIxL returns 33, consuming 37 bytes.
+fI[0] = #3c690000 ffffffff ffffffff
+fI[1] = #3c6a0000 80000000 0
+fI[1] == strtoxL
+
+
+Input: 2.2250738585072014e-308
+
+strtoxL consumes 23 bytes and returns 17
+with bits = #3c010000 80000000 46
+g_xLfmt(0) gives 23 bytes: "2.2250738585072014e-308"
+
+strtoIxL returns 17, consuming 23 bytes.
+fI[0] = #3c010000 80000000 46
+fI[1] = #3c010000 80000000 47
+fI[0] == strtoxL
+
+
+Input: 2.2250738585072013e-308
+
+strtoxL consumes 23 bytes and returns 17
+with bits = #3c000000 ffffffff fffffd4f
+g_xLfmt(0) gives 23 bytes: "2.2250738585072013e-308"
+
+strtoIxL returns 17, consuming 23 bytes.
+fI[0] = #3c000000 ffffffff fffffd4f
+fI[1] = #3c000000 ffffffff fffffd50
+fI[0] == strtoxL
+
+Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero)
+
+Input: 1.1
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 8ccccccc cccccccc
+g_xLfmt(0) gives 21 bytes: "1.0999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 8ccccccc cccccccc
+fI[1] = #3fff0000 8ccccccc cccccccd
+fI[0] == strtoxL
+
+
+Input: -1.1
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 8ccccccc cccccccc
+g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 8ccccccc cccccccd
+fI[1] = #bfff0000 8ccccccc cccccccc
+fI[1] == strtoxL
+
+
+Input: 1.2
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 99999999 99999999
+g_xLfmt(0) gives 21 bytes: "1.1999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 99999999 99999999
+fI[1] = #3fff0000 99999999 9999999a
+fI[0] == strtoxL
+
+
+Input: -1.2
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 99999999 99999999
+g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 99999999 9999999a
+fI[1] = #bfff0000 99999999 99999999
+fI[1] == strtoxL
+
+
+Input: 1.3
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 a6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.3"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 a6666666 66666666
+fI[1] = #3fff0000 a6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.3
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 a6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.3"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 a6666666 66666667
+fI[1] = #bfff0000 a6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.4
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 b3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.4"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 b3333333 33333333
+fI[1] = #3fff0000 b3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.4
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 b3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.4"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 b3333333 33333334
+fI[1] = #bfff0000 b3333333 33333333
+fI[1] == strtoxL
+
+
+Input: 1.5
+
+strtoxL consumes 3 bytes and returns 1
+with bits = #3fff0000 c0000000 0
+g_xLfmt(0) gives 3 bytes: "1.5"
+
+strtoIxL returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: -1.5
+
+strtoxL consumes 4 bytes and returns 9
+with bits = #bfff0000 c0000000 0
+g_xLfmt(0) gives 4 bytes: "-1.5"
+
+strtoIxL returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.6
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 cccccccc cccccccc
+g_xLfmt(0) gives 21 bytes: "1.5999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 cccccccc cccccccc
+fI[1] = #3fff0000 cccccccc cccccccd
+fI[0] == strtoxL
+
+
+Input: -1.6
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 cccccccc cccccccc
+g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 cccccccc cccccccd
+fI[1] = #bfff0000 cccccccc cccccccc
+fI[1] == strtoxL
+
+
+Input: 1.7
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 d9999999 99999999
+g_xLfmt(0) gives 21 bytes: "1.6999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 d9999999 99999999
+fI[1] = #3fff0000 d9999999 9999999a
+fI[0] == strtoxL
+
+
+Input: -1.7
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 d9999999 99999999
+g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 d9999999 9999999a
+fI[1] = #bfff0000 d9999999 99999999
+fI[1] == strtoxL
+
+
+Input: 1.8
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 e6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.8"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 e6666666 66666666
+fI[1] = #3fff0000 e6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.8
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 e6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.8"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 e6666666 66666667
+fI[1] = #bfff0000 e6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.9
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 f3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.9"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 f3333333 33333333
+fI[1] = #3fff0000 f3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.9
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 f3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.9"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 f3333333 33333334
+fI[1] = #bfff0000 f3333333 33333333
+fI[1] == strtoxL
+
+Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest)
+
+Input: 1.1
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 8ccccccc cccccccd
+g_xLfmt(0) gives 3 bytes: "1.1"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 8ccccccc cccccccc
+fI[1] = #3fff0000 8ccccccc cccccccd
+fI[1] == strtoxL
+
+
+Input: -1.1
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 8ccccccc cccccccd
+g_xLfmt(0) gives 4 bytes: "-1.1"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 8ccccccc cccccccd
+fI[1] = #bfff0000 8ccccccc cccccccc
+fI[0] == strtoxL
+
+
+Input: 1.2
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 99999999 9999999a
+g_xLfmt(0) gives 3 bytes: "1.2"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 99999999 99999999
+fI[1] = #3fff0000 99999999 9999999a
+fI[1] == strtoxL
+
+
+Input: -1.2
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 99999999 9999999a
+g_xLfmt(0) gives 4 bytes: "-1.2"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 99999999 9999999a
+fI[1] = #bfff0000 99999999 99999999
+fI[0] == strtoxL
+
+
+Input: 1.3
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 a6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.3"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 a6666666 66666666
+fI[1] = #3fff0000 a6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.3
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 a6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.3"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 a6666666 66666667
+fI[1] = #bfff0000 a6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.4
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 b3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.4"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 b3333333 33333333
+fI[1] = #3fff0000 b3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.4
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 b3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.4"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 b3333333 33333334
+fI[1] = #bfff0000 b3333333 33333333
+fI[1] == strtoxL
+
+
+Input: 1.5
+
+strtoxL consumes 3 bytes and returns 1
+with bits = #3fff0000 c0000000 0
+g_xLfmt(0) gives 3 bytes: "1.5"
+
+strtoIxL returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: -1.5
+
+strtoxL consumes 4 bytes and returns 9
+with bits = #bfff0000 c0000000 0
+g_xLfmt(0) gives 4 bytes: "-1.5"
+
+strtoIxL returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.6
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 cccccccc cccccccd
+g_xLfmt(0) gives 3 bytes: "1.6"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 cccccccc cccccccc
+fI[1] = #3fff0000 cccccccc cccccccd
+fI[1] == strtoxL
+
+
+Input: -1.6
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 cccccccc cccccccd
+g_xLfmt(0) gives 4 bytes: "-1.6"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 cccccccc cccccccd
+fI[1] = #bfff0000 cccccccc cccccccc
+fI[0] == strtoxL
+
+
+Input: 1.7
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 d9999999 9999999a
+g_xLfmt(0) gives 3 bytes: "1.7"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 d9999999 99999999
+fI[1] = #3fff0000 d9999999 9999999a
+fI[1] == strtoxL
+
+
+Input: -1.7
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 d9999999 9999999a
+g_xLfmt(0) gives 4 bytes: "-1.7"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 d9999999 9999999a
+fI[1] = #bfff0000 d9999999 99999999
+fI[0] == strtoxL
+
+
+Input: 1.8
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 e6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.8"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 e6666666 66666666
+fI[1] = #3fff0000 e6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.8
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 e6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.8"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 e6666666 66666667
+fI[1] = #bfff0000 e6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.9
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 f3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.9"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 f3333333 33333333
+fI[1] = #3fff0000 f3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.9
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 f3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.9"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 f3333333 33333334
+fI[1] = #bfff0000 f3333333 33333333
+fI[1] == strtoxL
+
+Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity)
+
+Input: 1.1
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 8ccccccc cccccccd
+g_xLfmt(0) gives 3 bytes: "1.1"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 8ccccccc cccccccc
+fI[1] = #3fff0000 8ccccccc cccccccd
+fI[1] == strtoxL
+
+
+Input: -1.1
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 8ccccccc cccccccc
+g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 8ccccccc cccccccd
+fI[1] = #bfff0000 8ccccccc cccccccc
+fI[1] == strtoxL
+
+
+Input: 1.2
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 99999999 9999999a
+g_xLfmt(0) gives 3 bytes: "1.2"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 99999999 99999999
+fI[1] = #3fff0000 99999999 9999999a
+fI[1] == strtoxL
+
+
+Input: -1.2
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 99999999 99999999
+g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 99999999 9999999a
+fI[1] = #bfff0000 99999999 99999999
+fI[1] == strtoxL
+
+
+Input: 1.3
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 a6666666 66666667
+g_xLfmt(0) gives 21 bytes: "1.3000000000000000001"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 a6666666 66666666
+fI[1] = #3fff0000 a6666666 66666667
+fI[1] == strtoxL
+
+
+Input: -1.3
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 a6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.3"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 a6666666 66666667
+fI[1] = #bfff0000 a6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.4
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 b3333333 33333334
+g_xLfmt(0) gives 21 bytes: "1.4000000000000000001"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 b3333333 33333333
+fI[1] = #3fff0000 b3333333 33333334
+fI[1] == strtoxL
+
+
+Input: -1.4
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 b3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.4"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 b3333333 33333334
+fI[1] = #bfff0000 b3333333 33333333
+fI[1] == strtoxL
+
+
+Input: 1.5
+
+strtoxL consumes 3 bytes and returns 1
+with bits = #3fff0000 c0000000 0
+g_xLfmt(0) gives 3 bytes: "1.5"
+
+strtoIxL returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: -1.5
+
+strtoxL consumes 4 bytes and returns 9
+with bits = #bfff0000 c0000000 0
+g_xLfmt(0) gives 4 bytes: "-1.5"
+
+strtoIxL returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.6
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 cccccccc cccccccd
+g_xLfmt(0) gives 3 bytes: "1.6"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 cccccccc cccccccc
+fI[1] = #3fff0000 cccccccc cccccccd
+fI[1] == strtoxL
+
+
+Input: -1.6
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 cccccccc cccccccc
+g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 cccccccc cccccccd
+fI[1] = #bfff0000 cccccccc cccccccc
+fI[1] == strtoxL
+
+
+Input: 1.7
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 d9999999 9999999a
+g_xLfmt(0) gives 3 bytes: "1.7"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 d9999999 99999999
+fI[1] = #3fff0000 d9999999 9999999a
+fI[1] == strtoxL
+
+
+Input: -1.7
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 d9999999 99999999
+g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 d9999999 9999999a
+fI[1] = #bfff0000 d9999999 99999999
+fI[1] == strtoxL
+
+
+Input: 1.8
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 e6666666 66666667
+g_xLfmt(0) gives 21 bytes: "1.8000000000000000001"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 e6666666 66666666
+fI[1] = #3fff0000 e6666666 66666667
+fI[1] == strtoxL
+
+
+Input: -1.8
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 e6666666 66666666
+g_xLfmt(0) gives 4 bytes: "-1.8"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 e6666666 66666667
+fI[1] = #bfff0000 e6666666 66666666
+fI[1] == strtoxL
+
+
+Input: 1.9
+
+strtoxL consumes 3 bytes and returns 33
+with bits = #3fff0000 f3333333 33333334
+g_xLfmt(0) gives 21 bytes: "1.9000000000000000001"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 f3333333 33333333
+fI[1] = #3fff0000 f3333333 33333334
+fI[1] == strtoxL
+
+
+Input: -1.9
+
+strtoxL consumes 4 bytes and returns 25
+with bits = #bfff0000 f3333333 33333333
+g_xLfmt(0) gives 4 bytes: "-1.9"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 f3333333 33333334
+fI[1] = #bfff0000 f3333333 33333333
+fI[1] == strtoxL
+
+Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity)
+
+Input: 1.1
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 8ccccccc cccccccc
+g_xLfmt(0) gives 21 bytes: "1.0999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 8ccccccc cccccccc
+fI[1] = #3fff0000 8ccccccc cccccccd
+fI[0] == strtoxL
+
+
+Input: -1.1
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 8ccccccc cccccccd
+g_xLfmt(0) gives 4 bytes: "-1.1"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 8ccccccc cccccccd
+fI[1] = #bfff0000 8ccccccc cccccccc
+fI[0] == strtoxL
+
+
+Input: 1.2
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 99999999 99999999
+g_xLfmt(0) gives 21 bytes: "1.1999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 99999999 99999999
+fI[1] = #3fff0000 99999999 9999999a
+fI[0] == strtoxL
+
+
+Input: -1.2
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 99999999 9999999a
+g_xLfmt(0) gives 4 bytes: "-1.2"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 99999999 9999999a
+fI[1] = #bfff0000 99999999 99999999
+fI[0] == strtoxL
+
+
+Input: 1.3
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 a6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.3"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 a6666666 66666666
+fI[1] = #3fff0000 a6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.3
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 a6666666 66666667
+g_xLfmt(0) gives 22 bytes: "-1.3000000000000000001"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 a6666666 66666667
+fI[1] = #bfff0000 a6666666 66666666
+fI[0] == strtoxL
+
+
+Input: 1.4
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 b3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.4"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 b3333333 33333333
+fI[1] = #3fff0000 b3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.4
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 b3333333 33333334
+g_xLfmt(0) gives 22 bytes: "-1.4000000000000000001"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 b3333333 33333334
+fI[1] = #bfff0000 b3333333 33333333
+fI[0] == strtoxL
+
+
+Input: 1.5
+
+strtoxL consumes 3 bytes and returns 1
+with bits = #3fff0000 c0000000 0
+g_xLfmt(0) gives 3 bytes: "1.5"
+
+strtoIxL returns 1, consuming 3 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: -1.5
+
+strtoxL consumes 4 bytes and returns 9
+with bits = #bfff0000 c0000000 0
+g_xLfmt(0) gives 4 bytes: "-1.5"
+
+strtoIxL returns 9, consuming 4 bytes.
+fI[0] == fI[1] == strtoxL
+
+
+Input: 1.6
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 cccccccc cccccccc
+g_xLfmt(0) gives 21 bytes: "1.5999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 cccccccc cccccccc
+fI[1] = #3fff0000 cccccccc cccccccd
+fI[0] == strtoxL
+
+
+Input: -1.6
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 cccccccc cccccccd
+g_xLfmt(0) gives 4 bytes: "-1.6"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 cccccccc cccccccd
+fI[1] = #bfff0000 cccccccc cccccccc
+fI[0] == strtoxL
+
+
+Input: 1.7
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 d9999999 99999999
+g_xLfmt(0) gives 21 bytes: "1.6999999999999999999"
+
+strtoIxL returns 33, consuming 3 bytes.
+fI[0] = #3fff0000 d9999999 99999999
+fI[1] = #3fff0000 d9999999 9999999a
+fI[0] == strtoxL
+
+
+Input: -1.7
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 d9999999 9999999a
+g_xLfmt(0) gives 4 bytes: "-1.7"
+
+strtoIxL returns 41, consuming 4 bytes.
+fI[0] = #bfff0000 d9999999 9999999a
+fI[1] = #bfff0000 d9999999 99999999
+fI[0] == strtoxL
+
+
+Input: 1.8
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 e6666666 66666666
+g_xLfmt(0) gives 3 bytes: "1.8"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 e6666666 66666666
+fI[1] = #3fff0000 e6666666 66666667
+fI[0] == strtoxL
+
+
+Input: -1.8
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 e6666666 66666667
+g_xLfmt(0) gives 22 bytes: "-1.8000000000000000001"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 e6666666 66666667
+fI[1] = #bfff0000 e6666666 66666666
+fI[0] == strtoxL
+
+
+Input: 1.9
+
+strtoxL consumes 3 bytes and returns 17
+with bits = #3fff0000 f3333333 33333333
+g_xLfmt(0) gives 3 bytes: "1.9"
+
+strtoIxL returns 17, consuming 3 bytes.
+fI[0] = #3fff0000 f3333333 33333333
+fI[1] = #3fff0000 f3333333 33333334
+fI[0] == strtoxL
+
+
+Input: -1.9
+
+strtoxL consumes 4 bytes and returns 41
+with bits = #bfff0000 f3333333 33333334
+g_xLfmt(0) gives 22 bytes: "-1.9000000000000000001"
+
+strtoIxL returns 25, consuming 4 bytes.
+fI[0] = #bfff0000 f3333333 33333334
+fI[1] = #bfff0000 f3333333 33333333
+fI[0] == strtoxL
+
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/xLtest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/xLtest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/xLtest.c	(revision 2404)
@@ -0,0 +1,169 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* Test program for g_xLfmt, strtoIxL, strtopxL, and strtorxL.
+ *
+ * Inputs (on stdin):
+ *		r rounding_mode
+ *		n ndig
+ *		number
+ *		#hex0 hex1 hex2
+ *
+ *	rounding_mode values:
+ *		0 = toward zero
+ *		1 = nearest
+ *		2 = toward +Infinity
+ *		3 = toward -Infinity
+ *
+ * where number is a decimal floating-point number,
+ * hex0 is a string of <= 8 Hex digits for the most significant
+ * word of the number, hex1 is a similar string for the next
+ * word, etc., and ndig is a parameters to g_xLfmt.
+ */
+
+#include "gdtoa.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+ extern int getround ANSI((int,char*));
+
+ static char ibuf[2048], obuf[2048];
+
+#define U (unsigned long)
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#endif
+#ifdef IEEE_8087
+#define _0 2
+#define _1 1
+#define _2 0
+#endif
+
+ int
+main(Void)
+{
+	char *s, *se, *se1;
+	int dItry, i, ndig = 0, r = 1;
+	union { long double d; ULong bits[3]; } u, v[2];
+
+	while(s = fgets(ibuf, sizeof(ibuf), stdin)) {
+		while(*s <= ' ')
+			if (!*s++)
+				continue;
+		dItry = 0;
+		switch(*s) {
+		  case 'r':
+			r = getround(r, s);
+			continue;
+		  case 'n':
+			i = s[1];
+			if (i <= ' ' || i >= '0' && i <= '9') {
+				ndig = atoi(s+1);
+				continue;
+				}
+			break; /* nan? */
+		  case '#':
+			sscanf(s+1, "%lx %lx %lx", &u.bits[_0],
+				&u.bits[_1], &u.bits[_2]);
+			printf("\nInput: %s", ibuf);
+			printf(" --> f = #%lx %lx %lx\n", u.bits[_0],
+				u.bits[_1], u.bits[_2]);
+			goto fmt_test;
+			}
+		dItry = 1;
+		printf("\nInput: %s", ibuf);
+		i = strtorxL(ibuf, &se, r, u.bits);
+		if (r == 1 && (i != strtopxL(ibuf, &se1, v[0].bits) || se1 != se
+		 || memcmp(u.bits, v[0].bits, 12)))
+			printf("***strtoxL and strtorxL disagree!!\n:");
+		printf("\nstrtoxL consumes %d bytes and returns %d\n",
+				(int)(se-ibuf), i);
+		printf("with bits = #%lx %lx %lx\n",
+			U u.bits[_0], U u.bits[_1], U u.bits[_2]);
+		if (sizeof(long double) == 12)
+			printf("printf(\"%%.21Lg\") gives %.21Lg\n", u.d);
+ fmt_test:
+		se = g_xLfmt(obuf, u.bits, ndig, sizeof(obuf));
+		printf("g_xLfmt(%d) gives %d bytes: \"%s\"\n\n",
+			ndig, (int)(se-obuf), se ? obuf : "<null>");
+		if (!dItry)
+			continue;
+		printf("strtoIxL returns %d,",
+			strtoIxL(ibuf, &se, v[0].bits, v[1].bits));
+		printf(" consuming %d bytes.\n", (int)(se-ibuf));
+		if (!memcmp(v[0].bits, v[1].bits, 12)) {
+			if (!memcmp(u.bits, v[0].bits, 12))
+				printf("fI[0] == fI[1] == strtoxL\n");
+			else {
+				printf("fI[0] == fI[1] = #%lx %lx %lx\n",
+					U v[0].bits[_0], U v[0].bits[_1],
+					U v[0].bits[_2]);
+				if (sizeof(long double) == 12)
+				    printf("= %.21Lg\n", v[0].d);
+				}
+			}
+		else {
+			printf("fI[0] = #%lx %lx %lx\n",
+					U v[0].bits[_0], U v[0].bits[_1],
+					U v[0].bits[_2]);
+			if (sizeof(long double) == 12)
+				printf("= %.21Lg\n", v[0].d);
+			printf("fI[1] = #%lx %lx %lx\n",
+					U v[1].bits[_0], U v[1].bits[_1],
+					U v[1].bits[_2]);
+			if (sizeof(long double) == 12)
+				printf("= %.21Lg\n", v[1].d);
+			if (!memcmp(v[0].bits, u.bits, 12))
+				printf("fI[0] == strtoxL\n");
+			else if (!memcmp(v[1].bits, u.bits, 12))
+				printf("fI[1] == strtoxL\n");
+			else
+				printf("**** Both differ from strtod ****\n");
+			}
+		printf("\n");
+		}
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/xQtest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/xQtest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/xQtest.c	(revision 2404)
@@ -0,0 +1,46 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 2002 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+#include <stdio.h>
+
+ int
+main(void)
+{
+	switch(sizeof(long double)) {
+	  case 10:
+	  case 12:
+		printf("cp x.ou1 x.out; cp xL.ou1 xL.out; cp Q.ou0 Q.out\n");
+		break;
+	  case 16:
+		printf("cp x.ou0 x.out; cp xL.ou0 xL.out; cp Q.ou1 Q.out\n");
+		break;
+	  default:
+		printf("cp x.ou0 x.out; cp xL.ou0 xL.out; cp Q.ou0 Q.out\n");
+	  }
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/xsum0.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/xsum0.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/xsum0.out	(revision 2404)
@@ -0,0 +1,35 @@
+README	e6ebdc91	2429
+Qtest.c	140625e2	4778
+dItest.c	8689031	2401
+ddtest.c	ea24d330	4943
+dtest.c	900d971	4071
+dt.c	addb61c	6198
+ftest.c	f609ce43	3958
+getround.c	f471599	2041
+strtoIdSI.c	7bfb88b	49
+strtoIddSI.c	72e8852	50
+strtodISI.c	ed08b740	49
+strtodt.c	17aca428	3213
+strtopddSI.c	13e7138d	50
+strtorddSI.c	f7e4b1d5	50
+xLtest.c	faca328f	4646
+xQtest.c	efdea3a2	1549
+xtest.c	1f19b87	4858
+rtestnos	f94bcdf6	336
+testnos	e89999d6	485
+testnos1	7e16229	294
+testnos3	fa5c8aca	11998
+dI.out	d522eef	4369
+dIsi.out	1dd6d02f	4350
+ddsi.out	1f94bbe2	10251
+dd.out	e262456e	40923
+dtst.out	ee75f6b9	23308
+d.out	f271efc9	28131
+f.out	4b0bd51	21207
+x.ou0	1cfc5d22	25378
+xL.ou0	faa3a741	26363
+x.ou1	1a7e9dd4	34587
+xL.ou1	418057a	26476
+Q.ou0	e4592b85	28742
+Q.ou1	ea0b344d	39572
+makefile	ebbea1e1	4191
Index: /vendor/FreeBSD-libc/5.3/gdtoa/test/xtest.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/test/xtest.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/test/xtest.c	(revision 2404)
@@ -0,0 +1,176 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+/* Test program for g_xfmt, strtoIx, strtopx, and strtorx.
+ *
+ * Inputs (on stdin):
+ *		r rounding_mode
+ *		n ndig
+ *		number
+ *		#hex0 hex1 hex2 hex3 hex4
+ *
+ *	rounding_mode values:
+ *		0 = toward zero
+ *		1 = nearest
+ *		2 = toward +Infinity
+ *		3 = toward -Infinity
+ *
+ * where number is a decimal floating-point number,
+ * hex0 is a string of <= 4 Hex digits for the most significant
+ * half-word of the number, hex1 is a similar string for the next
+ * half-word, etc., and ndig is a parameters to g_xfmt.
+ */
+
+#include "gdtoa.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+ extern int getround ANSI((int,char*));
+
+ static char ibuf[2048], obuf[2048];
+
+#undef _0
+#undef _1
+
+/* one or the other of IEEE_MC68k or IEEE_8087 should be #defined */
+
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#define _2 2
+#define _3 3
+#define _4 4
+#endif
+#ifdef IEEE_8087
+#define _0 4
+#define _1 3
+#define _2 2
+#define _3 1
+#define _4 0
+#endif
+
+ int
+main(Void)
+{
+	char *s, *se, *se1;
+	int i, dItry, ndig = 0, r = 1;
+	union { long double d; UShort bits[5]; } u, v[2];
+
+	while(s = fgets(ibuf, sizeof(ibuf), stdin)) {
+		while(*s <= ' ')
+			if (!*s++)
+				continue;
+		dItry = 0;
+		switch(*s) {
+		  case 'r':
+			r = getround(r, s);
+			continue;
+		  case 'n':
+			i = s[1];
+			if (i <= ' ' || i >= '0' && i <= '9') {
+				ndig = atoi(s+1);
+				continue;
+				}
+			break; /* nan? */
+		  case '#':
+			sscanf(s+1, "%hx %hx %hx %hx hx", &u.bits[_0],
+				&u.bits[_1], &u.bits[_2], &u.bits[_3],
+				&u.bits[_4]);
+			printf("\nInput: %s", ibuf);
+			printf(" --> f = #%x %x %x %x %x\n", u.bits[_0],
+				u.bits[_1], u.bits[_2], u.bits[_3], u.bits[4]);
+			goto fmt_test;
+			}
+		dItry = 1;
+		printf("\nInput: %s", ibuf);
+		i = strtorx(ibuf, &se, r, u.bits);
+		if (r == 1 && (i != strtopx(ibuf, &se1, v[0].bits) || se1 != se
+		 || memcmp(u.bits, v[0].bits, 10)))
+			printf("***strtox and strtorx disagree!!\n:");
+		printf("\nstrtox consumes %d bytes and returns %d\n",
+				(int)(se-ibuf), i);
+		printf("with bits = #%x %x %x %x %x\n",
+			u.bits[_0], u.bits[_1], u.bits[_2],
+			u.bits[_3], u.bits[_4]);
+		if (sizeof(long double) == 12)
+			printf("printf(\"%%.21Lg\") gives %.21Lg\n", u.d);
+ fmt_test:
+		se = g_xfmt(obuf, u.bits, ndig, sizeof(obuf));
+		printf("g_xfmt(%d) gives %d bytes: \"%s\"\n\n",
+			ndig, (int)(se-obuf), se ? obuf : "<null>");
+		if (!dItry)
+			continue;
+		printf("strtoIx returns %d,",
+			strtoIx(ibuf, &se, v[0].bits, v[1].bits));
+		printf(" consuming %d bytes.\n", (int)(se-ibuf));
+		if (!memcmp(v[0].bits, v[1].bits, 10)) {
+			if (!memcmp(u.bits, v[0].bits, 10))
+				printf("fI[0] == fI[1] == strtox\n");
+			else {
+				printf("fI[0] == fI[1] = #%x %x %x %x %x\n",
+					v[0].bits[_0], v[0].bits[_1],
+					v[0].bits[_2], v[0].bits[_3],
+					v[0].bits[_4]);
+				if (sizeof(long double) == 12)
+				    printf("= %.21Lg\n", v[0].d);
+				}
+			}
+		else {
+			printf("fI[0] = #%x %x %x %x %x\n",
+					v[0].bits[_0], v[0].bits[_1],
+					v[0].bits[_2], v[0].bits[_3],
+					v[0].bits[_4]);
+			if (sizeof(long double) == 12)
+				printf("= %.21Lg\n", v[0].d);
+			printf("fI[1] = #%x %x %x %x %x\n",
+					v[1].bits[_0], v[1].bits[_1],
+					v[1].bits[_2], v[0].bits[_3],
+					v[0].bits[_4]);
+			if (sizeof(long double) == 12)
+				printf("= %.21Lg\n", v[1].d);
+			if (!memcmp(v[0].bits, u.bits, 10))
+				printf("fI[0] == strtox\n");
+			else if (!memcmp(v[1].bits, u.bits, 10))
+				printf("fI[1] == strtox\n");
+			else
+				printf("**** Both differ from strtod ****\n");
+			}
+		printf("\n");
+		}
+	return 0;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/ulp.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/ulp.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/ulp.c	(revision 2404)
@@ -0,0 +1,76 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998, 1999 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+	David M. Gay
+	Bell Laboratories, Room 2C-463
+	600 Mountain Avenue
+	Murray Hill, NJ 07974-0636
+	U.S.A.
+	dmg@bell-labs.com
+ */
+
+#include "gdtoaimp.h"
+
+ double
+ulp
+#ifdef KR_headers
+	(x) double x;
+#else
+	(double x)
+#endif
+{
+	Long L;
+	double a;
+
+	L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
+#ifndef Sudden_Underflow
+	if (L > 0) {
+#endif
+#ifdef IBM
+		L |= Exp_msk1 >> 4;
+#endif
+		word0(a) = L;
+		word1(a) = 0;
+#ifndef Sudden_Underflow
+		}
+	else {
+		L = -L >> Exp_shift;
+		if (L < Exp_shift) {
+			word0(a) = 0x80000 >> L;
+			word1(a) = 0;
+			}
+		else {
+			word0(a) = 0;
+			L -= Exp_shift;
+			word1(a) = L >= 31 ? 1 : 1 << 31 - L;
+			}
+		}
+#endif
+	return a;
+	}
Index: /vendor/FreeBSD-libc/5.3/gdtoa/xsum0.out
===================================================================
--- /vendor/FreeBSD-libc/5.3/gdtoa/xsum0.out	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gdtoa/xsum0.out	(revision 2404)
@@ -0,0 +1,46 @@
+README	c9c34c1	13153
+arithchk.c	e37b8a75	4070
+dmisc.c	e8d262b6	4712
+dtoa.c	f3c132b3	16905
+g_Qfmt.c	e5847e9	2870
+g__fmt.c	ee5f9be0	2439
+g_ddfmt.c	fcf94527	3790
+g_dfmt.c	f30e55a9	2533
+g_ffmt.c	7c4ea96	2459
+g_xLfmt.c	36ee116	2716
+g_xfmt.c	c20a5e4	2795
+gdtoa.c	364a0d2	17017
+gdtoa.h	1eb440de	4810
+gdtoaimp.h	6a955ba	19106
+gethex.c	1c586a03	5075
+gmisc.c	e1a268ea	2114
+hd_init.c	cf9a94e	1827
+hexnan.c	f53be1da	2988
+makefile	e84d078f	2802
+misc.c	ea539bdb	14168
+smisc.c	f659f036	3685
+strtoIQ.c	13ac9f44	1969
+strtoId.c	d05a7a6	1961
+strtoIdd.c	fa36260d	2135
+strtoIf.c	eb75ac99	1905
+strtoIg.c	ec59c2fa	3484
+strtoIx.c	8f8c9d	1990
+strtoIxL.c	1313ff7f	1961
+strtod.c	fd6556c8	19985
+strtodI.c	e58338e0	4062
+strtodg.c	e04b9254	19458
+strtof.c	1e7a787a	2202
+strtopQ.c	e232c542	2685
+strtopd.c	e865dc64	1701
+strtopdd.c	1c240126	4540
+strtopf.c	1c762782	2196
+strtopx.c	17c3fafb	2665
+strtopxL.c	ed474cdb	2505
+strtorQ.c	126cc92b	2898
+strtord.c	1fce44b9	2528
+strtordd.c	c32bca0	4979
+strtorf.c	fe6a2687	2430
+strtorx.c	18389f0c	2888
+strtorxL.c	f63fc249	2730
+sum.c	dc07b9b	2524
+ulp.c	f6db0b4d	1894
Index: /vendor/FreeBSD-libc/5.3/gen/_rand48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/_rand48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/_rand48.c	(revision 2404)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/_rand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+unsigned short _rand48_seed[3] = {
+	RAND48_SEED_0,
+	RAND48_SEED_1,
+	RAND48_SEED_2
+};
+unsigned short _rand48_mult[3] = {
+	RAND48_MULT_0,
+	RAND48_MULT_1,
+	RAND48_MULT_2
+};
+unsigned short _rand48_add = RAND48_ADD;
+
+void
+_dorand48(unsigned short xseed[3])
+{
+	unsigned long accu;
+	unsigned short temp[2];
+
+	accu = (unsigned long) _rand48_mult[0] * (unsigned long) xseed[0] +
+	 (unsigned long) _rand48_add;
+	temp[0] = (unsigned short) accu;	/* lower 16 bits */
+	accu >>= sizeof(unsigned short) * 8;
+	accu += (unsigned long) _rand48_mult[0] * (unsigned long) xseed[1] +
+	 (unsigned long) _rand48_mult[1] * (unsigned long) xseed[0];
+	temp[1] = (unsigned short) accu;	/* middle 16 bits */
+	accu >>= sizeof(unsigned short) * 8;
+	accu += _rand48_mult[0] * xseed[2] + _rand48_mult[1] * xseed[1] + _rand48_mult[2] * xseed[0];
+	xseed[0] = temp[0];
+	xseed[1] = temp[1];
+	xseed[2] = (unsigned short) accu;
+}
Index: /vendor/FreeBSD-libc/5.3/gen/alarm.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/alarm.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/alarm.c	(revision 2404)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1983, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)alarm.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/alarm.c,v 1.2 2002/02/01 01:08:47 obrien Exp $");
+
+/*
+ * Backwards compatible alarm.
+ */
+#include <sys/time.h>
+#include <unistd.h>
+
+unsigned int
+alarm(secs)
+	unsigned int secs;
+{
+	struct itimerval it, oitv;
+	struct itimerval *itp = &it;
+
+	timerclear(&itp->it_interval);
+	itp->it_value.tv_sec = secs;
+	itp->it_value.tv_usec = 0;
+	if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
+		return (-1);
+	if (oitv.it_value.tv_usec)
+		oitv.it_value.tv_sec++;
+	return (oitv.it_value.tv_sec);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/drand48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/drand48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/drand48.c	(revision 2404)
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/drand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+extern unsigned short _rand48_seed[3];
+
+double
+drand48(void)
+{
+	return erand48(_rand48_seed);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/erand48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/erand48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/erand48.c	(revision 2404)
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/erand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+double
+erand48(unsigned short xseed[3])
+{
+	_dorand48(xseed);
+	return ldexp((double) xseed[0], -48) +
+	       ldexp((double) xseed[1], -32) +
+	       ldexp((double) xseed[2], -16);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/err.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/err.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/err.c	(revision 2404)
@@ -0,0 +1,213 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)err.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/err.c,v 1.13 2002/03/29 22:43:41 markm Exp $");
+
+#include "namespace.h"
+#include <err.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "un-namespace.h"
+
+#include "libc_private.h"
+
+static FILE *err_file; /* file to use for error output */
+static void (*err_exit)(int);
+
+/*
+ * This is declared to take a `void *' so that the caller is not required
+ * to include <stdio.h> first.  However, it is really a `FILE *', and the
+ * manual page documents it as such.
+ */
+void
+err_set_file(void *fp)
+{
+	if (fp)
+		err_file = fp;
+	else
+		err_file = stderr;
+}
+
+void
+err_set_exit(void (*ef)(int))
+{
+	err_exit = ef;
+}
+
+__weak_reference(_err, err);
+
+void
+_err(int eval, const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	verrc(eval, errno, fmt, ap);
+	va_end(ap);
+}
+
+void
+verr(eval, fmt, ap)
+	int eval;
+	const char *fmt;
+	va_list ap;
+{
+	verrc(eval, errno, fmt, ap);
+}
+
+void
+errc(int eval, int code, const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	verrc(eval, code, fmt, ap);
+	va_end(ap);
+}
+
+void
+verrc(eval, code, fmt, ap)
+	int eval;
+	int code;
+	const char *fmt;
+	va_list ap;
+{
+	if (err_file == 0)
+		err_set_file((FILE *)0);
+	fprintf(err_file, "%s: ", _getprogname());
+	if (fmt != NULL) {
+		vfprintf(err_file, fmt, ap);
+		fprintf(err_file, ": ");
+	}
+	fprintf(err_file, "%s\n", strerror(code));
+	if (err_exit)
+		err_exit(eval);
+	exit(eval);
+}
+
+void
+errx(int eval, const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	verrx(eval, fmt, ap);
+	va_end(ap);
+}
+
+void
+verrx(eval, fmt, ap)
+	int eval;
+	const char *fmt;
+	va_list ap;
+{
+	if (err_file == 0)
+		err_set_file((FILE *)0);
+	fprintf(err_file, "%s: ", _getprogname());
+	if (fmt != NULL)
+		vfprintf(err_file, fmt, ap);
+	fprintf(err_file, "\n");
+	if (err_exit)
+		err_exit(eval);
+	exit(eval);
+}
+
+__weak_reference(_warn, warn);
+
+void
+_warn(const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	vwarnc(errno, fmt, ap);
+	va_end(ap);
+}
+
+void
+vwarn(fmt, ap)
+	const char *fmt;
+	va_list ap;
+{
+	vwarnc(errno, fmt, ap);
+}
+
+void
+warnc(int code, const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	vwarnc(code, fmt, ap);
+	va_end(ap);
+}
+
+void
+vwarnc(code, fmt, ap)
+	int code;
+	const char *fmt;
+	va_list ap;
+{
+	if (err_file == 0)
+		err_set_file((FILE *)0);
+	fprintf(err_file, "%s: ", _getprogname());
+	if (fmt != NULL) {
+		vfprintf(err_file, fmt, ap);
+		fprintf(err_file, ": ");
+	}
+	fprintf(err_file, "%s\n", strerror(code));
+}
+
+void
+warnx(const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	vwarnx(fmt, ap);
+	va_end(ap);
+}
+
+void
+vwarnx(fmt, ap)
+	const char *fmt;
+	va_list ap;
+{
+	if (err_file == 0)
+		err_set_file((FILE *)0);
+	fprintf(err_file, "%s: ", _getprogname());
+	if (fmt != NULL)
+		vfprintf(err_file, fmt, ap);
+	fprintf(err_file, "\n");
+}
Index: /vendor/FreeBSD-libc/5.3/gen/getgrent.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/getgrent.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/getgrent.c	(revision 2404)
@@ -0,0 +1,1152 @@
+/*-
+ * Copyright (c) 2003 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by
+ * Jacques A. Vidrine, Safeport Network Services, and Network
+ * Associates Laboratories, the Security Research Division of Network
+ * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
+ * ("CBOSS"), as part of the DARPA CHATS research program.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/getgrent.c,v 1.32 2004/05/17 22:15:49 kientzle Exp $");
+
+#include "namespace.h"
+#include <sys/param.h>
+#ifdef YP
+#include <rpc/rpc.h>
+#include <rpcsvc/yp_prot.h>
+#include <rpcsvc/ypclnt.h>
+#endif
+#include <ctype.h>
+#include <errno.h>
+#ifdef HESIOD
+#include <hesiod.h>
+#endif
+#include <grp.h>
+#include <nsswitch.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+#include "nss_tls.h"
+
+
+enum constants {
+	GRP_STORAGE_INITIAL	= 1 << 10, /* 1 KByte */
+	GRP_STORAGE_MAX		= 1 << 20, /* 1 MByte */
+	SETGRENT		= 1,
+	ENDGRENT		= 2,
+	HESIOD_NAME_MAX		= 256,
+};
+
+static const ns_src defaultsrc[] = {
+	{ NSSRC_COMPAT, NS_SUCCESS },
+	{ NULL, 0 }
+};
+
+int	 __gr_match_entry(const char *, size_t, enum nss_lookup_type,
+	    const char *, gid_t);
+int	 __gr_parse_entry(char *, size_t, struct group *, char *, size_t,
+	    int *);
+
+static	int	 is_comment_line(const char *, size_t);
+
+union key {
+	const char	*name;
+	gid_t		 gid;
+};
+static	struct group *getgr(int (*)(union key, struct group *, char *, size_t,
+		    struct group **), union key);
+static	int	 wrap_getgrnam_r(union key, struct group *, char *, size_t,
+		    struct group **);
+static	int	 wrap_getgrgid_r(union key, struct group *, char *, size_t,
+		    struct group **);
+static	int	 wrap_getgrent_r(union key, struct group *, char *, size_t,
+		    struct group **);
+
+struct files_state {
+	FILE	*fp;
+	int	 stayopen;
+};
+static	void	 files_endstate(void *);
+NSS_TLS_HANDLING(files);
+static	int	 files_setgrent(void *, void *, va_list);
+static	int	 files_group(void *, void *, va_list);
+
+
+#ifdef HESIOD
+struct dns_state {
+	long	counter;
+};
+static	void	 dns_endstate(void *);
+NSS_TLS_HANDLING(dns);
+static	int	 dns_setgrent(void *, void *, va_list);
+static	int	 dns_group(void *, void *, va_list);
+#endif
+
+
+#ifdef YP
+struct nis_state {
+	char	 domain[MAXHOSTNAMELEN];
+	int	 done;
+	char	*key;
+	int	 keylen;
+};
+static	void	 nis_endstate(void *);
+NSS_TLS_HANDLING(nis);
+static	int	 nis_setgrent(void *, void *, va_list);
+static	int	 nis_group(void *, void *, va_list);
+#endif
+
+struct compat_state {
+	FILE	*fp;
+	int	 stayopen;
+	char	*name;
+	enum _compat {
+		COMPAT_MODE_OFF = 0,
+		COMPAT_MODE_ALL,
+		COMPAT_MODE_NAME
+	}	 compat;
+};
+static	void	 compat_endstate(void *);
+NSS_TLS_HANDLING(compat);
+static	int	 compat_setgrent(void *, void *, va_list);
+static	int	 compat_group(void *, void *, va_list);
+
+
+/* XXX IEEE Std 1003.1, 2003 specifies `void setgrent(void)' */
+int				
+setgrent(void)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_setgrent, (void *)SETGRENT },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_setgrent, (void *)SETGRENT },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_setgrent, (void *)SETGRENT },
+#endif
+		{ NSSRC_COMPAT, compat_setgrent, (void *)SETGRENT },
+		{ NULL, NULL, NULL }
+	};
+	(void)_nsdispatch(NULL, dtab, NSDB_GROUP, "setgrent", defaultsrc, 0);
+	return (1);
+}
+
+
+int
+setgroupent(int stayopen)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_setgrent, (void *)SETGRENT },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_setgrent, (void *)SETGRENT },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_setgrent, (void *)SETGRENT },
+#endif
+		{ NSSRC_COMPAT, compat_setgrent, (void *)SETGRENT },
+		{ NULL, NULL, NULL }
+	};
+	(void)_nsdispatch(NULL, dtab, NSDB_GROUP, "setgrent", defaultsrc,
+	    stayopen);
+	return (1);
+}
+
+
+void
+endgrent(void)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_setgrent, (void *)ENDGRENT },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_setgrent, (void *)ENDGRENT },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_setgrent, (void *)ENDGRENT },
+#endif
+		{ NSSRC_COMPAT, compat_setgrent, (void *)ENDGRENT },
+		{ NULL, NULL, NULL }
+	};
+	(void)_nsdispatch(NULL, dtab, NSDB_GROUP, "endgrent", defaultsrc);
+}
+
+
+int
+getgrent_r(struct group *grp, char *buffer, size_t bufsize,
+    struct group **result)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_group, (void *)nss_lt_all },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_group, (void *)nss_lt_all },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_group, (void *)nss_lt_all },
+#endif
+		{ NSSRC_COMPAT, compat_group, (void *)nss_lt_all },
+		{ NULL, NULL, NULL }
+	};
+	int	rv, ret_errno;
+
+	ret_errno = 0;
+	*result = NULL;
+	rv = _nsdispatch(result, dtab, NSDB_GROUP, "getgrent_r", defaultsrc,
+	    grp, buffer, bufsize, &ret_errno);
+	if (rv == NS_SUCCESS)
+		return (0);
+	else
+		return (ret_errno);
+}
+
+
+int
+getgrnam_r(const char *name, struct group *grp, char *buffer, size_t bufsize,
+    struct group **result)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_group, (void *)nss_lt_name },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_group, (void *)nss_lt_name },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_group, (void *)nss_lt_name },
+#endif
+		{ NSSRC_COMPAT, compat_group, (void *)nss_lt_name },
+		{ NULL, NULL, NULL }
+	};
+	int	rv, ret_errno;
+
+	ret_errno = 0;
+	*result = NULL;
+	rv = _nsdispatch(result, dtab, NSDB_GROUP, "getgrnam_r", defaultsrc,
+	    name, grp, buffer, bufsize, &ret_errno);
+	if (rv == NS_SUCCESS)
+		return (0);
+	else
+		return (ret_errno);
+}
+
+
+int
+getgrgid_r(gid_t gid, struct group *grp, char *buffer, size_t bufsize,
+    struct group **result)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_group, (void *)nss_lt_id },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_group, (void *)nss_lt_id },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_group, (void *)nss_lt_id },
+#endif
+		{ NSSRC_COMPAT, compat_group, (void *)nss_lt_id },
+		{ NULL, NULL, NULL }
+	};
+	int	rv, ret_errno;
+
+	ret_errno = 0;
+	*result = NULL;
+	rv = _nsdispatch(result, dtab, NSDB_GROUP, "getgrgid_r", defaultsrc,
+	    gid, grp, buffer, bufsize, &ret_errno);
+	if (rv == NS_SUCCESS)
+		return (0);
+	else
+		return (ret_errno);
+}
+
+
+static struct group	 grp;
+static char		*grp_storage;
+static size_t		 grp_storage_size;
+
+static struct group *
+getgr(int (*fn)(union key, struct group *, char *, size_t, struct group **),
+    union key key)
+{
+	int		 rv;
+	struct group	*res;
+
+	if (grp_storage == NULL) {
+		grp_storage = malloc(GRP_STORAGE_INITIAL);
+		if (grp_storage == NULL)
+			return (NULL);
+		grp_storage_size = GRP_STORAGE_INITIAL;
+	}
+	do {
+		rv = fn(key, &grp, grp_storage, grp_storage_size, &res);
+		if (res == NULL && rv == ERANGE) {
+			free(grp_storage);
+			if ((grp_storage_size << 1) > GRP_STORAGE_MAX) {
+				grp_storage = NULL;
+				errno = ERANGE;
+				return (NULL);
+			}
+			grp_storage_size <<= 1;
+			grp_storage = malloc(grp_storage_size);
+			if (grp_storage == NULL)
+				return (NULL);
+		}
+	} while (res == NULL && rv == ERANGE);
+	if (rv != 0)
+		errno = rv;
+	return (res);
+}
+
+
+static int
+wrap_getgrnam_r(union key key, struct group *grp, char *buffer, size_t bufsize,
+    struct group **res)
+{
+	return (getgrnam_r(key.name, grp, buffer, bufsize, res));
+}
+
+
+static int
+wrap_getgrgid_r(union key key, struct group *grp, char *buffer, size_t bufsize,
+    struct group **res)
+{
+	return (getgrgid_r(key.gid, grp, buffer, bufsize, res));
+}
+
+
+static int
+wrap_getgrent_r(union key key __unused, struct group *grp, char *buffer,
+    size_t bufsize, struct group **res)
+{
+	return (getgrent_r(grp, buffer, bufsize, res));
+}
+
+
+struct group *
+getgrnam(const char *name)
+{
+	union key key;
+
+	key.name = name;
+	return (getgr(wrap_getgrnam_r, key));
+}
+
+
+struct group *
+getgrgid(gid_t gid)
+{
+	union key key;
+
+	key.gid = gid;
+	return (getgr(wrap_getgrgid_r, key));
+}
+
+
+struct group *
+getgrent(void)
+{
+	union key key;
+
+	key.gid = 0; /* not used */
+	return (getgr(wrap_getgrent_r, key));
+}
+
+
+static int
+is_comment_line(const char *s, size_t n)
+{
+	const char	*eom;
+
+	eom = &s[n];
+
+	for (; s < eom; s++)
+		if (*s == '#' || !isspace((unsigned char)*s))
+			break;
+	return (*s == '#' || s == eom);
+}
+
+
+/*
+ * files backend
+ */
+static void
+files_endstate(void *p)
+{
+
+	if (p == NULL)
+		return;
+	if (((struct files_state *)p)->fp != NULL)
+		fclose(((struct files_state *)p)->fp);
+	free(p);
+}
+
+
+static int
+files_setgrent(void *retval, void *mdata, va_list ap)
+{
+	struct files_state *st;
+	int		 rv, stayopen;
+
+	rv = files_getstate(&st);
+	if (rv != 0) 
+		return (NS_UNAVAIL);
+	switch ((enum constants)mdata) {
+	case SETGRENT:
+		stayopen = va_arg(ap, int);
+		if (st->fp != NULL)
+			rewind(st->fp);
+		else if (stayopen)
+			st->fp = fopen(_PATH_GROUP, "r");
+		break;
+	case ENDGRENT:
+		if (st->fp != NULL) {
+			fclose(st->fp);
+			st->fp = NULL;
+		}
+		break;
+	default:
+		break;
+	}
+	return (NS_UNAVAIL);
+}
+
+
+static int
+files_group(void *retval, void *mdata, va_list ap)
+{
+	struct files_state	*st;
+	enum nss_lookup_type	 how;
+	const char		*name, *line;
+	struct group		*grp;
+	gid_t			 gid;
+	char			*buffer;
+	size_t			 bufsize, linesize;
+	int			 rv, stayopen, *errnop;
+
+	name = NULL;
+	gid = (gid_t)-1;
+	how = (enum nss_lookup_type)mdata;
+	switch (how) {
+	case nss_lt_name:
+		name = va_arg(ap, const char *);
+		break;
+	case nss_lt_id:
+		gid = va_arg(ap, gid_t);
+		break;
+	case nss_lt_all:
+		break;
+	default:
+		return (NS_NOTFOUND);
+	}
+	grp = va_arg(ap, struct group *);
+	buffer = va_arg(ap, char *);
+	bufsize = va_arg(ap, size_t);
+	errnop = va_arg(ap, int *);
+	*errnop = files_getstate(&st);
+	if (*errnop != 0)
+		return (NS_UNAVAIL);
+	if (st->fp == NULL &&
+	    ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+		*errnop = errno;
+		return (NS_UNAVAIL);
+	}
+	if (how == nss_lt_all)
+		stayopen = 1;
+	else {
+		rewind(st->fp);
+		stayopen = st->stayopen;
+	}
+	rv = NS_NOTFOUND;
+	while ((line = fgetln(st->fp, &linesize)) != NULL) {
+		if (line[linesize-1] == '\n')
+			linesize--;
+		rv = __gr_match_entry(line, linesize, how, name, gid);
+		if (rv != NS_SUCCESS)
+			continue;
+		/* We need room at least for the line, a string NUL
+		 * terminator, alignment padding, and one (char *)
+		 * pointer for the member list terminator.
+		 */
+		if (bufsize <= linesize + _ALIGNBYTES + sizeof(char *)) {
+			*errnop = ERANGE;
+			rv = NS_RETURN;
+			break;
+		}
+		memcpy(buffer, line, linesize);
+		buffer[linesize] = '\0';
+		rv = __gr_parse_entry(buffer, linesize, grp, 
+		    &buffer[linesize + 1], bufsize - linesize - 1, errnop);
+		if (rv & NS_TERMINATE)
+			break;
+	}
+	if (!stayopen && st->fp != NULL) {
+		fclose(st->fp);
+		st->fp = NULL;
+	}
+	if (rv == NS_SUCCESS && retval != NULL)
+		*(struct group **)retval = grp;
+	return (rv);
+}
+
+
+#ifdef HESIOD
+/*
+ * dns backend
+ */
+static void
+dns_endstate(void *p)
+{
+
+	free(p);
+}
+
+
+static int
+dns_setgrent(void *retval, void *cb_data, va_list ap)
+{
+	struct dns_state	*st;
+	int			 rv;
+
+	rv = dns_getstate(&st);
+	if (rv != 0)
+		return (NS_UNAVAIL);
+	st->counter = 0;
+	return (NS_UNAVAIL);
+}
+
+
+static int
+dns_group(void *retval, void *mdata, va_list ap)
+{
+	char			 buf[HESIOD_NAME_MAX];
+	struct dns_state	*st;
+	struct group		*grp;
+	const char		*name, *label;
+	void			*ctx;
+	char			*buffer, **hes;
+	size_t			 bufsize, adjsize, linesize;
+	gid_t			 gid;
+	enum nss_lookup_type	 how;
+	int			 rv, *errnop;
+
+	ctx = NULL;
+	hes = NULL;
+	name = NULL;
+	gid = (gid_t)-1;
+	how = (enum nss_lookup_type)mdata;
+	switch (how) {
+	case nss_lt_name:
+		name = va_arg(ap, const char *);
+		break;
+	case nss_lt_id:
+		gid = va_arg(ap, gid_t);
+		break;
+	case nss_lt_all:
+		break;
+	}
+	grp     = va_arg(ap, struct group *);
+	buffer  = va_arg(ap, char *);
+	bufsize = va_arg(ap, size_t);
+	errnop  = va_arg(ap, int *);
+	*errnop = dns_getstate(&st);
+	if (*errnop != 0)
+		return (NS_UNAVAIL);
+	if (hesiod_init(&ctx) != 0) {
+		*errnop = errno;
+		rv = NS_UNAVAIL;
+		goto fin;
+	}
+	do {
+		rv = NS_NOTFOUND;
+		switch (how) {
+		case nss_lt_name:
+			label = name;
+			break;
+		case nss_lt_id:
+			if (snprintf(buf, sizeof(buf), "%lu",
+			    (unsigned long)gid) >= sizeof(buf))
+				goto fin;
+			label = buf;
+			break;
+		case nss_lt_all:
+			if (st->counter < 0)
+				goto fin;
+			if (snprintf(buf, sizeof(buf), "group-%ld",
+			    st->counter++) >= sizeof(buf))
+				goto fin;
+			label = buf;
+			break;
+		}
+		hes = hesiod_resolve(ctx, label,
+		    how == nss_lt_id ? "gid" : "group");
+		if ((how == nss_lt_id && hes == NULL &&
+		    (hes = hesiod_resolve(ctx, buf, "group")) == NULL) ||
+		    hes == NULL) {
+			if (how == nss_lt_all)
+				st->counter = -1;
+			if (errno != ENOENT)
+				*errnop = errno;
+			goto fin;
+		}
+		rv = __gr_match_entry(hes[0], strlen(hes[0]), how, name, gid);
+		if (rv != NS_SUCCESS) {
+			hesiod_free_list(ctx, hes);
+			hes = NULL;
+			continue;
+		}
+		/* We need room at least for the line, a string NUL
+		 * terminator, alignment padding, and one (char *)
+		 * pointer for the member list terminator.
+		 */
+		adjsize = bufsize - _ALIGNBYTES - sizeof(char *);
+		linesize = strlcpy(buffer, hes[0], adjsize);
+		if (linesize >= adjsize) {
+			*errnop = ERANGE;
+			rv = NS_RETURN;
+			goto fin;
+		}
+		hesiod_free_list(ctx, hes);
+		hes = NULL;
+		rv = __gr_parse_entry(buffer, linesize, grp,
+		    &buffer[linesize + 1], bufsize - linesize - 1, errnop);
+	} while (how == nss_lt_all && !(rv & NS_TERMINATE));
+fin:
+	if (hes != NULL)
+		hesiod_free_list(ctx, hes);
+	if (ctx != NULL)
+		hesiod_end(ctx);
+	if (rv == NS_SUCCESS && retval != NULL)
+		*(struct group **)retval = grp;
+	return (rv);
+}
+#endif /* HESIOD */
+
+
+#ifdef YP
+/*
+ * nis backend
+ */
+static void
+nis_endstate(void *p)
+{
+
+	if (p == NULL)
+		return;
+	free(((struct nis_state *)p)->key);
+	free(p);
+}
+
+
+static int
+nis_setgrent(void *retval, void *cb_data, va_list ap)
+{
+	struct nis_state	*st;
+	int			 rv;
+
+	rv = nis_getstate(&st);
+	if (rv != 0)
+		return (NS_UNAVAIL);
+	st->done = 0;
+	free(st->key);
+	st->key = NULL;
+	return (NS_UNAVAIL);
+}
+
+
+static int
+nis_group(void *retval, void *mdata, va_list ap)
+{
+	char		 *map;
+	struct nis_state *st;
+	struct group	*grp;
+	const char	*name;
+	char		*buffer, *key, *result;
+	size_t		 bufsize;
+	gid_t		 gid;
+	enum nss_lookup_type how;
+	int		*errnop, keylen, resultlen, rv;
+	
+	name = NULL;
+	gid = (gid_t)-1;
+	how = (enum nss_lookup_type)mdata;
+	switch (how) {
+	case nss_lt_name:
+		name = va_arg(ap, const char *);
+		map = "group.byname";
+		break;
+	case nss_lt_id:
+		gid = va_arg(ap, gid_t);
+		map = "group.bygid";
+		break;
+	case nss_lt_all:
+		map = "group.byname";
+		break;
+	}
+	grp     = va_arg(ap, struct group *);
+	buffer  = va_arg(ap, char *);
+	bufsize = va_arg(ap, size_t);
+	errnop  = va_arg(ap, int *);
+	*errnop = nis_getstate(&st);
+	if (*errnop != 0)
+		return (NS_UNAVAIL);
+	if (st->domain[0] == '\0') {
+		if (getdomainname(st->domain, sizeof(st->domain)) != 0) {
+			*errnop = errno;
+			return (NS_UNAVAIL);
+		}
+	}
+	result = NULL;
+	do {
+		rv = NS_NOTFOUND;
+		switch (how) {
+		case nss_lt_name:
+			if (strlcpy(buffer, name, bufsize) >= bufsize)
+				goto erange;
+			break;
+		case nss_lt_id:
+			if (snprintf(buffer, bufsize, "%lu",
+			    (unsigned long)gid) >= bufsize)
+				goto erange;
+			break;
+		case nss_lt_all:
+			if (st->done)
+				goto fin;
+			break;
+		}
+		result = NULL;
+		if (how == nss_lt_all) {
+			if (st->key == NULL)
+				rv = yp_first(st->domain, map, &st->key,
+				    &st->keylen, &result, &resultlen);
+			else {
+				key = st->key;
+				keylen = st->keylen;
+				st->key = NULL;
+				rv = yp_next(st->domain, map, key, keylen,
+				    &st->key, &st->keylen, &result,
+				    &resultlen);
+				free(key);
+			}
+			if (rv != 0) {
+				free(result);
+				free(st->key);
+				st->key = NULL;
+				if (rv == YPERR_NOMORE) {
+					st->done = 1;
+					rv = NS_NOTFOUND;
+				} else
+					rv = NS_UNAVAIL;
+				goto fin;
+			}
+		} else {
+			rv = yp_match(st->domain, map, buffer, strlen(buffer),
+			    &result, &resultlen);
+			if (rv == YPERR_KEY) {
+				rv = NS_NOTFOUND;
+				continue;
+			} else if (rv != 0) {
+				free(result);
+				rv = NS_UNAVAIL;
+				continue;
+			}
+		}
+		/* We need room at least for the line, a string NUL
+		 * terminator, alignment padding, and one (char *)
+		 * pointer for the member list terminator.
+		 */
+		if (resultlen >= bufsize - _ALIGNBYTES - sizeof(char *))
+			goto erange;
+		memcpy(buffer, result, resultlen);
+		buffer[resultlen] = '\0';
+		free(result);
+		rv = __gr_match_entry(buffer, resultlen, how, name, gid);
+		if (rv == NS_SUCCESS)
+			rv = __gr_parse_entry(buffer, resultlen, grp,
+			    &buffer[resultlen+1], bufsize - resultlen - 1,
+			    errnop);
+	} while (how == nss_lt_all && !(rv & NS_TERMINATE));
+fin:
+	if (rv == NS_SUCCESS && retval != NULL)
+		*(struct group **)retval = grp;
+	return (rv);	
+erange:
+	*errnop = ERANGE;
+	return (NS_RETURN);
+}
+#endif /* YP */
+
+
+
+/*
+ * compat backend
+ */
+static void
+compat_endstate(void *p)
+{
+	struct compat_state *st;
+
+	if (p == NULL)
+		return;
+	st = (struct compat_state *)p;
+	free(st->name);
+	if (st->fp != NULL)
+		fclose(st->fp);
+	free(p);
+}
+
+
+static int
+compat_setgrent(void *retval, void *mdata, va_list ap)
+{
+	static const ns_src compatsrc[] = {
+#ifdef YP
+		{ NSSRC_NIS, NS_SUCCESS },
+#endif
+		{ NULL, 0 }
+	};
+	ns_dtab dtab[] = {
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_setgrent, NULL },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_setgrent, NULL },
+#endif
+		{ NULL, NULL, NULL }
+	};
+	struct compat_state *st;
+	int		 rv, stayopen;
+
+#define set_setent(x, y) do {	 				\
+	int i;							\
+								\
+	for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++)	\
+		x[i].mdata = (void *)y;				\
+} while (0)
+
+	rv = compat_getstate(&st);
+	if (rv != 0) 
+		return (NS_UNAVAIL);
+	switch ((enum constants)mdata) {
+	case SETGRENT:
+		stayopen = va_arg(ap, int);
+		if (st->fp != NULL)
+			rewind(st->fp);
+		else if (stayopen)
+			st->fp = fopen(_PATH_GROUP, "r");
+		set_setent(dtab, mdata);
+		(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
+		    compatsrc, 0);
+		break;
+	case ENDGRENT:
+		if (st->fp != NULL) {
+			fclose(st->fp);
+			st->fp = NULL;
+		}
+		set_setent(dtab, mdata);
+		(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "endgrent",
+		    compatsrc, 0);
+		break;
+	default:
+		break;
+	}
+	st->compat = COMPAT_MODE_OFF;
+	free(st->name);
+	st->name = NULL;
+	return (NS_UNAVAIL);
+#undef set_setent
+}
+
+
+static int
+compat_group(void *retval, void *mdata, va_list ap)
+{
+	static const ns_src compatsrc[] = {
+#ifdef YP
+		{ NSSRC_NIS, NS_SUCCESS },
+#endif
+		{ NULL, 0 }
+	};
+	ns_dtab dtab[] = {
+#ifdef YP
+		{ NSSRC_NIS, nis_group, NULL },
+#endif
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_group, NULL },
+#endif
+		{ NULL, NULL, NULL }
+	};
+	struct compat_state	*st;
+	enum nss_lookup_type	 how;
+	const char		*name, *line;
+	struct group		*grp;
+	gid_t			 gid;
+	char			*buffer, *p;
+	void			*discard;
+	size_t			 bufsize, linesize;
+	int			 rv, stayopen, *errnop;
+
+#define set_lookup_type(x, y) do { 				\
+	int i;							\
+								\
+	for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++)	\
+		x[i].mdata = (void *)y;				\
+} while (0)
+
+	name = NULL;
+	gid = (gid_t)-1;
+	how = (enum nss_lookup_type)mdata;
+	switch (how) {
+	case nss_lt_name:
+		name = va_arg(ap, const char *);
+		break;
+	case nss_lt_id:
+		gid = va_arg(ap, gid_t);
+		break;
+	case nss_lt_all:
+		break;
+	default:
+		return (NS_NOTFOUND);
+	}
+	grp = va_arg(ap, struct group *);
+	buffer = va_arg(ap, char *);
+	bufsize = va_arg(ap, size_t);
+	errnop = va_arg(ap, int *);
+	*errnop = compat_getstate(&st);
+	if (*errnop != 0)
+		return (NS_UNAVAIL);
+	if (st->fp == NULL &&
+	    ((st->fp = fopen(_PATH_GROUP, "r")) == NULL)) {
+		*errnop = errno;
+		rv = NS_UNAVAIL;
+		goto fin;
+	}
+	if (how == nss_lt_all)
+		stayopen = 1;
+	else {
+		rewind(st->fp);
+		stayopen = st->stayopen;
+	}
+docompat:
+	switch (st->compat) {
+	case COMPAT_MODE_ALL:
+		set_lookup_type(dtab, how);
+		switch (how) {
+		case nss_lt_all:
+			rv = _nsdispatch(&discard, dtab, NSDB_GROUP_COMPAT,
+			    "getgrent_r", compatsrc, grp, buffer, bufsize,
+			    errnop);
+			break;
+		case nss_lt_id:
+			rv = _nsdispatch(&discard, dtab, NSDB_GROUP_COMPAT,
+			    "getgrgid_r", compatsrc, gid, grp, buffer, bufsize,
+			    errnop);
+			break;
+		case nss_lt_name:
+			rv = _nsdispatch(&discard, dtab, NSDB_GROUP_COMPAT,
+			    "getgrnam_r", compatsrc, name, grp, buffer,
+			    bufsize, errnop);
+			break;
+		}
+		if (rv & NS_TERMINATE)
+			goto fin;
+		st->compat = COMPAT_MODE_OFF;
+		break;
+	case COMPAT_MODE_NAME:
+		set_lookup_type(dtab, nss_lt_name);
+		rv = _nsdispatch(&discard, dtab, NSDB_GROUP_COMPAT,
+		    "getgrnam_r", compatsrc, st->name, grp, buffer, bufsize,
+		    errnop);
+		switch (rv) {
+		case NS_SUCCESS:
+			switch (how) {
+			case nss_lt_name:
+				if (strcmp(name, grp->gr_name) != 0)
+					rv = NS_NOTFOUND;
+				break;
+			case nss_lt_id:
+				if (gid != grp->gr_gid)
+					rv = NS_NOTFOUND;
+				break;
+			default:
+				break;
+			}
+			break;
+		case NS_RETURN:
+			goto fin;
+		default:
+			break;
+		}
+		free(st->name);
+		st->name = NULL;
+		st->compat = COMPAT_MODE_OFF;
+		if (rv == NS_SUCCESS)
+			goto fin;
+		break;
+	default:
+		break;
+	}
+	rv = NS_NOTFOUND;
+	while ((line = fgetln(st->fp, &linesize)) != NULL) {
+		if (line[linesize-1] == '\n')
+			linesize--;
+		if (linesize > 2 && line[0] == '+') {
+			p = memchr(&line[1], ':', linesize);
+			if (p == NULL || p == &line[1])
+				st->compat = COMPAT_MODE_ALL;
+			else {
+				st->name = malloc(p - line);
+				if (st->name == NULL) {
+					syslog(LOG_ERR,
+					 "getgrent memory allocation failure");
+					*errnop = ENOMEM;
+					rv = NS_UNAVAIL;
+					break;
+				}
+				memcpy(st->name, &line[1], p - line - 1);
+				st->name[p - line - 1] = '\0';
+				st->compat = COMPAT_MODE_NAME;
+			}
+			goto docompat;
+		} 
+		rv = __gr_match_entry(line, linesize, how, name, gid);
+		if (rv != NS_SUCCESS)
+			continue;
+		/* We need room at least for the line, a string NUL
+		 * terminator, alignment padding, and one (char *)
+		 * pointer for the member list terminator.
+		 */
+		if (bufsize <= linesize + _ALIGNBYTES + sizeof(char *)) {
+			*errnop = ERANGE;
+			rv = NS_RETURN;
+			break;
+		}
+		memcpy(buffer, line, linesize);
+		buffer[linesize] = '\0';
+		rv = __gr_parse_entry(buffer, linesize, grp, 
+		    &buffer[linesize + 1], bufsize - linesize - 1, errnop);
+		if (rv & NS_TERMINATE)
+			break;
+	}
+fin:
+	if (!stayopen && st->fp != NULL) {
+		fclose(st->fp);
+		st->fp = NULL;
+	}
+	if (rv == NS_SUCCESS && retval != NULL)
+		*(struct group **)retval = grp;
+	return (rv);
+#undef set_lookup_type
+}
+
+
+/*
+ * common group line matching and parsing
+ */
+int
+__gr_match_entry(const char *line, size_t linesize, enum nss_lookup_type how,
+    const char *name, gid_t gid)
+{
+	size_t		 namesize;
+	const char	*p, *eol;
+	char		*q;
+	unsigned long	 n;
+	int		 i, needed;
+
+	if (linesize == 0 || is_comment_line(line, linesize))
+		return (NS_NOTFOUND);
+	switch (how) {
+	case nss_lt_name:	needed = 1; break;
+	case nss_lt_id:		needed = 2; break;
+	default:		needed = 2; break;
+	}
+	eol = &line[linesize];
+	for (p = line, i = 0; i < needed && p < eol; p++)
+		if (*p == ':')
+			i++;
+	if (i < needed)
+		return (NS_NOTFOUND);
+	switch (how) {
+	case nss_lt_name:
+		namesize = strlen(name);
+		if (namesize + 1 == (size_t)(p - line) &&
+		    memcmp(line, name, namesize) == 0)
+			return (NS_SUCCESS);
+		break;
+	case nss_lt_id:
+		n = strtoul(p, &q, 10);
+		if (q < eol && *q == ':' && gid == (gid_t)n)
+			return (NS_SUCCESS);
+		break;
+	case nss_lt_all:
+		return (NS_SUCCESS);
+	default:
+		break;
+	}
+	return (NS_NOTFOUND);
+}
+
+
+int
+__gr_parse_entry(char *line, size_t linesize, struct group *grp, char *membuf,
+    size_t membufsize, int *errnop)
+{
+	char	       *s_gid, *s_mem, *p, **members;
+	unsigned long	n;
+	int		maxmembers;
+
+	memset(grp, 0, sizeof(*grp));
+	members = (char **)_ALIGN(membuf);
+	membufsize -= (char *)members - membuf;
+	maxmembers = membufsize / sizeof(*members);
+	if (maxmembers <= 0 ||
+	    (grp->gr_name = strsep(&line, ":")) == NULL ||
+	    grp->gr_name[0] == '\0' ||
+	    (grp->gr_passwd = strsep(&line, ":")) == NULL ||
+	    (s_gid = strsep(&line, ":")) == NULL ||
+	    s_gid[0] == '\0')
+		return (NS_NOTFOUND);
+	s_mem = line;
+	n = strtoul(s_gid, &s_gid, 10);
+	if (s_gid[0] != '\0')
+		return (NS_NOTFOUND);
+	grp->gr_gid = (gid_t)n;
+	grp->gr_mem = members;
+	while (maxmembers > 1 && s_mem != NULL) {
+		p = strsep(&s_mem, ",");
+		if (p != NULL && *p != '\0') {
+			*members++ = p;
+			maxmembers--;
+		}
+	}
+	*members = NULL;
+	if (s_mem == NULL)
+		return (NS_SUCCESS);
+	else {
+		*errnop = ERANGE;
+		return (NS_RETURN);
+	}
+}
Index: /vendor/FreeBSD-libc/5.3/gen/getgrouplist.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/getgrouplist.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/getgrouplist.c	(revision 2404)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getgrouplist.c	8.2 (Berkeley) 12/8/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/getgrouplist.c,v 1.13 2003/02/16 17:29:09 nectar Exp $");
+
+/*
+ * get credential
+ */
+#include <sys/types.h>
+#include <string.h>
+#include <grp.h>
+
+int
+getgrouplist(uname, agroup, groups, grpcnt)
+	const char *uname;
+	gid_t agroup;
+	gid_t *groups;
+	int *grpcnt;
+{
+	struct group *grp;
+	int i, maxgroups, ngroups, ret;
+
+	ret = 0;
+	ngroups = 0;
+	maxgroups = *grpcnt;
+	/*
+	 * When installing primary group, duplicate it;
+	 * the first element of groups is the effective gid
+	 * and will be overwritten when a setgid file is executed.
+	 */
+	groups[ngroups++] = agroup;
+	if (maxgroups > 1)
+		groups[ngroups++] = agroup;
+	/*
+	 * Scan the group file to find additional groups.
+	 */
+	setgrent();
+	while ((grp = getgrent()) != NULL) {
+		for (i = 0; i < ngroups; i++) {
+			if (grp->gr_gid == groups[i])
+				goto skip;
+		}
+		for (i = 0; grp->gr_mem[i]; i++) {
+			if (!strcmp(grp->gr_mem[i], uname)) {
+				if (ngroups >= maxgroups) {
+					ret = -1;
+					break;
+				}
+				groups[ngroups++] = grp->gr_gid;
+				break;
+			}
+		}
+skip:
+		;
+	}
+	endgrent();
+	*grpcnt = ngroups;
+	return (ret);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/getmntinfo.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/getmntinfo.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/getmntinfo.c	(revision 2404)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getmntinfo.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/getmntinfo.c,v 1.4 2002/02/01 00:57:29 obrien Exp $");
+
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#include <stdlib.h>
+
+/*
+ * Return information about mounted filesystems.
+ */
+int
+getmntinfo(mntbufp, flags)
+	struct statfs **mntbufp;
+	int flags;
+{
+	static struct statfs *mntbuf;
+	static int mntsize;
+	static long bufsize;
+
+	if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) < 0)
+		return (0);
+	if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, flags)) < 0)
+		return (0);
+	while (bufsize <= mntsize * sizeof(struct statfs)) {
+		if (mntbuf)
+			free(mntbuf);
+		bufsize = (mntsize + 1) * sizeof(struct statfs);
+		if ((mntbuf = (struct statfs *)malloc(bufsize)) == 0)
+			return (0);
+		if ((mntsize = getfsstat(mntbuf, bufsize, flags)) < 0)
+			return (0);
+	}
+	*mntbufp = mntbuf;
+	return (mntsize);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/getnetgrent.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/getnetgrent.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/getnetgrent.c	(revision 2404)
@@ -0,0 +1,632 @@
+/*
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Rick Macklem at The University of Guelph.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getnetgrent.c	8.2 (Berkeley) 4/27/95";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/getnetgrent.c,v 1.31 2004/07/28 11:56:03 des Exp $");
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef YP
+/*
+ * Notes:
+ * We want to be able to use NIS netgroups properly while retaining
+ * the ability to use a local /etc/netgroup file. Unfortunately, you
+ * can't really do both at the same time - at least, not efficiently.
+ * NetBSD deals with this problem by creating a netgroup database
+ * using Berkeley DB (just like the password database) that allows
+ * for lookups using netgroup, netgroup.byuser or netgroup.byhost
+ * searches. This is a neat idea, but I don't have time to implement
+ * something like that now. (I think ultimately it would be nice
+ * if we DB-fied the group and netgroup stuff all in one shot, but
+ * for now I'm satisfied just to have something that works well
+ * without requiring massive code changes.)
+ * 
+ * Therefore, to still permit the use of the local file and maintain
+ * optimum NIS performance, we allow for the following conditions:
+ *
+ * - If /etc/netgroup does not exist and NIS is turned on, we use
+ *   NIS netgroups only.
+ *
+ * - If /etc/netgroup exists but is empty, we use NIS netgroups
+ *   only.
+ *
+ * - If /etc/netgroup exists and contains _only_ a '+', we use
+ *   NIS netgroups only.
+ *
+ * - If /etc/netgroup exists, contains locally defined netgroups
+ *   and a '+', we use a mixture of NIS and the local entries.
+ *   This method should return the same NIS data as just using
+ *   NIS alone, but it will be slower if the NIS netgroup database
+ *   is large (innetgr() in particular will suffer since extra
+ *   processing has to be done in order to determine memberships
+ *   using just the raw netgroup data).
+ *
+ * - If /etc/netgroup exists and contains only locally defined
+ *   netgroup entries, we use just those local entries and ignore
+ *   NIS (this is the original, pre-NIS behavior).
+ */
+
+#include <rpc/rpc.h>
+#include <rpcsvc/yp_prot.h>
+#include <rpcsvc/ypclnt.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/errno.h>
+static char *_netgr_yp_domain;
+int _use_only_yp;
+static int _netgr_yp_enabled;
+static int _yp_innetgr;
+#endif
+
+#ifndef _PATH_NETGROUP
+#define _PATH_NETGROUP "/etc/netgroup"
+#endif
+
+/*
+ * Static Variables and functions used by setnetgrent(), getnetgrent() and
+ * endnetgrent().
+ * There are two linked lists:
+ * - linelist is just used by setnetgrent() to parse the net group file via.
+ *   parse_netgrp()
+ * - netgrp is the list of entries for the current netgroup
+ */
+struct linelist {
+	struct linelist	*l_next;	/* Chain ptr. */
+	int		l_parsed;	/* Flag for cycles */
+	char		*l_groupname;	/* Name of netgroup */
+	char		*l_line;	/* Netgroup entrie(s) to be parsed */
+};
+
+struct netgrp {
+	struct netgrp	*ng_next;	/* Chain ptr */
+	char		*ng_str[3];	/* Field pointers, see below */
+};
+#define NG_HOST		0	/* Host name */
+#define NG_USER		1	/* User name */
+#define NG_DOM		2	/* and Domain name */
+
+static struct linelist	*linehead = (struct linelist *)0;
+static struct netgrp	*nextgrp = (struct netgrp *)0;
+static struct {
+	struct netgrp	*gr;
+	char		*grname;
+} grouphead = {
+	(struct netgrp *)0,
+	(char *)0,
+};
+static FILE *netf = (FILE *)0;
+
+static int parse_netgrp(const char *);
+static struct linelist *read_for_group(const char *);
+void setnetgrent(const char *);
+void endnetgrent(void);
+int getnetgrent(char **, char **, char **);
+int innetgr(const char *, const char *, const char *, const char *);
+
+#define	LINSIZ	1024	/* Length of netgroup file line */
+
+/*
+ * setnetgrent()
+ * Parse the netgroup file looking for the netgroup and build the list
+ * of netgrp structures. Let parse_netgrp() and read_for_group() do
+ * most of the work.
+ */
+void
+setnetgrent(const char *group)
+{
+#ifdef YP
+	struct stat _yp_statp;
+	char _yp_plus;
+#endif
+
+	/* Sanity check */
+
+	if (group == NULL || !strlen(group))
+		return;
+
+	if (grouphead.gr == (struct netgrp *)0 ||
+		strcmp(group, grouphead.grname)) {
+		endnetgrent();
+#ifdef YP
+		/* Presumed guilty until proven innocent. */
+		_use_only_yp = 0;
+		/*
+		 * If /etc/netgroup doesn't exist or is empty,
+		 * use NIS exclusively.
+		 */
+		if (((stat(_PATH_NETGROUP, &_yp_statp) < 0) &&
+			errno == ENOENT) || _yp_statp.st_size == 0)
+			_use_only_yp = _netgr_yp_enabled = 1;
+		if ((netf = fopen(_PATH_NETGROUP,"r")) != NULL ||_use_only_yp){
+		/*
+		 * Icky: grab the first character of the netgroup file
+		 * and turn on NIS if it's a '+'. rewind the stream
+		 * afterwards so we don't goof up read_for_group() later.
+		 */
+			if (netf) {
+				fscanf(netf, "%c", &_yp_plus);
+				rewind(netf);
+				if (_yp_plus == '+')
+					_use_only_yp = _netgr_yp_enabled = 1;
+			}
+		/*
+		 * If we were called specifically for an innetgr()
+		 * lookup and we're in NIS-only mode, short-circuit
+		 * parse_netgroup() and cut directly to the chase.
+		 */
+			if (_use_only_yp && _yp_innetgr) {
+				/* dohw! */
+				if (netf != NULL)
+					fclose(netf);
+				return;
+			}
+#else
+		if (netf = fopen(_PATH_NETGROUP, "r")) {
+#endif
+			if (parse_netgrp(group))
+				endnetgrent();
+			else {
+				grouphead.grname = (char *)
+					malloc(strlen(group) + 1);
+				strcpy(grouphead.grname, group);
+			}
+			if (netf)
+				fclose(netf);
+		}
+	}
+	nextgrp = grouphead.gr;
+}
+
+/*
+ * Get the next netgroup off the list.
+ */
+int
+getnetgrent(char **hostp, char **userp, char **domp)
+{
+#ifdef YP
+	_yp_innetgr = 0;
+#endif
+
+	if (nextgrp) {
+		*hostp = nextgrp->ng_str[NG_HOST];
+		*userp = nextgrp->ng_str[NG_USER];
+		*domp = nextgrp->ng_str[NG_DOM];
+		nextgrp = nextgrp->ng_next;
+		return (1);
+	}
+	return (0);
+}
+
+/*
+ * endnetgrent() - cleanup
+ */
+void
+endnetgrent(void)
+{
+	struct linelist *lp, *olp;
+	struct netgrp *gp, *ogp;
+
+	lp = linehead;
+	while (lp) {
+		olp = lp;
+		lp = lp->l_next;
+		free(olp->l_groupname);
+		free(olp->l_line);
+		free((char *)olp);
+	}
+	linehead = (struct linelist *)0;
+	if (grouphead.grname) {
+		free(grouphead.grname);
+		grouphead.grname = (char *)0;
+	}
+	gp = grouphead.gr;
+	while (gp) {
+		ogp = gp;
+		gp = gp->ng_next;
+		if (ogp->ng_str[NG_HOST])
+			free(ogp->ng_str[NG_HOST]);
+		if (ogp->ng_str[NG_USER])
+			free(ogp->ng_str[NG_USER]);
+		if (ogp->ng_str[NG_DOM])
+			free(ogp->ng_str[NG_DOM]);
+		free((char *)ogp);
+	}
+	grouphead.gr = (struct netgrp *)0;
+#ifdef YP
+	_netgr_yp_enabled = 0;
+#endif
+}
+
+#ifdef YP
+static int
+_listmatch(const char *list, const char *group, int len)
+{
+	const char *ptr = list;
+	const char *cptr;
+	int glen = strlen(group);
+
+	/* skip possible leading whitespace */
+	while(isspace((unsigned char)*ptr))
+		ptr++;
+
+	while (ptr < list + len) {
+		cptr = ptr;
+		while(*ptr != ','  && *ptr != '\0' && !isspace((unsigned char)*ptr))
+			ptr++;
+		if (strncmp(cptr, group, glen) == 0 && glen == (ptr - cptr))
+			return(1);
+		while(*ptr == ','  || isspace((unsigned char)*ptr))
+			ptr++;
+	}
+
+	return(0);
+}
+
+static int
+_buildkey(char *key, const char *str, const char *dom, int *rotation)
+{
+	(*rotation)++;
+	if (*rotation > 4)
+		return(0);
+	switch(*rotation) {
+		case(1): sprintf((char *)key, "%s.%s", str, dom ? dom : "*");
+			 break;
+		case(2): sprintf((char *)key, "%s.*", str);
+			 break;
+		case(3): sprintf((char *)key, "*.%s", dom ? dom : "*");
+			 break;
+		case(4): sprintf((char *)key, "*.*");
+			 break;
+	}
+	return(1);
+}
+#endif
+
+/*
+ * Search for a match in a netgroup.
+ */
+int
+innetgr(const char *group, const char *host, const char *user, const char *dom)
+{
+	char *hst, *usr, *dm;
+#ifdef YP
+	char *result;
+	int resultlen;
+	int rv;
+#endif
+	/* Sanity check */
+	
+	if (group == NULL || !strlen(group))
+		return (0);
+
+#ifdef YP
+	_yp_innetgr = 1;
+#endif
+	setnetgrent(group);
+#ifdef YP
+	_yp_innetgr = 0;
+	/*
+	 * If we're in NIS-only mode, do the search using
+	 * NIS 'reverse netgroup' lookups.
+	 */
+	if (_use_only_yp) {
+		char _key[MAXHOSTNAMELEN];
+		int rot = 0, y = 0;
+
+		if(yp_get_default_domain(&_netgr_yp_domain))
+			return(0);
+		while(_buildkey(_key, user ? user : host, dom, &rot)) {
+			y = yp_match(_netgr_yp_domain, user? "netgroup.byuser":
+			    "netgroup.byhost", _key, strlen(_key), &result,
+			    	&resultlen);
+			if (y) {
+				/*
+				 * If we get an error other than 'no
+				 * such key in map' then something is
+				 * wrong and we should stop the search.
+				 */
+				if (y != YPERR_KEY)
+					break;
+			} else {
+				rv = _listmatch(result, group, resultlen);
+				free(result);
+				if (rv)
+					return(1);
+				else
+					return(0);
+			}
+		}
+		/*
+		 * Couldn't match using NIS-exclusive mode. If the error
+	 	 * was YPERR_MAP, then the failure happened because there
+	 	 * was no netgroup.byhost or netgroup.byuser map. The odds
+		 * are we are talking to a Sun NIS+ server in YP emulation
+		 * mode; if this is the case, then we have to do the check
+		 * the 'old-fashioned' way by grovelling through the netgroup
+		 * map and resolving memberships on the fly.
+		 */
+		if (y != YPERR_MAP)
+			return(0);
+	}
+
+	setnetgrent(group);
+#endif /* YP */
+
+	while (getnetgrent(&hst, &usr, &dm))
+		if ((host == NULL || hst == NULL || !strcmp(host, hst)) &&
+		    (user == NULL || usr == NULL || !strcmp(user, usr)) &&
+		    ( dom == NULL ||  dm == NULL || !strcmp(dom, dm))) {
+			endnetgrent();
+			return (1);
+		}
+	endnetgrent();
+	return (0);
+}
+
+/*
+ * Parse the netgroup file setting up the linked lists.
+ */
+static int
+parse_netgrp(const char *group)
+{
+	char *spos, *epos;
+	int len, strpos;
+#ifdef DEBUG
+	int fields;
+#endif
+	char *pos, *gpos;
+	struct netgrp *grp;
+	struct linelist *lp = linehead;
+
+	/*
+	 * First, see if the line has already been read in.
+	 */
+	while (lp) {
+		if (!strcmp(group, lp->l_groupname))
+			break;
+		lp = lp->l_next;
+	}
+	if (lp == (struct linelist *)0 &&
+	    (lp = read_for_group(group)) == (struct linelist *)0)
+		return (1);
+	if (lp->l_parsed) {
+#ifdef DEBUG
+		/*
+		 * This error message is largely superflous since the
+		 * code handles the error condition sucessfully, and
+		 * spewing it out from inside libc can actually hose
+		 * certain programs.
+		 */
+		fprintf(stderr, "Cycle in netgroup %s\n", lp->l_groupname);
+#endif
+		return (1);
+	} else
+		lp->l_parsed = 1;
+	pos = lp->l_line;
+	/* Watch for null pointer dereferences, dammit! */
+	while (pos != NULL && *pos != '\0') {
+		if (*pos == '(') {
+			grp = (struct netgrp *)malloc(sizeof (struct netgrp));
+			bzero((char *)grp, sizeof (struct netgrp));
+			grp->ng_next = grouphead.gr;
+			grouphead.gr = grp;
+			pos++;
+			gpos = strsep(&pos, ")");
+#ifdef DEBUG
+			fields = 0;
+#endif
+			for (strpos = 0; strpos < 3; strpos++) {
+				if ((spos = strsep(&gpos, ","))) {
+#ifdef DEBUG
+					fields++;
+#endif
+					while (*spos == ' ' || *spos == '\t')
+						spos++;
+					if ((epos = strpbrk(spos, " \t"))) {
+						*epos = '\0';
+						len = epos - spos;
+					} else
+						len = strlen(spos);
+					if (len > 0) {
+						grp->ng_str[strpos] =  (char *)
+							malloc(len + 1);
+						bcopy(spos, grp->ng_str[strpos],
+							len + 1);
+					}
+				} else {
+					/*
+					 * All other systems I've tested
+					 * return NULL for empty netgroup
+					 * fields. It's up to user programs
+					 * to handle the NULLs appropriately.
+					 */
+					grp->ng_str[strpos] = NULL;
+				}
+			}
+#ifdef DEBUG
+			/*
+			 * Note: on other platforms, malformed netgroup
+			 * entries are not normally flagged. While we
+			 * can catch bad entries and report them, we should
+			 * stay silent by default for compatibility's sake.
+			 */
+			if (fields < 3)
+					fprintf(stderr, "Bad entry (%s%s%s%s%s) in netgroup \"%s\"\n",
+						grp->ng_str[NG_HOST] == NULL ? "" : grp->ng_str[NG_HOST],
+						grp->ng_str[NG_USER] == NULL ? "" : ",",
+						grp->ng_str[NG_USER] == NULL ? "" : grp->ng_str[NG_USER],
+						grp->ng_str[NG_DOM] == NULL ? "" : ",",
+						grp->ng_str[NG_DOM] == NULL ? "" : grp->ng_str[NG_DOM],
+						lp->l_groupname);
+#endif
+		} else {
+			spos = strsep(&pos, ", \t");
+			if (parse_netgrp(spos))
+				continue;
+		}
+		if (pos == NULL)
+			break;
+		while (*pos == ' ' || *pos == ',' || *pos == '\t')
+			pos++;
+	}
+	return (0);
+}
+
+/*
+ * Read the netgroup file and save lines until the line for the netgroup
+ * is found. Return 1 if eof is encountered.
+ */
+static struct linelist *
+read_for_group(const char *group)
+{
+	char *pos, *spos, *linep, *olinep;
+	int len, olen;
+	int cont;
+	struct linelist *lp;
+	char line[LINSIZ + 2];
+#ifdef YP
+	char *result;
+	int resultlen;
+
+	while (_netgr_yp_enabled || fgets(line, LINSIZ, netf) != NULL) {
+		if (_netgr_yp_enabled) {
+			if(!_netgr_yp_domain)
+				if(yp_get_default_domain(&_netgr_yp_domain))
+					continue;
+			if (yp_match(_netgr_yp_domain, "netgroup", group,
+					strlen(group), &result, &resultlen)) {
+				free(result);
+				if (_use_only_yp)
+					return ((struct linelist *)0);
+				else {
+					_netgr_yp_enabled = 0;
+					continue;
+				}
+			}
+			snprintf(line, LINSIZ, "%s %s", group, result);
+			free(result);
+		}
+#else
+	while (fgets(line, LINSIZ, netf) != NULL) {
+#endif
+		pos = (char *)&line;
+#ifdef YP
+		if (*pos == '+') {
+			_netgr_yp_enabled = 1;
+			continue;
+		}
+#endif
+		if (*pos == '#')
+			continue;
+		while (*pos == ' ' || *pos == '\t')
+			pos++;
+		spos = pos;
+		while (*pos != ' ' && *pos != '\t' && *pos != '\n' &&
+			*pos != '\0')
+			pos++;
+		len = pos - spos;
+		while (*pos == ' ' || *pos == '\t')
+			pos++;
+		if (*pos != '\n' && *pos != '\0') {
+			lp = (struct linelist *)malloc(sizeof (*lp));
+			lp->l_parsed = 0;
+			lp->l_groupname = (char *)malloc(len + 1);
+			bcopy(spos, lp->l_groupname, len);
+			*(lp->l_groupname + len) = '\0';
+			len = strlen(pos);
+			olen = 0;
+
+			/*
+			 * Loop around handling line continuations.
+			 */
+			do {
+				if (*(pos + len - 1) == '\n')
+					len--;
+				if (*(pos + len - 1) == '\\') {
+					len--;
+					cont = 1;
+				} else
+					cont = 0;
+				if (len > 0) {
+					linep = (char *)malloc(olen + len + 1);
+					if (olen > 0) {
+						bcopy(olinep, linep, olen);
+						free(olinep);
+					}
+					bcopy(pos, linep + olen, len);
+					olen += len;
+					*(linep + olen) = '\0';
+					olinep = linep;
+				}
+				if (cont) {
+					if (fgets(line, LINSIZ, netf)) {
+						pos = line;
+						len = strlen(pos);
+					} else
+						cont = 0;
+				}
+			} while (cont);
+			lp->l_line = linep;
+			lp->l_next = linehead;
+			linehead = lp;
+
+			/*
+			 * If this is the one we wanted, we are done.
+			 */
+			if (!strcmp(lp->l_groupname, group))
+				return (lp);
+		}
+	}
+#ifdef YP
+	/*
+	 * Yucky. The recursive nature of this whole mess might require
+	 * us to make more than one pass through the netgroup file.
+	 * This might be best left outside the #ifdef YP, but YP is
+	 * defined by default anyway, so I'll leave it like this
+	 * until I know better.
+	 */
+	rewind(netf);
+#endif
+	return ((struct linelist *)0);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/getprogname.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/getprogname.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/getprogname.c	(revision 2404)
@@ -0,0 +1,17 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/getprogname.c,v 1.4 2002/03/29 22:43:41 markm Exp $");
+
+#include "namespace.h"
+#include <stdlib.h>
+#include "un-namespace.h"
+
+#include "libc_private.h"
+
+__weak_reference(_getprogname, getprogname);
+
+const char *
+_getprogname(void)
+{
+
+	return (__progname);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/getpwent.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/getpwent.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/getpwent.c	(revision 2404)
@@ -0,0 +1,1732 @@
+/*-
+ * Copyright (c) 2003 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by
+ * Jacques A. Vidrine, Safeport Network Services, and Network
+ * Associates Laboratories, the Security Research Division of Network
+ * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
+ * ("CBOSS"), as part of the DARPA CHATS research program.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/getpwent.c,v 1.89 2004/05/17 18:27:05 kientzle Exp $");
+
+#include "namespace.h"
+#include <sys/param.h>
+#ifdef YP
+#include <rpc/rpc.h>
+#include <rpcsvc/yp_prot.h>
+#include <rpcsvc/ypclnt.h>
+#endif
+#include <arpa/inet.h>
+#include <errno.h>
+#include <fcntl.h>
+#ifdef HESIOD
+#include <hesiod.h>
+#endif
+#include <netdb.h>
+#include <nsswitch.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#include <pwd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include "un-namespace.h"
+#include <db.h>
+#include "libc_private.h"
+#include "pw_scan.h"
+#include "nss_tls.h"
+
+#ifndef CTASSERT
+#define CTASSERT(x)		_CTASSERT(x, __LINE__)
+#define _CTASSERT(x, y)		__CTASSERT(x, y)
+#define __CTASSERT(x, y)	typedef char __assert_ ## y [(x) ? 1 : -1]
+#endif
+
+/* Counter as stored in /etc/pwd.db */
+typedef	int		pwkeynum;
+
+CTASSERT(MAXLOGNAME > sizeof(uid_t));
+CTASSERT(MAXLOGNAME > sizeof(pwkeynum));
+
+enum constants {
+	PWD_STORAGE_INITIAL	= 1 << 10, /* 1 KByte */
+	PWD_STORAGE_MAX		= 1 << 20, /* 1 MByte */
+	SETPWENT		= 1,
+	ENDPWENT		= 2,
+	HESIOD_NAME_MAX		= 256
+};
+
+static const ns_src defaultsrc[] = {
+	{ NSSRC_COMPAT, NS_SUCCESS },
+	{ NULL, 0 }
+};
+
+int	__pw_match_entry(const char *, size_t, enum nss_lookup_type,
+	    const char *, uid_t);
+int	__pw_parse_entry(char *, size_t, struct passwd *, int, int *errnop);
+
+static	void	 pwd_init(struct passwd *);
+
+union key {
+	const char	*name;
+	uid_t		 uid;
+};
+
+static	struct passwd *getpw(int (*fn)(union key, struct passwd *, char *,
+		    size_t, struct passwd **), union key);
+static	int	 wrap_getpwnam_r(union key, struct passwd *, char *,
+		    size_t, struct passwd **);
+static	int	 wrap_getpwuid_r(union key, struct passwd *, char *, size_t,
+		    struct passwd **);
+static	int	 wrap_getpwent_r(union key, struct passwd *, char *, size_t,
+		    struct passwd **);
+
+static	int	 pwdb_match_entry_v3(char *, size_t, enum nss_lookup_type,
+		    const char *, uid_t);
+static	int	 pwdb_parse_entry_v3(char *, size_t, struct passwd *, int *);
+static	int	 pwdb_match_entry_v4(char *, size_t, enum nss_lookup_type,
+		    const char *, uid_t);
+static	int	 pwdb_parse_entry_v4(char *, size_t, struct passwd *, int *);
+
+
+struct {
+	int	(*match)(char *, size_t, enum nss_lookup_type, const char *,
+		    uid_t);
+	int	(*parse)(char *, size_t, struct passwd *, int *);
+} pwdb_versions[] = {
+	{ NULL, NULL },					/* version 0 */
+	{ NULL, NULL },					/* version 1 */
+	{ NULL, NULL },					/* version 2 */
+	{ pwdb_match_entry_v3, pwdb_parse_entry_v3 },	/* version 3 */
+	{ pwdb_match_entry_v4, pwdb_parse_entry_v4 },	/* version 4 */
+};
+
+
+struct files_state {
+	DB		*db;
+	pwkeynum	 keynum;
+	int		 stayopen;
+	int		 version;
+};
+static	void	files_endstate(void *);
+NSS_TLS_HANDLING(files);
+static	DB	*pwdbopen(int *);
+static	void	 files_endstate(void *);
+static	int	 files_setpwent(void *, void *, va_list);
+static	int	 files_passwd(void *, void *, va_list);
+
+
+#ifdef HESIOD
+struct dns_state {
+	long	counter;
+};
+static	void	dns_endstate(void *);
+NSS_TLS_HANDLING(dns);
+static	int	 dns_setpwent(void *, void *, va_list);
+static	int	 dns_passwd(void *, void *, va_list);
+#endif
+
+
+#ifdef YP
+struct nis_state {
+	char	 domain[MAXHOSTNAMELEN];
+	int	 done;
+	char	*key;
+	int	 keylen;
+};
+static	void	 nis_endstate(void *);
+NSS_TLS_HANDLING(nis);
+static	int	 nis_setpwent(void *, void *, va_list);
+static	int	 nis_passwd(void *, void *, va_list);
+static	int	 nis_map(char *, enum nss_lookup_type, char *, size_t, int *);
+static	int	 nis_adjunct(char *, const char *, char *, size_t);
+#endif
+
+
+struct compat_state {
+	DB		*db;
+	pwkeynum	 keynum;
+	int		 stayopen;
+	int		 version;
+	DB		*exclude;
+	struct passwd	 template;
+	char		*name;
+	enum _compat {
+		COMPAT_MODE_OFF = 0,
+		COMPAT_MODE_ALL,
+		COMPAT_MODE_NAME,
+		COMPAT_MODE_NETGROUP
+	}		 compat;
+};
+static	void	 compat_endstate(void *);
+NSS_TLS_HANDLING(compat);
+static	int	 compat_setpwent(void *, void *, va_list);
+static	int	 compat_passwd(void *, void *, va_list);
+static	void	 compat_clear_template(struct passwd *);
+static	int	 compat_set_template(struct passwd *, struct passwd *);
+static	int	 compat_use_template(struct passwd *, struct passwd *, char *,
+		    size_t);
+static	int	 compat_redispatch(struct compat_state *, enum nss_lookup_type,
+		    enum nss_lookup_type, const char *, const char *, uid_t,
+		    struct passwd *, char *, size_t, int *);
+void
+setpwent(void)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_setpwent, (void *)SETPWENT },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_setpwent, (void *)SETPWENT },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_setpwent, (void *)SETPWENT },
+#endif
+		{ NSSRC_COMPAT, compat_setpwent, (void *)SETPWENT },
+		{ NULL, NULL, NULL }
+	};
+	(void)_nsdispatch(NULL, dtab, NSDB_PASSWD, "setpwent", defaultsrc, 0);
+}
+
+
+int
+setpassent(int stayopen)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_setpwent, (void *)SETPWENT },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_setpwent, (void *)SETPWENT },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_setpwent, (void *)SETPWENT },
+#endif
+		{ NSSRC_COMPAT, compat_setpwent, (void *)SETPWENT },
+		{ NULL, NULL, NULL }
+	};
+	(void)_nsdispatch(NULL, dtab, NSDB_PASSWD, "setpwent", defaultsrc,
+	    stayopen);
+	return (1);
+}
+
+
+void
+endpwent(void)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_setpwent, (void *)ENDPWENT },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_setpwent, (void *)ENDPWENT },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_setpwent, (void *)ENDPWENT },
+#endif
+		{ NSSRC_COMPAT, compat_setpwent, (void *)ENDPWENT },
+		{ NULL, NULL, NULL }
+	};
+	(void)_nsdispatch(NULL, dtab, NSDB_PASSWD, "endpwent", defaultsrc);
+}
+
+
+int
+getpwent_r(struct passwd *pwd, char *buffer, size_t bufsize,
+    struct passwd **result)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_passwd, (void *)nss_lt_all },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_passwd, (void *)nss_lt_all },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_passwd, (void *)nss_lt_all },
+#endif
+		{ NSSRC_COMPAT, compat_passwd, (void *)nss_lt_all },
+		{ NULL, NULL, NULL }
+	};
+	int	rv, ret_errno;
+
+	pwd_init(pwd);
+	ret_errno = 0;
+	*result = NULL;
+	rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwent_r", defaultsrc,
+	    pwd, buffer, bufsize, &ret_errno);
+	if (rv == NS_SUCCESS)
+		return (0);
+	else
+		return (ret_errno);
+}
+
+
+int
+getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t bufsize,
+    struct passwd **result)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_passwd, (void *)nss_lt_name },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_passwd, (void *)nss_lt_name },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_passwd, (void *)nss_lt_name },
+#endif
+		{ NSSRC_COMPAT, compat_passwd, (void *)nss_lt_name },
+		{ NULL, NULL, NULL }
+	};
+	int	rv, ret_errno;
+
+	pwd_init(pwd);
+	ret_errno = 0;
+	*result = NULL;
+	rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwnam_r", defaultsrc,
+	    name, pwd, buffer, bufsize, &ret_errno);
+	if (rv == NS_SUCCESS)
+		return (0);
+	else
+		return (ret_errno);
+}
+
+
+int
+getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize,
+    struct passwd **result)
+{
+	static const ns_dtab dtab[] = {
+		{ NSSRC_FILES, files_passwd, (void *)nss_lt_id },
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_passwd, (void *)nss_lt_id },
+#endif
+#ifdef YP
+		{ NSSRC_NIS, nis_passwd, (void *)nss_lt_id },
+#endif
+		{ NSSRC_COMPAT, compat_passwd, (void *)nss_lt_id },
+		{ NULL, NULL, NULL }
+	};
+	int	rv, ret_errno;
+
+	pwd_init(pwd);
+	ret_errno = 0;
+	*result = NULL;
+	rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwuid_r", defaultsrc,
+	    uid, pwd, buffer, bufsize, &ret_errno);
+	if (rv == NS_SUCCESS)
+		return (0);
+	else
+		return (ret_errno);
+}
+
+
+static void
+pwd_init(struct passwd *pwd)
+{
+	static char nul[] = "";
+
+	memset(pwd, 0, sizeof(*pwd));
+	pwd->pw_uid = (uid_t)-1;  /* Considered least likely to lead to */
+	pwd->pw_gid = (gid_t)-1;  /* a security issue.                  */
+	pwd->pw_name = nul;
+	pwd->pw_passwd = nul;
+	pwd->pw_class = nul;
+	pwd->pw_gecos = nul;
+	pwd->pw_dir = nul;
+	pwd->pw_shell = nul;
+}
+
+
+static struct passwd	 pwd;
+static char		*pwd_storage;
+static size_t		 pwd_storage_size;
+
+
+static struct passwd *
+getpw(int (*fn)(union key, struct passwd *, char *, size_t, struct passwd **),
+    union key key)
+{
+	int		 rv;
+	struct passwd	*res;
+
+	if (pwd_storage == NULL) {
+		pwd_storage = malloc(PWD_STORAGE_INITIAL);
+		if (pwd_storage == NULL)
+			return (NULL);
+		pwd_storage_size = PWD_STORAGE_INITIAL;
+	}
+	do {
+		rv = fn(key, &pwd, pwd_storage, pwd_storage_size, &res);
+		if (res == NULL && rv == ERANGE) {
+			free(pwd_storage);
+			if ((pwd_storage_size << 1) > PWD_STORAGE_MAX) {
+				pwd_storage = NULL;
+				errno = ERANGE;
+				return (NULL);
+			}
+			pwd_storage_size <<= 1;
+			pwd_storage = malloc(pwd_storage_size);
+			if (pwd_storage == NULL)
+				return (NULL);
+		}
+	} while (res == NULL && rv == ERANGE);
+	if (rv != 0)
+		errno = rv;
+	return (res);
+}
+
+
+static int
+wrap_getpwnam_r(union key key, struct passwd *pwd, char *buffer,
+    size_t bufsize, struct passwd **res)
+{
+	return (getpwnam_r(key.name, pwd, buffer, bufsize, res));
+}
+
+
+static int
+wrap_getpwuid_r(union key key, struct passwd *pwd, char *buffer,
+    size_t bufsize, struct passwd **res)
+{
+	return (getpwuid_r(key.uid, pwd, buffer, bufsize, res));
+}
+
+
+static int
+wrap_getpwent_r(union key key __unused, struct passwd *pwd, char *buffer,
+    size_t bufsize, struct passwd **res)
+{
+	return (getpwent_r(pwd, buffer, bufsize, res));
+}
+
+
+struct passwd *
+getpwnam(const char *name)
+{
+	union key key;
+
+	key.name = name;
+	return (getpw(wrap_getpwnam_r, key));
+}
+
+
+struct passwd *
+getpwuid(uid_t uid)
+{
+	union key key;
+
+	key.uid = uid;
+	return (getpw(wrap_getpwuid_r, key));
+}
+
+
+struct passwd *
+getpwent(void)
+{
+	union key key;
+
+	key.uid = 0; /* not used */
+	return (getpw(wrap_getpwent_r, key));
+}
+
+
+/*
+ * files backend
+ */
+static DB *
+pwdbopen(int *version)
+{
+	DB	*res;
+	DBT	 key, entry;
+	int	 rv;
+
+	if (geteuid() != 0 ||
+	    (res = dbopen(_PATH_SMP_DB, O_RDONLY, 0, DB_HASH, NULL)) == NULL)
+		res = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL);
+	if (res == NULL)
+		return (NULL);
+	key.data = _PWD_VERSION_KEY;
+	key.size = strlen(_PWD_VERSION_KEY);
+	rv = res->get(res, &key, &entry, 0);
+	if (rv == 0)
+		*version = *(unsigned char *)entry.data;
+	else
+		*version = 3;
+	if (*version < 3 ||
+	    *version >= sizeof(pwdb_versions)/sizeof(pwdb_versions[0])) {
+		syslog(LOG_CRIT, "Unsupported password database version %d",
+		    *version);
+		res->close(res);
+		res = NULL;
+	}
+	return (res);
+}
+
+
+static void
+files_endstate(void *p)
+{
+	DB	*db;
+
+	if (p == NULL)
+		return;
+	db = ((struct files_state *)p)->db;
+	if (db != NULL)
+		db->close(db);
+	free(p);
+}
+
+
+static int
+files_setpwent(void *retval, void *mdata, va_list ap)
+{
+	struct files_state	*st;
+	int			 rv, stayopen;
+
+	rv = files_getstate(&st);
+	if (rv != 0)
+		return (NS_UNAVAIL);
+	switch ((enum constants)mdata) {
+	case SETPWENT:
+		stayopen = va_arg(ap, int);
+		st->keynum = 0;
+		if (stayopen)
+			st->db = pwdbopen(&st->version);
+		st->stayopen = stayopen;
+		break;
+	case ENDPWENT:
+		if (st->db != NULL) {
+			(void)st->db->close(st->db);
+			st->db = NULL;
+		}
+		break;
+	default:
+		break;
+	}
+	return (NS_UNAVAIL);
+}
+
+
+static int
+files_passwd(void *retval, void *mdata, va_list ap)
+{
+	char			 keybuf[MAXLOGNAME + 1];
+	DBT			 key, entry;
+	struct files_state	*st;
+	enum nss_lookup_type	 how;
+	const char		*name;
+	struct passwd		*pwd;
+	char			*buffer;
+	size_t			 bufsize, namesize;
+	uid_t			 uid;
+	uint32_t		 store;
+	int			 rv, stayopen, *errnop;
+
+	name = NULL;
+	uid = (uid_t)-1;
+	how = (enum nss_lookup_type)mdata;
+	switch (how) {
+	case nss_lt_name:
+		name = va_arg(ap, const char *);
+		keybuf[0] = _PW_KEYBYNAME;
+		break;
+	case nss_lt_id:
+		uid = va_arg(ap, uid_t);
+		keybuf[0] = _PW_KEYBYUID;
+		break;
+	case nss_lt_all:
+		keybuf[0] = _PW_KEYBYNUM;
+		break;
+	default:
+		rv = NS_NOTFOUND;
+		goto fin;
+	}
+	pwd = va_arg(ap, struct passwd *);
+	buffer = va_arg(ap, char *);
+	bufsize = va_arg(ap, size_t);
+	errnop = va_arg(ap, int *);
+	*errnop = files_getstate(&st);
+	if (*errnop != 0)
+		return (NS_UNAVAIL);
+	if (how == nss_lt_all && st->keynum < 0) {
+		rv = NS_NOTFOUND;
+		goto fin;
+	}
+	if (st->db == NULL &&
+	    (st->db = pwdbopen(&st->version)) == NULL) {
+		*errnop = errno;
+		rv = NS_UNAVAIL;
+		goto fin;
+	}
+	if (how == nss_lt_all)
+		stayopen = 1;
+	else
+		stayopen = st->stayopen;
+	key.data = keybuf;
+	do {
+		switch (how) {
+		case nss_lt_name:
+			/* MAXLOGNAME includes NUL byte, but we do not
+			 * include the NUL byte in the key.
+			 */
+			namesize = strlcpy(&keybuf[1], name, sizeof(keybuf)-1);
+			if (namesize >= sizeof(keybuf)-1) {
+				*errnop = EINVAL;
+				rv = NS_NOTFOUND;
+				goto fin;
+			}
+			key.size = namesize + 1;
+			break;
+		case nss_lt_id:
+			if (st->version < _PWD_CURRENT_VERSION) {
+				memcpy(&keybuf[1], &uid, sizeof(uid));
+				key.size = sizeof(uid) + 1;
+			} else {
+				store = htonl(uid);
+				memcpy(&keybuf[1], &store, sizeof(store));
+				key.size = sizeof(store) + 1;
+			}
+			break;
+		case nss_lt_all:
+			st->keynum++;
+			if (st->version < _PWD_CURRENT_VERSION) {
+				memcpy(&keybuf[1], &st->keynum,
+				    sizeof(st->keynum));
+				key.size = sizeof(st->keynum) + 1;
+			} else {
+				store = htonl(st->keynum);
+				memcpy(&keybuf[1], &store, sizeof(store));
+				key.size = sizeof(store) + 1;
+			}
+			break;
+		}
+		keybuf[0] = _PW_VERSIONED(keybuf[0], st->version);
+		rv = st->db->get(st->db, &key, &entry, 0);
+		if (rv < 0 || rv > 1) { /* should never return > 1 */
+			*errnop = errno;
+			rv = NS_UNAVAIL;
+			goto fin;
+		} else if (rv == 1) {
+			if (how == nss_lt_all)
+				st->keynum = -1;
+			rv = NS_NOTFOUND;
+			goto fin;
+		}
+		rv = pwdb_versions[st->version].match(entry.data, entry.size,
+		    how, name, uid);
+		if (rv != NS_SUCCESS)
+			continue;
+		if (entry.size > bufsize) {
+			*errnop = ERANGE;
+			rv = NS_RETURN;
+			break;
+		}
+		memcpy(buffer, entry.data, entry.size);
+		rv = pwdb_versions[st->version].parse(buffer, entry.size, pwd,
+		    errnop);
+	} while (how == nss_lt_all && !(rv & NS_TERMINATE));
+fin:
+	if (!stayopen && st->db != NULL) {
+		(void)st->db->close(st->db);
+		st->db = NULL;
+	}
+	if (rv == NS_SUCCESS) {
+		pwd->pw_fields &= ~_PWF_SOURCE;
+		pwd->pw_fields |= _PWF_FILES;
+		if (retval != NULL)
+			*(struct passwd **)retval = pwd;
+	}
+	return (rv);
+}
+
+
+static int
+pwdb_match_entry_v3(char *entry, size_t entrysize, enum nss_lookup_type how,
+    const char *name, uid_t uid)
+{
+	const char	*p, *eom;
+	uid_t		 uid2;
+
+	eom = &entry[entrysize];
+	for (p = entry; p < eom; p++)
+		if (*p == '\0')
+			break;
+	if (*p != '\0')
+		return (NS_NOTFOUND);
+	if (how == nss_lt_all)
+		return (NS_SUCCESS);
+	if (how == nss_lt_name)
+		return (strcmp(name, entry) == 0 ? NS_SUCCESS : NS_NOTFOUND);
+	for (p++; p < eom; p++)
+		if (*p == '\0')
+			break;
+	if (*p != '\0' || (++p) + sizeof(uid) >= eom)
+		return (NS_NOTFOUND);
+	memcpy(&uid2, p, sizeof(uid2));
+	return (uid == uid2 ? NS_SUCCESS : NS_NOTFOUND);
+}
+
+
+static int
+pwdb_parse_entry_v3(char *buffer, size_t bufsize, struct passwd *pwd,
+    int *errnop)
+{
+	char		*p, *eom;
+	int32_t		 pw_change, pw_expire;
+
+	/* THIS CODE MUST MATCH THAT IN pwd_mkdb. */
+	p = buffer;
+	eom = &buffer[bufsize];
+#define STRING(field)	do {			\
+		(field) = p;			\
+		while (p < eom && *p != '\0')	\
+			p++;			\
+		if (p >= eom)			\
+			return (NS_NOTFOUND);	\
+		p++;				\
+	} while (0)
+#define SCALAR(field)	do {				\
+		if (p + sizeof(field) > eom)		\
+			return (NS_NOTFOUND);		\
+		memcpy(&(field), p, sizeof(field));	\
+		p += sizeof(field);			\
+	} while (0)
+	STRING(pwd->pw_name);
+	STRING(pwd->pw_passwd);
+	SCALAR(pwd->pw_uid);
+	SCALAR(pwd->pw_gid);
+	SCALAR(pw_change);
+	STRING(pwd->pw_class);
+	STRING(pwd->pw_gecos);
+	STRING(pwd->pw_dir);
+	STRING(pwd->pw_shell);
+	SCALAR(pw_expire);
+	SCALAR(pwd->pw_fields);
+#undef STRING
+#undef SCALAR
+	pwd->pw_change = pw_change;
+	pwd->pw_expire = pw_expire;
+	return (NS_SUCCESS);
+}
+
+
+static int
+pwdb_match_entry_v4(char *entry, size_t entrysize, enum nss_lookup_type how,
+    const char *name, uid_t uid)
+{
+	const char	*p, *eom;
+	uint32_t	 uid2;
+
+	eom = &entry[entrysize];
+	for (p = entry; p < eom; p++)
+		if (*p == '\0')
+			break;
+	if (*p != '\0')
+		return (NS_NOTFOUND);
+	if (how == nss_lt_all)
+		return (NS_SUCCESS);
+	if (how == nss_lt_name)
+		return (strcmp(name, entry) == 0 ? NS_SUCCESS : NS_NOTFOUND);
+	for (p++; p < eom; p++)
+		if (*p == '\0')
+			break;
+	if (*p != '\0' || (++p) + sizeof(uid) >= eom)
+		return (NS_NOTFOUND);
+	memcpy(&uid2, p, sizeof(uid2));
+	uid2 = ntohl(uid2);
+	return (uid == (uid_t)uid2 ? NS_SUCCESS : NS_NOTFOUND);
+}
+
+
+static int
+pwdb_parse_entry_v4(char *buffer, size_t bufsize, struct passwd *pwd,
+    int *errnop)
+{
+	char		*p, *eom;
+	uint32_t	 n;
+
+	/* THIS CODE MUST MATCH THAT IN pwd_mkdb. */
+	p = buffer;
+	eom = &buffer[bufsize];
+#define STRING(field)	do {			\
+		(field) = p;			\
+		while (p < eom && *p != '\0')	\
+			p++;			\
+		if (p >= eom)			\
+			return (NS_NOTFOUND);	\
+		p++;				\
+	} while (0)
+#define SCALAR(field)	do {				\
+		if (p + sizeof(n) > eom)		\
+			return (NS_NOTFOUND);		\
+		memcpy(&n, p, sizeof(n));		\
+		(field) = ntohl(n);			\
+		p += sizeof(n);				\
+	} while (0)
+	STRING(pwd->pw_name);
+	STRING(pwd->pw_passwd);
+	SCALAR(pwd->pw_uid);
+	SCALAR(pwd->pw_gid);
+	SCALAR(pwd->pw_change);
+	STRING(pwd->pw_class);
+	STRING(pwd->pw_gecos);
+	STRING(pwd->pw_dir);
+	STRING(pwd->pw_shell);
+	SCALAR(pwd->pw_expire);
+	SCALAR(pwd->pw_fields);
+#undef STRING
+#undef SCALAR
+	return (NS_SUCCESS);
+}
+
+
+#ifdef HESIOD
+/*
+ * dns backend
+ */
+static void
+dns_endstate(void *p)
+{
+	free(p);
+}
+
+
+static int
+dns_setpwent(void *retval, void *mdata, va_list ap)
+{
+	struct dns_state	*st;
+	int			 rv;
+
+	rv = dns_getstate(&st);
+	if (rv != 0)
+		return (NS_UNAVAIL);
+	st->counter = 0;
+	return (NS_UNAVAIL);
+}
+
+
+static int
+dns_passwd(void *retval, void *mdata, va_list ap)
+{
+	char			 buf[HESIOD_NAME_MAX];
+	struct dns_state	*st;
+	struct passwd		*pwd;
+	const char		*name, *label;
+	void			*ctx;
+	char			*buffer, **hes;
+	size_t			 bufsize, linesize;
+	uid_t			 uid;
+	enum nss_lookup_type	 how;
+	int			 rv, *errnop;
+
+	ctx = NULL;
+	hes = NULL;
+	name = NULL;
+	uid = (uid_t)-1;
+	how = (enum nss_lookup_type)mdata;
+	switch (how) {
+	case nss_lt_name:
+		name = va_arg(ap, const char *);
+		break;
+	case nss_lt_id:
+		uid = va_arg(ap, uid_t);
+		break;
+	case nss_lt_all:
+		break;
+	}
+	pwd     = va_arg(ap, struct passwd *);
+	buffer  = va_arg(ap, char *);
+	bufsize = va_arg(ap, size_t);
+	errnop  = va_arg(ap, int *);
+	*errnop = dns_getstate(&st);
+	if (*errnop != 0)
+		return (NS_UNAVAIL);
+	if (hesiod_init(&ctx) != 0) {
+		*errnop = errno;
+		rv = NS_UNAVAIL;
+		goto fin;
+	}
+	do {
+		rv = NS_NOTFOUND;
+		switch (how) {
+		case nss_lt_name:
+			label = name;
+			break;
+		case nss_lt_id:
+			if (snprintf(buf, sizeof(buf), "%lu",
+			    (unsigned long)uid) >= sizeof(buf))
+				goto fin;
+			label = buf;
+			break;
+		case nss_lt_all:
+			if (st->counter < 0)
+				goto fin;
+			if (snprintf(buf, sizeof(buf), "passwd-%ld",
+			    st->counter++) >= sizeof(buf))
+				goto fin;
+			label = buf;
+			break;
+		}
+		hes = hesiod_resolve(ctx, label,
+		    how == nss_lt_id ? "uid" : "passwd");
+		if (hes == NULL) {
+			if (how == nss_lt_all)
+				st->counter = -1;
+			if (errno != ENOENT)
+				*errnop = errno;
+			goto fin;
+		}
+		rv = __pw_match_entry(hes[0], strlen(hes[0]), how, name, uid);
+		if (rv != NS_SUCCESS) {
+			hesiod_free_list(ctx, hes);
+			hes = NULL;
+			continue;
+		}
+		linesize = strlcpy(buffer, hes[0], bufsize);
+		if (linesize >= bufsize) {
+			*errnop = ERANGE;
+			rv = NS_RETURN;
+			continue;
+		}
+		hesiod_free_list(ctx, hes);
+		hes = NULL;
+		rv = __pw_parse_entry(buffer, bufsize, pwd, 0, errnop);
+	} while (how == nss_lt_all && !(rv & NS_TERMINATE));
+fin:
+	if (hes != NULL)
+		hesiod_free_list(ctx, hes);
+	if (ctx != NULL)
+		hesiod_end(ctx);
+	if (rv == NS_SUCCESS) {
+		pwd->pw_fields &= ~_PWF_SOURCE;
+		pwd->pw_fields |= _PWF_HESIOD;
+		if (retval != NULL)
+			*(struct passwd **)retval = pwd;
+	}
+	return (rv);
+}
+#endif /* HESIOD */
+
+
+#ifdef YP
+/*
+ * nis backend
+ */
+static void
+nis_endstate(void *p)
+{
+	free(((struct nis_state *)p)->key);
+	free(p);
+}
+
+/*
+ * Test for the presence of special FreeBSD-specific master.passwd.by*
+ * maps. We do this using yp_order(). If it fails, then either the server
+ * doesn't have the map, or the YPPROC_ORDER procedure isn't supported by
+ * the server (Sun NIS+ servers in YP compat mode behave this way). If
+ * the master.passwd.by* maps don't exist, then let the lookup routine try
+ * the regular passwd.by* maps instead. If the lookup routine fails, it
+ * can return an error as needed.
+ */
+static int
+nis_map(char *domain, enum nss_lookup_type how, char *buffer, size_t bufsize,
+    int *master)
+{
+	int	rv, order;
+
+	*master = 0;
+	if (geteuid() == 0) {
+		if (snprintf(buffer, bufsize, "master.passwd.by%s",
+		    (how == nss_lt_id) ? "uid" : "name") >= bufsize)
+			return (NS_UNAVAIL);
+		rv = yp_order(domain, buffer, &order);
+		if (rv == 0) {
+			*master = 1;
+			return (NS_SUCCESS);
+		}
+	}
+
+	if (snprintf(buffer, bufsize, "passwd.by%s",
+	    (how == nss_lt_id) ? "uid" : "name") >= bufsize)
+		return (NS_UNAVAIL);
+
+	return (NS_SUCCESS);
+}
+
+
+static int
+nis_adjunct(char *domain, const char *name, char *buffer, size_t bufsize)
+{
+	int	 rv;
+	char	*result, *p, *q, *eor;
+	int	 resultlen;
+
+	result = NULL;
+	rv = yp_match(domain, "passwd.adjunct.byname", name, strlen(name),
+	    &result, &resultlen);
+	if (rv != 0)
+		rv = 1;
+	else {
+		eor = &result[resultlen];
+		p = memchr(result, ':', eor - result);
+		if (p != NULL && ++p < eor &&
+		    (q = memchr(p, ':', eor - p)) != NULL) {
+			if (q - p >= bufsize)
+				rv = -1;
+			else {
+				memcpy(buffer, p, q - p);
+				buffer[q - p] ='\0';
+			}
+		} else
+			rv = 1;
+	}
+	free(result);
+	return (rv);
+}
+
+
+static int
+nis_setpwent(void *retval, void *mdata, va_list ap)
+{
+	struct nis_state	*st;
+	int			 rv;
+
+	rv = nis_getstate(&st);
+	if (rv != 0)
+		return (NS_UNAVAIL);
+	st->done = 0;
+	free(st->key);
+	st->key = NULL;
+	return (NS_UNAVAIL);
+}
+
+
+static int
+nis_passwd(void *retval, void *mdata, va_list ap)
+{
+	char		 map[YPMAXMAP];
+	struct nis_state *st;
+	struct passwd	*pwd;
+	const char	*name;
+	char		*buffer, *key, *result;
+	size_t		 bufsize;
+	uid_t		 uid;
+	enum nss_lookup_type how;
+	int		*errnop, keylen, resultlen, rv, master;
+
+	name = NULL;
+	uid = (uid_t)-1;
+	how = (enum nss_lookup_type)mdata;
+	switch (how) {
+	case nss_lt_name:
+		name = va_arg(ap, const char *);
+		break;
+	case nss_lt_id:
+		uid = va_arg(ap, uid_t);
+		break;
+	case nss_lt_all:
+		break;
+	}
+	pwd     = va_arg(ap, struct passwd *);
+	buffer  = va_arg(ap, char *);
+	bufsize = va_arg(ap, size_t);
+	errnop  = va_arg(ap, int *);
+	*errnop = nis_getstate(&st);
+	if (*errnop != 0)
+		return (NS_UNAVAIL);
+	if (st->domain[0] == '\0') {
+		if (getdomainname(st->domain, sizeof(st->domain)) != 0) {
+			*errnop = errno;
+			return (NS_UNAVAIL);
+		}
+	}
+	rv = nis_map(st->domain, how, map, sizeof(map), &master);
+	if (rv != NS_SUCCESS)
+		return (rv);
+	result = NULL;
+	do {
+		rv = NS_NOTFOUND;
+		switch (how) {
+		case nss_lt_name:
+			if (strlcpy(buffer, name, bufsize) >= bufsize)
+				goto erange;
+			break;
+		case nss_lt_id:
+			if (snprintf(buffer, bufsize, "%lu",
+			    (unsigned long)uid) >= bufsize)
+				goto erange;
+			break;
+		case nss_lt_all:
+			if (st->done)
+				goto fin;
+			break;
+		}
+		result = NULL;
+		if (how == nss_lt_all) {
+			if (st->key == NULL)
+				rv = yp_first(st->domain, map, &st->key,
+				    &st->keylen, &result, &resultlen);
+			else {
+				key = st->key;
+				keylen = st->keylen;
+				st->key = NULL;
+				rv = yp_next(st->domain, map, key, keylen,
+				    &st->key, &st->keylen, &result,
+				    &resultlen);
+				free(key);
+			}
+			if (rv != 0) {
+				free(result);
+				free(st->key);
+				st->key = NULL;
+				if (rv == YPERR_NOMORE)
+					st->done = 1;
+				else
+					rv = NS_UNAVAIL;
+				goto fin;
+			}
+		} else {
+			rv = yp_match(st->domain, map, buffer, strlen(buffer),
+			    &result, &resultlen);
+			if (rv == YPERR_KEY) {
+				rv = NS_NOTFOUND;
+				continue;
+			} else if (rv != 0) {
+				free(result);
+				rv = NS_UNAVAIL;
+				continue;
+			}
+		}
+		if (resultlen >= bufsize)
+			goto erange;
+		memcpy(buffer, result, resultlen);
+		buffer[resultlen] = '\0';
+		free(result);
+		rv = __pw_match_entry(buffer, resultlen, how, name, uid);
+		if (rv == NS_SUCCESS)
+			rv = __pw_parse_entry(buffer, resultlen, pwd, master,
+			    errnop);
+	} while (how == nss_lt_all && !(rv & NS_TERMINATE));
+fin:
+	if (rv == NS_SUCCESS) {
+		if (strstr(pwd->pw_passwd, "##") != NULL) {
+			rv = nis_adjunct(st->domain, pwd->pw_name,
+			    &buffer[resultlen+1], bufsize-resultlen-1);
+			if (rv < 0)
+				goto erange;
+			else if (rv == 0)
+				pwd->pw_passwd = &buffer[resultlen+1];
+		}
+		pwd->pw_fields &= ~_PWF_SOURCE;
+		pwd->pw_fields |= _PWF_NIS;
+		if (retval != NULL)
+			*(struct passwd **)retval = pwd;
+		rv = NS_SUCCESS;
+	}
+	return (rv);
+erange:
+	*errnop = ERANGE;
+	return (NS_RETURN);
+}
+#endif /* YP */
+
+
+/*
+ * compat backend
+ */
+static void
+compat_clear_template(struct passwd *template)
+{
+
+	free(template->pw_passwd);
+	free(template->pw_gecos);
+	free(template->pw_dir);
+	free(template->pw_shell);
+	memset(template, 0, sizeof(*template));
+}
+
+
+static int
+compat_set_template(struct passwd *src, struct passwd *template)
+{
+
+	compat_clear_template(template);
+#ifdef PW_OVERRIDE_PASSWD
+	if ((src->pw_fields & _PWF_PASSWD) &&
+	    (template->pw_passwd = strdup(src->pw_passwd)) == NULL)
+		goto enomem;
+#endif
+	if (src->pw_fields & _PWF_UID)
+		template->pw_uid = src->pw_uid;
+	if (src->pw_fields & _PWF_GID)
+		template->pw_gid = src->pw_gid;
+	if ((src->pw_fields & _PWF_GECOS) &&
+	    (template->pw_gecos = strdup(src->pw_gecos)) == NULL)
+		goto enomem;
+	if ((src->pw_fields & _PWF_DIR) &&
+	    (template->pw_dir = strdup(src->pw_dir)) == NULL)
+		goto enomem;
+	if ((src->pw_fields & _PWF_SHELL) &&
+	    (template->pw_shell = strdup(src->pw_shell)) == NULL)
+		goto enomem;
+	template->pw_fields = src->pw_fields;
+	return (0);
+enomem:
+	syslog(LOG_ERR, "getpwent memory allocation failure");
+	return (-1);
+}
+
+
+static int
+compat_use_template(struct passwd *pwd, struct passwd *template, char *buffer,
+    size_t bufsize)
+{
+	struct passwd hold;
+	char	*copy, *p, *q, *eob;
+	size_t	 n;
+
+	/* We cannot know the layout of the password fields in `buffer',
+	 * so we have to copy everything.
+	 */
+	if (template->pw_fields == 0) /* nothing to fill-in */
+		return (0);
+	n = 0;
+	n += pwd->pw_name != NULL ? strlen(pwd->pw_name) + 1 : 0;
+	n += pwd->pw_passwd != NULL ? strlen(pwd->pw_passwd) + 1 : 0;
+	n += pwd->pw_class != NULL ? strlen(pwd->pw_class) + 1 : 0;
+	n += pwd->pw_gecos != NULL ? strlen(pwd->pw_gecos) + 1 : 0;
+	n += pwd->pw_dir != NULL ? strlen(pwd->pw_dir) + 1 : 0;
+	n += pwd->pw_shell != NULL ? strlen(pwd->pw_shell) + 1 : 0;
+	copy = malloc(n);
+	if (copy == NULL) {
+		syslog(LOG_ERR, "getpwent memory allocation failure");
+		return (ENOMEM);
+	}
+	p = copy;
+	eob = &copy[n];
+#define COPY(field) do {				\
+	if (pwd->field == NULL)				\
+		hold.field = NULL;			\
+	else {						\
+		hold.field = p;				\
+		p += strlcpy(p, pwd->field, eob-p) + 1;	\
+	}						\
+} while (0)
+	COPY(pw_name);
+	COPY(pw_passwd);
+	COPY(pw_class);
+	COPY(pw_gecos);
+	COPY(pw_dir);
+	COPY(pw_shell);
+#undef COPY
+	p = buffer;
+	eob = &buffer[bufsize];
+#define COPY(field, flag) do {						 \
+	q = (template->pw_fields & flag) ? template->field : hold.field; \
+	if (q == NULL)							 \
+		pwd->field = NULL;					 \
+	else {								 \
+		pwd->field = p;						 \
+		if ((n = strlcpy(p, q, eob-p)) >= eob-p) {		 \
+			free(copy);					 \
+			return (ERANGE);				 \
+		}							 \
+		p += n + 1;						 \
+	}								 \
+} while (0)
+	COPY(pw_name, 0);
+#ifdef PW_OVERRIDE_PASSWD
+	COPY(pw_passwd, _PWF_PASSWD);
+#else
+	COPY(pw_passwd, 0);
+#endif
+	COPY(pw_class, 0);
+	COPY(pw_gecos, _PWF_GECOS);
+	COPY(pw_dir, _PWF_DIR);
+	COPY(pw_shell, _PWF_SHELL);
+#undef COPY
+#define COPY(field, flag) do {			\
+	if (template->pw_fields & flag)		\
+		pwd->field = template->field;	\
+} while (0)
+	COPY(pw_uid, _PWF_UID);
+	COPY(pw_gid, _PWF_GID);
+#undef COPY
+	free(copy);
+	return (0);
+}
+
+
+static int
+compat_exclude(const char *name, DB **db)
+{
+	DBT	key, data;
+
+	if (*db == NULL &&
+	    (*db = dbopen(NULL, O_RDWR, 600, DB_HASH, 0)) == NULL)
+		return (errno);
+	key.size = strlen(name);
+	key.data = (char *)name;
+	data.size = 0;
+	data.data = NULL;
+
+	if ((*db)->put(*db, &key, &data, 0) == -1)
+		return (errno);
+	return (0);
+}
+
+
+static int
+compat_is_excluded(const char *name, DB *db)
+{
+	DBT	key, data;
+
+	if (db == NULL)
+		return (0);
+	key.size = strlen(name);
+	key.data = (char *)name;
+	return (db->get(db, &key, &data, 0) == 0);
+}
+
+
+static int
+compat_redispatch(struct compat_state *st, enum nss_lookup_type how,
+    enum nss_lookup_type lookup_how, const char *name, const char *lookup_name,
+    uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, int *errnop)
+{
+	static const ns_src compatsrc[] = {
+#ifdef YP
+		{ NSSRC_NIS, NS_SUCCESS },
+#endif
+		{ NULL, 0 }
+	};
+	ns_dtab dtab[] = {
+#ifdef YP
+		{ NSSRC_NIS, nis_passwd, NULL },
+#endif
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_passwd, NULL },
+#endif
+		{ NULL, NULL, NULL }
+	};
+	void		*discard;
+	int		 rv, e, i;
+
+	for (i = 0; i < sizeof(dtab)/sizeof(dtab[0]) - 1; i++)
+		dtab[i].mdata = (void *)lookup_how;
+more:
+	pwd_init(pwd);
+	switch (lookup_how) {
+	case nss_lt_all:
+		rv = _nsdispatch(&discard, dtab, NSDB_PASSWD_COMPAT,
+		    "getpwent_r", compatsrc, pwd, buffer, bufsize,
+		    errnop);
+		break;
+	case nss_lt_id:
+		rv = _nsdispatch(&discard, dtab, NSDB_PASSWD_COMPAT,
+		    "getpwuid_r", compatsrc, uid, pwd, buffer,
+		    bufsize, errnop);
+		break;
+	case nss_lt_name:
+		rv = _nsdispatch(&discard, dtab, NSDB_PASSWD_COMPAT,
+		    "getpwnam_r", compatsrc, lookup_name, pwd, buffer,
+		    bufsize, errnop);
+		break;
+	default:
+		return (NS_UNAVAIL);
+	}
+	if (rv != NS_SUCCESS)
+		return (rv);
+	if (compat_is_excluded(pwd->pw_name, st->exclude)) {
+		if (how == nss_lt_all)
+			goto more;
+		return (NS_NOTFOUND);
+	}
+	e = compat_use_template(pwd, &st->template, buffer, bufsize);
+	if (e != 0) {
+		*errnop = e;
+		if (e == ERANGE)
+			return (NS_RETURN);
+		else
+			return (NS_UNAVAIL);
+	}
+	switch (how) {
+	case nss_lt_name:
+		if (strcmp(name, pwd->pw_name) != 0)
+			return (NS_NOTFOUND);
+		break;
+	case nss_lt_id:
+		if (uid != pwd->pw_uid)
+			return (NS_NOTFOUND);
+		break;
+	default:
+		break;
+	}
+	return (NS_SUCCESS);
+}
+
+
+static void
+compat_endstate(void *p)
+{
+	struct compat_state *st;
+
+	if (p == NULL)
+		return;
+	st = (struct compat_state *)p;
+	if (st->db != NULL)
+		st->db->close(st->db);
+	if (st->exclude != NULL)
+		st->exclude->close(st->exclude);
+	compat_clear_template(&st->template);
+	free(p);
+}
+
+
+static int
+compat_setpwent(void *retval, void *mdata, va_list ap)
+{
+	static const ns_src compatsrc[] = {
+#ifdef YP
+		{ NSSRC_NIS, NS_SUCCESS },
+#endif
+		{ NULL, 0 }
+	};
+	ns_dtab dtab[] = {
+#ifdef YP
+		{ NSSRC_NIS, nis_setpwent, NULL },
+#endif
+#ifdef HESIOD
+		{ NSSRC_DNS, dns_setpwent, NULL },
+#endif
+		{ NULL, NULL, NULL }
+	};
+	struct compat_state	*st;
+	int			 rv, stayopen;
+
+#define set_setent(x, y) do {	 				\
+	int i;							\
+								\
+	for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++)	\
+		x[i].mdata = (void *)y;				\
+} while (0)
+
+	rv = compat_getstate(&st);
+	if (rv != 0)
+		return (NS_UNAVAIL);
+	switch ((enum constants)mdata) {
+	case SETPWENT:
+		stayopen = va_arg(ap, int);
+		st->keynum = 0;
+		if (stayopen)
+			st->db = pwdbopen(&st->version);
+		st->stayopen = stayopen;
+		set_setent(dtab, mdata);
+		(void)_nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "setpwent",
+		    compatsrc, 0);
+		break;
+	case ENDPWENT:
+		if (st->db != NULL) {
+			(void)st->db->close(st->db);
+			st->db = NULL;
+		}
+		set_setent(dtab, mdata);
+		(void)_nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "endpwent",
+		    compatsrc, 0);
+		break;
+	default:
+		break;
+	}
+	return (NS_UNAVAIL);
+#undef set_setent
+}
+
+
+static int
+compat_passwd(void *retval, void *mdata, va_list ap)
+{
+	char			 keybuf[MAXLOGNAME + 1];
+	DBT			 key, entry;
+	struct compat_state	*st;
+	enum nss_lookup_type	 how;
+	const char		*name;
+	struct passwd		*pwd;
+	char			*buffer, *pw_name;
+	char			*host, *user, *domain;
+	size_t			 bufsize;
+	uid_t			 uid;
+	uint32_t		 store;
+	int			 rv, from_compat, stayopen, *errnop;
+
+	from_compat = 0;
+	name = NULL;
+	uid = (uid_t)-1;
+	how = (enum nss_lookup_type)mdata;
+	switch (how) {
+	case nss_lt_name:
+		name = va_arg(ap, const char *);
+		break;
+	case nss_lt_id:
+		uid = va_arg(ap, uid_t);
+		break;
+	case nss_lt_all:
+		break;
+	default:
+		rv = NS_NOTFOUND;
+		goto fin;
+	}
+	pwd = va_arg(ap, struct passwd *);
+	buffer = va_arg(ap, char *);
+	bufsize = va_arg(ap, size_t);
+	errnop = va_arg(ap, int *);
+	*errnop = compat_getstate(&st);
+	if (*errnop != 0)
+		return (NS_UNAVAIL);
+	if (how == nss_lt_all && st->keynum < 0) {
+		rv = NS_NOTFOUND;
+		goto fin;
+	}
+	if (st->db == NULL &&
+	    (st->db = pwdbopen(&st->version)) == NULL) {
+		*errnop = errno;
+		rv = NS_UNAVAIL;
+		goto fin;
+	}
+	if (how == nss_lt_all) {
+		if (st->keynum < 0) {
+			rv = NS_NOTFOUND;
+			goto fin;
+		}
+		stayopen = 1;
+	} else {
+		st->keynum = 0;
+		stayopen = st->stayopen;
+	}
+docompat:
+	rv = NS_NOTFOUND;
+	switch (st->compat) {
+	case COMPAT_MODE_ALL:
+		rv = compat_redispatch(st, how, how, name, name, uid, pwd,
+		    buffer, bufsize, errnop);
+		if (rv != NS_SUCCESS)
+			st->compat = COMPAT_MODE_OFF;
+		break;
+	case COMPAT_MODE_NETGROUP:
+		/* XXX getnetgrent is not thread-safe. */
+		do {
+			rv = getnetgrent(&host, &user, &domain);
+			if (rv == 0) {
+				endnetgrent();
+				st->compat = COMPAT_MODE_OFF;
+				rv = NS_NOTFOUND;
+				continue;
+			} else if (user == NULL || user[0] == '\0')
+				continue;
+			rv = compat_redispatch(st, how, nss_lt_name, name,
+			    user, uid, pwd, buffer, bufsize, errnop);
+		} while (st->compat == COMPAT_MODE_NETGROUP &&
+		    !(rv & NS_TERMINATE));
+		break;
+	case COMPAT_MODE_NAME:
+		rv = compat_redispatch(st, how, nss_lt_name, name, st->name,
+		    uid, pwd, buffer, bufsize, errnop);
+		free(st->name);
+		st->name = NULL;
+		st->compat = COMPAT_MODE_OFF;
+		break;
+	default:
+		break;
+	}
+	if (rv & NS_TERMINATE) {
+		from_compat = 1;
+		goto fin;
+	}
+	key.data = keybuf;
+	rv = NS_NOTFOUND;
+	while (st->keynum >= 0) {
+		st->keynum++;
+		if (st->version < _PWD_CURRENT_VERSION) {
+			memcpy(&keybuf[1], &st->keynum, sizeof(st->keynum));
+			key.size = sizeof(st->keynum) + 1;
+		} else {
+			store = htonl(st->keynum);
+			memcpy(&keybuf[1], &store, sizeof(store));
+			key.size = sizeof(store) + 1;
+		}
+		keybuf[0] = _PW_VERSIONED(_PW_KEYBYNUM, st->version);
+		rv = st->db->get(st->db, &key, &entry, 0);
+		if (rv < 0 || rv > 1) { /* should never return > 1 */
+			*errnop = errno;
+			rv = NS_UNAVAIL;
+			goto fin;
+		} else if (rv == 1) {
+			st->keynum = -1;
+			rv = NS_NOTFOUND;
+			goto fin;
+		}
+		pw_name = (char *)entry.data;
+		switch (pw_name[0]) {
+		case '+':
+			switch (pw_name[1]) {
+			case '\0':
+				st->compat = COMPAT_MODE_ALL;
+				break;
+			case '@':
+				setnetgrent(&pw_name[2]);
+				st->compat = COMPAT_MODE_NETGROUP;
+				break;
+			default:
+				st->name = strdup(&pw_name[1]);
+				if (st->name == NULL) {
+					syslog(LOG_ERR,
+					 "getpwent memory allocation failure");
+					*errnop = ENOMEM;
+					rv = NS_UNAVAIL;
+					break;
+				}
+				st->compat = COMPAT_MODE_NAME;
+			}
+			if (entry.size > bufsize) {
+				*errnop = ERANGE;
+				rv = NS_RETURN;
+				goto fin;
+			}
+			memcpy(buffer, entry.data, entry.size);
+			rv = pwdb_versions[st->version].parse(buffer,
+			    entry.size, pwd, errnop);
+			if (rv != NS_SUCCESS)
+				;
+			else if (compat_set_template(pwd, &st->template) < 0) {
+				*errnop = ENOMEM;
+				rv = NS_UNAVAIL;
+				goto fin;
+			}
+			goto docompat;
+		case '-':
+			switch (pw_name[1]) {
+			case '\0':
+				/* XXX Maybe syslog warning */
+				continue;
+			case '@':
+				setnetgrent(&pw_name[2]);
+				while (getnetgrent(&host, &user, &domain) !=
+				    0) {
+					if (user != NULL && user[0] != '\0')
+						compat_exclude(user,
+						    &st->exclude);
+				}
+				endnetgrent();
+				continue;
+			default:
+				compat_exclude(&pw_name[1], &st->exclude);
+				continue;
+			}
+			break;
+		default:
+			break;
+		}
+		if (compat_is_excluded((char *)entry.data, st->exclude))
+			continue;
+		rv = pwdb_versions[st->version].match(entry.data, entry.size,
+		    how, name, uid);
+		if (rv == NS_RETURN)
+			break;
+		else if (rv != NS_SUCCESS)
+			continue;
+		if (entry.size > bufsize) {
+			*errnop = ERANGE;
+			rv = NS_RETURN;
+			break;
+		}
+		memcpy(buffer, entry.data, entry.size);
+		rv = pwdb_versions[st->version].parse(buffer, entry.size, pwd,
+		    errnop);
+		if (rv & NS_TERMINATE)
+			break;
+	}
+fin:
+	if (!stayopen && st->db != NULL) {
+		(void)st->db->close(st->db);
+		st->db = NULL;
+	}
+	if (rv == NS_SUCCESS) {
+		if (!from_compat) {
+			pwd->pw_fields &= ~_PWF_SOURCE;
+			pwd->pw_fields |= _PWF_FILES;
+		}
+		if (retval != NULL)
+			*(struct passwd **)retval = pwd;
+	}
+	return (rv);
+}
+
+
+/*
+ * common passwd line matching and parsing
+ */
+int
+__pw_match_entry(const char *entry, size_t entrysize, enum nss_lookup_type how,
+    const char *name, uid_t uid)
+{
+	const char	*p, *eom;
+	char		*q;
+	size_t		 len;
+	unsigned long	 m;
+
+	eom = entry + entrysize;
+	for (p = entry; p < eom; p++)
+		if (*p == ':')
+			break;
+	if (*p != ':')
+		return (NS_NOTFOUND);
+	if (how == nss_lt_all)
+		return (NS_SUCCESS);
+	if (how == nss_lt_name) {
+		len = strlen(name);
+		if (len == (p - entry) && memcmp(name, entry, len) == 0)
+			return (NS_SUCCESS);
+		else
+			return (NS_NOTFOUND);
+	}
+	for (p++; p < eom; p++)
+		if (*p == ':')
+			break;
+	if (*p != ':')
+		return (NS_NOTFOUND);
+	m = strtoul(++p, &q, 10);
+	if (q[0] != ':' || (uid_t)m != uid)
+		return (NS_NOTFOUND);
+	else
+		return (NS_SUCCESS);
+}
+
+
+/* XXX buffer must be NUL-terminated.  errnop is not set correctly. */
+int
+__pw_parse_entry(char *buffer, size_t bufsize __unused, struct passwd *pwd,
+    int master, int *errnop __unused)
+{
+
+	if (__pw_scan(buffer, pwd, master ? _PWSCAN_MASTER : 0) == 0)
+		return (NS_NOTFOUND);
+	else
+		return (NS_SUCCESS);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/getusershell.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/getusershell.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/getusershell.c	(revision 2404)
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 1985, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getusershell.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+/*	$NetBSD: getusershell.c,v 1.17 1999/01/25 01:09:34 lukem Exp $	*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/getusershell.c,v 1.9 2003/04/24 20:16:21 nectar Exp $");
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/file.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <nsswitch.h>
+#include <paths.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stringlist.h>
+#include <unistd.h>
+
+#ifdef HESIOD
+#include <hesiod.h>
+#endif
+#ifdef YP
+#include <rpc/rpc.h>
+#include <rpcsvc/ypclnt.h>
+#include <rpcsvc/yp_prot.h>
+#endif
+#include "un-namespace.h"
+
+/*
+ * Local shells should NOT be added here.  They should be added in
+ * /etc/shells.
+ */
+
+static const char *const okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL };
+static const char *const *curshell;
+static StringList	 *sl;
+
+static const char *const *initshells(void);
+
+/*
+ * Get a list of shells from "shells" nsswitch database
+ */
+char *
+getusershell(void)
+{
+	char *ret;
+
+	if (curshell == NULL)
+		curshell = initshells();
+	/*LINTED*/
+	ret = (char *)*curshell;
+	if (ret != NULL)
+		curshell++;
+	return (ret);
+}
+
+void
+endusershell(void)
+{
+	if (sl) {
+		sl_free(sl, 1);
+		sl = NULL;
+	}
+	curshell = NULL;
+}
+
+void
+setusershell(void)
+{
+
+	curshell = initshells();
+}
+
+
+static int	_local_initshells(void *, void *, va_list);
+
+/*ARGSUSED*/
+static int
+_local_initshells(rv, cb_data, ap)
+	void	*rv;
+	void	*cb_data;
+	va_list	 ap;
+{
+	char	*sp, *cp;
+	FILE	*fp;
+	char	 line[MAXPATHLEN + 2];
+
+	if (sl)
+		sl_free(sl, 1);
+	sl = sl_init();
+
+	if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
+		return NS_UNAVAIL;
+
+	sp = cp = line;
+	while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
+		while (*cp != '#' && *cp != '/' && *cp != '\0')
+			cp++;
+		if (*cp == '#' || *cp == '\0')
+			continue;
+		sp = cp;
+		while (!isspace(*cp) && *cp != '#' && *cp != '\0')
+			cp++;
+		*cp++ = '\0';
+		sl_add(sl, strdup(sp));
+	}
+	(void)fclose(fp);
+	return NS_SUCCESS;
+}
+
+#ifdef HESIOD
+static int	_dns_initshells(void *, void *, va_list);
+
+/*ARGSUSED*/
+static int
+_dns_initshells(rv, cb_data, ap)
+	void	*rv;
+	void	*cb_data;
+	va_list	 ap;
+{
+	char	  shellname[] = "shells-XXXXX";
+	int	  hsindex, hpi, r;
+	char	**hp;
+	void	 *context;
+
+	if (sl)
+		sl_free(sl, 1);
+	sl = sl_init();
+	r = NS_UNAVAIL;
+	if (hesiod_init(&context) == -1)
+		return (r);
+
+	for (hsindex = 0; ; hsindex++) {
+		snprintf(shellname, sizeof(shellname)-1, "shells-%d", hsindex);
+		hp = hesiod_resolve(context, shellname, "shells");
+		if (hp == NULL) {
+			if (errno == ENOENT) {
+				if (hsindex == 0)
+					r = NS_NOTFOUND;
+				else
+					r = NS_SUCCESS;
+			}
+			break;
+		} else {
+			for (hpi = 0; hp[hpi]; hpi++)
+				sl_add(sl, hp[hpi]);
+			free(hp);
+		}
+	}
+	hesiod_end(context);
+	return (r);
+}
+#endif /* HESIOD */
+
+#ifdef YP
+static int	_nis_initshells(void *, void *, va_list);
+
+/*ARGSUSED*/
+static int
+_nis_initshells(rv, cb_data, ap)
+	void	*rv;
+	void	*cb_data;
+	va_list	 ap;
+{
+	static char *ypdomain;
+	char	*key, *data;
+	char	*lastkey;
+	int	 keylen, datalen;
+	int	 r;
+
+	if (sl)
+		sl_free(sl, 1);
+	sl = sl_init();
+
+	if (ypdomain == NULL) {
+		switch (yp_get_default_domain(&ypdomain)) {
+		case 0:
+			break;
+		case YPERR_RESRC:
+			return NS_TRYAGAIN;
+		default:
+			return NS_UNAVAIL;
+		}
+	}
+
+	/*
+	 * `key' and `data' point to strings dynamically allocated by
+	 * the yp_... functions.
+	 * `data' is directly put into the stringlist of shells.
+	 */
+	key = data = NULL;
+	if (yp_first(ypdomain, "shells", &key, &keylen, &data, &datalen))
+		return NS_UNAVAIL;
+	do {
+		data[datalen] = '\0';		/* clear trailing \n */
+		sl_add(sl, data);
+
+		lastkey = key;
+		r = yp_next(ypdomain, "shells", lastkey, keylen,
+		    &key, &keylen, &data, &datalen);
+		free(lastkey);
+	} while (r == 0);
+	
+	if (r == YPERR_NOMORE) {
+		/*
+		 * `data' and `key' ought to be NULL - do not try to free them.
+		 */
+		return NS_SUCCESS;
+	}
+
+	return NS_UNAVAIL;
+}
+#endif /* YP */
+
+static const char *const *
+initshells()
+{
+	static const ns_dtab dtab[] = {
+		NS_FILES_CB(_local_initshells, NULL)
+		NS_DNS_CB(_dns_initshells, NULL)
+		NS_NIS_CB(_nis_initshells, NULL)
+		{ 0 }
+	};
+	if (sl)
+		sl_free(sl, 1);
+	sl = sl_init();
+
+	if (_nsdispatch(NULL, dtab, NSDB_SHELLS, "initshells", __nsdefaultsrc)
+	    != NS_SUCCESS) {
+		if (sl)
+			sl_free(sl, 1);
+		sl = NULL;
+		return (okshells);
+	}
+	sl_add(sl, NULL);
+
+	return (const char *const *)(sl->sl_str);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/glob.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/glob.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/glob.c	(revision 2404)
@@ -0,0 +1,956 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guido van Rossum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)glob.c	8.3 (Berkeley) 10/13/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.22 2004/07/29 03:48:52 tjr Exp $");
+
+/*
+ * glob(3) -- a superset of the one defined in POSIX 1003.2.
+ *
+ * The [!...] convention to negate a range is supported (SysV, Posix, ksh).
+ *
+ * Optional extra services, controlled by flags not defined by POSIX:
+ *
+ * GLOB_QUOTE:
+ *	Escaping convention: \ inhibits any special meaning the following
+ *	character might have (except \ at end of string is retained).
+ * GLOB_MAGCHAR:
+ *	Set in gl_flags if pattern contained a globbing character.
+ * GLOB_NOMAGIC:
+ *	Same as GLOB_NOCHECK, but it will only append pattern if it did
+ *	not contain any magic characters.  [Used in csh style globbing]
+ * GLOB_ALTDIRFUNC:
+ *	Use alternately specified directory access functions.
+ * GLOB_TILDE:
+ *	expand ~user/foo to the /home/dir/of/user/foo
+ * GLOB_BRACE:
+ *	expand {1,2}{a,b} to 1a 1b 2a 2b
+ * gl_matchc:
+ *	Number of matches in the current invocation of glob.
+ */
+
+/*
+ * Some notes on multibyte character support:
+ * 1. Patterns with illegal byte sequences match nothing - even if
+ *    GLOB_NOCHECK is specified.
+ * 2. Illegal byte sequences in filenames are handled by treating them as
+ *    single-byte characters with a value of the first byte of the sequence
+ *    cast to wchar_t.
+ * 3. State-dependent encodings are not currently supported.
+ */
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <glob.h>
+#include <limits.h>
+#include <pwd.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wchar.h>
+
+#include "collate.h"
+
+#define	DOLLAR		'$'
+#define	DOT		'.'
+#define	EOS		'\0'
+#define	LBRACKET	'['
+#define	NOT		'!'
+#define	QUESTION	'?'
+#define	QUOTE		'\\'
+#define	RANGE		'-'
+#define	RBRACKET	']'
+#define	SEP		'/'
+#define	STAR		'*'
+#define	TILDE		'~'
+#define	UNDERSCORE	'_'
+#define	LBRACE		'{'
+#define	RBRACE		'}'
+#define	SLASH		'/'
+#define	COMMA		','
+
+#ifndef DEBUG
+
+#define	M_QUOTE		0x8000000000ULL
+#define	M_PROTECT	0x4000000000ULL
+#define	M_MASK		0xffffffffffULL
+#define	M_CHAR		0x00ffffffffULL
+
+typedef uint_fast64_t Char;
+
+#else
+
+#define	M_QUOTE		0x80
+#define	M_PROTECT	0x40
+#define	M_MASK		0xff
+#define	M_CHAR		0x7f
+
+typedef char Char;
+
+#endif
+
+
+#define	CHAR(c)		((Char)((c)&M_CHAR))
+#define	META(c)		((Char)((c)|M_QUOTE))
+#define	M_ALL		META('*')
+#define	M_END		META(']')
+#define	M_NOT		META('!')
+#define	M_ONE		META('?')
+#define	M_RNG		META('-')
+#define	M_SET		META('[')
+#define	ismeta(c)	(((c)&M_QUOTE) != 0)
+
+
+static int	 compare(const void *, const void *);
+static int	 g_Ctoc(const Char *, char *, u_int);
+static int	 g_lstat(Char *, struct stat *, glob_t *);
+static DIR	*g_opendir(Char *, glob_t *);
+static Char	*g_strchr(Char *, wchar_t);
+#ifdef notdef
+static Char	*g_strcat(Char *, const Char *);
+#endif
+static int	 g_stat(Char *, struct stat *, glob_t *);
+static int	 glob0(const Char *, glob_t *, int *);
+static int	 glob1(Char *, glob_t *, int *);
+static int	 glob2(Char *, Char *, Char *, Char *, glob_t *, int *);
+static int	 glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, int *);
+static int	 globextend(const Char *, glob_t *, int *);
+static const Char *	
+		 globtilde(const Char *, Char *, size_t, glob_t *);
+static int	 globexp1(const Char *, glob_t *, int *);
+static int	 globexp2(const Char *, const Char *, glob_t *, int *, int *);
+static int	 match(Char *, Char *, Char *);
+#ifdef DEBUG
+static void	 qprintf(const char *, Char *);
+#endif
+
+int
+glob(pattern, flags, errfunc, pglob)
+	const char *pattern;
+	int flags, (*errfunc)(const char *, int);
+	glob_t *pglob;
+{
+	const u_char *patnext;
+	int limit;
+	Char *bufnext, *bufend, patbuf[MAXPATHLEN], prot;
+	mbstate_t mbs;
+	wchar_t wc;
+	size_t clen;
+
+	patnext = (u_char *) pattern;
+	if (!(flags & GLOB_APPEND)) {
+		pglob->gl_pathc = 0;
+		pglob->gl_pathv = NULL;
+		if (!(flags & GLOB_DOOFFS))
+			pglob->gl_offs = 0;
+	}
+	if (flags & GLOB_LIMIT) {
+		limit = pglob->gl_matchc;
+		if (limit == 0)
+			limit = ARG_MAX;
+	} else
+		limit = 0;
+	pglob->gl_flags = flags & ~GLOB_MAGCHAR;
+	pglob->gl_errfunc = errfunc;
+	pglob->gl_matchc = 0;
+
+	bufnext = patbuf;
+	bufend = bufnext + MAXPATHLEN - 1;
+	if (flags & GLOB_NOESCAPE) {
+		memset(&mbs, 0, sizeof(mbs));
+		while (bufend - bufnext >= MB_CUR_MAX) {
+			clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
+			if (clen == (size_t)-1 || clen == (size_t)-2)
+				return (GLOB_NOMATCH);
+			else if (clen == 0)
+				break;
+			*bufnext++ = wc;
+			patnext += clen;
+		}
+	} else {
+		/* Protect the quoted characters. */
+		memset(&mbs, 0, sizeof(mbs));
+		while (bufend - bufnext >= MB_CUR_MAX) {
+			if (*patnext == QUOTE) {
+				if (*++patnext == EOS) {
+					*bufnext++ = QUOTE | M_PROTECT;
+					continue;
+				}
+				prot = M_PROTECT;
+			} else
+				prot = 0;
+			clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
+			if (clen == (size_t)-1 || clen == (size_t)-2)
+				return (GLOB_NOMATCH);
+			else if (clen == 0)
+				break;
+			*bufnext++ = wc | prot;
+			patnext += clen;
+		}
+	}
+	*bufnext = EOS;
+
+	if (flags & GLOB_BRACE)
+	    return globexp1(patbuf, pglob, &limit);
+	else
+	    return glob0(patbuf, pglob, &limit);
+}
+
+/*
+ * Expand recursively a glob {} pattern. When there is no more expansion
+ * invoke the standard globbing routine to glob the rest of the magic
+ * characters
+ */
+static int
+globexp1(pattern, pglob, limit)
+	const Char *pattern;
+	glob_t *pglob;
+	int *limit;
+{
+	const Char* ptr = pattern;
+	int rv;
+
+	/* Protect a single {}, for find(1), like csh */
+	if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
+		return glob0(pattern, pglob, limit);
+
+	while ((ptr = (const Char *) g_strchr((Char *) ptr, LBRACE)) != NULL)
+		if (!globexp2(ptr, pattern, pglob, &rv, limit))
+			return rv;
+
+	return glob0(pattern, pglob, limit);
+}
+
+
+/*
+ * Recursive brace globbing helper. Tries to expand a single brace.
+ * If it succeeds then it invokes globexp1 with the new pattern.
+ * If it fails then it tries to glob the rest of the pattern and returns.
+ */
+static int
+globexp2(ptr, pattern, pglob, rv, limit)
+	const Char *ptr, *pattern;
+	glob_t *pglob;
+	int *rv, *limit;
+{
+	int     i;
+	Char   *lm, *ls;
+	const Char *pe, *pm, *pl;
+	Char    patbuf[MAXPATHLEN];
+
+	/* copy part up to the brace */
+	for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++)
+		continue;
+	*lm = EOS;
+	ls = lm;
+
+	/* Find the balanced brace */
+	for (i = 0, pe = ++ptr; *pe; pe++)
+		if (*pe == LBRACKET) {
+			/* Ignore everything between [] */
+			for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)
+				continue;
+			if (*pe == EOS) {
+				/*
+				 * We could not find a matching RBRACKET.
+				 * Ignore and just look for RBRACE
+				 */
+				pe = pm;
+			}
+		}
+		else if (*pe == LBRACE)
+			i++;
+		else if (*pe == RBRACE) {
+			if (i == 0)
+				break;
+			i--;
+		}
+
+	/* Non matching braces; just glob the pattern */
+	if (i != 0 || *pe == EOS) {
+		*rv = glob0(patbuf, pglob, limit);
+		return 0;
+	}
+
+	for (i = 0, pl = pm = ptr; pm <= pe; pm++)
+		switch (*pm) {
+		case LBRACKET:
+			/* Ignore everything between [] */
+			for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++)
+				continue;
+			if (*pm == EOS) {
+				/*
+				 * We could not find a matching RBRACKET.
+				 * Ignore and just look for RBRACE
+				 */
+				pm = pl;
+			}
+			break;
+
+		case LBRACE:
+			i++;
+			break;
+
+		case RBRACE:
+			if (i) {
+			    i--;
+			    break;
+			}
+			/* FALLTHROUGH */
+		case COMMA:
+			if (i && *pm == COMMA)
+				break;
+			else {
+				/* Append the current string */
+				for (lm = ls; (pl < pm); *lm++ = *pl++)
+					continue;
+				/*
+				 * Append the rest of the pattern after the
+				 * closing brace
+				 */
+				for (pl = pe + 1; (*lm++ = *pl++) != EOS;)
+					continue;
+
+				/* Expand the current pattern */
+#ifdef DEBUG
+				qprintf("globexp2:", patbuf);
+#endif
+				*rv = globexp1(patbuf, pglob, limit);
+
+				/* move after the comma, to the next string */
+				pl = pm + 1;
+			}
+			break;
+
+		default:
+			break;
+		}
+	*rv = 0;
+	return 0;
+}
+
+
+
+/*
+ * expand tilde from the passwd file.
+ */
+static const Char *
+globtilde(pattern, patbuf, patbuf_len, pglob)
+	const Char *pattern;
+	Char *patbuf;
+	size_t patbuf_len;
+	glob_t *pglob;
+{
+	struct passwd *pwd;
+	char *h;
+	const Char *p;
+	Char *b, *eb;
+
+	if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
+		return pattern;
+
+	/* 
+	 * Copy up to the end of the string or / 
+	 */
+	eb = &patbuf[patbuf_len - 1];
+	for (p = pattern + 1, h = (char *) patbuf;
+	    h < (char *)eb && *p && *p != SLASH; *h++ = *p++)
+		continue;
+
+	*h = EOS;
+
+	if (((char *) patbuf)[0] == EOS) {
+		/*
+		 * handle a plain ~ or ~/ by expanding $HOME first (iff
+		 * we're not running setuid or setgid) and then trying
+		 * the password file
+		 */
+		if (issetugid() != 0 ||
+		    (h = getenv("HOME")) == NULL) {
+			if (((h = getlogin()) != NULL &&
+			     (pwd = getpwnam(h)) != NULL) ||
+			    (pwd = getpwuid(getuid())) != NULL)
+				h = pwd->pw_dir;
+			else
+				return pattern;
+		}
+	}
+	else {
+		/*
+		 * Expand a ~user
+		 */
+		if ((pwd = getpwnam((char*) patbuf)) == NULL)
+			return pattern;
+		else
+			h = pwd->pw_dir;
+	}
+
+	/* Copy the home directory */
+	for (b = patbuf; b < eb && *h; *b++ = *h++)
+		continue;
+
+	/* Append the rest of the pattern */
+	while (b < eb && (*b++ = *p++) != EOS)
+		continue;
+	*b = EOS;
+
+	return patbuf;
+}
+
+
+/*
+ * The main glob() routine: compiles the pattern (optionally processing
+ * quotes), calls glob1() to do the real pattern matching, and finally
+ * sorts the list (unless unsorted operation is requested).  Returns 0
+ * if things went well, nonzero if errors occurred.
+ */
+static int
+glob0(pattern, pglob, limit)
+	const Char *pattern;
+	glob_t *pglob;
+	int *limit;
+{
+	const Char *qpatnext;
+	int c, err, oldpathc;
+	Char *bufnext, patbuf[MAXPATHLEN];
+
+	qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
+	oldpathc = pglob->gl_pathc;
+	bufnext = patbuf;
+
+	/* We don't need to check for buffer overflow any more. */
+	while ((c = *qpatnext++) != EOS) {
+		switch (c) {
+		case LBRACKET:
+			c = *qpatnext;
+			if (c == NOT)
+				++qpatnext;
+			if (*qpatnext == EOS ||
+			    g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) {
+				*bufnext++ = LBRACKET;
+				if (c == NOT)
+					--qpatnext;
+				break;
+			}
+			*bufnext++ = M_SET;
+			if (c == NOT)
+				*bufnext++ = M_NOT;
+			c = *qpatnext++;
+			do {
+				*bufnext++ = CHAR(c);
+				if (*qpatnext == RANGE &&
+				    (c = qpatnext[1]) != RBRACKET) {
+					*bufnext++ = M_RNG;
+					*bufnext++ = CHAR(c);
+					qpatnext += 2;
+				}
+			} while ((c = *qpatnext++) != RBRACKET);
+			pglob->gl_flags |= GLOB_MAGCHAR;
+			*bufnext++ = M_END;
+			break;
+		case QUESTION:
+			pglob->gl_flags |= GLOB_MAGCHAR;
+			*bufnext++ = M_ONE;
+			break;
+		case STAR:
+			pglob->gl_flags |= GLOB_MAGCHAR;
+			/* collapse adjacent stars to one,
+			 * to avoid exponential behavior
+			 */
+			if (bufnext == patbuf || bufnext[-1] != M_ALL)
+			    *bufnext++ = M_ALL;
+			break;
+		default:
+			*bufnext++ = CHAR(c);
+			break;
+		}
+	}
+	*bufnext = EOS;
+#ifdef DEBUG
+	qprintf("glob0:", patbuf);
+#endif
+
+	if ((err = glob1(patbuf, pglob, limit)) != 0)
+		return(err);
+
+	/*
+	 * If there was no match we are going to append the pattern
+	 * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
+	 * and the pattern did not contain any magic characters
+	 * GLOB_NOMAGIC is there just for compatibility with csh.
+	 */
+	if (pglob->gl_pathc == oldpathc) {
+		if (((pglob->gl_flags & GLOB_NOCHECK) ||
+		    ((pglob->gl_flags & GLOB_NOMAGIC) &&
+			!(pglob->gl_flags & GLOB_MAGCHAR))))
+			return(globextend(pattern, pglob, limit));
+		else
+			return(GLOB_NOMATCH);
+	}
+	if (!(pglob->gl_flags & GLOB_NOSORT))
+		qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
+		    pglob->gl_pathc - oldpathc, sizeof(char *), compare);
+	return(0);
+}
+
+static int
+compare(p, q)
+	const void *p, *q;
+{
+	return(strcmp(*(char **)p, *(char **)q));
+}
+
+static int
+glob1(pattern, pglob, limit)
+	Char *pattern;
+	glob_t *pglob;
+	int *limit;
+{
+	Char pathbuf[MAXPATHLEN];
+
+	/* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
+	if (*pattern == EOS)
+		return(0);
+	return(glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1,
+	    pattern, pglob, limit));
+}
+
+/*
+ * The functions glob2 and glob3 are mutually recursive; there is one level
+ * of recursion for each segment in the pattern that contains one or more
+ * meta characters.
+ */
+static int
+glob2(pathbuf, pathend, pathend_last, pattern, pglob, limit)
+	Char *pathbuf, *pathend, *pathend_last, *pattern;
+	glob_t *pglob;
+	int *limit;
+{
+	struct stat sb;
+	Char *p, *q;
+	int anymeta;
+
+	/*
+	 * Loop over pattern segments until end of pattern or until
+	 * segment with meta character found.
+	 */
+	for (anymeta = 0;;) {
+		if (*pattern == EOS) {		/* End of pattern? */
+			*pathend = EOS;
+			if (g_lstat(pathbuf, &sb, pglob))
+				return(0);
+
+			if (((pglob->gl_flags & GLOB_MARK) &&
+			    pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
+			    || (S_ISLNK(sb.st_mode) &&
+			    (g_stat(pathbuf, &sb, pglob) == 0) &&
+			    S_ISDIR(sb.st_mode)))) {
+				if (pathend + 1 > pathend_last)
+					return (GLOB_ABORTED);
+				*pathend++ = SEP;
+				*pathend = EOS;
+			}
+			++pglob->gl_matchc;
+			return(globextend(pathbuf, pglob, limit));
+		}
+
+		/* Find end of next segment, copy tentatively to pathend. */
+		q = pathend;
+		p = pattern;
+		while (*p != EOS && *p != SEP) {
+			if (ismeta(*p))
+				anymeta = 1;
+			if (q + 1 > pathend_last)
+				return (GLOB_ABORTED);
+			*q++ = *p++;
+		}
+
+		if (!anymeta) {		/* No expansion, do next segment. */
+			pathend = q;
+			pattern = p;
+			while (*pattern == SEP) {
+				if (pathend + 1 > pathend_last)
+					return (GLOB_ABORTED);
+				*pathend++ = *pattern++;
+			}
+		} else			/* Need expansion, recurse. */
+			return(glob3(pathbuf, pathend, pathend_last, pattern, p,
+			    pglob, limit));
+	}
+	/* NOTREACHED */
+}
+
+static int
+glob3(pathbuf, pathend, pathend_last, pattern, restpattern, pglob, limit)
+	Char *pathbuf, *pathend, *pathend_last, *pattern, *restpattern;
+	glob_t *pglob;
+	int *limit;
+{
+	struct dirent *dp;
+	DIR *dirp;
+	int err;
+	char buf[MAXPATHLEN];
+
+	/*
+	 * The readdirfunc declaration can't be prototyped, because it is
+	 * assigned, below, to two functions which are prototyped in glob.h
+	 * and dirent.h as taking pointers to differently typed opaque
+	 * structures.
+	 */
+	struct dirent *(*readdirfunc)();
+
+	if (pathend > pathend_last)
+		return (GLOB_ABORTED);
+	*pathend = EOS;
+	errno = 0;
+
+	if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
+		/* TODO: don't call for ENOENT or ENOTDIR? */
+		if (pglob->gl_errfunc) {
+			if (g_Ctoc(pathbuf, buf, sizeof(buf)))
+				return (GLOB_ABORTED);
+			if (pglob->gl_errfunc(buf, errno) ||
+			    pglob->gl_flags & GLOB_ERR)
+				return (GLOB_ABORTED);
+		}
+		return(0);
+	}
+
+	err = 0;
+
+	/* Search directory for matching names. */
+	if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+		readdirfunc = pglob->gl_readdir;
+	else
+		readdirfunc = readdir;
+	while ((dp = (*readdirfunc)(dirp))) {
+		u_char *sc;
+		Char *dc;
+		wchar_t wc;
+		size_t clen;
+		mbstate_t mbs;
+
+		/* Initial DOT must be matched literally. */
+		if (dp->d_name[0] == DOT && *pattern != DOT)
+			continue;
+		memset(&mbs, 0, sizeof(mbs));
+		dc = pathend;
+		sc = (u_char *) dp->d_name;
+		while (dc < pathend_last) {
+			clen = mbrtowc(&wc, sc, MB_LEN_MAX, &mbs);
+			if (clen == (size_t)-1 || clen == (size_t)-2) {
+				wc = *sc;
+				clen = 1;
+				memset(&mbs, 0, sizeof(mbs));
+			}
+			if ((*dc++ = wc) == EOS)
+				break;
+			sc += clen;
+		}
+		if (!match(pathend, pattern, restpattern)) {
+			*pathend = EOS;
+			continue;
+		}
+		err = glob2(pathbuf, --dc, pathend_last, restpattern,
+		    pglob, limit);
+		if (err)
+			break;
+	}
+
+	if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+		(*pglob->gl_closedir)(dirp);
+	else
+		closedir(dirp);
+	return(err);
+}
+
+
+/*
+ * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
+ * add the new item, and update gl_pathc.
+ *
+ * This assumes the BSD realloc, which only copies the block when its size
+ * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic
+ * behavior.
+ *
+ * Return 0 if new item added, error code if memory couldn't be allocated.
+ *
+ * Invariant of the glob_t structure:
+ *	Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
+ *	gl_pathv points to (gl_offs + gl_pathc + 1) items.
+ */
+static int
+globextend(path, pglob, limit)
+	const Char *path;
+	glob_t *pglob;
+	int *limit;
+{
+	char **pathv;
+	int i;
+	u_int newsize, len;
+	char *copy;
+	const Char *p;
+
+	if (*limit && pglob->gl_pathc > *limit) {
+		errno = 0;
+		return (GLOB_NOSPACE);
+	}
+
+	newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
+	pathv = pglob->gl_pathv ?
+		    realloc((char *)pglob->gl_pathv, newsize) :
+		    malloc(newsize);
+	if (pathv == NULL) {
+		if (pglob->gl_pathv) {
+			free(pglob->gl_pathv);
+			pglob->gl_pathv = NULL;
+		}
+		return(GLOB_NOSPACE);
+	}
+
+	if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
+		/* first time around -- clear initial gl_offs items */
+		pathv += pglob->gl_offs;
+		for (i = pglob->gl_offs; --i >= 0; )
+			*--pathv = NULL;
+	}
+	pglob->gl_pathv = pathv;
+
+	for (p = path; *p++;)
+		continue;
+	len = MB_CUR_MAX * (size_t)(p - path);	/* XXX overallocation */
+	if ((copy = malloc(len)) != NULL) {
+		if (g_Ctoc(path, copy, len)) {
+			free(copy);
+			return (GLOB_NOSPACE);
+		}
+		pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
+	}
+	pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
+	return(copy == NULL ? GLOB_NOSPACE : 0);
+}
+
+/*
+ * pattern matching function for filenames.  Each occurrence of the *
+ * pattern causes a recursion level.
+ */
+static int
+match(name, pat, patend)
+	Char *name, *pat, *patend;
+{
+	int ok, negate_range;
+	Char c, k;
+
+	while (pat < patend) {
+		c = *pat++;
+		switch (c & M_MASK) {
+		case M_ALL:
+			if (pat == patend)
+				return(1);
+			do
+			    if (match(name, pat, patend))
+				    return(1);
+			while (*name++ != EOS);
+			return(0);
+		case M_ONE:
+			if (*name++ == EOS)
+				return(0);
+			break;
+		case M_SET:
+			ok = 0;
+			if ((k = *name++) == EOS)
+				return(0);
+			if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
+				++pat;
+			while (((c = *pat++) & M_MASK) != M_END)
+				if ((*pat & M_MASK) == M_RNG) {
+					if (__collate_load_error ?
+					    CHAR(c) <= CHAR(k) && CHAR(k) <= CHAR(pat[1]) :
+					       __collate_range_cmp(CHAR(c), CHAR(k)) <= 0
+					    && __collate_range_cmp(CHAR(k), CHAR(pat[1])) <= 0
+					   )
+						ok = 1;
+					pat += 2;
+				} else if (c == k)
+					ok = 1;
+			if (ok == negate_range)
+				return(0);
+			break;
+		default:
+			if (*name++ != c)
+				return(0);
+			break;
+		}
+	}
+	return(*name == EOS);
+}
+
+/* Free allocated data belonging to a glob_t structure. */
+void
+globfree(pglob)
+	glob_t *pglob;
+{
+	int i;
+	char **pp;
+
+	if (pglob->gl_pathv != NULL) {
+		pp = pglob->gl_pathv + pglob->gl_offs;
+		for (i = pglob->gl_pathc; i--; ++pp)
+			if (*pp)
+				free(*pp);
+		free(pglob->gl_pathv);
+		pglob->gl_pathv = NULL;
+	}
+}
+
+static DIR *
+g_opendir(str, pglob)
+	Char *str;
+	glob_t *pglob;
+{
+	char buf[MAXPATHLEN];
+
+	if (!*str)
+		strcpy(buf, ".");
+	else {
+		if (g_Ctoc(str, buf, sizeof(buf)))
+			return (NULL);
+	}
+
+	if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+		return((*pglob->gl_opendir)(buf));
+
+	return(opendir(buf));
+}
+
+static int
+g_lstat(fn, sb, pglob)
+	Char *fn;
+	struct stat *sb;
+	glob_t *pglob;
+{
+	char buf[MAXPATHLEN];
+
+	if (g_Ctoc(fn, buf, sizeof(buf))) {
+		errno = ENAMETOOLONG;
+		return (-1);
+	}
+	if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+		return((*pglob->gl_lstat)(buf, sb));
+	return(lstat(buf, sb));
+}
+
+static int
+g_stat(fn, sb, pglob)
+	Char *fn;
+	struct stat *sb;
+	glob_t *pglob;
+{
+	char buf[MAXPATHLEN];
+
+	if (g_Ctoc(fn, buf, sizeof(buf))) {
+		errno = ENAMETOOLONG;
+		return (-1);
+	}
+	if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+		return((*pglob->gl_stat)(buf, sb));
+	return(stat(buf, sb));
+}
+
+static Char *
+g_strchr(str, ch)
+	Char *str;
+	wchar_t ch;
+{
+	do {
+		if (*str == ch)
+			return (str);
+	} while (*str++);
+	return (NULL);
+}
+
+static int
+g_Ctoc(str, buf, len)
+	const Char *str;
+	char *buf;
+	u_int len;
+{
+	mbstate_t mbs;
+	size_t clen;
+
+	memset(&mbs, 0, sizeof(mbs));
+	while (len >= MB_CUR_MAX) {
+		clen = wcrtomb(buf, *str, &mbs);
+		if (clen == (size_t)-1)
+			return (1);
+		if (*str == L'\0')
+			return (0);
+		str++;
+		buf += clen;
+		len -= clen;
+	}
+	return (1);
+}
+
+#ifdef DEBUG
+static void
+qprintf(str, s)
+	const char *str;
+	Char *s;
+{
+	Char *p;
+
+	(void)printf("%s:\n", str);
+	for (p = s; *p; p++)
+		(void)printf("%c", CHAR(*p));
+	(void)printf("\n");
+	for (p = s; *p; p++)
+		(void)printf("%c", *p & M_PROTECT ? '"' : ' ');
+	(void)printf("\n");
+	for (p = s; *p; p++)
+		(void)printf("%c", ismeta(*p) ? '_' : ' ');
+	(void)printf("\n");
+}
+#endif
Index: /vendor/FreeBSD-libc/5.3/gen/initgroups.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/initgroups.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/initgroups.c	(revision 2404)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1983, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)initgroups.c	8.1 (Berkeley) 6/4/93";
+#endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/initgroups.c,v 1.8 2003/11/19 15:51:26 dds Exp $");
+
+#include <sys/param.h>
+
+#include <stdio.h>
+#include "namespace.h"
+#include <err.h>
+#include "un-namespace.h"
+#include <unistd.h>
+
+int
+initgroups(uname, agroup)
+	const char *uname;
+	gid_t agroup;
+{
+	int ngroups;
+	/*
+	 * Provide space for one group more than NGROUPS to allow
+	 * setgroups to fail and set errno.
+	 */
+	gid_t groups[NGROUPS + 1];
+
+	ngroups = NGROUPS + 1;
+	getgrouplist(uname, agroup, groups, &ngroups);
+	return (setgroups(ngroups, groups));
+}
Index: /vendor/FreeBSD-libc/5.3/gen/isinf.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/isinf.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/isinf.c	(revision 2404)
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: src/lib/libc/gen/isinf.c,v 1.2 2004/07/10 15:52:26 marcel Exp $
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+/*
+ * XXX These routines belong in libm, but they must remain in libc for
+ *     binary compat until we can bump libm's major version number.
+ */
+
+__weak_reference(__isinf, isinf);
+
+int
+__isinf(double d)
+{
+	union IEEEd2bits u;
+
+	u.d = d;
+	return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
+}
+
+int
+__isinff(float f)
+{
+	union IEEEf2bits u;
+
+	u.f = f;
+	return (u.bits.exp == 255 && u.bits.man == 0);
+}
+
+int
+__isinfl(long double e)
+{
+	union IEEEl2bits u;
+
+	u.e = e;
+	mask_nbit_l(u);
+#ifndef __alpha__
+	return (u.bits.exp == 32767 && u.bits.manl == 0 && u.bits.manh == 0);
+#else
+	return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
+#endif
+}
Index: /vendor/FreeBSD-libc/5.3/gen/jrand48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/jrand48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/jrand48.c	(revision 2404)
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/jrand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+long
+jrand48(unsigned short xseed[3])
+{
+	_dorand48(xseed);
+	return ((long) xseed[2] << 16) + (long) xseed[1];
+}
Index: /vendor/FreeBSD-libc/5.3/gen/lcong48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/lcong48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/lcong48.c	(revision 2404)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/lcong48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+extern unsigned short _rand48_seed[3];
+extern unsigned short _rand48_mult[3];
+extern unsigned short _rand48_add;
+
+void
+lcong48(unsigned short p[7])
+{
+	_rand48_seed[0] = p[0];
+	_rand48_seed[1] = p[1];
+	_rand48_seed[2] = p[2];
+	_rand48_mult[0] = p[3];
+	_rand48_mult[1] = p[4];
+	_rand48_mult[2] = p[5];
+	_rand48_add = p[6];
+}
Index: /vendor/FreeBSD-libc/5.3/gen/lrand48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/lrand48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/lrand48.c	(revision 2404)
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/lrand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+extern unsigned short _rand48_seed[3];
+
+long
+lrand48(void)
+{
+	_dorand48(_rand48_seed);
+	return ((long) _rand48_seed[2] << 15) + ((long) _rand48_seed[1] >> 1);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/mrand48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/mrand48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/mrand48.c	(revision 2404)
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/mrand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+extern unsigned short _rand48_seed[3];
+
+long
+mrand48(void)
+{
+	_dorand48(_rand48_seed);
+	return ((long) _rand48_seed[2] << 16) + (long) _rand48_seed[1];
+}
Index: /vendor/FreeBSD-libc/5.3/gen/nrand48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/nrand48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/nrand48.c	(revision 2404)
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/nrand48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+long
+nrand48(unsigned short xseed[3])
+{
+	_dorand48(xseed);
+	return ((long) xseed[2] << 15) + ((long) xseed[1] >> 1);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/pw_scan.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/pw_scan.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/pw_scan.c	(revision 2404)
@@ -0,0 +1,205 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)pw_scan.c	8.3 (Berkeley) 4/2/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/pw_scan.c,v 1.25 2004/01/18 21:33:25 charnier Exp $");
+
+/*
+ * This module is used to "verify" password entries by chpass(1) and
+ * pwd_mkdb(8).
+ */
+
+#include <sys/param.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "pw_scan.h"
+
+/*
+ * Some software assumes that IDs are short.  We should emit warnings
+ * for id's which cannot be stored in a short, but we are more liberal
+ * by default, warning for IDs greater than USHRT_MAX.
+ *
+ * If pw_big_ids_warning is -1 on entry to pw_scan(), it will be set based
+ * on the existence of PW_SCAN_BIG_IDS in the environment.
+ */
+static int	pw_big_ids_warning = -1;
+
+int
+__pw_scan(char *bp, struct passwd *pw, int flags)
+{
+	uid_t id;
+	int root;
+	char *ep, *p, *sh;
+
+	if (pw_big_ids_warning == -1)
+		pw_big_ids_warning = getenv("PW_SCAN_BIG_IDS") == NULL ? 1 : 0;
+
+	pw->pw_fields = 0;
+	if (!(pw->pw_name = strsep(&bp, ":")))		/* login */
+		goto fmt;
+	root = !strcmp(pw->pw_name, "root");
+	if (pw->pw_name[0] && (pw->pw_name[0] != '+' || pw->pw_name[1] == '\0'))
+		pw->pw_fields |= _PWF_NAME;
+
+	if (!(pw->pw_passwd = strsep(&bp, ":")))	/* passwd */
+		goto fmt;
+	if (pw->pw_passwd[0])
+		pw->pw_fields |= _PWF_PASSWD;
+
+	if (!(p = strsep(&bp, ":")))			/* uid */
+		goto fmt;
+	if (p[0])
+		pw->pw_fields |= _PWF_UID;
+	else {
+		if (pw->pw_name[0] != '+' && pw->pw_name[0] != '-') {
+			if (flags & _PWSCAN_WARN)
+				warnx("no uid for user %s", pw->pw_name);
+			return (0);
+		}
+	}
+	id = strtoul(p, &ep, 10);
+	if (errno == ERANGE) {
+		if (flags & _PWSCAN_WARN)
+			warnx("%s > max uid value (%lu)", p, ULONG_MAX);
+		return (0);
+	}
+	if (*ep != '\0') {
+		if (flags & _PWSCAN_WARN)
+			warnx("%s uid is incorrect", p);
+		return (0);
+	}
+	if (root && id) {
+		if (flags & _PWSCAN_WARN)
+			warnx("root uid should be 0");
+		return (0);
+	}
+	if (flags & _PWSCAN_WARN && pw_big_ids_warning && id > USHRT_MAX) {
+		warnx("%s > recommended max uid value (%u)", p, USHRT_MAX);
+		/*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
+	}
+	pw->pw_uid = id;
+
+	if (!(p = strsep(&bp, ":")))			/* gid */
+		goto fmt;
+	if (p[0])
+		pw->pw_fields |= _PWF_GID;
+	else {
+		if (pw->pw_name[0] != '+' && pw->pw_name[0] != '-') {
+			if (flags & _PWSCAN_WARN)
+				warnx("no gid for user %s", pw->pw_name);
+			return (0);
+		}
+	}
+	id = strtoul(p, &ep, 10);
+	if (errno == ERANGE) {
+		if (flags & _PWSCAN_WARN)
+			warnx("%s > max gid value (%lu)", p, ULONG_MAX);
+		return (0);
+	}
+	if (*ep != '\0') {
+		if (flags & _PWSCAN_WARN)
+			warnx("%s gid is incorrect", p);
+		return (0);
+	}
+	if (flags & _PWSCAN_WARN && pw_big_ids_warning && id > USHRT_MAX) {
+		warnx("%s > recommended max gid value (%u)", p, USHRT_MAX);
+		/* return (0); This should not be fatal! */
+	}
+	pw->pw_gid = id;
+
+	if (flags & _PWSCAN_MASTER ) {
+		if (!(pw->pw_class = strsep(&bp, ":")))	/* class */
+			goto fmt;
+		if (pw->pw_class[0])
+			pw->pw_fields |= _PWF_CLASS;
+		
+		if (!(p = strsep(&bp, ":")))		/* change */
+			goto fmt;
+		if (p[0])
+			pw->pw_fields |= _PWF_CHANGE;
+		pw->pw_change = atol(p);
+		
+		if (!(p = strsep(&bp, ":")))		/* expire */
+			goto fmt;
+		if (p[0])
+			pw->pw_fields |= _PWF_EXPIRE;
+		pw->pw_expire = atol(p);
+	}
+	if (!(pw->pw_gecos = strsep(&bp, ":")))		/* gecos */
+		goto fmt;
+	if (pw->pw_gecos[0])
+		pw->pw_fields |= _PWF_GECOS;
+
+	if (!(pw->pw_dir = strsep(&bp, ":")))		/* directory */
+		goto fmt;
+	if (pw->pw_dir[0])
+		pw->pw_fields |= _PWF_DIR;
+
+	if (!(pw->pw_shell = strsep(&bp, ":")))		/* shell */
+		goto fmt;
+
+	p = pw->pw_shell;
+	if (root && *p) {				/* empty == /bin/sh */
+		for (setusershell();;) {
+			if (!(sh = getusershell())) {
+				if (flags & _PWSCAN_WARN)
+					warnx("warning, unknown root shell");
+				break;
+			}
+			if (!strcmp(p, sh))
+				break;
+		}
+		endusershell();
+	}
+	if (p[0])
+		pw->pw_fields |= _PWF_SHELL;
+
+	if ((p = strsep(&bp, ":"))) {			/* too many */
+fmt:		
+		if (flags & _PWSCAN_WARN)
+			warnx("corrupted entry");
+		return (0);
+	}
+	return (1);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/pw_scan.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/pw_scan.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/pw_scan.h	(revision 2404)
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ *
+ *	@(#)pw_scan.h	8.1 (Berkeley) 4/1/94
+ * $FreeBSD: src/lib/libc/gen/pw_scan.h,v 1.6 2002/03/22 23:41:42 obrien Exp $
+ */
+
+#define _PWSCAN_MASTER 0x01
+#define _PWSCAN_WARN   0x02
+
+extern int	__pw_scan(char *, struct passwd *, int);
Index: /vendor/FreeBSD-libc/5.3/gen/rand48.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/rand48.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/rand48.h	(revision 2404)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ *
+ * $FreeBSD: src/lib/libc/gen/rand48.h,v 1.2 2002/02/01 01:32:19 obrien Exp $
+ */
+
+#ifndef _RAND48_H_
+#define _RAND48_H_
+
+#include <math.h>
+#include <stdlib.h>
+
+void		_dorand48(unsigned short[3]);
+
+#define	RAND48_SEED_0	(0x330e)
+#define	RAND48_SEED_1	(0xabcd)
+#define	RAND48_SEED_2	(0x1234)
+#define	RAND48_MULT_0	(0xe66d)
+#define	RAND48_MULT_1	(0xdeec)
+#define	RAND48_MULT_2	(0x0005)
+#define	RAND48_ADD	(0x000b)
+
+#endif /* _RAND48_H_ */
Index: /vendor/FreeBSD-libc/5.3/gen/seed48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/seed48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/seed48.c	(revision 2404)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/seed48.c,v 1.2 2002/03/22 21:52:05 obrien Exp $");
+
+#include "rand48.h"
+
+extern unsigned short _rand48_seed[3];
+extern unsigned short _rand48_mult[3];
+extern unsigned short _rand48_add;
+
+unsigned short *
+seed48(unsigned short xseed[3])
+{
+	static unsigned short sseed[3];
+
+	sseed[0] = _rand48_seed[0];
+	sseed[1] = _rand48_seed[1];
+	sseed[2] = _rand48_seed[2];
+	_rand48_seed[0] = xseed[0];
+	_rand48_seed[1] = xseed[1];
+	_rand48_seed[2] = xseed[2];
+	_rand48_mult[0] = RAND48_MULT_0;
+	_rand48_mult[1] = RAND48_MULT_1;
+	_rand48_mult[2] = RAND48_MULT_2;
+	_rand48_add = RAND48_ADD;
+	return sseed;
+}
Index: /vendor/FreeBSD-libc/5.3/gen/setprogname.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/setprogname.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/setprogname.c	(revision 2404)
@@ -0,0 +1,19 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/setprogname.c,v 1.8 2002/03/29 22:43:41 markm Exp $");
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "libc_private.h"
+
+void
+setprogname(const char *progname)
+{
+	const char *p;
+
+	p = strrchr(progname, '/');
+	if (p != NULL)
+		__progname = p + 1;
+	else
+		__progname = progname;
+}
Index: /vendor/FreeBSD-libc/5.3/gen/sleep.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/sleep.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/sleep.c	(revision 2404)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)sleep.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/sleep.c,v 1.31 2002/02/01 00:57:29 obrien Exp $");
+
+#include "namespace.h"
+#include <errno.h>
+#include <limits.h>
+#include <time.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+unsigned int
+__sleep(seconds)
+	unsigned int seconds;
+{
+	struct timespec time_to_sleep;
+	struct timespec time_remaining;
+
+	/*
+	 * Avoid overflow when `seconds' is huge.  This assumes that
+	 * the maximum value for a time_t is >= INT_MAX.
+	 */
+	if (seconds > INT_MAX)
+		return (seconds - INT_MAX + __sleep(INT_MAX));
+
+	time_to_sleep.tv_sec = seconds;
+	time_to_sleep.tv_nsec = 0;
+	if (_nanosleep(&time_to_sleep, &time_remaining) != -1)
+		return (0);
+	if (errno != EINTR)
+		return (seconds);		/* best guess */
+	return (time_remaining.tv_sec +
+		(time_remaining.tv_nsec != 0)); /* round up */
+}
+
+__weak_reference(__sleep, sleep);
+__weak_reference(__sleep, _sleep);
Index: /vendor/FreeBSD-libc/5.3/gen/srand48.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/srand48.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/srand48.c	(revision 2404)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 1993 Martin Birgmeier
+ * All rights reserved.
+ *
+ * You may redistribute unmodified or modified versions of this source
+ * code provided that the above copyright notice and this and the
+ * following conditions are retained.
+ *
+ * This software is provided ``as is'', and comes with no warranties
+ * of any kind. I shall in no event be liable for anything that happens
+ * to anyone/anything when using this software.
+ */
+
+#include "rand48.h"
+
+extern unsigned short _rand48_seed[3];
+extern unsigned short _rand48_mult[3];
+extern unsigned short _rand48_add;
+
+void
+srand48(long seed)
+{
+	_rand48_seed[0] = RAND48_SEED_0;
+	_rand48_seed[1] = (unsigned short) seed;
+	_rand48_seed[2] = (unsigned short) (seed >> 16);
+	_rand48_mult[0] = RAND48_MULT_0;
+	_rand48_mult[1] = RAND48_MULT_1;
+	_rand48_mult[2] = RAND48_MULT_2;
+	_rand48_add = RAND48_ADD;
+}
Index: /vendor/FreeBSD-libc/5.3/gen/statvfs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/statvfs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/statvfs.c	(revision 2404)
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2002 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that both the above copyright notice and this
+ * permission notice appear in all copies, that both the above
+ * copyright notice and this permission notice appear in all
+ * supporting documentation, and that the name of M.I.T. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  M.I.T. makes
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
+ * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL M.I.T. 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/statvfs.c,v 1.2 2002/09/06 11:23:40 tjr Exp $");
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/statvfs.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+static int	sfs2svfs(const struct statfs *from, struct statvfs *to);
+
+int
+fstatvfs(int fd, struct statvfs *result)
+{
+	struct statfs sfs;
+	int rv;
+	long pcval;
+
+	rv = _fstatfs(fd, &sfs);
+	if (rv != 0)
+		return (rv);
+
+	rv = sfs2svfs(&sfs, result);
+	if (rv != 0)
+		return (rv);
+
+	/*
+	 * Whether pathconf's -1 return means error or unlimited does not
+	 * make any difference in this best-effort implementation.
+	 */
+	pcval = _fpathconf(fd, _PC_NAME_MAX);
+	if (pcval == -1)
+		result->f_namemax = ~0UL;
+	else
+		result->f_namemax = (unsigned long)pcval;
+	return (0);
+}
+
+int
+statvfs(const char * __restrict path, struct statvfs * __restrict result)
+{
+	struct statfs sfs;
+	int rv;
+	long pcval;
+
+	rv = statfs(path, &sfs);
+	if (rv != 0)
+		return (rv);
+
+	sfs2svfs(&sfs, result);
+
+	/*
+	 * Whether pathconf's -1 return means error or unlimited does not
+	 * make any difference in this best-effort implementation.
+	 */
+	pcval = pathconf(path, _PC_NAME_MAX);
+	if (pcval == -1)
+		result->f_namemax = ~0UL;
+	else
+		result->f_namemax = (unsigned long)pcval;
+	return (0);
+}
+
+static int
+sfs2svfs(const struct statfs *from, struct statvfs *to)
+{
+	static const struct statvfs zvfs;
+
+	*to = zvfs;
+
+	if (from->f_flags & MNT_RDONLY)
+		to->f_flag |= ST_RDONLY;
+	if (from->f_flags & MNT_NOSUID)
+		to->f_flag |= ST_NOSUID;
+
+	/* XXX should we clamp negative values? */
+#define COPY(field) \
+	do { \
+		to->field = from->field; \
+		if (from->field != to->field) { \
+			errno = EOVERFLOW; \
+			return (-1); \
+		} \
+	} while(0)
+
+	COPY(f_bavail);
+	COPY(f_bfree);
+	COPY(f_blocks);
+	COPY(f_ffree);
+	COPY(f_files);
+	to->f_bsize = from->f_iosize;
+	to->f_frsize = from->f_bsize;
+	to->f_favail = to->f_ffree;
+	return (0);
+}
+								 
+#ifdef MAIN
+#include <err.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+	struct statvfs buf;
+
+	if (statvfs(argv[1], &buf) < 0)
+		err(1, "statvfs");
+
+#define SHOW(field) \
+	printf(#field ": %ju\n", (uintmax_t)buf.field)
+
+	SHOW(f_bavail);
+	SHOW(f_bfree);
+	SHOW(f_blocks);
+	SHOW(f_favail);
+	SHOW(f_ffree);
+	SHOW(f_files);
+	SHOW(f_bsize);
+	SHOW(f_frsize);
+	SHOW(f_namemax);
+	printf("f_flag: %lx\n", (unsigned long)buf.f_flag);
+
+	return 0;
+}
+
+#endif /* MAIN */
Index: /vendor/FreeBSD-libc/5.3/gen/stringlist.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/stringlist.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/stringlist.c	(revision 2404)
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * 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 Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$NetBSD: stringlist.c,v 1.2 1997/01/17 07:26:20 lukem Exp $";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/stringlist.c,v 1.7 2003/01/19 01:16:01 obrien Exp $");
+
+#include "namespace.h"
+#include <stdio.h>
+#include <string.h>
+#include <err.h>
+#include <stdlib.h>
+#include <stringlist.h>
+#include "un-namespace.h"
+
+#define _SL_CHUNKSIZE	20
+
+/*
+ * sl_init(): Initialize a string list
+ */
+StringList *
+sl_init()
+{
+	StringList *sl;
+
+	sl = malloc(sizeof(StringList));
+	if (sl == NULL)
+		_err(1, "stringlist: %m");
+
+	sl->sl_cur = 0;
+	sl->sl_max = _SL_CHUNKSIZE;
+	sl->sl_str = malloc(sl->sl_max * sizeof(char *));
+	if (sl->sl_str == NULL)
+		_err(1, "stringlist: %m");
+	return sl;
+}
+
+
+/*
+ * sl_add(): Add an item to the string list
+ */
+int
+sl_add(sl, name)
+	StringList *sl;
+	char *name;
+{
+	if (sl->sl_cur == sl->sl_max - 1) {
+		sl->sl_max += _SL_CHUNKSIZE;
+		sl->sl_str = reallocf(sl->sl_str, sl->sl_max * sizeof(char *));
+		if (sl->sl_str == NULL)
+			return (-1);
+	}
+	sl->sl_str[sl->sl_cur++] = name;
+	return (0);
+}
+
+
+/*
+ * sl_free(): Free a stringlist
+ */
+void
+sl_free(sl, all)
+	StringList *sl;
+	int all;
+{
+	size_t i;
+
+	if (sl == NULL)
+		return;
+	if (sl->sl_str) {
+		if (all)
+			for (i = 0; i < sl->sl_cur; i++)
+				free(sl->sl_str[i]);
+		free(sl->sl_str);
+	}
+	free(sl);
+}
+
+
+/*
+ * sl_find(): Find a name in the string list
+ */
+char *
+sl_find(sl, name)
+	StringList *sl;
+	char *name;
+{
+	size_t i;
+
+	for (i = 0; i < sl->sl_cur; i++)
+		if (strcmp(sl->sl_str[i], name) == 0)
+			return sl->sl_str[i];
+
+	return NULL;
+}
Index: /vendor/FreeBSD-libc/5.3/gen/sysctlbyname.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/sysctlbyname.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/sysctlbyname.c	(revision 2404)
@@ -0,0 +1,39 @@
+/*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/sysctlbyname.c,v 1.5 2002/02/01 00:57:29 obrien Exp $");
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <string.h>
+
+int
+sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp,
+	     size_t newlen)
+{
+	int name2oid_oid[2];
+	int real_oid[CTL_MAXNAME+2];
+	int error;
+	size_t oidlen;
+
+	name2oid_oid[0] = 0;	/* This is magic & undocumented! */
+	name2oid_oid[1] = 3;
+
+	oidlen = sizeof(real_oid);
+	error = sysctl(name2oid_oid, 2, real_oid, &oidlen, (void *)name,
+		       strlen(name));
+	if (error < 0) 
+		return error;
+	oidlen /= sizeof (int);
+	error = sysctl(real_oid, oidlen, oldp, oldlenp, newp, newlen);
+	return (error);
+}
+
Index: /vendor/FreeBSD-libc/5.3/gen/sysctlnametomib.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/sysctlnametomib.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/sysctlnametomib.c	(revision 2404)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2001 The FreeBSD Project. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``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 FREEBSD PROJECT 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/sysctlnametomib.c,v 1.4 2003/01/04 00:11:11 tjr Exp $");
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <string.h>
+
+/*
+ * This function uses a presently undocumented interface to the kernel
+ * to walk the tree and get the type so it can print the value.
+ * This interface is under work and consideration, and should probably
+ * be killed with a big axe by the first person who can find the time.
+ * (be aware though, that the proper interface isn't as obvious as it
+ * may seem, there are various conflicting requirements.
+ */
+int
+sysctlnametomib(const char *name, int *mibp, size_t *sizep)
+{
+	int oid[2];
+	int error;
+
+	oid[0] = 0;
+	oid[1] = 3;
+
+	*sizep *= sizeof (int);
+	error = sysctl(oid, 2, mibp, sizep, (void *)name, strlen(name));
+	*sizep /= sizeof (int);
+	return (error);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/ualarm.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/ualarm.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/ualarm.c	(revision 2404)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1985, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ualarm.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/ualarm.c,v 1.4 2002/12/29 00:59:09 mike Exp $");
+
+#include <sys/time.h>
+#include <unistd.h>
+
+#define	USPS	1000000		/* # of microseconds in a second */
+
+/*
+ * Generate a SIGALRM signal in ``usecs'' microseconds.
+ * If ``reload'' is non-zero, keep generating SIGALRM
+ * every ``reload'' microseconds after the first signal.
+ */
+useconds_t
+ualarm(usecs, reload)
+	useconds_t usecs;
+	useconds_t reload;
+{
+	struct itimerval new, old;
+
+	new.it_interval.tv_usec = reload % USPS;
+	new.it_interval.tv_sec = reload / USPS;
+
+	new.it_value.tv_usec = usecs % USPS;
+	new.it_value.tv_sec = usecs / USPS;
+
+	if (setitimer(ITIMER_REAL, &new, &old) == 0)
+		return (old.it_value.tv_sec * USPS + old.it_value.tv_usec);
+	/* else */
+		return (-1);
+}
Index: /vendor/FreeBSD-libc/5.3/gen/usleep.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/gen/usleep.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/gen/usleep.c	(revision 2404)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)usleep.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/usleep.c,v 1.28 2002/12/29 00:59:09 mike Exp $");
+
+#include "namespace.h"
+#include <time.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+int
+usleep(useconds)
+	useconds_t useconds;
+{
+	struct timespec time_to_sleep;
+
+	time_to_sleep.tv_nsec = (useconds % 1000000) * 1000;
+	time_to_sleep.tv_sec = useconds / 1000000;
+	return (_nanosleep(&time_to_sleep, NULL));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/btowc.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/btowc.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/btowc.c	(revision 2404)
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2002, 2003 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/btowc.c,v 1.4 2004/05/12 14:26:54 tjr Exp $");
+
+#include <stdio.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+wint_t
+btowc(int c)
+{
+	static const mbstate_t initial;
+	mbstate_t mbs = initial;
+	char cc;
+	wchar_t wc;
+
+	if (c == EOF)
+		return (WEOF);
+	/*
+	 * We expect mbrtowc() to return 0 or 1, hence the check for n > 1
+	 * which detects error return values as well as "impossible" byte
+	 * counts.
+	 */
+	cc = (char)c;
+	if (__mbrtowc(&wc, &cc, 1, &mbs) > 1)
+		return (WEOF);
+	return (wc);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/collate.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/collate.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/collate.h	(revision 2404)
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
+ *		at Electronni Visti IA, Kiev, Ukraine.
+ *			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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD: src/lib/libc/locale/collate.h,v 1.14 2002/08/30 20:26:02 ache Exp $
+ */
+
+#ifndef _COLLATE_H_
+#define	_COLLATE_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <limits.h>
+
+#define STR_LEN 10
+#define TABLE_SIZE 100
+#define COLLATE_VERSION    "1.0\n"
+#define COLLATE_VERSION1_1 "1.1\n"
+
+struct __collate_st_char_pri {
+	int prim, sec;
+};
+struct __collate_st_chain_pri {
+	u_char str[STR_LEN];
+	int prim, sec;
+};
+
+extern int __collate_load_error;
+extern int __collate_substitute_nontrivial;
+#define __collate_substitute_table (*__collate_substitute_table_ptr)
+extern u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN];
+#define __collate_char_pri_table (*__collate_char_pri_table_ptr)
+extern struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1];
+extern struct __collate_st_chain_pri *__collate_chain_pri_table;
+
+__BEGIN_DECLS
+u_char	*__collate_strdup(u_char *);
+u_char	*__collate_substitute(const u_char *);
+int	__collate_load_tables(const char *);
+void	__collate_lookup(const u_char *, int *, int *, int *);
+int	__collate_range_cmp(int, int);
+#ifdef COLLATE_DEBUG
+void	__collate_print_tables(void);
+#endif
+__END_DECLS
+
+#endif /* !_COLLATE_H_ */
Index: /vendor/FreeBSD-libc/5.3/locale/collcmp.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/collcmp.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/collcmp.c	(revision 2404)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 1996 by Andrey A. Chernov, Moscow, Russia.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/collcmp.c,v 1.17 2003/08/03 19:28:23 ache Exp $");
+
+#include <string.h>
+#include "collate.h"
+
+/*
+ * Compare two characters using collate
+ */
+
+int __collate_range_cmp(c1, c2)
+	int c1, c2;
+{
+	static char s1[2], s2[2];
+
+	s1[0] = c1;
+	s2[0] = c2;
+	return (strcoll(s1, s2));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/ldpart.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/ldpart.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/ldpart.h	(revision 2404)
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: src/lib/libc/locale/ldpart.h,v 1.6 2003/06/13 00:14:07 jkh Exp $
+ */
+
+#ifndef _LDPART_H_
+#define	_LDPART_H_
+
+#define _LDP_LOADED 0
+#define _LDP_ERROR  (-1)
+#define _LDP_CACHE  1
+
+int	__part_load_locale(const char *, int*, char **, const char *,
+		    int, int, const char **);
+
+#endif /* !_LDPART_H_ */
Index: /vendor/FreeBSD-libc/5.3/locale/mblen.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mblen.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mblen.c	(revision 2404)
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/mblen.c,v 1.9 2004/07/29 06:18:40 tjr Exp $");
+
+#include <stdlib.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+int
+mblen(const char *s, size_t n)
+{
+	static const mbstate_t initial;
+	static mbstate_t mbs;
+	size_t rval;
+
+	if (s == NULL) {
+		/* No support for state dependent encodings. */
+		mbs = initial;
+		return (0);
+	}
+	rval = __mbrtowc(NULL, s, n, &mbs);
+	if (rval == (size_t)-1 || rval == (size_t)-2)
+		return (-1);
+	return ((int)rval);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/mblocal.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mblocal.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mblocal.h	(revision 2404)
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: src/lib/libc/locale/mblocal.h,v 1.3 2004/07/21 10:54:57 tjr Exp $
+ */
+
+#ifndef _MBLOCAL_H_
+#define	_MBLOCAL_H_
+
+#include <stddef.h>	/* XXX for rune_t */
+
+/*
+ * Conversion function pointers for current encoding.
+ */
+extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
+    size_t, mbstate_t * __restrict);
+extern int (*__mbsinit)(const mbstate_t *);
+extern size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict,
+    size_t, size_t, mbstate_t * __restrict);
+extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
+extern size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
+    size_t, size_t, mbstate_t * __restrict);
+
+/*
+ * Conversion functions for "NONE"/C/POSIX encoding.
+ */
+extern size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict,
+    size_t, mbstate_t * __restrict);
+extern int _none_mbsinit(const mbstate_t *);
+extern size_t _none_mbsnrtowcs(wchar_t * __restrict, const char ** __restrict,
+    size_t, size_t, mbstate_t * __restrict);
+extern size_t _none_wcrtomb(char * __restrict, wchar_t,
+    mbstate_t * __restrict);
+extern size_t _none_wcsnrtombs(char * __restrict, const wchar_t ** __restrict,
+    size_t, size_t, mbstate_t * __restrict);
+
+extern size_t __mbsnrtowcs_std(wchar_t * __restrict, const char ** __restrict,
+    size_t, size_t, mbstate_t * __restrict);
+extern size_t __wcsnrtombs_std(char * __restrict, const wchar_t ** __restrict,
+    size_t, size_t, mbstate_t * __restrict);
+
+/*
+ * Rune emulation functions.
+ */
+extern rune_t __emulated_sgetrune(const char *, size_t, const char **);
+extern int __emulated_sputrune(rune_t, char *, size_t, char **);
+
+#endif	/* _MBLOCAL_H_ */
Index: /vendor/FreeBSD-libc/5.3/locale/mbrlen.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mbrlen.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mbrlen.c	(revision 2404)
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/mbrlen.c,v 1.4 2004/05/12 14:26:54 tjr Exp $");
+
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+mbrlen(const char * __restrict s, size_t n, mbstate_t * __restrict ps)
+{
+	static mbstate_t mbs;
+
+	if (ps == NULL)
+		ps = &mbs;
+	return (__mbrtowc(NULL, s, n, ps));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/mbrtowc.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mbrtowc.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mbrtowc.c	(revision 2404)
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/mbrtowc.c,v 1.7 2004/05/12 14:09:04 tjr Exp $");
+
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
+    size_t n, mbstate_t * __restrict ps)
+{
+	static mbstate_t mbs;
+
+	if (ps == NULL)
+		ps = &mbs;
+	return (__mbrtowc(pwc, s, n, ps));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/mbsinit.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mbsinit.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mbsinit.c	(revision 2404)
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/mbsinit.c,v 1.3 2004/05/12 14:09:04 tjr Exp $");
+
+#include <wchar.h>
+#include "mblocal.h"
+
+int
+mbsinit(const mbstate_t *ps)
+{
+
+	return (__mbsinit(ps));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/mbsnrtowcs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mbsnrtowcs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mbsnrtowcs.c	(revision 2404)
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/mbsnrtowcs.c,v 1.1 2004/07/21 10:54:57 tjr Exp $");
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src,
+    size_t nms, size_t len, mbstate_t * __restrict ps)
+{
+	static mbstate_t mbs;
+
+	if (ps == NULL)
+		ps = &mbs;
+	return (__mbsnrtowcs(dst, src, nms, len, ps));
+}
+
+size_t
+__mbsnrtowcs_std(wchar_t * __restrict dst, const char ** __restrict src,
+    size_t nms, size_t len, mbstate_t * __restrict ps)
+{
+	const char *s;
+	size_t nchr;
+	wchar_t wc;
+	size_t nb;
+
+	s = *src;
+	nchr = 0;
+
+	if (dst == NULL) {
+		for (;;) {
+			if ((nb = __mbrtowc(&wc, s, nms, ps)) == (size_t)-1)
+				/* Invalid sequence - mbrtowc() sets errno. */
+				return ((size_t)-1);
+			else if (nb == 0 || nb == (size_t)-2)
+				return (nchr);
+			s += nb;
+			nms -= nb;
+			nchr++;
+		}
+		/*NOTREACHED*/
+	}
+
+	while (len-- > 0) {
+		if ((nb = __mbrtowc(dst, s, nms, ps)) == (size_t)-1) {
+			*src = s;
+			return ((size_t)-1);
+		} else if (nb == (size_t)-2) {
+			*src = s + nms;
+			return (nchr);
+		} else if (nb == 0) {
+			*src = NULL;
+			return (nchr);
+		}
+		s += nb;
+		nms -= nb;
+		nchr++;
+		dst++;
+	}
+	*src = s;
+	return (nchr);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/mbsrtowcs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mbsrtowcs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mbsrtowcs.c	(revision 2404)
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/mbsrtowcs.c,v 1.6 2004/07/21 10:54:57 tjr Exp $");
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+mbsrtowcs(wchar_t * __restrict dst, const char ** __restrict src, size_t len,
+    mbstate_t * __restrict ps)
+{
+	static mbstate_t mbs;
+
+	if (ps == NULL)
+		ps = &mbs;
+	return (__mbsnrtowcs(dst, src, SIZE_T_MAX, len, ps));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/mbstowcs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mbstowcs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mbstowcs.c	(revision 2404)
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/mbstowcs.c,v 1.11 2004/07/21 10:54:57 tjr Exp $");
+
+#include <limits.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
+{
+	static const mbstate_t initial;
+	mbstate_t mbs;
+
+	mbs = initial;
+	return (__mbsnrtowcs(pwcs, &s, SIZE_T_MAX, n, &mbs));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/mbtowc.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/mbtowc.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/mbtowc.c	(revision 2404)
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/mbtowc.c,v 1.11 2004/07/29 06:18:40 tjr Exp $");
+
+#include <stdlib.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+int
+mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n)
+{
+	static const mbstate_t initial;
+	static mbstate_t mbs;
+	size_t rval;
+
+	if (s == NULL) {
+		/* No support for state dependent encodings. */
+		mbs = initial;
+		return (0);
+	}
+	rval = __mbrtowc(pwc, s, n, &mbs);
+	if (rval == (size_t)-1 || rval == (size_t)-2)
+		return (-1);
+	return ((int)rval);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/utf8.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/utf8.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/utf8.c	(revision 2404)
@@ -0,0 +1,419 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/param.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/utf8.c,v 1.11 2004/07/27 06:29:48 tjr Exp $");
+
+#include <errno.h>
+#include <limits.h>
+#include <runetype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t	_UTF8_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
+	    mbstate_t * __restrict);
+int	_UTF8_mbsinit(const mbstate_t *);
+size_t	_UTF8_mbsnrtowcs(wchar_t * __restrict, const char ** __restrict,
+	    size_t, size_t, mbstate_t * __restrict);
+size_t	_UTF8_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
+size_t	_UTF8_wcsnrtombs(char * __restrict, const wchar_t ** __restrict,
+	    size_t, size_t, mbstate_t * __restrict);
+
+typedef struct {
+	wchar_t	ch;
+	int	want;
+	wchar_t	lbound;
+} _UTF8State;
+
+int
+_UTF8_init(_RuneLocale *rl)
+{
+
+	__mbrtowc = _UTF8_mbrtowc;
+	__wcrtomb = _UTF8_wcrtomb;
+	__mbsinit = _UTF8_mbsinit;
+	__mbsnrtowcs = _UTF8_mbsnrtowcs;
+	__wcsnrtombs = _UTF8_wcsnrtombs;
+	_CurrentRuneLocale = rl;
+	__mb_cur_max = 6;
+
+	return (0);
+}
+
+int
+_UTF8_mbsinit(const mbstate_t *ps)
+{
+
+	return (ps == NULL || ((const _UTF8State *)ps)->want == 0);
+}
+
+size_t
+_UTF8_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n,
+    mbstate_t * __restrict ps)
+{
+	_UTF8State *us;
+	int ch, i, mask, want;
+	wchar_t lbound, wch;
+
+	us = (_UTF8State *)ps;
+
+	if (us->want < 0 || us->want > 6) {
+		errno = EINVAL;
+		return ((size_t)-1);
+	}
+
+	if (s == NULL) {
+		s = "";
+		n = 1;
+		pwc = NULL;
+	}
+
+	if (n == 0)
+		/* Incomplete multibyte sequence */
+		return ((size_t)-2);
+
+	if (us->want == 0 && ((ch = (unsigned char)*s) & ~0x7f) == 0) {
+		/* Fast path for plain ASCII characters. */
+		if (pwc != NULL)
+			*pwc = ch;
+		return (ch != '\0' ? 1 : 0);
+	}
+
+	if (us->want == 0) {
+		/*
+		 * Determine the number of octets that make up this character
+		 * from the first octet, and a mask that extracts the
+		 * interesting bits of the first octet. We already know
+		 * the character is at least two bytes long.
+		 *
+		 * We also specify a lower bound for the character code to
+		 * detect redundant, non-"shortest form" encodings. For
+		 * example, the sequence C0 80 is _not_ a legal representation
+		 * of the null character. This enforces a 1-to-1 mapping
+		 * between character codes and their multibyte representations.
+		 */
+		ch = (unsigned char)*s;
+		if ((ch & 0x80) == 0) {
+			mask = 0x7f;
+			want = 1;
+			lbound = 0;
+		} else if ((ch & 0xe0) == 0xc0) {
+			mask = 0x1f;
+			want = 2;
+			lbound = 0x80;
+		} else if ((ch & 0xf0) == 0xe0) {
+			mask = 0x0f;
+			want = 3;
+			lbound = 0x800;
+		} else if ((ch & 0xf8) == 0xf0) {
+			mask = 0x07;
+			want = 4;
+			lbound = 0x10000;
+		} else if ((ch & 0xfc) == 0xf8) {
+			mask = 0x03;
+			want = 5;
+			lbound = 0x200000;
+		} else if ((ch & 0xfc) == 0xfc) {
+			mask = 0x01;
+			want = 6;
+			lbound = 0x4000000;
+		} else {
+			/*
+			 * Malformed input; input is not UTF-8.
+			 */
+			errno = EILSEQ;
+			return ((size_t)-1);
+		}
+	} else {
+		want = us->want;
+		lbound = us->lbound;
+	}
+
+	/*
+	 * Decode the octet sequence representing the character in chunks
+	 * of 6 bits, most significant first.
+	 */
+	if (us->want == 0)
+		wch = (unsigned char)*s++ & mask;
+	else
+		wch = us->ch;
+	for (i = (us->want == 0) ? 1 : 0; i < MIN(want, n); i++) {
+		if ((*s & 0xc0) != 0x80) {
+			/*
+			 * Malformed input; bad characters in the middle
+			 * of a character.
+			 */
+			errno = EILSEQ;
+			return ((size_t)-1);
+		}
+		wch <<= 6;
+		wch |= *s++ & 0x3f;
+	}
+	if (i < want) {
+		/* Incomplete multibyte sequence. */
+		us->want = want - i;
+		us->lbound = lbound;
+		us->ch = wch;
+		return ((size_t)-2);
+	}
+	if (wch < lbound) {
+		/*
+		 * Malformed input; redundant encoding.
+		 */
+		errno = EILSEQ;
+		return ((size_t)-1);
+	}
+	if (pwc != NULL)
+		*pwc = wch;
+	us->want = 0;
+	return (wch == L'\0' ? 0 : want);
+}
+
+size_t
+_UTF8_mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src,
+    size_t nms, size_t len, mbstate_t * __restrict ps)
+{
+	_UTF8State *us;
+	const char *s;
+	size_t nchr;
+	wchar_t wc;
+	size_t nb;
+
+	us = (_UTF8State *)ps;
+
+	s = *src;
+	nchr = 0;
+
+	if (dst == NULL) {
+		/*
+		 * The fast path in the loop below is not safe if an ASCII
+		 * character appears as anything but the first byte of a
+		 * multibyte sequence. Check now to avoid doing it in the loop.
+		 */
+		if (nms > 0 && us->want > 0 && (signed char)*s > 0) {
+			errno = EILSEQ;
+			return ((size_t)-1);
+		}
+		for (;;) {
+			if (nms > 0 && (signed char)*s > 0)
+				/*
+				 * Fast path for plain ASCII characters
+				 * excluding NUL.
+				 */
+				nb = 1;
+			else if ((nb = _UTF8_mbrtowc(&wc, s, nms, ps)) ==
+			    (size_t)-1)
+				/* Invalid sequence - mbrtowc() sets errno. */
+				return ((size_t)-1);
+			else if (nb == 0 || nb == (size_t)-2)
+				return (nchr);
+			s += nb;
+			nms -= nb;
+			nchr++;
+		}
+		/*NOTREACHED*/
+	}
+
+	/*
+	 * The fast path in the loop below is not safe if an ASCII
+	 * character appears as anything but the first byte of a
+	 * multibyte sequence. Check now to avoid doing it in the loop.
+	 */
+	if (nms > 0 && len > 0 && us->want > 0 && (signed char)*s > 0) {
+		errno = EILSEQ;
+		return ((size_t)-1);
+	}
+	while (len-- > 0) {
+		if (nms > 0 && (signed char)*s > 0) {
+			/*
+			 * Fast path for plain ASCII characters
+			 * excluding NUL.
+			 */
+			*dst = (wchar_t)*s;
+			nb = 1;
+		} else if ((nb = _UTF8_mbrtowc(dst, s, nms, ps)) ==
+		    (size_t)-1) {
+			*src = s;
+			return ((size_t)-1);
+		} else if (nb == (size_t)-2) {
+			*src = s + nms;
+			return (nchr);
+		} else if (nb == 0) {
+			*src = NULL;
+			return (nchr);
+		}
+		s += nb;
+		nms -= nb;
+		nchr++;
+		dst++;
+	}
+	*src = s;
+	return (nchr);
+}
+
+size_t
+_UTF8_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
+{
+	_UTF8State *us;
+	unsigned char lead;
+	int i, len;
+
+	us = (_UTF8State *)ps;
+
+	if (us->want != 0) {
+		errno = EINVAL;
+		return ((size_t)-1);
+	}
+
+	if (s == NULL)
+		/* Reset to initial shift state (no-op) */
+		return (1);
+
+	if ((wc & ~0x7f) == 0) {
+		/* Fast path for plain ASCII characters. */
+		*s = (char)wc;
+		return (1);
+	}
+
+	/*
+	 * Determine the number of octets needed to represent this character.
+	 * We always output the shortest sequence possible. Also specify the
+	 * first few bits of the first octet, which contains the information
+	 * about the sequence length.
+	 */
+	if ((wc & ~0x7f) == 0) {
+		lead = 0;
+		len = 1;
+	} else if ((wc & ~0x7ff) == 0) {
+		lead = 0xc0;
+		len = 2;
+	} else if ((wc & ~0xffff) == 0) {
+		lead = 0xe0;
+		len = 3;
+	} else if ((wc & ~0x1fffff) == 0) {
+		lead = 0xf0;
+		len = 4;
+	} else if ((wc & ~0x3ffffff) == 0) {
+		lead = 0xf8;
+		len = 5;
+	} else if ((wc & ~0x7fffffff) == 0) {
+		lead = 0xfc;
+		len = 6;
+	} else {
+		errno = EILSEQ;
+		return ((size_t)-1);
+	}
+
+	/*
+	 * Output the octets representing the character in chunks
+	 * of 6 bits, least significant last. The first octet is
+	 * a special case because it contains the sequence length
+	 * information.
+	 */
+	for (i = len - 1; i > 0; i--) {
+		s[i] = (wc & 0x3f) | 0x80;
+		wc >>= 6;
+	}
+	*s = (wc & 0xff) | lead;
+
+	return (len);
+}
+
+size_t
+_UTF8_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src,
+    size_t nwc, size_t len, mbstate_t * __restrict ps)
+{
+	_UTF8State *us;
+	char buf[MB_LEN_MAX];
+	const wchar_t *s;
+	size_t nbytes;
+	size_t nb;
+
+	us = (_UTF8State *)ps;
+
+	if (us->want != 0) {
+		errno = EINVAL;
+		return ((size_t)-1);
+	}
+
+	s = *src;
+	nbytes = 0;
+
+	if (dst == NULL) {
+		while (nwc-- > 0) {
+			if (0 <= *s && *s < 0x80)
+				/* Fast path for plain ASCII characters. */
+				nb = 1;
+			else if ((nb = _UTF8_wcrtomb(buf, *s, ps)) ==
+			    (size_t)-1)
+				/* Invalid character - wcrtomb() sets errno. */
+				return ((size_t)-1);
+			if (*s == L'\0')
+				return (nbytes + nb - 1);
+			s++;
+			nbytes += nb;
+		}
+		return (nbytes);
+	}
+
+	while (len > 0 && nwc-- > 0) {
+		if (0 <= *s && *s < 0x80) {
+			/* Fast path for plain ASCII characters. */
+			nb = 1;
+			*dst = *s;
+		} else if (len > (size_t)MB_CUR_MAX) {
+			/* Enough space to translate in-place. */
+			if ((nb = (int)_UTF8_wcrtomb(dst, *s, ps)) < 0) {
+				*src = s;
+				return ((size_t)-1);
+			}
+		} else {
+			/*
+			 * May not be enough space; use temp. buffer.
+			 */
+			if ((nb = (int)_UTF8_wcrtomb(buf, *s, ps)) < 0) {
+				*src = s;
+				return ((size_t)-1);
+			}
+			if (nb > (int)len)
+				/* MB sequence for character won't fit. */
+				break;
+			memcpy(dst, buf, nb);
+		}
+		if (*s == L'\0') {
+			*src = NULL;
+			return (nbytes + nb - 1);
+		}
+		s++;
+		dst += nb;
+		len -= nb;
+		nbytes += nb;
+	}
+	*src = s;
+	return (nbytes);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcrtomb.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcrtomb.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcrtomb.c	(revision 2404)
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcrtomb.c,v 1.8 2004/05/12 14:09:04 tjr Exp $");
+
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
+{
+	static mbstate_t mbs;
+
+	if (ps == NULL)
+		ps = &mbs;
+	return (__wcrtomb(s, wc, ps));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcsftime.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcsftime.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcsftime.c	(revision 2404)
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcsftime.c,v 1.4 2004/04/07 09:47:56 tjr Exp $");
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <time.h>
+#include <wchar.h>
+
+/*
+ * Convert date and time to a wide-character string.
+ *
+ * This is the wide-character counterpart of strftime(). So that we do not
+ * have to duplicate the code of strftime(), we convert the format string to
+ * multibyte, call strftime(), then convert the result back into wide
+ * characters.
+ *
+ * This technique loses in the presence of stateful multibyte encoding if any
+ * of the conversions in the format string change conversion state. When
+ * stateful encoding is implemented, we will need to reset the state between
+ * format specifications in the format string.
+ */
+size_t
+wcsftime(wchar_t * __restrict wcs, size_t maxsize,
+    const wchar_t * __restrict format, const struct tm * __restrict timeptr)
+{
+	static const mbstate_t initial;
+	mbstate_t mbs;
+	char *dst, *dstp, *sformat;
+	size_t n, sflen;
+	int sverrno;
+
+	sformat = dst = NULL;
+
+	/*
+	 * Convert the supplied format string to a multibyte representation
+	 * for strftime(), which only handles single-byte characters.
+	 */
+	mbs = initial;
+	sflen = wcsrtombs(NULL, &format, 0, &mbs);
+	if (sflen == (size_t)-1)
+		goto error;
+	if ((sformat = malloc(sflen + 1)) == NULL)
+		goto error;
+	mbs = initial;
+	wcsrtombs(sformat, &format, sflen + 1, &mbs);
+
+	/*
+	 * Allocate memory for longest multibyte sequence that will fit
+	 * into the caller's buffer and call strftime() to fill it.
+	 * Then, copy and convert the result back into wide characters in
+	 * the caller's buffer.
+	 */
+	if (SIZE_T_MAX / MB_CUR_MAX <= maxsize) {
+		/* maxsize is prepostorously large - avoid int. overflow. */
+		errno = EINVAL;
+		goto error;
+	}
+	if ((dst = malloc(maxsize * MB_CUR_MAX)) == NULL)
+		goto error;
+	if (strftime(dst, maxsize, sformat, timeptr) == 0)
+		goto error;
+	dstp = dst;
+	mbs = initial;
+	n = mbsrtowcs(wcs, (const char **)&dstp, maxsize, &mbs);
+	if (n == (size_t)-2 || n == (size_t)-1 || dstp != NULL)
+		goto error;
+
+	free(sformat);
+	free(dst);
+	return (n);
+
+error:
+	sverrno = errno;
+	free(sformat);
+	free(dst);
+	errno = sverrno;
+	return (0);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcsnrtombs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcsnrtombs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcsnrtombs.c	(revision 2404)
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcsnrtombs.c,v 1.2 2004/07/22 02:57:29 tjr Exp $");
+
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t nwc,
+    size_t len, mbstate_t * __restrict ps)
+{
+	static mbstate_t mbs;
+
+	if (ps == NULL)
+		ps = &mbs;
+	return (__wcsnrtombs(dst, src, nwc, len, ps));
+}
+
+size_t
+__wcsnrtombs_std(char * __restrict dst, const wchar_t ** __restrict src,
+    size_t nwc, size_t len, mbstate_t * __restrict ps)
+{
+	mbstate_t mbsbak;
+	char buf[MB_LEN_MAX];
+	const wchar_t *s;
+	size_t nbytes;
+	size_t nb;
+
+	s = *src;
+	nbytes = 0;
+
+	if (dst == NULL) {
+		while (nwc-- > 0) {
+			if ((nb = __wcrtomb(buf, *s, ps)) == (size_t)-1)
+				/* Invalid character - wcrtomb() sets errno. */
+				return ((size_t)-1);
+			else if (*s == L'\0')
+				return (nbytes + nb - 1);
+			s++;
+			nbytes += nb;
+		}
+		return (nbytes);
+	}
+
+	while (len > 0 && nwc-- > 0) {
+		if (len > (size_t)MB_CUR_MAX) {
+			/* Enough space to translate in-place. */
+			if ((nb = (int)__wcrtomb(dst, *s, ps)) < 0) {
+				*src = s;
+				return ((size_t)-1);
+			}
+		} else {
+			/*
+			 * May not be enough space; use temp. buffer.
+			 *
+			 * We need to save a copy of the conversion state
+			 * here so we can restore it if the multibyte
+			 * character is too long for the buffer.
+			 */
+			mbsbak = *ps;
+			if ((nb = (int)__wcrtomb(buf, *s, ps)) < 0) {
+				*src = s;
+				return ((size_t)-1);
+			}
+			if (nb > (int)len) {
+				/* MB sequence for character won't fit. */
+				*ps = mbsbak;
+				break;
+			}
+			memcpy(dst, buf, nb);
+		}
+		if (*s == L'\0') {
+			*src = NULL;
+			return (nbytes + nb - 1);
+		}
+		s++;
+		dst += nb;
+		len -= nb;
+		nbytes += nb;
+	}
+	*src = s;
+	return (nbytes);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcsrtombs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcsrtombs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcsrtombs.c	(revision 2404)
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcsrtombs.c,v 1.6 2004/07/21 10:54:57 tjr Exp $");
+
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+wcsrtombs(char * __restrict dst, const wchar_t ** __restrict src, size_t len,
+    mbstate_t * __restrict ps)
+{
+	static mbstate_t mbs;
+
+	if (ps == NULL)
+		ps = &mbs;
+	return (__wcsnrtombs(dst, src, SIZE_T_MAX, len, ps));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstod.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstod.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstod.c	(revision 2404)
@@ -0,0 +1,94 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstod.c,v 1.4 2004/04/07 09:47:56 tjr Exp $");
+
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * Convert a string to a double-precision number.
+ *
+ * This is the wide-character counterpart of strtod(). So that we do not
+ * have to duplicate the code of strtod() here, we convert the supplied
+ * wide character string to multibyte and call strtod() on the result.
+ * This assumes that the multibyte encoding is compatible with ASCII
+ * for at least the digits, radix character and letters.
+ */
+double
+wcstod(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
+{
+	static const mbstate_t initial;
+	mbstate_t mbs;
+	double val;
+	char *buf, *end;
+	const wchar_t *wcp;
+	size_t len;
+
+	while (iswspace(*nptr))
+		nptr++;
+
+	/*
+	 * Convert the supplied numeric wide char. string to multibyte.
+	 *
+	 * We could attempt to find the end of the numeric portion of the
+	 * wide char. string to avoid converting unneeded characters but
+	 * choose not to bother; optimising the uncommon case where
+	 * the input string contains a lot of text after the number
+	 * duplicates a lot of strtod()'s functionality and slows down the
+	 * most common cases.
+	 */
+	wcp = nptr;
+	mbs = initial;
+	if ((len = wcsrtombs(NULL, &wcp, 0, &mbs)) == (size_t)-1) {
+		if (endptr != NULL)
+			*endptr = (wchar_t *)nptr;
+		return (0.0);
+	}
+	if ((buf = malloc(len + 1)) == NULL)
+		return (0.0);
+	mbs = initial;
+	wcsrtombs(buf, &wcp, len + 1, &mbs);
+
+	/* Let strtod() do most of the work for us. */
+	val = strtod(buf, &end);
+
+	/*
+	 * We only know where the number ended in the _multibyte_
+	 * representation of the string. If the caller wants to know
+	 * where it ended, count multibyte characters to find the
+	 * corresponding position in the wide char string.
+	 */
+	if (endptr != NULL)
+		/* XXX Assume each wide char is one byte. */
+		*endptr = (wchar_t *)nptr + (end - buf);
+
+	free(buf);
+
+	return (val);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstof.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstof.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstof.c	(revision 2404)
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2002, 2003 Tim J. Robbins
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstof.c,v 1.3 2004/04/07 09:47:56 tjr Exp $");
+
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * See wcstod() for comments as to the logic used.
+ */
+float
+wcstof(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
+{
+	static const mbstate_t initial;
+	mbstate_t mbs;
+	float val;
+	char *buf, *end;
+	const wchar_t *wcp;
+	size_t len;
+
+	while (iswspace(*nptr))
+		nptr++;
+
+	wcp = nptr;
+	mbs = initial;
+	if ((len = wcsrtombs(NULL, &wcp, 0, &mbs)) == (size_t)-1) {
+		if (endptr != NULL)
+			*endptr = (wchar_t *)nptr;
+		return (0.0);
+	}
+	if ((buf = malloc(len + 1)) == NULL)
+		return (0.0);
+	mbs = initial;
+	wcsrtombs(buf, &wcp, len + 1, &mbs);
+
+	val = strtof(buf, &end);
+
+	if (endptr != NULL)
+		*endptr = (wchar_t *)nptr + (end - buf);
+
+	free(buf);
+
+	return (val);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstoimax.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstoimax.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstoimax.c	(revision 2404)
@@ -0,0 +1,128 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "from @(#)strtol.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoimax.c,v 1.8 2002/09/06 11:23:59 tjr Exp ");
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstoimax.c,v 1.2 2003/01/01 18:48:43 schweikh Exp $");
+
+#include <errno.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * Convert a wide character string to an intmax_t integer.
+ */
+intmax_t
+wcstoimax(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
+    int base)
+{
+	const wchar_t *s;
+	uintmax_t acc;
+	wchar_t c;
+	uintmax_t cutoff;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtoimax for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = *s++;
+	} while (iswspace(c));
+	if (c == L'-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == L'+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == L'0' && (*s == L'x' || *s == L'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == L'0' ? 8 : 10;
+	acc = any = 0;
+	if (base < 2 || base > 36)
+		goto noconv;
+
+	cutoff = neg ? (uintmax_t)-(INTMAX_MIN + INTMAX_MAX) + INTMAX_MAX
+	    : INTMAX_MAX;
+	cutlim = cutoff % base;
+	cutoff /= base;
+	for ( ; ; c = *s++) {
+#ifdef notyet
+		if (iswdigit(c))
+			c = digittoint(c);
+		else
+#endif
+		if (c >= L'0' && c <= L'9')
+			c -= L'0';
+		else if (c >= L'A' && c <= L'Z')
+			c -= L'A' - 10;
+		else if (c >= 'a' && c <= 'z')
+			c -= L'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+			any = -1;
+		else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+	if (any < 0) {
+		acc = neg ? INTMAX_MIN : INTMAX_MAX;
+		errno = ERANGE;
+	} else if (!any) {
+noconv:
+		errno = EINVAL;
+	} else if (neg)
+		acc = -acc;
+	if (endptr != NULL)
+		*endptr = (wchar_t *)(any ? s - 1 : nptr);
+	return (acc);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstol.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstol.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstol.c	(revision 2404)
@@ -0,0 +1,121 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstol.c,v 1.1 2002/09/08 13:27:26 tjr Exp $");
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * Convert a string to a long integer.
+ */
+long
+wcstol(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
+{
+	const wchar_t *s;
+	unsigned long acc;
+	wchar_t c;
+	unsigned long cutoff;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtol for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = *s++;
+	} while (iswspace(c));
+	if (c == '-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == L'+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == L'0' && (*s == L'x' || *s == L'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == L'0' ? 8 : 10;
+	acc = any = 0;
+	if (base < 2 || base > 36)
+		goto noconv;
+
+	cutoff = neg ? (unsigned long)-(LONG_MIN + LONG_MAX) + LONG_MAX
+	    : LONG_MAX;
+	cutlim = cutoff % base;
+	cutoff /= base;
+	for ( ; ; c = *s++) {
+#ifdef notyet
+		if (iswdigit(c))
+			c = digittoint(c);
+		else
+#endif
+		if (c >= L'0' && c <= L'9')
+			c -= L'0';
+		else if (c >= L'A' && c <= L'Z')
+			c -= L'A' - 10;
+		else if (c >= L'a' && c <= L'z')
+			c -= L'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+			any = -1;
+		else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+	if (any < 0) {
+		acc = neg ? LONG_MIN : LONG_MAX;
+		errno = ERANGE;
+	} else if (!any) {
+noconv:
+		errno = EINVAL;
+	} else if (neg)
+		acc = -acc;
+	if (endptr != NULL)
+		*endptr = (wchar_t *)(any ? s - 1 : nptr);
+	return (acc);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstold.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstold.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstold.c	(revision 2404)
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2002, 2003 Tim J. Robbins
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstold.c,v 1.4 2004/04/07 09:47:56 tjr Exp $");
+
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * See wcstod() for comments as to the logic used.
+ */
+long double
+wcstold(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
+{
+	static const mbstate_t initial;
+	mbstate_t mbs;
+	long double val;
+	char *buf, *end;
+	const wchar_t *wcp;
+	size_t len;
+
+	while (iswspace(*nptr))
+		nptr++;
+
+	wcp = nptr;
+	mbs = initial;
+	if ((len = wcsrtombs(NULL, &wcp, 0, &mbs)) == (size_t)-1) {
+		if (endptr != NULL)
+			*endptr = (wchar_t *)nptr;
+		return (0.0);
+	}
+	if ((buf = malloc(len + 1)) == NULL)
+		return (0.0);
+	mbs = initial;
+	wcsrtombs(buf, &wcp, len + 1, &mbs);
+
+	val = strtold(buf, &end);
+
+	if (endptr != NULL)
+		*endptr = (wchar_t *)nptr + (end - buf);
+
+	free(buf);
+
+	return (val);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstoll.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstoll.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstoll.c	(revision 2404)
@@ -0,0 +1,127 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strtoq.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoll.c,v 1.19 2002/09/06 11:23:59 tjr Exp ");
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstoll.c,v 1.1 2002/09/22 08:06:45 tjr Exp $");
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * Convert a wide character string to a long long integer.
+ */
+long long
+wcstoll(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
+{
+	const wchar_t *s;
+	unsigned long long acc;
+	wchar_t c;
+	unsigned long long cutoff;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtoll for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = *s++;
+	} while (iswspace(c));
+	if (c == L'-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == L'+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == L'0' && (*s == L'x' || *s == L'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == L'0' ? 8 : 10;
+	acc = any = 0;
+	if (base < 2 || base > 36)
+		goto noconv;
+
+	cutoff = neg ? (unsigned long long)-(LLONG_MIN + LLONG_MAX) + LLONG_MAX
+	    : LLONG_MAX;
+	cutlim = cutoff % base;
+	cutoff /= base;
+	for ( ; ; c = *s++) {
+#ifdef notyet
+		if (iswdigit(c))
+			c = digittoint(c);
+		else
+#endif
+		if (c >= L'0' && c <= L'9')
+			c -= L'0';
+		else if (c >= L'A' && c <= L'Z')
+			c -= L'A' - 10;
+		else if (c >= L'a' && c <= L'z')
+			c -= L'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+			any = -1;
+		else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+	if (any < 0) {
+		acc = neg ? LLONG_MIN : LLONG_MAX;
+		errno = ERANGE;
+	} else if (!any) {
+noconv:
+		errno = EINVAL;
+	} else if (neg)
+		acc = -acc;
+	if (endptr != NULL)
+		*endptr = (wchar_t *)(any ? s - 1 : nptr);
+	return (acc);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstombs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstombs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstombs.c	(revision 2404)
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstombs.c,v 1.10 2004/07/21 10:54:57 tjr Exp $");
+
+#include <limits.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+size_t
+wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
+{
+	static const mbstate_t initial;
+	mbstate_t mbs;
+
+	mbs = initial;
+	return (__wcsnrtombs(s, &pwcs, SIZE_T_MAX, n, &mbs));
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstoul.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstoul.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstoul.c	(revision 2404)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstoul.c,v 1.1 2002/09/08 13:27:26 tjr Exp $");
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * Convert a wide character string to an unsigned long integer.
+ */
+unsigned long
+wcstoul(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int base)
+{
+	const wchar_t *s;
+	unsigned long acc;
+	wchar_t c;
+	unsigned long cutoff;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtol for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = *s++;
+	} while (iswspace(c));
+	if (c == L'-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == L'+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == L'0' && (*s == L'x' || *s == L'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == L'0' ? 8 : 10;
+	acc = any = 0;
+	if (base < 2 || base > 36)
+		goto noconv;
+
+	cutoff = ULONG_MAX / base;
+	cutlim = ULONG_MAX % base;
+	for ( ; ; c = *s++) {
+#ifdef notyet
+		if (iswdigit(c))
+			c = digittoint(c);
+		else
+#endif
+		if (c >= L'0' && c <= L'9')
+			c -= L'0';
+		else if (c >= L'A' && c <= L'Z')
+			c -= L'A' - 10;
+		else if (c >= L'a' && c <= L'z')
+			c -= L'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+			any = -1;
+		else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+	if (any < 0) {
+		acc = ULONG_MAX;
+		errno = ERANGE;
+	} else if (!any) {
+noconv:
+		errno = EINVAL;
+	} else if (neg)
+		acc = -acc;
+	if (endptr != NULL)
+		*endptr = (wchar_t *)(any ? s - 1 : nptr);
+	return (acc);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstoull.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstoull.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstoull.c	(revision 2404)
@@ -0,0 +1,126 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strtouq.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoull.c,v 1.18 2002/09/06 11:23:59 tjr Exp ");
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstoull.c,v 1.1 2002/09/22 08:06:45 tjr Exp $");
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * Convert a wide character string to an unsigned long long integer.
+ */
+unsigned long long
+wcstoull(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
+    int base)
+{
+	const wchar_t *s;
+	unsigned long long acc;
+	wchar_t c;
+	unsigned long long cutoff;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtoull for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = *s++;
+	} while (iswspace(c));
+	if (c == L'-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == L'+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == L'0' && (*s == L'x' || *s == L'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == L'0' ? 8 : 10;
+	acc = any = 0;
+	if (base < 2 || base > 36)
+		goto noconv;
+
+	cutoff = ULLONG_MAX / base;
+	cutlim = ULLONG_MAX % base;
+	for ( ; ; c = *s++) {
+#ifdef notyet
+		if (iswdigit(c))
+			c = digittoint(c);
+		else
+#endif
+		if (c >= L'0' && c <= L'9')
+			c -= L'0';
+		else if (c >= L'A' && c <= L'Z')
+			c -= L'A' - 10;
+		else if (c >= L'a' && c <= L'z')
+			c -= L'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+			any = -1;
+		else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+	if (any < 0) {
+		acc = ULLONG_MAX;
+		errno = ERANGE;
+	} else if (!any) {
+noconv:
+		errno = EINVAL;
+	} else if (neg)
+		acc = -acc;
+	if (endptr != NULL)
+		*endptr = (wchar_t *)(any ? s - 1 : nptr);
+	return (acc);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wcstoumax.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wcstoumax.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wcstoumax.c	(revision 2404)
@@ -0,0 +1,126 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "from @(#)strtoul.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoumax.c,v 1.8 2002/09/06 11:23:59 tjr Exp ");
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/locale/wcstoumax.c,v 1.1 2002/09/22 08:06:45 tjr Exp $");
+
+#include <errno.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <wctype.h>
+
+/*
+ * Convert a wide character string to a uintmax_t integer.
+ */
+uintmax_t
+wcstoumax(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
+    int base)
+{
+	const wchar_t *s;
+	uintmax_t acc;
+	wchar_t c;
+	uintmax_t cutoff;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtoimax for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = *s++;
+	} while (iswspace(c));
+	if (c == L'-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == L'+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == L'0' && (*s == L'x' || *s == L'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == L'0' ? 8 : 10;
+	acc = any = 0;
+	if (base < 2 || base > 36)
+		goto noconv;
+
+	cutoff = UINTMAX_MAX / base;
+	cutlim = UINTMAX_MAX % base;
+	for ( ; ; c = *s++) {
+#ifdef notyet
+		if (iswdigit(c))
+			c = digittoint(c);
+		else
+#endif
+		if (c >= L'0' && c <= L'9')
+			c -= L'0';
+		else if (c >= L'A' && c <= L'Z')
+			c -= L'A' - 10;
+		else if (c >= L'a' && c <= L'z')
+			c -= L'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+			any = -1;
+		else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+	if (any < 0) {
+		acc = UINTMAX_MAX;
+		errno = ERANGE;
+	} else if (!any) {
+noconv:
+		errno = EINVAL;
+	} else if (neg)
+		acc = -acc;
+	if (endptr != NULL)
+		*endptr = (wchar_t *)(any ? s - 1 : nptr);
+	return (acc);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wctob.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wctob.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wctob.c	(revision 2404)
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wctob.c,v 1.4 2004/05/12 14:26:54 tjr Exp $");
+
+#include <limits.h>
+#include <stdio.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+int
+wctob(wint_t c)
+{
+	static const mbstate_t initial;
+	mbstate_t mbs = initial;
+	char buf[MB_LEN_MAX];
+
+	if (c == WEOF || __wcrtomb(buf, c, &mbs) != 1)
+		return (EOF);
+	return ((unsigned char)*buf);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wctomb.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wctomb.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wctomb.c	(revision 2404)
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wctomb.c,v 1.8 2004/07/29 06:18:40 tjr Exp $");
+
+#include <stdlib.h>
+#include <wchar.h>
+#include "mblocal.h"
+
+int
+wctomb(char *s, wchar_t wchar)
+{
+	static const mbstate_t initial;
+	static mbstate_t mbs;
+	size_t rval;
+
+	if (s == NULL) {
+		/* No support for state dependent encodings. */
+		mbs = initial;
+		return (0);
+	}
+	if ((rval = __wcrtomb(s, wchar, &mbs)) == (size_t)-1)
+		return (-1);
+	return ((int)rval);
+}
Index: /vendor/FreeBSD-libc/5.3/locale/wctrans.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/locale/wctrans.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/locale/wctrans.c	(revision 2404)
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/locale/wctrans.c,v 1.3 2003/11/01 08:20:58 tjr Exp $");
+
+#include <errno.h>
+#include <string.h>
+#include <wctype.h>
+
+enum {
+	_WCT_ERROR	= 0,
+	_WCT_TOLOWER	= 1,
+	_WCT_TOUPPER	= 2
+};
+
+wint_t
+towctrans(wint_t wc, wctrans_t desc)
+{
+
+	switch (desc) {
+	case _WCT_TOLOWER:
+		wc = towlower(wc);
+		break;
+	case _WCT_TOUPPER:
+		wc = towupper(wc);
+		break;
+	case _WCT_ERROR:
+	default:
+		errno = EINVAL;
+		break;
+	}
+
+	return (wc);
+}
+
+wctrans_t
+wctrans(const char *charclass)
+{
+	struct {
+		const char	*name;
+		wctrans_t	 trans;
+	} ccls[] = {
+		{ "tolower",	_WCT_TOLOWER },
+		{ "toupper",	_WCT_TOUPPER },
+		{ NULL,		_WCT_ERROR },		/* Default */
+	};
+	int i;
+
+	i = 0;
+	while (ccls[i].name != NULL && strcmp(ccls[i].name, charclass) != 0)
+		i++;
+
+	if (ccls[i].trans == _WCT_ERROR)
+		errno = EINVAL;
+	return (ccls[i].trans);
+}
Index: /vendor/FreeBSD-libc/5.3/net/nsdispatch.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/net/nsdispatch.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/net/nsdispatch.c	(revision 2404)
@@ -0,0 +1,628 @@
+/*	$NetBSD: nsdispatch.c,v 1.9 1999/01/25 00:16:17 lukem Exp $	*/
+
+/*-
+ * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Luke Mewburn.
+ *
+ * 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.
+ */
+/*-
+ * Copyright (c) 2003 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * Portions of this software were developed for the FreeBSD Project by
+ * Jacques A. Vidrine, Safeport Network Services, and Network
+ * Associates Laboratories, the Security Research Division of Network
+ * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
+ * ("CBOSS"), as part of the DARPA CHATS research program.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/net/nsdispatch.c,v 1.12 2004/04/01 19:12:45 nectar Exp $");
+
+#include "namespace.h"
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+#define _NS_PRIVATE
+#include <nsswitch.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+enum _nss_constants {
+	/* Number of elements allocated when we grow a vector */
+	ELEMSPERCHUNK =	8
+};
+
+/*
+ * Global NSS data structures are mostly read-only, but we update
+ * them when we read or re-read the nsswitch.conf.
+ */
+static	pthread_rwlock_t	nss_lock = PTHREAD_RWLOCK_INITIALIZER;
+
+/*
+ * Runtime determination of whether we are dynamically linked or not.
+ */
+extern	int		_DYNAMIC __attribute__ ((weak));
+#define	is_dynamic()	(&_DYNAMIC != NULL)
+
+/*
+ * default sourcelist: `files'
+ */
+const ns_src __nsdefaultsrc[] = {
+	{ NSSRC_FILES, NS_SUCCESS },
+	{ 0 },
+};
+
+/* Database, source mappings. */
+static	unsigned int		 _nsmapsize;
+static	ns_dbt			*_nsmap = NULL;
+
+/* NSS modules. */
+static	unsigned int		 _nsmodsize;
+static	ns_mod			*_nsmod;
+
+/* Placeholder for builtin modules' dlopen `handle'. */
+static	int			 __nss_builtin_handle;
+static	void			*nss_builtin_handle = &__nss_builtin_handle;
+
+/*
+ * Attempt to spew relatively uniform messages to syslog.
+ */
+#define nss_log(level, fmt, ...) \
+	syslog((level), "NSSWITCH(%s): " fmt, __func__, __VA_ARGS__)
+#define nss_log_simple(level, s) \
+	syslog((level), "NSSWITCH(%s): " s, __func__)
+
+/*
+ * Dynamically growable arrays are used for lists of databases, sources,
+ * and modules.  The following `vector' interface is used to isolate the
+ * common operations.
+ */
+typedef	int	(*vector_comparison)(const void *, const void *);
+typedef	void	(*vector_free_elem)(void *);
+static	void	  vector_sort(void *, unsigned int, size_t,
+		    vector_comparison);
+static	void	  vector_free(void *, unsigned int *, size_t,
+		    vector_free_elem);
+static	void	 *vector_ref(unsigned int, void *, unsigned int, size_t);
+static	void	 *vector_search(const void *, void *, unsigned int, size_t,
+		    vector_comparison);
+static	void	 *vector_append(const void *, void *, unsigned int *, size_t);
+
+
+/*
+ * Internal interfaces.
+ */
+static	int	 string_compare(const void *, const void *);
+static	int	 mtab_compare(const void *, const void *);
+static	int	 nss_configure(void);
+static	void	 ns_dbt_free(ns_dbt *);
+static	void	 ns_mod_free(ns_mod *);
+static	void	 ns_src_free(ns_src **, int);
+static	void	 nss_load_builtin_modules(void);
+static	void	 nss_load_module(const char *, nss_module_register_fn);
+static	void	 nss_atexit(void);
+/* nsparser */
+extern	FILE	*_nsyyin;
+
+
+/*
+ * The vector operations
+ */
+static void
+vector_sort(void *vec, unsigned int count, size_t esize,
+    vector_comparison comparison)
+{
+	qsort(vec, count, esize, comparison);
+}
+
+
+static void *
+vector_search(const void *key, void *vec, unsigned int count, size_t esize,
+    vector_comparison comparison)
+{
+	return (bsearch(key, vec, count, esize, comparison));
+}
+
+
+static void *
+vector_append(const void *elem, void *vec, unsigned int *count, size_t esize)
+{
+	void	*p;
+
+	if ((*count % ELEMSPERCHUNK) == 0) {
+		p = realloc(vec, (*count + ELEMSPERCHUNK) * esize);
+		if (p == NULL) {
+			nss_log_simple(LOG_ERR, "memory allocation failure");
+			return (vec);
+		}
+		vec = p;
+	}
+	memmove((void *)(((uintptr_t)vec) + (*count * esize)), elem, esize);
+	(*count)++;
+	return (vec);
+}
+
+
+static void *
+vector_ref(unsigned int i, void *vec, unsigned int count, size_t esize)
+{
+	if (i < count)
+		return (void *)((uintptr_t)vec + (i * esize));
+	else
+		return (NULL);
+}
+
+
+#define VECTOR_FREE(v, c, s, f) \
+	do { vector_free(v, c, s, f); v = NULL; } while (0)
+static void
+vector_free(void *vec, unsigned int *count, size_t esize,
+    vector_free_elem free_elem)
+{
+	unsigned int	 i;
+	void		*elem;
+
+	for (i = 0; i < *count; i++) {
+		elem = vector_ref(i, vec, *count, esize);
+		if (elem != NULL)
+			free_elem(elem);
+	}
+	free(vec);
+	*count = 0;
+}
+
+
+
+/*
+ * Comparison functions for vector_search.
+ */
+static int
+string_compare(const void *a, const void *b)
+{
+      return (strcasecmp(*(const char * const *)a, *(const char * const *)b));
+}
+
+
+static int
+mtab_compare(const void *a, const void *b)
+{
+      int     cmp;
+
+      cmp = strcmp(((const ns_mtab *)a)->name, ((const ns_mtab *)b)->name);
+      if (cmp != 0)
+	      return (cmp);
+      else
+	      return (strcmp(((const ns_mtab *)a)->database,
+		  ((const ns_mtab *)b)->database));
+}
+
+
+
+/*
+ * NSS nsmap management.
+ */
+void
+_nsdbtaddsrc(ns_dbt *dbt, const ns_src *src)
+{
+	const ns_mod	*modp;
+
+	dbt->srclist = vector_append(src, dbt->srclist, &dbt->srclistsize,
+	    sizeof(*src));
+	modp = vector_search(&src->name, _nsmod, _nsmodsize, sizeof(*_nsmod),
+	    string_compare);
+	if (modp == NULL)
+		nss_load_module(src->name, NULL);
+}
+
+
+#ifdef _NSS_DEBUG
+void
+_nsdbtdump(const ns_dbt *dbt)
+{
+	int i;
+
+	printf("%s (%d source%s):", dbt->name, dbt->srclistsize,
+	    dbt->srclistsize == 1 ? "" : "s");
+	for (i = 0; i < (int)dbt->srclistsize; i++) {
+		printf(" %s", dbt->srclist[i].name);
+		if (!(dbt->srclist[i].flags &
+		    (NS_UNAVAIL|NS_NOTFOUND|NS_TRYAGAIN)) &&
+		    (dbt->srclist[i].flags & NS_SUCCESS))
+			continue;
+		printf(" [");
+		if (!(dbt->srclist[i].flags & NS_SUCCESS))
+			printf(" SUCCESS=continue");
+		if (dbt->srclist[i].flags & NS_UNAVAIL)
+			printf(" UNAVAIL=return");
+		if (dbt->srclist[i].flags & NS_NOTFOUND)
+			printf(" NOTFOUND=return");
+		if (dbt->srclist[i].flags & NS_TRYAGAIN)
+			printf(" TRYAGAIN=return");
+		printf(" ]");
+	}
+	printf("\n");
+}
+#endif
+
+
+/*
+ * The first time nsdispatch is called (during a process's lifetime,
+ * or after nsswitch.conf has been updated), nss_configure will
+ * prepare global data needed by NSS.
+ */
+static int
+nss_configure(void)
+{
+	static pthread_mutex_t conf_lock = PTHREAD_MUTEX_INITIALIZER;
+	static time_t	 confmod;
+	struct stat	 statbuf;
+	int		 result, isthreaded;
+	const char	*path;
+
+	result = 0;
+	isthreaded = __isthreaded;
+#if defined(_NSS_DEBUG) && defined(_NSS_SHOOT_FOOT)
+	/* NOTE WELL:  THIS IS A SECURITY HOLE. This must only be built
+	 * for debugging purposes and MUST NEVER be used in production.
+	 */
+	path = getenv("NSSWITCH_CONF");
+	if (path == NULL)
+#endif
+	path = _PATH_NS_CONF;
+	if (stat(path, &statbuf) != 0)
+		return (0);
+	if (statbuf.st_mtime <= confmod)
+		return (0);
+	if (isthreaded) {
+	    result = _pthread_mutex_trylock(&conf_lock);
+	    if (result != 0)
+		    return (0);
+	    (void)_pthread_rwlock_unlock(&nss_lock);
+	    result = _pthread_rwlock_wrlock(&nss_lock);
+	    if (result != 0)
+		    goto fin2;
+	}
+	_nsyyin = fopen(path, "r");
+	if (_nsyyin == NULL)
+		goto fin;
+	VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap),
+	    (vector_free_elem)ns_dbt_free);
+	VECTOR_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod),
+	    (vector_free_elem)ns_mod_free);
+	nss_load_builtin_modules();
+	_nsyyparse();
+	(void)fclose(_nsyyin);
+	vector_sort(_nsmap, _nsmapsize, sizeof(*_nsmap), string_compare);
+	if (confmod == 0)
+		(void)atexit(nss_atexit);
+	confmod = statbuf.st_mtime;
+fin:
+	if (isthreaded) {
+	    (void)_pthread_rwlock_unlock(&nss_lock);
+	    if (result == 0)
+		    result = _pthread_rwlock_rdlock(&nss_lock);
+	}
+fin2:
+	if (isthreaded)
+		(void)_pthread_mutex_unlock(&conf_lock);
+	return (result);
+}
+
+
+void
+_nsdbtput(const ns_dbt *dbt)
+{
+	unsigned int	 i;
+	ns_dbt		*p;
+
+	for (i = 0; i < _nsmapsize; i++) {
+		p = vector_ref(i, _nsmap, _nsmapsize, sizeof(*_nsmap));
+		if (string_compare(&dbt->name, &p->name) == 0) {
+			/* overwrite existing entry */
+			if (p->srclist != NULL)
+				ns_src_free(&p->srclist, p->srclistsize);
+			memmove(p, dbt, sizeof(*dbt));
+			return;
+		}
+	}
+	_nsmap = vector_append(dbt, _nsmap, &_nsmapsize, sizeof(*_nsmap));
+}
+
+
+static void
+ns_dbt_free(ns_dbt *dbt)
+{
+	ns_src_free(&dbt->srclist, dbt->srclistsize);
+}
+
+
+static void
+ns_src_free(ns_src **src, int srclistsize)
+{
+	int	i;
+
+	for (i = 0; i < srclistsize; i++)
+		if ((*src)[i].name != NULL)
+			/* This one was allocated by nslexer. You'll just
+			 * have to trust me.
+			 */
+			free((void *)((*src)[i].name));
+	free(*src);
+	*src = NULL;
+}
+
+
+
+/*
+ * NSS module management.
+ */
+/* The built-in NSS modules are all loaded at once. */
+#define NSS_BACKEND(name, reg) \
+ns_mtab	*reg(unsigned int *, nss_module_unregister_fn *);
+#include "nss_backends.h"
+#undef NSS_BACKEND
+
+static void
+nss_load_builtin_modules(void)
+{
+#define NSS_BACKEND(name, reg) nss_load_module(#name, reg);
+#include "nss_backends.h"
+#undef NSS_BACKEND
+}
+
+
+/* Load a built-in or dynamically linked module.  If the `reg_fn'
+ * argument is non-NULL, assume a built-in module and use reg_fn to
+ * register it.  Otherwise, search for a dynamic NSS module.
+ */
+static void
+nss_load_module(const char *source, nss_module_register_fn reg_fn)
+{
+	char		 buf[PATH_MAX];
+	ns_mod		 mod;
+	nss_module_register_fn fn;
+
+	memset(&mod, 0, sizeof(mod));
+	mod.name = strdup(source);
+	if (mod.name == NULL) {
+		nss_log_simple(LOG_ERR, "memory allocation failure");
+		return;
+	}
+	if (reg_fn != NULL) {
+		/* The placeholder is required, as a NULL handle
+		 * represents an invalid module.
+		 */
+		mod.handle = nss_builtin_handle;
+		fn = reg_fn;
+	} else if (!is_dynamic())
+		goto fin;
+	else {
+		if (snprintf(buf, sizeof(buf), "nss_%s.so.%d", mod.name,
+		    NSS_MODULE_INTERFACE_VERSION) >= (int)sizeof(buf))
+			goto fin;
+		mod.handle = dlopen(buf, RTLD_LOCAL|RTLD_LAZY);
+		if (mod.handle == NULL) {
+#ifdef _NSS_DEBUG
+			/* This gets pretty annoying since the built-in
+			 * sources aren't modules yet.
+			 */
+			nss_log(LOG_DEBUG, "%s, %s", mod.name, dlerror());
+#endif
+			goto fin;
+		}
+		fn = (nss_module_register_fn)dlfunc(mod.handle,
+		    "nss_module_register");
+		if (fn == NULL) {
+			(void)dlclose(mod.handle);
+			mod.handle = NULL;
+			nss_log(LOG_ERR, "%s, %s", mod.name, dlerror());
+			goto fin;
+		}
+	}
+	mod.mtab = fn(mod.name, &mod.mtabsize, &mod.unregister);
+	if (mod.mtab == NULL || mod.mtabsize == 0) {
+		if (mod.handle != nss_builtin_handle)
+			(void)dlclose(mod.handle);
+		mod.handle = NULL;
+		nss_log(LOG_ERR, "%s, registration failed", mod.name);
+		goto fin;
+	}
+	if (mod.mtabsize > 1)
+		qsort(mod.mtab, mod.mtabsize, sizeof(mod.mtab[0]),
+		    mtab_compare);
+fin:
+	_nsmod = vector_append(&mod, _nsmod, &_nsmodsize, sizeof(*_nsmod));
+	vector_sort(_nsmod, _nsmodsize, sizeof(*_nsmod), string_compare);
+}
+
+
+
+static void
+ns_mod_free(ns_mod *mod)
+{
+
+	free(mod->name);
+	if (mod->handle == NULL)
+		return;
+	if (mod->unregister != NULL)
+		mod->unregister(mod->mtab, mod->mtabsize);
+	if (mod->handle != nss_builtin_handle)
+		(void)dlclose(mod->handle);
+}
+
+
+
+/*
+ * Cleanup
+ */
+static void
+nss_atexit(void)
+{
+	int isthreaded;
+
+	isthreaded = __isthreaded;
+	if (isthreaded)
+		(void)_pthread_rwlock_wrlock(&nss_lock);
+	VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap),
+	    (vector_free_elem)ns_dbt_free);
+	VECTOR_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod),
+	    (vector_free_elem)ns_mod_free);
+	if (isthreaded)
+		(void)_pthread_rwlock_unlock(&nss_lock);
+}
+
+
+
+/*
+ * Finally, the actual implementation.
+ */
+static nss_method
+nss_method_lookup(const char *source, const char *database,
+    const char *method, const ns_dtab disp_tab[], void **mdata)
+{
+	ns_mod	*mod;
+	ns_mtab	*match, key;
+	int	 i;
+
+	if (disp_tab != NULL)
+		for (i = 0; disp_tab[i].src != NULL; i++)
+			if (strcasecmp(source, disp_tab[i].src) == 0) {
+				*mdata = disp_tab[i].mdata;
+				return (disp_tab[i].method);
+			}
+	mod = vector_search(&source, _nsmod, _nsmodsize, sizeof(*_nsmod),
+	    string_compare);
+	if (mod != NULL && mod->handle != NULL) {
+		key.database = database;
+		key.name = method;
+		match = bsearch(&key, mod->mtab, mod->mtabsize,
+		    sizeof(mod->mtab[0]), mtab_compare);
+		if (match != NULL) {
+			*mdata = match->mdata;
+			return (match->method);
+		}
+	}
+	if (is_dynamic())
+		nss_log(LOG_DEBUG, "%s, %s, %s, not found", source, database,
+		    method);
+	*mdata = NULL;
+	return (NULL);
+}
+
+
+__weak_reference(_nsdispatch, nsdispatch);
+
+int
+_nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
+	    const char *method_name, const ns_src defaults[], ...)
+{
+	va_list		 ap;
+	const ns_dbt	*dbt;
+	const ns_src	*srclist;
+	nss_method	 method;
+	void		*mdata;
+	int		 isthreaded, serrno, i, result, srclistsize;
+
+	isthreaded = __isthreaded;
+	serrno = errno;
+	if (isthreaded) {
+		result = _pthread_rwlock_rdlock(&nss_lock);
+		if (result != 0) {
+			result = NS_UNAVAIL;
+			goto fin;
+		}
+	}
+	result = nss_configure();
+	if (result != 0) {
+		result = NS_UNAVAIL;
+		goto fin;
+	}
+	dbt = vector_search(&database, _nsmap, _nsmapsize, sizeof(*_nsmap),
+	    string_compare);
+	if (dbt != NULL) {
+		srclist = dbt->srclist;
+		srclistsize = dbt->srclistsize;
+	} else {
+		srclist = defaults;
+		srclistsize = 0;
+		while (srclist[srclistsize].name != NULL)
+			srclistsize++;
+	}
+	for (i = 0; i < srclistsize; i++) {
+		result = NS_NOTFOUND;
+		method = nss_method_lookup(srclist[i].name, database,
+		    method_name, disp_tab, &mdata);
+		if (method != NULL) {
+			va_start(ap, defaults);
+			result = method(retval, mdata, ap);
+			va_end(ap);
+			if (result & (srclist[i].flags))
+				break;
+		}
+	}
+	if (isthreaded)
+		(void)_pthread_rwlock_unlock(&nss_lock);
+fin:
+	errno = serrno;
+	return (result);
+}
Index: /vendor/FreeBSD-libc/5.3/net/nslexer.l
===================================================================
--- /vendor/FreeBSD-libc/5.3/net/nslexer.l	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/net/nslexer.l	(revision 2404)
@@ -0,0 +1,119 @@
+%{
+/*	$NetBSD: nslexer.l,v 1.3 1999/01/25 00:16:17 lukem Exp $	*/
+
+/*-
+ * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Luke Mewburn.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = 
+  "$FreeBSD: src/lib/libc/net/nslexer.l,v 1.5 2003/04/17 14:14:22 nectar Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <ctype.h>
+#define _NS_PRIVATE
+#include <nsswitch.h>
+#include <string.h>
+#include <syslog.h>
+#include "un-namespace.h"
+
+#include "nsparser.h"
+
+#define YY_NO_UNPUT
+
+%}
+
+%option yylineno
+
+BLANK		[ \t]
+CR		\n
+STRING		[a-zA-Z][a-zA-Z0-9_]*
+
+%%
+
+{BLANK}+	;			/* skip whitespace */
+
+#.*		;			/* skip comments */
+
+\\{CR}		;			/* allow continuation */
+
+{CR}		return NL;
+
+[sS][uU][cC][cC][eE][sS][sS]		return SUCCESS;
+[uU][nN][aA][vV][aA][iI][lL]		return UNAVAIL;
+[nN][oO][tT][fF][oO][uU][nN][dD]	return NOTFOUND;
+[tT][rR][yY][aA][gG][aA][iI][nN]	return TRYAGAIN;
+
+[rR][eE][tT][uU][rR][nN]		return RETURN;
+[cC][oO][nN][tT][iI][nN][uU][eE]	return CONTINUE;
+
+{STRING}	{
+			char *p;
+			int i;
+
+			if ((p = strdup(yytext)) == NULL) {
+				syslog(LOG_ERR,
+			       "NSSWITCH(nslexer): memory allocation failure");
+				return ERRORTOKEN;
+			}
+			for (i = 0; i < strlen(p); i++) {
+				if (isupper((unsigned char)p[i]))
+					p[i] = tolower((unsigned char)p[i]);
+			}
+			_nsyylval.str = p;
+			return STRING;
+		}
+
+.		return yytext[0];
+
+%%
+
+#undef _nsyywrap
+int
+_nsyywrap()
+{
+	return 1;
+} /* _nsyywrap */
+
+void
+_nsyyerror(msg)
+	const char *msg;
+{
+
+	 syslog(LOG_ERR, "NSSWITCH(nslexer): %s line %d: %s at '%s'",
+	     _PATH_NS_CONF, yylineno, msg, yytext);
+} /* _nsyyerror */
Index: /vendor/FreeBSD-libc/5.3/net/nsparser.y
===================================================================
--- /vendor/FreeBSD-libc/5.3/net/nsparser.y	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/net/nsparser.y	(revision 2404)
@@ -0,0 +1,178 @@
+%{
+/*	$NetBSD: nsparser.y,v 1.3 1999/01/25 00:16:18 lukem Exp $	*/
+
+/*-
+ * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Luke Mewburn.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/net/nsparser.y,v 1.4 2003/04/17 14:14:22 nectar Exp $");
+
+#include "namespace.h"
+#define _NS_PRIVATE
+#include <nsswitch.h>
+#include <stdio.h>
+#include <string.h>
+#include <syslog.h>
+#include "un-namespace.h"
+
+static	void	_nsaddsrctomap(const char *);
+
+static	ns_dbt		curdbt;
+static	ns_src		cursrc;
+%}
+
+%union {
+	char *str;
+	int   mapval;
+}
+
+%token	NL
+%token	SUCCESS UNAVAIL NOTFOUND TRYAGAIN
+%token	RETURN CONTINUE
+%token  ERRORTOKEN
+%token	<str> STRING
+
+%type	<mapval> Status Action
+
+%%
+
+File
+	:	/* empty */
+	| Lines
+	;
+
+Lines
+	: Entry
+	| Lines Entry
+	;
+
+Entry
+	: NL
+	| Database ':' NL
+	| Database ':' Srclist NL
+		{
+			_nsdbtput(&curdbt);
+		}
+	| error NL
+		{
+			yyerrok;
+		}
+	;
+
+Database
+	: STRING
+		{
+			curdbt.name = yylval.str;
+			curdbt.srclist = NULL;
+			curdbt.srclistsize = 0;
+		}
+	;
+
+Srclist
+	: Item
+	| Srclist Item
+	;
+
+Item
+	: STRING
+		{
+			cursrc.flags = NS_TERMINATE;
+			_nsaddsrctomap($1);
+		}
+	| STRING '[' { cursrc.flags = NS_SUCCESS; } Criteria ']'
+		{
+			_nsaddsrctomap($1);
+		}
+	;
+
+Criteria
+	: Criterion
+	| Criteria Criterion
+	;
+
+Criterion
+	: Status '=' Action
+		{
+			if ($3)	     /* if action == RETURN set RETURN bit */
+				cursrc.flags |= $1;  
+			else	     /* else unset it */
+				cursrc.flags &= ~$1;
+		}
+	;
+
+Status
+	: SUCCESS	{ $$ = NS_SUCCESS; }
+	| UNAVAIL	{ $$ = NS_UNAVAIL; }
+	| NOTFOUND	{ $$ = NS_NOTFOUND; }
+	| TRYAGAIN	{ $$ = NS_TRYAGAIN; }
+	;
+
+Action
+	: RETURN	{ $$ = NS_ACTION_RETURN; }
+	| CONTINUE	{ $$ = NS_ACTION_CONTINUE; }
+	;
+
+%%
+
+static void
+_nsaddsrctomap(elem)
+	const char *elem;
+{
+	int		i, lineno;
+	extern int	_nsyylineno;
+	extern char *	_nsyytext;
+
+	lineno = _nsyylineno - (*_nsyytext == '\n' ? 1 : 0);
+	if (curdbt.srclistsize > 0) {
+		if ((strcasecmp(elem, NSSRC_COMPAT) == 0) ||
+		    (strcasecmp(curdbt.srclist[0].name, NSSRC_COMPAT) == 0)) {
+			syslog(LOG_ERR,
+	    "NSSWITCH(nsparser): %s line %d: 'compat' used with other sources",
+			    _PATH_NS_CONF, lineno);
+			return;
+		}
+	}
+	for (i = 0; i < curdbt.srclistsize; i++) {
+		if (strcasecmp(curdbt.srclist[i].name, elem) == 0) {
+			syslog(LOG_ERR,
+		       "NSSWITCH(nsparser): %s line %d: duplicate source '%s'",
+			    _PATH_NS_CONF, lineno, elem);
+			return;
+		}
+	}
+	cursrc.name = elem;
+	_nsdbtaddsrc(&curdbt, &cursrc);
+}
Index: /vendor/FreeBSD-libc/5.3/net/nss_backends.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/net/nss_backends.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/net/nss_backends.h	(revision 2404)
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2003 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * This software was developed for the FreeBSD Project by
+ * Jacques A. Vidrine, Safeport Network Services, and Network
+ * Associates Laboratories, the Security Research Division of Network
+ * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
+ * ("CBOSS"), as part of the DARPA CHATS research program.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: src/lib/libc/net/nss_backends.h,v 1.1 2003/04/17 14:14:22 nectar Exp $
+ */
+/*
+ * Eventually, the implementations of existing built-in NSS functions
+ * may be moved into NSS modules and live here.
+ */
+#if 0
+NSS_BACKEND(	files,	_files_nss_module_register	)
+NSS_BACKEND(	dns,	_dns_nss_module_register	)
+NSS_BACKEND(	nis,	_nis_nss_module_register	)
+NSS_BACKEND(	compat,	_compat_nss_module_register	)
+#endif
Index: /vendor/FreeBSD-libc/5.3/nls/msgcat.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/nls/msgcat.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/nls/msgcat.c	(revision 2404)
@@ -0,0 +1,499 @@
+/***********************************************************
+Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that Alfalfa's name not be used in
+advertising or publicity pertaining to distribution of the software
+without specific, written prior permission.
+
+ALPHALPHA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ALPHALPHA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+If you make any modifications, bugfixes or other changes to this software
+we'd appreciate it if you could send a copy to us so we can keep things
+up-to-date.  Many thanks.
+				Kee Hinckley
+				Alfalfa Software, Inc.
+				267 Allston St., #3
+				Cambridge, MA 02139  USA
+				nazgul@alfalfa.com
+
+******************************************************************/
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/nls/msgcat.c,v 1.48 2003/10/29 10:45:01 tjr Exp $");
+
+/*
+ * We need a better way of handling errors than printing text.  I need
+ * to add an error handling routine.
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <locale.h>
+#include <nl_types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+#include "msgcat.h"
+#include "../locale/setlocale.h"        /* for ENCODING_LEN */
+
+#define _DEFAULT_NLS_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L"
+
+#define	TRUE	1
+#define	FALSE	0
+
+#define	NLERR		((nl_catd) -1)
+#define NLRETERR(errc)  { errno = errc; return (NLERR); }
+
+static nl_catd  loadCat();
+static int      loadSet();
+static void     __nls_free_resources();
+
+nl_catd
+catopen(name, type)
+	__const char    *name;
+	int             type;
+{
+	int             spcleft, saverr;
+	char            path[PATH_MAX];
+	char            *nlspath, *lang, *base, *cptr, *pathP, *tmpptr;
+	char            *cptr1, *plang, *pter, *pcode;
+	struct stat     sbuf;
+
+	if (name == NULL || *name == '\0')
+		NLRETERR(EINVAL);
+
+	/* is it absolute path ? if yes, load immediately */
+	if (strchr(name, '/') != NULL)
+		return (loadCat(name));
+
+	if (type == NL_CAT_LOCALE)
+		lang = setlocale(LC_MESSAGES, NULL);
+	else
+		lang = getenv("LANG");
+
+	if (lang == NULL || *lang == '\0' || strlen(lang) > ENCODING_LEN ||
+	    (lang[0] == '.' &&
+	     (lang[1] == '\0' || (lang[1] == '.' && lang[2] == '\0'))) ||
+	    strchr(lang, '/') != NULL)
+		lang = "C";
+
+	if ((plang = cptr1 = strdup(lang)) == NULL)
+		return (NLERR);
+	if ((cptr = strchr(cptr1, '@')) != NULL)
+		*cptr = '\0';
+	pter = pcode = "";
+	if ((cptr = strchr(cptr1, '_')) != NULL) {
+		*cptr++ = '\0';
+		pter = cptr1 = cptr;
+	}
+	if ((cptr = strchr(cptr1, '.')) != NULL) {
+		*cptr++ = '\0';
+		pcode = cptr;
+	}
+
+	if ((nlspath = getenv("NLSPATH")) == NULL || issetugid())
+		nlspath = _DEFAULT_NLS_PATH;
+
+	if ((base = cptr = strdup(nlspath)) == NULL) {
+		saverr = errno;
+		free(plang);
+		errno = saverr;
+		return (NLERR);
+	}
+
+	while ((nlspath = strsep(&cptr, ":")) != NULL) {
+		pathP = path;
+		if (*nlspath) {
+			for (; *nlspath; ++nlspath) {
+				if (*nlspath == '%') {
+					switch (*(nlspath + 1)) {
+					case 'l':
+						tmpptr = plang;
+						break;
+					case 't':
+						tmpptr = pter;
+						break;
+					case 'c':
+						tmpptr = pcode;
+						break;
+					case 'L':
+						tmpptr = lang;
+						break;
+					case 'N':
+						tmpptr = (char *)name;
+						break;
+					case '%':
+						++nlspath;
+						/* fallthrough */
+					default:
+						if (pathP - path >=
+						    sizeof(path) - 1)
+							goto too_long;
+						*(pathP++) = *nlspath;
+						continue;
+					}
+					++nlspath;
+			put_tmpptr:
+					spcleft = sizeof(path) -
+						  (pathP - path) - 1;
+					if (strlcpy(pathP, tmpptr, spcleft) >=
+					    spcleft) {
+				too_long:
+						free(plang);
+						free(base);
+						NLRETERR(ENAMETOOLONG);
+					}
+					pathP += strlen(tmpptr);
+				} else {
+					if (pathP - path >= sizeof(path) - 1)
+						goto too_long;
+					*(pathP++) = *nlspath;
+				}
+			}
+			*pathP = '\0';
+			if (stat(path, &sbuf) == 0) {
+				free(plang);
+				free(base);
+				return (loadCat(path));
+			}
+		} else {
+			tmpptr = (char *)name;
+			--nlspath;
+			goto put_tmpptr;
+		}
+	}
+	free(plang);
+	free(base);
+	NLRETERR(ENOENT);
+}
+
+/*
+ * We've got an odd situation here.  The odds are real good that the
+ * number we are looking for is almost the same as the index.  We could
+ * use the index, check the difference and do something intelligent, but
+ * I haven't quite figured out what's intelligent.
+ *
+ * Here's a start.
+ *	Take an id N.  If there are > N items in the list, then N cannot
+ *	be more than N items from the start, since otherwise there would
+ *	have to be duplicate items.  So we can safely set the top to N+1
+ *	(after taking into account that ids start at 1, and arrays at 0)
+ *
+ *	Let's say we are at position P, and we are looking for N, but have
+ *	V.  If N > V, then the furthest away that N could be is
+ *	P + (N-V).  So we can safely set hi to P+(N-V)+1.  For example:
+ *		We are looking for 10, but have 8
+ *		8	?	?	?	?
+ *			>=9	>=10	>=11
+ *
+ */
+
+#define LOOKUP(PARENT, CHILD, ID, NUM, SET) {                    \
+	lo = 0;                                                  \
+	if (ID - 1 < PARENT->NUM) {                              \
+		cur = ID - 1;                                    \
+		hi = ID;                                         \
+	} else {                                                 \
+		hi = PARENT->NUM;                                \
+		cur = (hi - lo) / 2;                             \
+	}                                                        \
+	while (TRUE) {                                           \
+		CHILD = PARENT->SET + cur;                       \
+		if (CHILD->ID == ID)                             \
+			break;                                   \
+		if (CHILD->ID < ID) {                            \
+			lo = cur + 1;                            \
+			if (hi > cur + (ID - CHILD->ID) + 1)     \
+				hi = cur + (ID - CHILD->ID) + 1; \
+			dir = 1;                                 \
+		} else {                                         \
+			hi = cur;                                \
+			dir = -1;                                \
+		}                                                \
+		if (lo >= hi)                                    \
+			return (NULL);                           \
+		if (hi - lo == 1)                                \
+			cur += dir;                              \
+		else                                             \
+			cur += ((hi - lo) / 2) * dir;            \
+	}                                                        \
+}
+
+static MCSetT *
+MCGetSet(cat, setId)
+	MCCatT  *cat;
+	int     setId;
+{
+	MCSetT  *set;
+	long    lo, hi, cur, dir;
+
+	if (cat == NULL || setId <= 0)
+		return (NULL);
+	LOOKUP(cat, set, setId, numSets, sets);
+	if (set->invalid && loadSet(cat, set) <= 0)
+		return (NULL);
+	return (set);
+}
+
+static MCMsgT *
+MCGetMsg(set, msgId)
+	MCSetT  *set;
+	int     msgId;
+{
+	MCMsgT  *msg;
+	long    lo, hi, cur, dir;
+
+	if (set == NULL || set->invalid || msgId <= 0)
+		return (NULL);
+	LOOKUP(set, msg, msgId, numMsgs, u.msgs);
+	return (msg);
+}
+
+char *
+catgets(catd, setId, msgId, dflt)
+	nl_catd         catd;
+	int             setId;
+	int             msgId;
+	__const char    *dflt;
+{
+	MCMsgT          *msg;
+	MCCatT          *cat = (MCCatT *)catd;
+	__const char    *cptr;
+
+	if (catd == NULL || catd == NLERR)
+		return ((char *)dflt);
+	msg = MCGetMsg(MCGetSet(cat, setId), msgId);
+	if (msg != NULL)
+		cptr = msg->msg.str;
+	else
+		cptr = dflt;
+	return ((char *)cptr);
+}
+
+int
+catclose(catd)
+	nl_catd catd;
+{
+	MCCatT  *cat = (MCCatT *)catd;
+
+	if (catd == NULL || catd == NLERR) {
+		errno = EBADF;
+		return (-1);
+	}
+#if 0
+	if (cat->loadType != MCLoadAll)
+#endif
+		(void)fclose(cat->fp);
+	__nls_free_resources(cat, cat->numSets);
+	free(cat);
+	return (0);
+}
+
+/*
+ * Internal routines
+ */
+
+/* Note that only malloc failures are allowed to return an error */
+static char     *_errowner = "Message Catalog System";
+
+#define CORRUPT() {                                            \
+	(void)fclose(cat->fp);                                 \
+	(void)fprintf(stderr, "%s: corrupt file.", _errowner); \
+	free(cat);                                             \
+	NLRETERR(EFTYPE);                                      \
+}
+
+#define NOSPACE() {                                              \
+	saverr = errno;                                          \
+	(void)fclose(cat->fp);                                   \
+	(void)fprintf(stderr, "%s: no more memory.", _errowner); \
+	free(cat);                                               \
+	errno = saverr;                                          \
+	return (NLERR);                                          \
+}
+
+static void
+__nls_free_resources(cat, i)
+	MCCatT  *cat;
+	int     i;
+{
+	MCSetT  *set;
+	int     j;
+
+	for (j = 0; j < i; j++) {
+		set = cat->sets + j;
+		if (!set->invalid) {
+			free(set->data.str);
+			free(set->u.msgs);
+		}
+	}
+	free(cat->sets);
+}
+
+static nl_catd
+loadCat(catpath)
+	__const char    *catpath;
+{
+	MCHeaderT       header;
+	MCCatT          *cat;
+	MCSetT          *set;
+	long            i;
+	off_t           nextSet;
+	int             saverr;
+
+	if ((cat = (MCCatT *)malloc(sizeof(MCCatT))) == NULL)
+		return (NLERR);
+	cat->loadType = MCLoadBySet;
+
+	if ((cat->fp = fopen(catpath, "r")) == NULL) {
+		saverr = errno;
+		free(cat);
+		errno = saverr;
+		return (NLERR);
+	}
+	(void)_fcntl(fileno(cat->fp), F_SETFD, FD_CLOEXEC);
+
+	if (fread(&header, sizeof(header), 1, cat->fp) != 1 ||
+	    strncmp(header.magic, MCMagic, MCMagicLen) != 0)
+		CORRUPT();
+
+	if (header.majorVer != MCMajorVer) {
+		(void)fclose(cat->fp);
+		free(cat);
+		(void)fprintf(stderr, "%s: %s is version %ld, we need %ld.\n",
+		    _errowner, catpath, header.majorVer, MCMajorVer);
+		NLRETERR(EFTYPE);
+	}
+	if (header.numSets <= 0) {
+		(void)fclose(cat->fp);
+		free(cat);
+		(void)fprintf(stderr, "%s: %s has %ld sets!\n",
+		    _errowner, catpath, header.numSets);
+		NLRETERR(EFTYPE);
+	}
+
+	cat->numSets = header.numSets;
+	if ((cat->sets = (MCSetT *)malloc(sizeof(MCSetT) * header.numSets)) ==
+	    NULL)
+		NOSPACE();
+
+	nextSet = header.firstSet;
+	for (i = 0; i < cat->numSets; ++i) {
+		if (fseeko(cat->fp, nextSet, SEEK_SET) == -1) {
+			__nls_free_resources(cat, i);
+			CORRUPT();
+		}
+
+		/* read in the set header */
+		set = cat->sets + i;
+		if (fread(set, sizeof(*set), 1, cat->fp) != 1) {
+			__nls_free_resources(cat, i);
+			CORRUPT();
+		}
+
+		/* if it's invalid, skip over it (and backup 'i') */
+		if (set->invalid) {
+			--i;
+			nextSet = set->nextSet;
+			continue;
+		}
+#if 0
+		if (cat->loadType == MCLoadAll) {
+			int     res;
+
+			if ((res = loadSet(cat, set)) <= 0) {
+				saverr = errno;
+				__nls_free_resources(cat, i);
+				errno = saverr;
+				if (res < 0)
+					NOSPACE();
+				CORRUPT();
+			}
+		} else
+#endif
+			set->invalid = TRUE;
+		nextSet = set->nextSet;
+	}
+#if 0
+	if (cat->loadType == MCLoadAll) {
+		(void)fclose(cat->fp);
+		cat->fp = NULL;
+	}
+#endif
+	return ((nl_catd) cat);
+}
+
+static int
+loadSet(cat, set)
+	MCCatT  *cat;
+	MCSetT  *set;
+{
+	MCMsgT  *msg;
+	int     i;
+	int     saverr;
+
+	/* Get the data */
+	if (fseeko(cat->fp, set->data.off, SEEK_SET) == -1)
+		return (0);
+	if ((set->data.str = malloc(set->dataLen)) == NULL)
+		return (-1);
+	if (fread(set->data.str, set->dataLen, 1, cat->fp) != 1) {
+		saverr = errno;
+		free(set->data.str);
+		errno = saverr;
+		return (0);
+	}
+
+	/* Get the messages */
+	if (fseeko(cat->fp, set->u.firstMsg, SEEK_SET) == -1) {
+		saverr = errno;
+		free(set->data.str);
+		errno = saverr;
+		return (0);
+	}
+	if ((set->u.msgs = (MCMsgT *)malloc(sizeof(MCMsgT) * set->numMsgs)) ==
+	    NULL) {
+		saverr = errno;
+		free(set->data.str);
+		errno = saverr;
+		return (-1);
+	}
+
+	for (i = 0; i < set->numMsgs; ++i) {
+		msg = set->u.msgs + i;
+		if (fread(msg, sizeof(*msg), 1, cat->fp) != 1) {
+			saverr = errno;
+			free(set->u.msgs);
+			free(set->data.str);
+			errno = saverr;
+			return (0);
+		}
+		if (msg->invalid) {
+			--i;
+			continue;
+		}
+		msg->msg.str = (char *)(set->data.str + msg->msg.off);
+	}
+	set->invalid = FALSE;
+	return (1);
+}
Index: /vendor/FreeBSD-libc/5.3/nls/msgcat.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/nls/msgcat.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/nls/msgcat.h	(revision 2404)
@@ -0,0 +1,155 @@
+/* $FreeBSD: src/lib/libc/nls/msgcat.h,v 1.8 2000/09/03 21:05:10 ache Exp $ */
+
+#ifndef _MSGCAT_H_
+#define _MSGCAT_H_
+
+
+/***********************************************************
+Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that Alfalfa's name not be used in
+advertising or publicity pertaining to distribution of the software
+without specific, written prior permission.
+
+ALPHALPHA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ALPHALPHA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+If you make any modifications, bugfixes or other changes to this software
+we'd appreciate it if you could send a copy to us so we can keep things
+up-to-date.  Many thanks.
+				Kee Hinckley
+				Alfalfa Software, Inc.
+				267 Allston St., #3
+				Cambridge, MA 02139  USA
+				nazgul@alfalfa.com
+
+******************************************************************/
+
+
+#include <sys/types.h>
+
+/*
+ * On disk data structures
+ */
+
+/* For or'd constants */
+#define MCMakeId(s,m)		(unsigned long) ( ((unsigned short)s << (sizeof(short)*8)) \
+						 | (unsigned short)m )
+#define MCSetId(id)		(unsigned int) ( id >> (sizeof(short) * 8) )
+#define MCMsgId(id)		(unsigned int) ( (id << (sizeof(short) * 8)) \
+						>> (sizeof(short) * 8) )
+#define MCMagicLen	8
+#define MCMagic		"*nazgul*"
+#define MCLastMsg	0
+#define MCLastSet	0
+
+#define MCMajorVer	1L
+#define MCMinorVer	0
+
+/*
+ * Critical note here.  Sets and Messages *MUST* be stored in ascending
+ * order.  There are stored that way (by specification) in the original
+ * data file, however in the process of merging in new stuff you might
+ * mix that up.  Don't!  The catget stuff does a binary search and will
+ * totally lose it if these aren't in order (not contiguous mind you, just
+ * in order.  If this turns out to be a major problem this could be enhanced
+ * by adding a 'sorted' flag to the db, and sorting msgs and sets at load
+ * time if things aren't sorted, but I'd like not to have to do that.
+ */
+
+/*
+ * I have tried here to define data structures which can be used
+ * while the catalog is on disk, and at runtime.
+ * This is rather dangerous of course, but I think it can be done without
+ * overly increasing the memory usage, and it makes loading and storing
+ * somewhat simpler and less prone to accidents.  I have also tried to
+ * define on disk data structures which can be updated in place, so that
+ * with a very large catalog (e.g. all system errors) you don't have to
+ * load everything in memory in order to add or update one set.  With
+ * this in mind there are "invalid" flags which allow items to be
+ * invalidated and thus not loaded at runtime.  Note however that although
+ * I pay attention to these when I load the DB, I do not currently use
+ * them in gencat (it just reads everything into memory), so there is
+ * no guarantee that this will all work.
+ */
+
+/* These should be publicly available */
+
+#define MCLoadBySet	0	/* Load entire sets as they are used */
+#define MCLoadAll	1	/* Load entire DB on catopen */
+
+/*
+ * MCOffsetT - Union to handle both disk and runtime pointers
+ */
+typedef union {
+    off_t	off;
+    char	*str;
+    void	*ptr;
+    struct _MCMsgT	*msg;
+    struct _MCSetT	*set;
+} MCOffsetT;
+
+/*
+ * MCMsgT - Message structure (disk and runtime)
+ */
+typedef struct _MCMsgT {
+    long	msgId;		/* Id of this message */
+    MCOffsetT	msg;		/* Relative offset on disk or pointer in memory */
+    long	invalid;	/* Valid on disk, loaded in memory */
+} MCMsgT;
+
+/*
+ * MCSetT - Set structure (disk and runtime)
+ */
+typedef struct _MCSetT {
+    long	setId;		/* Id of this set */
+    off_t	nextSet;	/* Offset of next set on disk */
+    union {
+	off_t	firstMsg;	/* Offset to first Msg (while on disk) */
+	MCMsgT	*msgs;		/* Pointer to array of msgs (in mem, loaded) */
+    } u;
+    MCOffsetT	data;		/* Offset to data, or pointer to data */
+    long	dataLen;	/* Length of data area on disk */
+    long	numMsgs;	/* Number of messages */
+    long	invalid;	/* Valid on disk, loaded in memory */
+} MCSetT;
+
+/*
+ * MCCatT - Runtime catalog pointer
+ */
+typedef struct {
+    long	loadType;	/* How to load the messages (see MSLoadType) */
+    FILE        *fp;            /* File descriptor of catalog (if load-on-demand) */
+    long	numSets;	/* Number of sets */
+    MCSetT	*sets;		/* Pointer to the sets */
+    off_t	firstSet;	/* Offset of first set on disk */
+} MCCatT;
+
+/*
+ * MCHeaderT - Disk file header
+ */
+typedef struct {
+    char	magic[MCMagicLen];	/* Magic cookie "*nazgul*" */
+    long	majorVer;		/* ++ on incompatible changes */
+    long	minorVer;		/* ++ on compatible changes */
+    long	flags;			/* Informational flags */
+    long	numSets;		/* Number of valid Sets */
+    off_t	firstSet;		/* Offset of first set on disk */
+} MCHeaderT;
+
+/* Some flags */
+#define MC68KByteOrder	0x01
+#define MCn86ByteOrder	0x02
+
+#endif /* !_MSGCAT_H_ */
Index: /vendor/FreeBSD-libc/5.3/regex/COPYRIGHT
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/COPYRIGHT	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/COPYRIGHT	(revision 2404)
@@ -0,0 +1,56 @@
+Copyright 1992, 1993, 1994 Henry Spencer.  All rights reserved.
+This software is not subject to any license of the American Telephone
+and Telegraph Company or of the Regents of the University of California.
+
+Permission is granted to anyone to use this software for any purpose on
+any computer system, and to alter it and redistribute it, subject
+to the following restrictions:
+
+1. The author is not responsible for the consequences of use of this
+   software, no matter how awful, even if they arise from flaws in it.
+
+2. The origin of this software must not be misrepresented, either by
+   explicit claim or by omission.  Since few users ever read sources,
+   credits must appear in the documentation.
+
+3. Altered versions must be plainly marked as such, and must not be
+   misrepresented as being the original software.  Since few users
+   ever read sources, credits must appear in the documentation.
+
+4. This notice may not be removed or altered.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+/*-
+ * Copyright (c) 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ *
+ *	@(#)COPYRIGHT	8.1 (Berkeley) 3/16/94
+ */
Index: /vendor/FreeBSD-libc/5.3/regex/WHATSNEW
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/WHATSNEW	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/WHATSNEW	(revision 2404)
@@ -0,0 +1,94 @@
+# @(#)WHATSNEW	8.3 (Berkeley) 3/18/94
+
+New in alpha3.4:  The complex bug alluded to below has been fixed (in a
+slightly kludgey temporary way that may hurt efficiency a bit; this is
+another "get it out the door for 4.4" release).  The tests at the end of
+the tests file have accordingly been uncommented.  The primary sign of
+the bug was that something like a?b matching ab matched b rather than ab.
+(The bug was essentially specific to this exact situation, else it would
+have shown up earlier.)
+
+New in alpha3.3:  The definition of word boundaries has been altered
+slightly, to more closely match the usual programming notion that "_"
+is an alphabetic.  Stuff used for pre-ANSI systems is now in a subdir,
+and the makefile no longer alludes to it in mysterious ways.  The
+makefile has generally been cleaned up some.  Fixes have been made
+(again!) so that the regression test will run without -DREDEBUG, at
+the cost of weaker checking.  A workaround for a bug in some folks'
+<assert.h> has been added.  And some more things have been added to
+tests, including a couple right at the end which are commented out
+because the code currently flunks them (complex bug; fix coming).
+Plus the usual minor cleanup.
+
+New in alpha3.2:  Assorted bits of cleanup and portability improvement
+(the development base is now a BSDI system using GCC instead of an ancient
+Sun system, and the newer compiler exposed some glitches).  Fix for a
+serious bug that affected REs using many [] (including REG_ICASE REs
+because of the way they are implemented), *sometimes*, depending on
+memory-allocation patterns.  The header-file prototypes no longer name
+the parameters, avoiding possible name conflicts.  The possibility that
+some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is
+now handled gracefully.  "uchar" is no longer used as an internal type
+name (too many people have the same idea).  Still the same old lousy
+performance, alas.
+
+New in alpha3.1:  Basically nothing, this release is just a bookkeeping
+convenience.  Stay tuned.
+
+New in alpha3.0:  Performance is no better, alas, but some fixes have been
+made and some functionality has been added.  (This is basically the "get
+it out the door in time for 4.4" release.)  One bug fix:  regfree() didn't
+free the main internal structure (how embarrassing).  It is now possible
+to put NULs in either the RE or the target string, using (resp.) a new
+REG_PEND flag and the old REG_STARTEND flag.  The REG_NOSPEC flag to
+regcomp() makes all characters ordinary, so you can match a literal
+string easily (this will become more useful when performance improves!).
+There are now primitives to match beginnings and ends of words, although
+the syntax is disgusting and so is the implementation.  The REG_ATOI
+debugging interface has changed a bit.  And there has been considerable
+internal cleanup of various kinds.
+
+New in alpha2.3:  Split change list out of README, and moved flags notes
+into Makefile.  Macro-ized the name of regex(7) in regex(3), since it has
+to change for 4.4BSD.  Cleanup work in engine.c, and some new regression
+tests to catch tricky cases thereof.
+
+New in alpha2.2:  Out-of-date manpages updated.  Regerror() acquires two
+small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges
+in my own test program and might be useful to others for similar purposes.
+The regression test will now compile (and run) without REDEBUG.  The
+BRE \$ bug is fixed.  Most uses of "uchar" are gone; it's all chars now.
+Char/uchar parameters are now written int/unsigned, to avoid possible
+portability problems with unpromoted parameters.  Some unsigned casts have
+been introduced to minimize portability problems with shifting into sign
+bits.
+
+New in alpha2.1:  Lots of little stuff, cleanup and fixes.  The one big
+thing is that regex.h is now generated, using mkh, rather than being
+supplied in the distribution; due to circularities in dependencies,
+you have to build regex.h explicitly by "make h".  The two known bugs
+have been fixed (and the regression test now checks for them), as has a
+problem with assertions not being suppressed in the absence of REDEBUG.
+No performance work yet.
+
+New in alpha2:  Backslash-anything is an ordinary character, not an
+error (except, of course, for the handful of backslashed metacharacters
+in BREs), which should reduce script breakage.  The regression test
+checks *where* null strings are supposed to match, and has generally
+been tightened up somewhat.  Small bug fixes in parameter passing (not
+harmful, but technically errors) and some other areas.  Debugging
+invoked by defining REDEBUG rather than not defining NDEBUG.
+
+New in alpha+3:  full prototyping for internal routines, using a little
+helper program, mkh, which extracts prototypes given in stylized comments.
+More minor cleanup.  Buglet fix:  it's CHAR_BIT, not CHAR_BITS.  Simple
+pre-screening of input when a literal string is known to be part of the
+RE; this does wonders for performance.
+
+New in alpha+2:  minor bits of cleanup.  Notably, the number "32" for the
+word width isn't hardwired into regexec.c any more, the public header
+file prototypes the functions if __STDC__ is defined, and some small typos
+in the manpages have been fixed.
+
+New in alpha+1:  improvements to the manual pages, and an important
+extension, the REG_STARTEND option to regexec().
Index: /vendor/FreeBSD-libc/5.3/regex/cclass.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/cclass.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/cclass.h	(revision 2404)
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ * $FreeBSD: src/lib/libc/regex/cclass.h,v 1.4 2002/03/22 23:41:56 obrien Exp $
+ */
+
+
+typedef enum {CALNUM, CALPHA, CBLANK, CCNTRL, CDIGIT, CGRAPH,
+	      CLOWER, CPRINT, CPUNCT, CSPACE, CUPPER, CXDIGIT} citype;
+
+/* character-class table */
+static struct cclass {
+	char *name;
+	citype fidx;
+} cclasses[] = {
+	{"alnum",       CALNUM},
+	{"alpha",       CALPHA},
+	{"blank",       CBLANK},
+	{"cntrl",       CCNTRL},
+	{"digit",       CDIGIT},
+	{"graph",       CGRAPH},
+	{"lower",       CLOWER},
+	{"print",       CPRINT},
+	{"punct",       CPUNCT},
+	{"space",       CSPACE},
+	{"upper",       CUPPER},
+	{"xdigit",      CXDIGIT},
+	{NULL,          }
+};
Index: /vendor/FreeBSD-libc/5.3/regex/cname.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/cname.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/cname.h	(revision 2404)
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ * $FreeBSD: src/lib/libc/regex/cname.h,v 1.3 2002/03/22 23:41:56 obrien Exp $
+ */
+
+/* character-name table */
+static struct cname {
+	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}
+};
Index: /vendor/FreeBSD-libc/5.3/regex/engine.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/engine.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/engine.c	(revision 2404)
@@ -0,0 +1,1192 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/regex/engine.c,v 1.14 2004/07/12 07:35:59 tjr Exp $");
+
+/*
+ * 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
+#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
+#endif
+#ifdef MNAMES
+#define	matcher	mmatcher
+#define	fast	mfast
+#define	slow	mslow
+#define	dissect	mdissect
+#define	backref	mbackref
+#define	step	mstep
+#define	print	mprint
+#define	at	mat
+#define	match	mmat
+#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 */
+	mbstate_t mbs;		/* multibyte conversion state */
+};
+
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* === engine.c === */
+static int matcher(struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
+static char *dissect(struct match *m, char *start, char *stop, sopno startst, sopno stopst);
+static char *backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev);
+static char *fast(struct match *m, char *start, char *stop, sopno startst, sopno stopst);
+static char *slow(struct match *m, char *start, char *stop, sopno startst, sopno stopst);
+static states step(struct re_guts *g, sopno start, sopno stop, states bef, wint_t 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	BADCHAR	(BOL-6)
+#define	NONCHAR(c)	((c) <= OUT)
+#ifdef REDEBUG
+static void print(struct match *m, char *caption, states st, int ch, FILE *d);
+#endif
+#ifdef REDEBUG
+static void at(struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst);
+#endif
+#ifdef REDEBUG
+static char *pchar(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)); }
+#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;
+	/* Boyer-Moore algorithms variables */
+	char *pp;
+	int cj, mj;
+	char *mustfirst;
+	char *mustlast;
+	int *matchjump;
+	int *charjump;
+
+	/* simplify the situation where possible */
+	if (g->cflags&REG_NOSUB)
+		nmatch = 0;
+	if (eflags&REG_STARTEND) {
+		start = string + pmatch[0].rm_so;
+		stop = string + 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) {
+		if (g->charjump != NULL && g->matchjump != NULL) {
+			mustfirst = g->must;
+			mustlast = g->must + g->mlen - 1;
+			charjump = g->charjump;
+			matchjump = g->matchjump;
+			pp = mustlast;
+			for (dp = start+g->mlen-1; dp < stop;) {
+				/* Fast skip non-matches */
+				while (dp < stop && charjump[(int)*dp])
+					dp += charjump[(int)*dp];
+
+				if (dp >= stop)
+					break;
+
+				/* Greedy matcher */
+				/* We depend on not being used for
+				 * for strings of length 1
+				 */
+				while (*--dp == *--pp && pp != mustfirst);
+
+				if (*dp == *pp)
+					break;
+
+				/* Jump to next possible match */
+				mj = matchjump[pp - mustfirst];
+				cj = charjump[(int)*dp];
+				dp += (cj < mj ? mj : cj);
+				pp = mustlast;
+			}
+			if (pp != mustfirst)
+				return(REG_NOMATCH);
+		} else {
+			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);
+	ZAPSTATE(&m->mbs);
+
+	/* Adjust start according to moffset, to speed things up */
+	if (g->moffset > -1)
+		start = ((dp - g->moffset) < start) ? start : dp - g->moffset;
+
+	/* this loop does only one repetition except for backrefs */
+	for (;;) {
+		endp = fast(m, start, stop, gf, gl);
+		if (endp == NULL) {		/* a miss */
+			STATETEARDOWN(m);
+			return(REG_NOMATCH);
+		}
+		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 += XMBRTOWC(NULL, m->coldp,
+			    m->endp - m->coldp, &m->mbs, 0);
+		}
+		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) {
+			STATETEARDOWN(m);
+			return(REG_ESPACE);
+		}
+		for (i = 1; i <= m->g->nsub; i++)
+			m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -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) {
+				free(m->pmatch);
+				STATETEARDOWN(m);
+				return(REG_ESPACE);
+			}
+			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 == -1);
+				assert(m->pmatch[i].rm_eo == -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");
+		/* recycle starting later */
+		start = m->coldp + XMBRTOWC(NULL, m->coldp,
+		    m->endp - m->coldp, &m->mbs, 0);
+		assert(start <= stop);
+	}
+
+	/* fill in the details if requested */
+	if (nmatch > 0) {
+		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 = -1;
+				pmatch[i].rm_eo = -1;
+			}
+	}
+
+	if (m->pmatch != NULL)
+		free((char *)m->pmatch);
+	if (m->lastpos != NULL)
+		free((char *)m->lastpos);
+	STATETEARDOWN(m);
+	return(0);
+}
+
+/*
+ - 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 */
+	char *dp;
+
+	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 += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0);
+			break;
+		case OBOL:
+		case OEOL:
+		case OBOW:
+		case OEOW:
+			break;
+		case OANY:
+		case OANYOF:
+			sp += XMBRTOWC(NULL, sp, stop - start, &m->mbs, 0);
+			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) {
+				dp = 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);
+			dp = 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);
+			}
+			dp = 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;
+	wint_t wc;
+
+	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)
+				return(NULL);
+			sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
+			if (wc != OPND(s))
+				return(NULL);
+			break;
+		case OANY:
+			if (sp == stop)
+				return(NULL);
+			sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
+			if (wc == BADCHAR)
+				return (NULL);
+			break;
+		case OANYOF:
+			if (sp == stop)
+				return (NULL);
+			cs = &m->g->sets[OPND(s)];
+			sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
+			if (wc == BADCHAR || !CHIN(cs, wc))
+				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 == -1)
+			return(NULL);
+		assert(m->pmatch[i].rm_so != -1);
+		len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
+		assert(stop - m->beginp >= len);
+		if (sp > stop - len)
+			return(NULL);	/* not enough left to match */
+		ssp = m->offp + 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));
+		break;
+	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));
+		break;
+	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));
+		break;
+	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)
+			return(backref(m, sp, stop, ss+1, stopst, lev-1));
+		else
+			return(dp);
+		break;
+	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);
+		}
+		break;
+	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);
+		break;
+	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);
+		break;
+	default:		/* uh oh */
+		assert(nope);
+		break;
+	}
+
+	/* "can't happen" */
+	assert(nope);
+	/* NOTREACHED */
+	return "shut up gcc";
+}
+
+/*
+ - 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;
+	wint_t c;
+	wint_t lastc;		/* previous c */
+	wint_t flagch;
+	int i;
+	char *coldp;		/* last p after which no match was underway */
+	size_t clen;
+
+	CLEAR(st);
+	SET1(st, startst);
+	st = step(m->g, startst, stopst, st, NOTHING, st);
+	ASSIGN(fresh, st);
+	SP("start", st, *p);
+	coldp = NULL;
+	if (start == m->beginp)
+		c = OUT;
+	else {
+		/*
+		 * XXX Wrong if the previous character was multi-byte.
+		 * Newline never is (in encodings supported by FreeBSD),
+		 * so this only breaks the ISWORD tests below.
+		 */
+		c = (uch)*(start - 1);
+	}
+	for (;;) {
+		/* next character */
+		lastc = c;
+		if (p == m->endp)
+			c = OUT;
+		else
+			clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR);
+		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 += clen;
+	}
+
+	assert(coldp != NULL);
+	m->coldp = coldp;
+	if (ISSET(st, stopst))
+		return(p+XMBRTOWC(NULL, p, m->endp - p, &m->mbs, 0));
+	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;
+	wint_t c;
+	wint_t lastc;		/* previous c */
+	wint_t flagch;
+	int i;
+	char *matchp;		/* last p at which a match ended */
+	size_t clen;
+
+	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;
+	if (start == m->beginp)
+		c = OUT;
+	else {
+		/*
+		 * XXX Wrong if the previous character was multi-byte.
+		 * Newline never is (in encodings supported by FreeBSD),
+		 * so this only breaks the ISWORD tests below.
+		 */
+		c = (uch)*(start - 1);
+	}
+	for (;;) {
+		/* next character */
+		lastc = c;
+		if (p == m->endp) {
+			c = OUT;
+			clen = 0;
+		} else
+			clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR);
+
+		/* 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 += clen;
+	}
+
+	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	BADCHAR	(BOL-6)
+ == #define	NONCHAR(c)	((c) <= OUT)
+ */
+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 */
+wint_t 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;
+
+	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 != OPND(s));
+			if (ch == 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;
+
+	if (!(m->eflags&REG_TRACE))
+		return;
+
+	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;
+{
+	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((uch)ch) || ch == ' ')
+		sprintf(pbuf, "%c", ch);
+	else
+		sprintf(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
Index: /vendor/FreeBSD-libc/5.3/regex/regcomp.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/regcomp.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/regcomp.c	(revision 2404)
@@ -0,0 +1,1843 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)regcomp.c	8.5 (Berkeley) 3/20/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/regex/regcomp.c,v 1.32.2.1 2004/09/08 04:42:46 tjr Exp $");
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <regex.h>
+#include <wchar.h>
+#include <wctype.h>
+
+#include "collate.h"
+
+#include "utils.h"
+#include "regex2.h"
+
+#include "cname.h"
+
+/*
+ * 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(struct parse *p, wint_t stop);
+static void p_ere_exp(struct parse *p);
+static void p_str(struct parse *p);
+static void p_bre(struct parse *p, wint_t end1, wint_t end2);
+static int p_simp_re(struct parse *p, int starordinary);
+static int p_count(struct parse *p);
+static void p_bracket(struct parse *p);
+static void p_b_term(struct parse *p, cset *cs);
+static void p_b_cclass(struct parse *p, cset *cs);
+static void p_b_eclass(struct parse *p, cset *cs);
+static wint_t p_b_symbol(struct parse *p);
+static wint_t p_b_coll_elem(struct parse *p, wint_t endc);
+static wint_t othercase(wint_t ch);
+static void bothcases(struct parse *p, wint_t ch);
+static void ordinary(struct parse *p, wint_t ch);
+static void nonnewline(struct parse *p);
+static void repeat(struct parse *p, sopno start, int from, int to);
+static int seterr(struct parse *p, int e);
+static cset *allocset(struct parse *p);
+static void freeset(struct parse *p, cset *cs);
+static void CHadd(struct parse *p, cset *cs, wint_t ch);
+static void CHaddrange(struct parse *p, cset *cs, wint_t min, wint_t max);
+static void CHaddtype(struct parse *p, cset *cs, wctype_t wct);
+static wint_t singleton(cset *cs);
+static sopno dupl(struct parse *p, sopno start, sopno finish);
+static void doemit(struct parse *p, sop op, size_t opnd);
+static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos);
+static void dofwd(struct parse *p, sopno pos, sop value);
+static void enlarge(struct parse *p, sopno size);
+static void stripsnug(struct parse *p, struct re_guts *g);
+static void findmust(struct parse *p, struct re_guts *g);
+static int altoffset(sop *scan, int offset);
+static void computejumps(struct parse *p, struct re_guts *g);
+static void computematchjumps(struct parse *p, struct re_guts *g);
+static sopno pluscount(struct parse *p, struct re_guts *g);
+static wint_t wgetnext(struct parse *p);
+
+#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	WGETNEXT()	wgetnext(p)
+#define	SETERROR(e)	seterr(p, (e))
+#define	REQUIRE(co, e)	((co) || SETERROR(e))
+#define	MUSTSEE(c, e)	(REQUIRE(MORE() && PEEK() == (c), e))
+#define	MUSTEAT(c, e)	(REQUIRE(MORE() && GETNEXT() == (c), e))
+#define	MUSTNOTSEE(c, e)	(REQUIRE(!MORE() || PEEK() != (c), e))
+#define	EMIT(op, sopnd)	doemit(p, (sop)(op), (size_t)(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
+
+/* Macro used by computejump()/computematchjump() */
+#define MIN(a,b)	((a)<(b)?(a):(b))
+
+/*
+ - 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 * __restrict preg;
+const char * __restrict 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
+
+	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((char *)pattern);
+
+	/* do the mallocs early so failure handling is easy */
+	g = (struct re_guts *)malloc(sizeof(struct re_guts));
+	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((char *)g);
+		return(REG_ESPACE);
+	}
+
+	/* set things up */
+	p->g = g;
+	p->next = (char *)pattern;	/* convenience; we do not modify it */
+	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->sets = NULL;
+	g->ncsets = 0;
+	g->cflags = cflags;
+	g->iflags = 0;
+	g->nbol = 0;
+	g->neol = 0;
+	g->must = NULL;
+	g->moffset = -1;
+	g->charjump = NULL;
+	g->matchjump = NULL;
+	g->mlen = 0;
+	g->nsub = 0;
+	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 */
+	stripsnug(p, g);
+	findmust(p, g);
+	/* only use Boyer-Moore algorithm if the pattern is bigger
+	 * than three characters
+	 */
+	if(g->mlen > 3) {
+		computejumps(p, g);
+		computematchjumps(p, g);
+		if(g->matchjump == NULL && g->charjump != NULL) {
+			free(g->charjump);
+			g->charjump = NULL;
+		}
+	}
+	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;
+	sopno prevfwd;
+	sopno conc;
+	int first = 1;		/* is this the first alternative? */
+
+	for (;;) {
+		/* do a bunch of concatenated expressions */
+		conc = HERE();
+		while (MORE() && (c = PEEK()) != '|' && c != stop)
+			p_ere_exp(p);
+		(void)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;
+	wint_t wc;
+	sopno pos;
+	int count;
+	int count2;
+	sopno subno;
+	int wascaret = 0;
+
+	assert(MORE());		/* caller should have ensured this */
+	c = GETNEXT();
+
+	pos = HERE();
+	switch (c) {
+	case '(':
+		(void)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);
+		(void)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 '\\':
+		(void)REQUIRE(MORE(), REG_EESCAPE);
+		wc = WGETNEXT();
+		ordinary(p, wc);
+		break;
+	case '{':		/* okay as ordinary except if digit follows */
+		(void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
+		/* FALLTHROUGH */
+	default:
+		p->next--;
+		wc = WGETNEXT();
+		ordinary(p, wc);
+		break;
+	}
+
+	if (!MORE())
+		return;
+	c = PEEK();
+	/* we call { a repetition if followed by a digit */
+	if (!( c == '*' || c == '+' || c == '?' ||
+				(c == '{' && MORE2() && isdigit((uch)PEEK2())) ))
+		return;		/* no repetition, we're done */
+	NEXT();
+
+	(void)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((uch)PEEK())) {
+				count2 = p_count(p);
+				(void)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();
+			(void)REQUIRE(MORE(), REG_EBRACE);
+			SETERROR(REG_BADBR);
+		}
+		break;
+	}
+
+	if (!MORE())
+		return;
+	c = PEEK();
+	if (!( c == '*' || c == '+' || c == '?' ||
+				(c == '{' && MORE2() && isdigit((uch)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;
+{
+	(void)REQUIRE(MORE(), REG_EMPTY);
+	while (MORE())
+		ordinary(p, WGETNEXT());
+}
+
+/*
+ - 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 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 = HERE();
+	int first = 1;			/* first subexpression? */
+	int wasdollar = 0;
+
+	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++;
+	}
+
+	(void)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;
+	wint_t wc;
+	sopno subno;
+#	define	BACKSL	(1<<CHAR_BIT)
+
+	pos = HERE();		/* repetion op, if any, covers from here */
+
+	assert(MORE());		/* caller should have ensured this */
+	c = GETNEXT();
+	if (c == '\\') {
+		(void)REQUIRE(MORE(), REG_EESCAPE);
+		c = BACKSL | 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);
+		(void)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 '*':
+		(void)REQUIRE(starordinary, REG_BADRPT);
+		/* FALLTHROUGH */
+	default:
+		p->next--;
+		wc = WGETNEXT();
+		ordinary(p, wc);
+		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((uch)PEEK())) {
+				count2 = p_count(p);
+				(void)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();
+			(void)REQUIRE(MORE(), REG_EBRACE);
+			SETERROR(REG_BADBR);
+		}
+	} else if (c == '$')     /* $ (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;
+
+	while (MORE() && isdigit((uch)PEEK()) && count <= DUPMAX) {
+		count = count*10 + (GETNEXT() - '0');
+		ndigits++;
+	}
+
+	(void)REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR);
+	return(count);
+}
+
+/*
+ - p_bracket - parse a bracketed character list
+ == static void p_bracket(struct parse *p);
+ */
+static void
+p_bracket(p)
+struct parse *p;
+{
+	cset *cs;
+	wint_t ch;
+
+	/* Dept of Truly Sickening Special-Case Kludges */
+	if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) {
+		EMIT(OBOW, 0);
+		NEXTn(6);
+		return;
+	}
+	if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) {
+		EMIT(OEOW, 0);
+		NEXTn(6);
+		return;
+	}
+
+	if ((cs = allocset(p)) == NULL)
+		return;
+
+	if (p->g->cflags&REG_ICASE)
+		cs->icase = 1;
+	if (EAT('^'))
+		cs->invert = 1;
+	if (EAT(']'))
+		CHadd(p, cs, ']');
+	else if (EAT('-'))
+		CHadd(p, cs, '-');
+	while (MORE() && PEEK() != ']' && !SEETWO('-', ']'))
+		p_b_term(p, cs);
+	if (EAT('-'))
+		CHadd(p, cs, '-');
+	(void)MUSTEAT(']', REG_EBRACK);
+
+	if (p->error != 0)	/* don't mess things up further */
+		return;
+
+	if (cs->invert && p->g->cflags&REG_NEWLINE)
+		cs->bmp['\n' >> 3] |= 1 << ('\n' & 7);
+
+	if ((ch = singleton(cs)) != OUT) {	/* optimize singleton sets */
+		ordinary(p, ch);
+		freeset(p, cs);
+	} else
+		EMIT(OANYOF, (int)(cs - p->g->sets));
+}
+
+/*
+ - 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;
+	wint_t start, finish;
+	wint_t i;
+
+	/* classify what we've got */
+	switch ((MORE()) ? PEEK() : '\0') {
+	case '[':
+		c = (MORE2()) ? PEEK2() : '\0';
+		break;
+	case '-':
+		SETERROR(REG_ERANGE);
+		return;			/* NOTE RETURN */
+		break;
+	default:
+		c = '\0';
+		break;
+	}
+
+	switch (c) {
+	case ':':		/* character class */
+		NEXT2();
+		(void)REQUIRE(MORE(), REG_EBRACK);
+		c = PEEK();
+		(void)REQUIRE(c != '-' && c != ']', REG_ECTYPE);
+		p_b_cclass(p, cs);
+		(void)REQUIRE(MORE(), REG_EBRACK);
+		(void)REQUIRE(EATTWO(':', ']'), REG_ECTYPE);
+		break;
+	case '=':		/* equivalence class */
+		NEXT2();
+		(void)REQUIRE(MORE(), REG_EBRACK);
+		c = PEEK();
+		(void)REQUIRE(c != '-' && c != ']', REG_ECOLLATE);
+		p_b_eclass(p, cs);
+		(void)REQUIRE(MORE(), REG_EBRACK);
+		(void)REQUIRE(EATTWO('=', ']'), REG_ECOLLATE);
+		break;
+	default:		/* symbol, ordinary character, or range */
+		start = p_b_symbol(p);
+		if (SEE('-') && MORE2() && PEEK2() != ']') {
+			/* range */
+			NEXT();
+			if (EAT('-'))
+				finish = '-';
+			else
+				finish = p_b_symbol(p);
+		} else
+			finish = start;
+		if (start == finish)
+			CHadd(p, cs, start);
+		else {
+			if (__collate_load_error) {
+				(void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE);
+				CHaddrange(p, cs, start, finish);
+			} else {
+				(void)REQUIRE(__collate_range_cmp(start, finish) <= 0, REG_ERANGE);
+				for (i = 0; i <= UCHAR_MAX; i++) {
+					if (   __collate_range_cmp(start, i) <= 0
+					    && __collate_range_cmp(i, finish) <= 0
+					   )
+						CHadd(p, 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 = p->next;
+	size_t len;
+	wctype_t wct;
+	char clname[16];
+
+	while (MORE() && isalpha((uch)PEEK()))
+		NEXT();
+	len = p->next - sp;
+	if (len >= sizeof(clname) - 1) {
+		SETERROR(REG_ECTYPE);
+		return;
+	}
+	memcpy(clname, sp, len);
+	clname[len] = '\0';
+	if ((wct = wctype(clname)) == 0) {
+		SETERROR(REG_ECTYPE);
+		return;
+	}
+	CHaddtype(p, cs, wct);
+}
+
+/*
+ - 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;
+{
+	wint_t c;
+
+	c = p_b_coll_elem(p, '=');
+	CHadd(p, cs, c);
+}
+
+/*
+ - p_b_symbol - parse a character or [..]ed multicharacter collating symbol
+ == static char p_b_symbol(struct parse *p);
+ */
+static wint_t			/* value of symbol */
+p_b_symbol(p)
+struct parse *p;
+{
+	wint_t value;
+
+	(void)REQUIRE(MORE(), REG_EBRACK);
+	if (!EATTWO('[', '.'))
+		return(WGETNEXT());
+
+	/* collating symbol */
+	value = p_b_coll_elem(p, '.');
+	(void)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 wint_t			/* value of collating element */
+p_b_coll_elem(p, endc)
+struct parse *p;
+wint_t endc;			/* name ended by endc,']' */
+{
+	char *sp = p->next;
+	struct cname *cp;
+	int len;
+	mbstate_t mbs;
+	wchar_t wc;
+	size_t clen;
+
+	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 */
+	memset(&mbs, 0, sizeof(mbs));
+	if ((clen = mbrtowc(&wc, sp, len, &mbs)) == len)
+		return (wc);			/* single character */
+	else if (clen == (size_t)-1 || clen == (size_t)-2)
+		SETERROR(REG_ILLSEQ);
+	else
+		SETERROR(REG_ECOLLATE);		/* neither */
+	return(0);
+}
+
+/*
+ - othercase - return the case counterpart of an alphabetic
+ == static char othercase(int ch);
+ */
+static wint_t			/* if no counterpart, return ch */
+othercase(ch)
+wint_t ch;
+{
+	assert(iswalpha(ch));
+	if (iswupper(ch))
+		return(towlower(ch));
+	else if (iswlower(ch))
+		return(towupper(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;
+wint_t ch;
+{
+	char *oldnext = p->next;
+	char *oldend = p->end;
+	char bracket[3 + MB_LEN_MAX];
+	size_t n;
+	mbstate_t mbs;
+
+	assert(othercase(ch) != ch);	/* p_bracket() would recurse */
+	p->next = bracket;
+	memset(&mbs, 0, sizeof(mbs));
+	n = wcrtomb(bracket, ch, &mbs);
+	assert(n != (size_t)-1);
+	bracket[n] = ']';
+	bracket[n + 1] = '\0';
+	p->end = bracket+n+1;
+	p_bracket(p);
+	assert(p->next == p->end);
+	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;
+wint_t ch;
+{
+	cset *cs;
+
+	if ((p->g->cflags&REG_ICASE) && iswalpha(ch) && othercase(ch) != ch)
+		bothcases(p, ch);
+	else if ((ch & OPDMASK) == ch)
+		EMIT(OCHAR, ch);
+	else {
+		/*
+		 * Kludge: character is too big to fit into an OCHAR operand.
+		 * Emit a singleton set.
+		 */
+		if ((cs = allocset(p)) == NULL)
+			return;
+		CHadd(p, cs, ch);
+		EMIT(OANYOF, (int)(cs - p->g->sets));
+	}
+}
+
+/*
+ - 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 = p->next;
+	char *oldend = p->end;
+	char bracket[4];
+
+	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 = HERE();
+#	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;
+
+	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;
+	}
+}
+
+/*
+ - wgetnext - helper function for WGETNEXT() macro. Gets the next wide
+ - character from the parse struct, signals a REG_ILLSEQ error if the
+ - character can't be converted. Returns the number of bytes consumed.
+ */
+static wint_t
+wgetnext(p)
+struct parse *p;
+{
+	mbstate_t mbs;
+	wchar_t wc;
+	size_t n;
+
+	memset(&mbs, 0, sizeof(mbs));
+	n = mbrtowc(&wc, p->next, p->end - p->next, &mbs);
+	if (n == (size_t)-1 || n == (size_t)-2) {
+		SETERROR(REG_ILLSEQ);
+		return (0);
+	}
+	if (n == 0)
+		n = 1;
+	p->next += n;
+	return (wc);
+}
+
+/*
+ - 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;
+{
+	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;
+{
+	cset *cs, *ncs;
+
+	ncs = realloc(p->g->sets, (p->g->ncsets + 1) * sizeof(*ncs));
+	if (ncs == NULL) {
+		SETERROR(REG_ESPACE);
+		return (NULL);
+	}
+	p->g->sets = ncs;
+	cs = &p->g->sets[p->g->ncsets++];
+	memset(cs, 0, sizeof(*cs));
+
+	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;
+{
+	cset *top = &p->g->sets[p->g->ncsets];
+
+	free(cs->wides);
+	free(cs->ranges);
+	free(cs->types);
+	memset(cs, 0, sizeof(*cs));
+	if (cs == top-1)	/* recover only the easy case */
+		p->g->ncsets--;
+}
+
+/*
+ - singleton - Determine whether a set contains only one character,
+ - returning it if so, otherwise returning OUT.
+ */
+static wint_t
+singleton(cs)
+cset *cs;
+{
+	wint_t i, s, n;
+
+	for (i = n = 0; i < NC; i++)
+		if (CHIN(cs, i)) {
+			n++;
+			s = i;
+		}
+	if (n == 1)
+		return (s);
+	if (cs->nwides == 1 && cs->nranges == 0 && cs->ntypes == 0 &&
+	    cs->icase == 0)
+		return (cs->wides[0]);
+	/* Don't bother handling the other cases. */
+	return (OUT);
+}
+
+/*
+ - CHadd - add character to character set.
+ */
+static void
+CHadd(p, cs, ch)
+struct parse *p;
+cset *cs;
+wint_t ch;
+{
+	wint_t nch, *newwides;
+	assert(ch >= 0);
+	if (ch < NC)
+		cs->bmp[ch >> 3] |= 1 << (ch & 7);
+	else {
+		newwides = realloc(cs->wides, (cs->nwides + 1) *
+		    sizeof(*cs->wides));
+		if (newwides == NULL) {
+			SETERROR(REG_ESPACE);
+			return;
+		}
+		cs->wides = newwides;
+		cs->wides[cs->nwides++] = ch;
+	}
+	if (cs->icase) {
+		if ((nch = towlower(ch)) < NC)
+			cs->bmp[nch >> 3] |= 1 << (nch & 7);
+		if ((nch = towupper(ch)) < NC)
+			cs->bmp[nch >> 3] |= 1 << (nch & 7);
+	}
+}
+
+/*
+ - CHaddrange - add all characters in the range [min,max] to a character set.
+ */
+static void
+CHaddrange(p, cs, min, max)
+struct parse *p;
+cset *cs;
+wint_t min, max;
+{
+	crange *newranges;
+
+	for (; min < NC && min <= max; min++)
+		CHadd(p, cs, min);
+	if (min >= max)
+		return;
+	newranges = realloc(cs->ranges, (cs->nranges + 1) *
+	    sizeof(*cs->ranges));
+	if (newranges == NULL) {
+		SETERROR(REG_ESPACE);
+		return;
+	}
+	cs->ranges = newranges;
+	cs->ranges[cs->nranges].min = min;
+	cs->ranges[cs->nranges].min = max;
+	cs->nranges++;
+}
+
+/*
+ - CHaddtype - add all characters of a certain type to a character set.
+ */
+static void
+CHaddtype(p, cs, wct)
+struct parse *p;
+cset *cs;
+wctype_t wct;
+{
+	wint_t i;
+	wctype_t *newtypes;
+
+	for (i = 0; i < NC; i++)
+		if (iswctype(i, wct))
+			CHadd(p, cs, i);
+	newtypes = realloc(cs->types, (cs->ntypes + 1) *
+	    sizeof(*cs->types));
+	if (newtypes == NULL) {
+		SETERROR(REG_ESPACE);
+		return;
+	}
+	cs->types = newtypes;
+	cs->types[cs->ntypes++] = wct;
+}
+
+/*
+ - 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 = HERE();
+	sopno len = finish - start;
+
+	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((char *)(p->strip + p->slen),
+		(char *)(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;
+size_t opnd;
+{
+	/* 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;
+size_t opnd;
+sopno pos;
+{
+	sopno sn;
+	sop s;
+	int i;
+
+	/* 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((char *)&p->strip[pos+1], (char *)&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;
+sop value;
+{
+	/* 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;
+
+	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;
+{
+	g->nstates = p->slen;
+	g->strip = (sop *)realloc((char *)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;
+	sop *newstart;
+	sopno newlen;
+	sop s;
+	char *cp;
+	int offset;
+	char buf[MB_LEN_MAX];
+	size_t clen;
+	mbstate_t mbs;
+
+	/* avoid making error situations worse */
+	if (p->error != 0)
+		return;
+
+	/*
+	 * It's not generally safe to do a ``char'' substring search on
+	 * multibyte character strings, but it's safe for at least
+	 * UTF-8 (see RFC 3629).
+	 */
+	if (MB_CUR_MAX > 1 &&
+	    strcmp(_CurrentRuneLocale->__encoding, "UTF-8") != 0)
+		return;
+
+	/* find the longest OCHAR sequence in strip */
+	newlen = 0;
+	offset = 0;
+	g->moffset = 0;
+	scan = g->strip + 1;
+	do {
+		s = *scan++;
+		switch (OP(s)) {
+		case OCHAR:		/* sequence member */
+			if (newlen == 0) {		/* new sequence */
+				memset(&mbs, 0, sizeof(mbs));
+				newstart = scan - 1;
+			}
+			clen = wcrtomb(buf, OPND(s), &mbs);
+			if (clen == (size_t)-1)
+				goto toohard;
+			newlen += clen;
+			break;
+		case OPLUS_:		/* things that don't break one */
+		case OLPAREN:
+		case ORPAREN:
+			break;
+		case OQUEST_:		/* things that must be skipped */
+		case OCH_:
+			offset = altoffset(scan, offset);
+			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 */
+		case OBOW:		/* things that break a sequence */
+		case OEOW:
+		case OBOL:
+		case OEOL:
+		case O_QUEST:
+		case O_CH:
+		case OEND:
+			if (newlen > g->mlen) {		/* ends one */
+				start = newstart;
+				g->mlen = newlen;
+				if (offset > -1) {
+					g->moffset += offset;
+					offset = newlen;
+				} else
+					g->moffset = offset;
+			} else {
+				if (offset > -1)
+					offset += newlen;
+			}
+			newlen = 0;
+			break;
+		case OANY:
+			if (newlen > g->mlen) {		/* ends one */
+				start = newstart;
+				g->mlen = newlen;
+				if (offset > -1) {
+					g->moffset += offset;
+					offset = newlen;
+				} else
+					g->moffset = offset;
+			} else {
+				if (offset > -1)
+					offset += newlen;
+			}
+			if (offset > -1)
+				offset++;
+			newlen = 0;
+			break;
+		case OANYOF:		/* may or may not invalidate offset */
+			/* First, everything as OANY */
+			if (newlen > g->mlen) {		/* ends one */
+				start = newstart;
+				g->mlen = newlen;
+				if (offset > -1) {
+					g->moffset += offset;
+					offset = newlen;
+				} else
+					g->moffset = offset;
+			} else {
+				if (offset > -1)
+					offset += newlen;
+			}
+			if (offset > -1)
+				offset++;
+			newlen = 0;
+			break;
+		toohard:
+		default:
+			/* Anything here makes it impossible or too hard
+			 * to calculate the offset -- so we give up;
+			 * save the last known good offset, in case the
+			 * must sequence doesn't occur later.
+			 */
+			if (newlen > g->mlen) {		/* ends one */
+				start = newstart;
+				g->mlen = newlen;
+				if (offset > -1)
+					g->moffset += offset;
+				else
+					g->moffset = offset;
+			}
+			offset = -1;
+			newlen = 0;
+			break;
+		}
+	} while (OP(s) != OEND);
+
+	if (g->mlen == 0) {		/* there isn't one */
+		g->moffset = -1;
+		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;
+		g->moffset = -1;
+		return;
+	}
+	cp = g->must;
+	scan = start;
+	memset(&mbs, 0, sizeof(mbs));
+	while (cp < g->must + g->mlen) {
+		while (OP(s = *scan++) != OCHAR)
+			continue;
+		clen = wcrtomb(cp, OPND(s), &mbs);
+		assert(clen != (size_t)-1);
+		cp += clen;
+	}
+	assert(cp == g->must + g->mlen);
+	*cp++ = '\0';		/* just on general principles */
+}
+
+/*
+ - altoffset - choose biggest offset among multiple choices
+ == static int altoffset(sop *scan, int offset);
+ *
+ * Compute, recursively if necessary, the largest offset among multiple
+ * re paths.
+ */
+static int
+altoffset(scan, offset)
+sop *scan;
+int offset;
+{
+	int largest;
+	int try;
+	sop s;
+
+	/* If we gave up already on offsets, return */
+	if (offset == -1)
+		return -1;
+
+	largest = 0;
+	try = 0;
+	s = *scan++;
+	while (OP(s) != O_QUEST && OP(s) != O_CH) {
+		switch (OP(s)) {
+		case OOR1:
+			if (try > largest)
+				largest = try;
+			try = 0;
+			break;
+		case OQUEST_:
+		case OCH_:
+			try = altoffset(scan, try);
+			if (try == -1)
+				return -1;
+			scan--;
+			do {
+				scan += OPND(s);
+				s = *scan;
+				if (OP(s) != O_QUEST && OP(s) != O_CH &&
+							OP(s) != OOR2)
+					return -1;
+			} while (OP(s) != O_QUEST && OP(s) != O_CH);
+			/* We must skip to the next position, or we'll
+			 * leave altoffset() too early.
+			 */
+			scan++;
+			break;
+		case OANYOF:
+		case OCHAR:
+		case OANY:
+			try++;
+		case OBOW:
+		case OEOW:
+		case OLPAREN:
+		case ORPAREN:
+		case OOR2:
+			break;
+		default:
+			try = -1;
+			break;
+		}
+		if (try == -1)
+			return -1;
+		s = *scan++;
+	}
+
+	if (try > largest)
+		largest = try;
+
+	return largest+offset;
+}
+
+/*
+ - computejumps - compute char jumps for BM scan
+ == static void computejumps(struct parse *p, struct re_guts *g);
+ *
+ * This algorithm assumes g->must exists and is has size greater than
+ * zero. It's based on the algorithm found on Computer Algorithms by
+ * Sara Baase.
+ *
+ * A char jump is the number of characters one needs to jump based on
+ * the value of the character from the text that was mismatched.
+ */
+static void
+computejumps(p, g)
+struct parse *p;
+struct re_guts *g;
+{
+	int ch;
+	int mindex;
+
+	/* Avoid making errors worse */
+	if (p->error != 0)
+		return;
+
+	g->charjump = (int*) malloc((NC + 1) * sizeof(int));
+	if (g->charjump == NULL)	/* Not a fatal error */
+		return;
+	/* Adjust for signed chars, if necessary */
+	g->charjump = &g->charjump[-(CHAR_MIN)];
+
+	/* If the character does not exist in the pattern, the jump
+	 * is equal to the number of characters in the pattern.
+	 */
+	for (ch = CHAR_MIN; ch < (CHAR_MAX + 1); ch++)
+		g->charjump[ch] = g->mlen;
+
+	/* If the character does exist, compute the jump that would
+	 * take us to the last character in the pattern equal to it
+	 * (notice that we match right to left, so that last character
+	 * is the first one that would be matched).
+	 */
+	for (mindex = 0; mindex < g->mlen; mindex++)
+		g->charjump[(int)g->must[mindex]] = g->mlen - mindex - 1;
+}
+
+/*
+ - computematchjumps - compute match jumps for BM scan
+ == static void computematchjumps(struct parse *p, struct re_guts *g);
+ *
+ * This algorithm assumes g->must exists and is has size greater than
+ * zero. It's based on the algorithm found on Computer Algorithms by
+ * Sara Baase.
+ *
+ * A match jump is the number of characters one needs to advance based
+ * on the already-matched suffix.
+ * Notice that all values here are minus (g->mlen-1), because of the way
+ * the search algorithm works.
+ */
+static void
+computematchjumps(p, g)
+struct parse *p;
+struct re_guts *g;
+{
+	int mindex;		/* General "must" iterator */
+	int suffix;		/* Keeps track of matching suffix */
+	int ssuffix;		/* Keeps track of suffixes' suffix */
+	int* pmatches;		/* pmatches[k] points to the next i
+				 * such that i+1...mlen is a substring
+				 * of k+1...k+mlen-i-1
+				 */
+
+	/* Avoid making errors worse */
+	if (p->error != 0)
+		return;
+
+	pmatches = (int*) malloc(g->mlen * sizeof(unsigned int));
+	if (pmatches == NULL) {
+		g->matchjump = NULL;
+		return;
+	}
+
+	g->matchjump = (int*) malloc(g->mlen * sizeof(unsigned int));
+	if (g->matchjump == NULL)	/* Not a fatal error */
+		return;
+
+	/* Set maximum possible jump for each character in the pattern */
+	for (mindex = 0; mindex < g->mlen; mindex++)
+		g->matchjump[mindex] = 2*g->mlen - mindex - 1;
+
+	/* Compute pmatches[] */
+	for (mindex = g->mlen - 1, suffix = g->mlen; mindex >= 0;
+	    mindex--, suffix--) {
+		pmatches[mindex] = suffix;
+
+		/* If a mismatch is found, interrupting the substring,
+		 * compute the matchjump for that position. If no
+		 * mismatch is found, then a text substring mismatched
+		 * against the suffix will also mismatch against the
+		 * substring.
+		 */
+		while (suffix < g->mlen
+		    && g->must[mindex] != g->must[suffix]) {
+			g->matchjump[suffix] = MIN(g->matchjump[suffix],
+			    g->mlen - mindex - 1);
+			suffix = pmatches[suffix];
+		}
+	}
+
+	/* Compute the matchjump up to the last substring found to jump
+	 * to the beginning of the largest must pattern prefix matching
+	 * it's own suffix.
+	 */
+	for (mindex = 0; mindex <= suffix; mindex++)
+		g->matchjump[mindex] = MIN(g->matchjump[mindex],
+		    g->mlen + suffix - mindex);
+
+        ssuffix = pmatches[suffix];
+        while (suffix < g->mlen) {
+                while (suffix <= ssuffix && suffix < g->mlen) {
+                        g->matchjump[suffix] = MIN(g->matchjump[suffix],
+			    g->mlen + ssuffix - suffix);
+                        suffix++;
+                }
+		if (suffix < g->mlen)
+                	ssuffix = pmatches[ssuffix];
+        }
+
+	free(pmatches);
+}
+
+/*
+ - 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;
+
+	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);
+}
Index: /vendor/FreeBSD-libc/5.3/regex/regerror.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/regerror.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/regerror.c	(revision 2404)
@@ -0,0 +1,181 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)regerror.c	8.4 (Berkeley) 3/20/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/regex/regerror.c,v 1.9 2004/07/12 06:07:26 tjr Exp $");
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <regex.h>
+
+#include "utils.h"
+
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* === regerror.c === */
+static char *regatoi(const regex_t *preg, char *localbuf);
+
+#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_ILLSEQ	17
+ = #define	REG_ATOI	255	// convert name to number (!)
+ = #define	REG_ITOA	0400	// convert number to name (!)
+ */
+static struct rerr {
+	int code;
+	char *name;
+	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"},
+	{REG_ILLSEQ,	"REG_ILLSEQ",	"illegal byte sequence"},
+	{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 * __restrict preg;
+char * __restrict errbuf;
+size_t errbuf_size;
+{
+	struct rerr *r;
+	size_t len;
+	int target = errcode &~ REG_ITOA;
+	char *s;
+	char convbuf[50];
+
+	if (errcode == REG_ATOI)
+		s = regatoi(preg, convbuf);
+	else {
+		for (r = rerrs; r->code != 0; r++)
+			if (r->code == target)
+				break;
+
+		if (errcode&REG_ITOA) {
+			if (r->code != 0)
+				(void) strcpy(convbuf, r->name);
+			else
+				sprintf(convbuf, "REG_0x%x", target);
+			assert(strlen(convbuf) < sizeof(convbuf));
+			s = convbuf;
+		} else
+			s = r->explain;
+	}
+
+	len = strlen(s) + 1;
+	if (errbuf_size > 0) {
+		if (errbuf_size > len)
+			(void) strcpy(errbuf, s);
+		else {
+			(void) strncpy(errbuf, s, errbuf_size-1);
+			errbuf[errbuf_size-1] = '\0';
+		}
+	}
+
+	return(len);
+}
+
+/*
+ - regatoi - internal routine to implement REG_ATOI
+ == static char *regatoi(const regex_t *preg, char *localbuf);
+ */
+static char *
+regatoi(preg, localbuf)
+const regex_t *preg;
+char *localbuf;
+{
+	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");
+
+	sprintf(localbuf, "%d", r->code);
+	return(localbuf);
+}
Index: /vendor/FreeBSD-libc/5.3/regex/regex2.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/regex2.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/regex2.h	(revision 2404)
@@ -0,0 +1,200 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ * $FreeBSD: src/lib/libc/regex/regex2.h,v 1.8 2004/07/12 07:35:59 tjr Exp $
+ */
+
+/*
+ * 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 unsigned long sop;	/* strip operator */
+typedef long sopno;
+#define	OPRMASK	0xf8000000L
+#define	OPDMASK	0x07ffffffL
+#define	OPSHIFT	((unsigned)27)
+#define	OP(n)	((n)&OPRMASK)
+#define	OPND(n)	((n)&OPDMASK)
+#define	SOP(op, opnd)	((op)|(opnd))
+/* operators			   meaning	operand			*/
+/*						(back, fwd are offsets)	*/
+#define	OEND	(1L<<OPSHIFT)	/* endmarker	-			*/
+#define	OCHAR	(2L<<OPSHIFT)	/* character	wide character		*/
+#define	OBOL	(3L<<OPSHIFT)	/* left anchor	-			*/
+#define	OEOL	(4L<<OPSHIFT)	/* right anchor	-			*/
+#define	OANY	(5L<<OPSHIFT)	/* .		-			*/
+#define	OANYOF	(6L<<OPSHIFT)	/* [...]	set number		*/
+#define	OBACK_	(7L<<OPSHIFT)	/* begin \d	paren number		*/
+#define	O_BACK	(8L<<OPSHIFT)	/* end \d	paren number		*/
+#define	OPLUS_	(9L<<OPSHIFT)	/* + prefix	fwd to suffix		*/
+#define	O_PLUS	(10L<<OPSHIFT)	/* + suffix	back to prefix		*/
+#define	OQUEST_	(11L<<OPSHIFT)	/* ? prefix	fwd to suffix		*/
+#define	O_QUEST	(12L<<OPSHIFT)	/* ? suffix	back to prefix		*/
+#define	OLPAREN	(13L<<OPSHIFT)	/* (		fwd to )		*/
+#define	ORPAREN	(14L<<OPSHIFT)	/* )		back to (		*/
+#define	OCH_	(15L<<OPSHIFT)	/* begin choice	fwd to OOR2		*/
+#define	OOR1	(16L<<OPSHIFT)	/* | pt. 1	back to OOR1 or OCH_	*/
+#define	OOR2	(17L<<OPSHIFT)	/* | pt. 2	fwd to OOR2 or O_CH	*/
+#define	O_CH	(18L<<OPSHIFT)	/* end choice	back to OOR1		*/
+#define	OBOW	(19L<<OPSHIFT)	/* begin word	-			*/
+#define	OEOW	(20L<<OPSHIFT)	/* end word	-			*/
+
+/*
+ * Structures for [] character-set representation.
+ */
+typedef struct {
+	wint_t		min;
+	wint_t		max;
+} crange;
+typedef struct {
+	unsigned char	bmp[NC / 8];
+	wctype_t	*types;
+	int		ntypes;
+	wint_t		*wides;
+	int		nwides;
+	crange		*ranges;
+	int		nranges;
+	int		invert;
+	int		icase;
+} cset;
+
+static int
+CHIN1(cs, ch)
+cset *cs;
+wint_t ch;
+{
+	int i;
+
+	assert(ch >= 0);
+	if (ch < NC)
+		return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^
+		    cs->invert);
+	for (i = 0; i < cs->nwides; i++)
+		if (ch == cs->wides[i])
+			return (!cs->invert);
+	for (i = 0; i < cs->nranges; i++)
+		if (cs->ranges[i].min <= ch && ch <= cs->ranges[i].max)
+			return (!cs->invert);
+	for (i = 0; i < cs->ntypes; i++)
+		if (iswctype(ch, cs->types[i]))
+			return (!cs->invert);
+	return (cs->invert);
+}
+
+static __inline int
+CHIN(cs, ch)
+cset *cs;
+wint_t ch;
+{
+
+	assert(ch >= 0);
+	if (ch < NC)
+		return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^
+		    cs->invert);
+	else if (cs->icase)
+		return (CHIN1(cs, ch) || CHIN1(cs, towlower(ch)) ||
+		    CHIN1(cs, towupper(ch)));
+	else
+		return (CHIN1(cs, ch));
+}
+
+/*
+ * main compiled-expression structure
+ */
+struct re_guts {
+	int magic;
+#		define	MAGIC2	((('R'^0200)<<8)|'E')
+	sop *strip;		/* malloced area for strip */
+	int ncsets;		/* number of csets in use */
+	cset *sets;		/* -> cset [ncsets] */
+	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 */
+	char *must;		/* match must contain this string */
+	int moffset;		/* latest point at which must may be located */
+	int *charjump;		/* Boyer-Moore char jump table */
+	int *matchjump;		/* Boyer-Moore match jump table */
+	int mlen;		/* length of must */
+	size_t nsub;		/* copy of re_nsub */
+	int backrefs;		/* does it use back references? */
+	sopno nplus;		/* how deep does it nest +s? */
+};
+
+/* misc utilities */
+#define	OUT	(-2)	/* a non-character value */
+#define ISWORD(c)       (iswalnum((uch)(c)) || (c) == '_')
Index: /vendor/FreeBSD-libc/5.3/regex/regexec.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/regexec.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/regexec.c	(revision 2404)
@@ -0,0 +1,244 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)regexec.c	8.3 (Berkeley) 3/20/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/regex/regexec.c,v 1.6 2004/07/12 07:35:59 tjr Exp $");
+
+/*
+ * the outer shell of regexec()
+ *
+ * This file includes engine.c three times, after muchos fiddling with the
+ * macros that code uses.  This lets the same code operate on two different
+ * representations for state sets and characters.
+ */
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <ctype.h>
+#include <regex.h>
+#include <wchar.h>
+#include <wctype.h>
+
+#include "utils.h"
+#include "regex2.h"
+
+static int nope __unused = 0;	/* for use in asserts; shuts lint up */
+
+static __inline size_t
+xmbrtowc(wi, s, n, mbs, dummy)
+wint_t *wi;
+const char *s;
+size_t n;
+mbstate_t *mbs;
+wint_t dummy;
+{
+	size_t nr;
+	wchar_t wc;
+
+	nr = mbrtowc(&wc, s, n, mbs);
+	if (wi != NULL)
+		*wi = wc;
+	if (nr == 0)
+		return (1);
+	else if (nr == (size_t)-1 || nr == (size_t)-2) {
+		memset(mbs, 0, sizeof(*mbs));
+		if (wi != NULL)
+			*wi = dummy;
+		return (1);
+	} else
+                return (nr);
+}
+
+static __inline size_t
+xmbrtowc_dummy(wi, s, n, mbs, dummy)
+wint_t *wi;
+const char *s;
+size_t n __unused;
+mbstate_t *mbs __unused;
+wint_t dummy __unused;
+{
+
+	if (wi != NULL)
+		*wi = (unsigned char)*s;
+	return (1);
+}
+
+/* macros for manipulating states, small version */
+#define	states	long
+#define	states1	states		/* 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	long dummy	/* dummy version */
+#define	STATESETUP(m, n)	/* nothing */
+#define	STATETEARDOWN(m)	/* nothing */
+#define	SETUP(v)	((v) = 0)
+#define	onestate	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)
+/* no multibyte support */
+#define	XMBRTOWC	xmbrtowc_dummy
+#define	ZAPSTATE(mbs)	((void)(mbs))
+/* 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
+#undef	XMBRTOWC
+#undef	ZAPSTATE
+
+/* macros for manipulating states, large version */
+#define	states	char *
+#define	CLEAR(v)	memset(v, 0, 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, m->g->nstates)
+#define	EQ(a, b)	(memcmp(a, b, m->g->nstates) == 0)
+#define	STATEVARS	long vn; char *space
+#define	STATESETUP(m, nv)	{ (m)->space = malloc((nv)*(m)->g->nstates); \
+				if ((m)->space == NULL) return(REG_ESPACE); \
+				(m)->vn = 0; }
+#define	STATETEARDOWN(m)	{ free((m)->space); }
+#define	SETUP(v)	((v) = &m->space[m->vn++ * m->g->nstates])
+#define	onestate	long
+#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)])
+/* no multibyte support */
+#define	XMBRTOWC	xmbrtowc_dummy
+#define	ZAPSTATE(mbs)	((void)(mbs))
+/* function names */
+#define	LNAMES			/* flag */
+
+#include "engine.c"
+
+/* multibyte character & large states version */
+#undef	LNAMES
+#undef	XMBRTOWC
+#undef	ZAPSTATE
+#define	XMBRTOWC	xmbrtowc
+#define	ZAPSTATE(mbs)	memset((mbs), 0, sizeof(*(mbs)))
+#define	MNAMES
+
+#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 * __restrict preg;
+const char * __restrict string;
+size_t nmatch;
+regmatch_t pmatch[__restrict];
+int eflags;
+{
+	struct re_guts *g = preg->re_g;
+#ifdef REDEBUG
+#	define	GOODFLAGS(f)	(f)
+#else
+#	define	GOODFLAGS(f)	((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
+#endif
+
+	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);
+
+	if (MB_CUR_MAX > 1)
+		return(mmatcher(g, (char *)string, nmatch, pmatch, eflags));
+	else if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
+		return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
+	else
+		return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));
+}
Index: /vendor/FreeBSD-libc/5.3/regex/regfree.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/regfree.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/regfree.c	(revision 2404)
@@ -0,0 +1,94 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)regfree.c	8.3 (Berkeley) 3/20/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/regex/regfree.c,v 1.6 2004/07/12 07:35:59 tjr Exp $");
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <regex.h>
+#include <wchar.h>
+#include <wctype.h>
+
+#include "utils.h"
+#include "regex2.h"
+
+/*
+ - regfree - free everything
+ = extern void regfree(regex_t *);
+ */
+void
+regfree(preg)
+regex_t *preg;
+{
+	struct re_guts *g;
+	int i;
+
+	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((char *)g->strip);
+	if (g->sets != NULL) {
+		for (i = 0; i < g->ncsets; i++) {
+			free(g->sets[i].ranges);
+			free(g->sets[i].wides);
+			free(g->sets[i].types);
+		}
+		free((char *)g->sets);
+	}
+	if (g->must != NULL)
+		free(g->must);
+	if (g->charjump != NULL)
+		free(&g->charjump[CHAR_MIN]);
+	if (g->matchjump != NULL)
+		free(g->matchjump);
+	free((char *)g);
+}
Index: /vendor/FreeBSD-libc/5.3/regex/utils.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/regex/utils.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/regex/utils.h	(revision 2404)
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * 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. 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
+ * $FreeBSD: src/lib/libc/regex/utils.h,v 1.2 2002/03/22 23:41:56 obrien Exp $
+ */
+
+/* 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
+#include <assert.h>
+
+/* for old systems with bcopy() but no memmove() */
+#ifdef USEBCOPY
+#define	memmove(d, s, c)	bcopy(s, d, c)
+#endif
Index: /vendor/FreeBSD-libc/5.3/stdlib/getopt_long.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/getopt_long.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/getopt_long.c	(revision 2404)
@@ -0,0 +1,642 @@
+/*	$OpenBSD: getopt_long.c,v 1.17 2004/06/03 18:46:52 millert Exp $	*/
+/*	$NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $	*/
+
+/*
+ * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * 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.
+ */
+
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$OpenBSD: getopt_long.c,v 1.16 2004/02/04 18:17:25 millert Exp $";
+#endif /* LIBC_SCCS and not lint */
+#endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/getopt_long.c,v 1.12 2004/07/06 13:58:45 ache Exp $");
+
+#include <err.h>
+#include <errno.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define GNU_COMPATIBLE		/* Be more compatible, configure's use us! */
+
+#ifndef GNU_COMPATIBLE
+#define	REPLACE_GETOPT		/* use this getopt as the system getopt(3) */
+#endif
+
+#ifdef REPLACE_GETOPT
+int	opterr = 1;		/* if error message should be printed */
+int	optind = 1;		/* index into parent argv vector */
+int	optopt = '?';		/* character checked for validity */
+int	optreset;		/* reset getopt */
+char    *optarg;		/* argument associated with option */
+#endif
+
+#define PRINT_ERROR	((opterr) && (*options != ':'))
+
+#define FLAG_PERMUTE	0x01	/* permute non-options to the end of argv */
+#define FLAG_ALLARGS	0x02	/* treat non-options as args to option "-1" */
+#define FLAG_LONGONLY	0x04	/* operate as getopt_long_only */
+
+/* return values */
+#define	BADCH		(int)'?'
+#define	BADARG		((*options == ':') ? (int)':' : (int)'?')
+#define	INORDER 	(int)1
+
+#define	EMSG		""
+
+#ifdef GNU_COMPATIBLE
+#define NO_PREFIX	(-1)
+#define D_PREFIX	0
+#define DD_PREFIX	1
+#define W_PREFIX	2
+#endif
+
+static int getopt_internal(int, char * const *, const char *,
+			   const struct option *, int *, int);
+static int parse_long_options(char * const *, const char *,
+			      const struct option *, int *, int, int);
+static int gcd(int, int);
+static void permute_args(int, int, int, char * const *);
+
+static char *place = EMSG; /* option letter processing */
+
+/* XXX: set optreset to 1 rather than these two */
+static int nonopt_start = -1; /* first non option argument (for permute) */
+static int nonopt_end = -1;   /* first option after non options (for permute) */
+
+/* Error messages */
+static const char recargchar[] = "option requires an argument -- %c";
+static const char illoptchar[] = "illegal option -- %c"; /* From P1003.2 */
+#ifdef GNU_COMPATIBLE
+static int dash_prefix = NO_PREFIX;
+static const char gnuoptchar[] = "invalid option -- %c";
+
+static const char recargstring[] = "option `%s%s' requires an argument";
+static const char ambig[] = "option `%s%.*s' is ambiguous";
+static const char noarg[] = "option `%s%.*s' doesn't allow an argument";
+static const char illoptstring[] = "unrecognized option `%s%s'";
+#else
+static const char recargstring[] = "option requires an argument -- %s";
+static const char ambig[] = "ambiguous option -- %.*s";
+static const char noarg[] = "option doesn't take an argument -- %.*s";
+static const char illoptstring[] = "unknown option -- %s";
+#endif
+
+/*
+ * Compute the greatest common divisor of a and b.
+ */
+static int
+gcd(int a, int b)
+{
+	int c;
+
+	c = a % b;
+	while (c != 0) {
+		a = b;
+		b = c;
+		c = a % b;
+	}
+
+	return (b);
+}
+
+/*
+ * Exchange the block from nonopt_start to nonopt_end with the block
+ * from nonopt_end to opt_end (keeping the same order of arguments
+ * in each block).
+ */
+static void
+permute_args(int panonopt_start, int panonopt_end, int opt_end,
+	char * const *nargv)
+{
+	int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
+	char *swap;
+
+	/*
+	 * compute lengths of blocks and number and size of cycles
+	 */
+	nnonopts = panonopt_end - panonopt_start;
+	nopts = opt_end - panonopt_end;
+	ncycle = gcd(nnonopts, nopts);
+	cyclelen = (opt_end - panonopt_start) / ncycle;
+
+	for (i = 0; i < ncycle; i++) {
+		cstart = panonopt_end+i;
+		pos = cstart;
+		for (j = 0; j < cyclelen; j++) {
+			if (pos >= panonopt_end)
+				pos -= nnonopts;
+			else
+				pos += nopts;
+			swap = nargv[pos];
+			/* LINTED const cast */
+			((char **) nargv)[pos] = nargv[cstart];
+			/* LINTED const cast */
+			((char **)nargv)[cstart] = swap;
+		}
+	}
+}
+
+/*
+ * parse_long_options --
+ *	Parse long options in argc/argv argument vector.
+ * Returns -1 if short_too is set and the option does not match long_options.
+ */
+static int
+parse_long_options(char * const *nargv, const char *options,
+	const struct option *long_options, int *idx, int short_too, int flags)
+{
+	char *current_argv, *has_equal;
+#ifdef GNU_COMPATIBLE
+	char *current_dash;
+#endif
+	size_t current_argv_len;
+	int i, match, exact_match, second_partial_match;
+
+	current_argv = place;
+#ifdef GNU_COMPATIBLE
+	switch (dash_prefix) {
+		case D_PREFIX:
+			current_dash = "-";
+			break;
+		case DD_PREFIX:
+			current_dash = "--";
+			break;
+		case W_PREFIX:
+			current_dash = "-W ";
+			break;
+		default:
+			current_dash = "";
+			break;
+	}
+#endif
+	match = -1;
+	exact_match = 0;
+	second_partial_match = 0;
+
+	optind++;
+
+	if ((has_equal = strchr(current_argv, '=')) != NULL) {
+		/* argument found (--option=arg) */
+		current_argv_len = has_equal - current_argv;
+		has_equal++;
+	} else
+		current_argv_len = strlen(current_argv);
+
+	for (i = 0; long_options[i].name; i++) {
+		/* find matching long option */
+		if (strncmp(current_argv, long_options[i].name,
+		    current_argv_len))
+			continue;
+
+		if (strlen(long_options[i].name) == current_argv_len) {
+			/* exact match */
+			match = i;
+			exact_match = 1;
+			break;
+		}
+		/*
+		 * If this is a known short option, don't allow
+		 * a partial match of a single character.
+		 */
+		if (short_too && current_argv_len == 1)
+			continue;
+
+		if (match == -1)        /* first partial match */
+			match = i;
+		else if ((flags & FLAG_LONGONLY) ||
+			 long_options[i].has_arg !=
+			     long_options[match].has_arg ||
+			 long_options[i].flag != long_options[match].flag ||
+			 long_options[i].val != long_options[match].val)
+			second_partial_match = 1;
+	}
+	if (!exact_match && second_partial_match) {
+		/* ambiguous abbreviation */
+		if (PRINT_ERROR)
+			warnx(ambig,
+#ifdef GNU_COMPATIBLE
+			     current_dash,
+#endif
+			     (int)current_argv_len,
+			     current_argv);
+		optopt = 0;
+		return (BADCH);
+	}
+	if (match != -1) {		/* option found */
+		if (long_options[match].has_arg == no_argument
+		    && has_equal) {
+			if (PRINT_ERROR)
+				warnx(noarg,
+#ifdef GNU_COMPATIBLE
+				     current_dash,
+#endif
+				     (int)current_argv_len,
+				     current_argv);
+			/*
+			 * XXX: GNU sets optopt to val regardless of flag
+			 */
+			if (long_options[match].flag == NULL)
+				optopt = long_options[match].val;
+			else
+				optopt = 0;
+#ifdef GNU_COMPATIBLE
+			return (BADCH);
+#else
+			return (BADARG);
+#endif
+		}
+		if (long_options[match].has_arg == required_argument ||
+		    long_options[match].has_arg == optional_argument) {
+			if (has_equal)
+				optarg = has_equal;
+			else if (long_options[match].has_arg ==
+			    required_argument) {
+				/*
+				 * optional argument doesn't use next nargv
+				 */
+				optarg = nargv[optind++];
+			}
+		}
+		if ((long_options[match].has_arg == required_argument)
+		    && (optarg == NULL)) {
+			/*
+			 * Missing argument; leading ':' indicates no error
+			 * should be generated.
+			 */
+			if (PRINT_ERROR)
+				warnx(recargstring,
+#ifdef GNU_COMPATIBLE
+				    current_dash,
+#endif
+				    current_argv);
+			/*
+			 * XXX: GNU sets optopt to val regardless of flag
+			 */
+			if (long_options[match].flag == NULL)
+				optopt = long_options[match].val;
+			else
+				optopt = 0;
+			--optind;
+			return (BADARG);
+		}
+	} else {			/* unknown option */
+		if (short_too) {
+			--optind;
+			return (-1);
+		}
+		if (PRINT_ERROR)
+			warnx(illoptstring,
+#ifdef GNU_COMPATIBLE
+			      current_dash,
+#endif
+			      current_argv);
+		optopt = 0;
+		return (BADCH);
+	}
+	if (idx)
+		*idx = match;
+	if (long_options[match].flag) {
+		*long_options[match].flag = long_options[match].val;
+		return (0);
+	} else
+		return (long_options[match].val);
+}
+
+/*
+ * getopt_internal --
+ *	Parse argc/argv argument vector.  Called by user level routines.
+ */
+static int
+getopt_internal(int nargc, char * const *nargv, const char *options,
+	const struct option *long_options, int *idx, int flags)
+{
+	char *oli;				/* option letter list index */
+	int optchar, short_too;
+	int posixly_correct;
+
+	if (options == NULL)
+		return (-1);
+
+	/*
+	 * Disable GNU extensions if POSIXLY_CORRECT is set or options
+	 * string begins with a '+'.
+	 */
+	posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
+#ifdef GNU_COMPATIBLE
+	if (*options == '-')
+		flags |= FLAG_ALLARGS;
+	else if (posixly_correct || *options == '+')
+		flags &= ~FLAG_PERMUTE;
+#else
+	if (posixly_correct || *options == '+')
+		flags &= ~FLAG_PERMUTE;
+	else if (*options == '-')
+		flags |= FLAG_ALLARGS;
+#endif
+	if (*options == '+' || *options == '-')
+		options++;
+
+	/*
+	 * XXX Some GNU programs (like cvs) set optind to 0 instead of
+	 * XXX using optreset.  Work around this braindamage.
+	 */
+	if (optind == 0)
+		optind = optreset = 1;
+
+	optarg = NULL;
+	if (optreset)
+		nonopt_start = nonopt_end = -1;
+start:
+	if (optreset || !*place) {		/* update scanning pointer */
+		optreset = 0;
+		if (optind >= nargc) {          /* end of argument vector */
+			place = EMSG;
+			if (nonopt_end != -1) {
+				/* do permutation, if we have to */
+				permute_args(nonopt_start, nonopt_end,
+				    optind, nargv);
+				optind -= nonopt_end - nonopt_start;
+			}
+			else if (nonopt_start != -1) {
+				/*
+				 * If we skipped non-options, set optind
+				 * to the first of them.
+				 */
+				optind = nonopt_start;
+			}
+			nonopt_start = nonopt_end = -1;
+			return (-1);
+		}
+		if (*(place = nargv[optind]) != '-' ||
+#ifdef GNU_COMPATIBLE
+		    place[1] == '\0') {
+#else
+		    (place[1] == '\0' && strchr(options, '-') == NULL)) {
+#endif
+			place = EMSG;		/* found non-option */
+			if (flags & FLAG_ALLARGS) {
+				/*
+				 * GNU extension:
+				 * return non-option as argument to option 1
+				 */
+				optarg = nargv[optind++];
+				return (INORDER);
+			}
+			if (!(flags & FLAG_PERMUTE)) {
+				/*
+				 * If no permutation wanted, stop parsing
+				 * at first non-option.
+				 */
+				return (-1);
+			}
+			/* do permutation */
+			if (nonopt_start == -1)
+				nonopt_start = optind;
+			else if (nonopt_end != -1) {
+				permute_args(nonopt_start, nonopt_end,
+				    optind, nargv);
+				nonopt_start = optind -
+				    (nonopt_end - nonopt_start);
+				nonopt_end = -1;
+			}
+			optind++;
+			/* process next argument */
+			goto start;
+		}
+		if (nonopt_start != -1 && nonopt_end == -1)
+			nonopt_end = optind;
+
+		/*
+		 * If we have "-" do nothing, if "--" we are done.
+		 */
+		if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
+			optind++;
+			place = EMSG;
+			/*
+			 * We found an option (--), so if we skipped
+			 * non-options, we have to permute.
+			 */
+			if (nonopt_end != -1) {
+				permute_args(nonopt_start, nonopt_end,
+				    optind, nargv);
+				optind -= nonopt_end - nonopt_start;
+			}
+			nonopt_start = nonopt_end = -1;
+			return (-1);
+		}
+	}
+
+	/*
+	 * Check long options if:
+	 *  1) we were passed some
+	 *  2) the arg is not just "-"
+	 *  3) either the arg starts with -- we are getopt_long_only()
+	 */
+	if (long_options != NULL && place != nargv[optind] &&
+	    (*place == '-' || (flags & FLAG_LONGONLY))) {
+		short_too = 0;
+#ifdef GNU_COMPATIBLE
+		dash_prefix = D_PREFIX;
+#endif
+		if (*place == '-') {
+			place++;		/* --foo long option */
+#ifdef GNU_COMPATIBLE
+			dash_prefix = DD_PREFIX;
+#endif
+		} else if (*place != ':' && strchr(options, *place) != NULL)
+			short_too = 1;		/* could be short option too */
+
+		optchar = parse_long_options(nargv, options, long_options,
+		    idx, short_too, flags);
+		if (optchar != -1) {
+			place = EMSG;
+			return (optchar);
+		}
+	}
+
+	if ((optchar = (int)*place++) == (int)':' ||
+	    (optchar == (int)'-' && *place != '\0') ||
+	    (oli = strchr(options, optchar)) == NULL) {
+		/*
+		 * If the user specified "-" and  '-' isn't listed in
+		 * options, return -1 (non-option) as per POSIX.
+		 * Otherwise, it is an unknown option character (or ':').
+		 */
+		if (optchar == (int)'-' && *place == '\0')
+			return (-1);
+		if (!*place)
+			++optind;
+#ifdef GNU_COMPATIBLE
+		if (PRINT_ERROR)
+			warnx(posixly_correct ? illoptchar : gnuoptchar,
+			      optchar);
+#else
+		if (PRINT_ERROR)
+			warnx(illoptchar, optchar);
+#endif
+		optopt = optchar;
+		return (BADCH);
+	}
+	if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
+		/* -W long-option */
+		if (*place)			/* no space */
+			/* NOTHING */;
+		else if (++optind >= nargc) {	/* no arg */
+			place = EMSG;
+			if (PRINT_ERROR)
+				warnx(recargchar, optchar);
+			optopt = optchar;
+			return (BADARG);
+		} else				/* white space */
+			place = nargv[optind];
+#ifdef GNU_COMPATIBLE
+		dash_prefix = W_PREFIX;
+#endif
+		optchar = parse_long_options(nargv, options, long_options,
+		    idx, 0, flags);
+		place = EMSG;
+		return (optchar);
+	}
+	if (*++oli != ':') {			/* doesn't take argument */
+		if (!*place)
+			++optind;
+	} else {				/* takes (optional) argument */
+		optarg = NULL;
+		if (*place)			/* no white space */
+			optarg = place;
+		/* XXX: disable test for :: if PC? (GNU doesn't) */
+		else if (oli[1] != ':') {	/* arg not optional */
+			if (++optind >= nargc) {	/* no arg */
+				place = EMSG;
+				if (PRINT_ERROR)
+					warnx(recargchar, optchar);
+				optopt = optchar;
+				return (BADARG);
+			} else
+				optarg = nargv[optind];
+		} else if (!(flags & FLAG_PERMUTE)) {
+			/*
+			 * If permutation is disabled, we can accept an
+			 * optional arg separated by whitespace so long
+			 * as it does not start with a dash (-).
+			 */
+			if (optind + 1 < nargc && *nargv[optind + 1] != '-')
+				optarg = nargv[++optind];
+		}
+		place = EMSG;
+		++optind;
+	}
+	/* dump back option letter */
+	return (optchar);
+}
+
+#ifdef REPLACE_GETOPT
+/*
+ * getopt --
+ *	Parse argc/argv argument vector.
+ *
+ * [eventually this will replace the BSD getopt]
+ */
+int
+getopt(int nargc, char * const *nargv, const char *options)
+{
+
+	/*
+	 * We don't pass FLAG_PERMUTE to getopt_internal() since
+	 * the BSD getopt(3) (unlike GNU) has never done this.
+	 *
+	 * Furthermore, since many privileged programs call getopt()
+	 * before dropping privileges it makes sense to keep things
+	 * as simple (and bug-free) as possible.
+	 */
+	return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
+}
+#endif /* REPLACE_GETOPT */
+
+/*
+ * getopt_long --
+ *	Parse argc/argv argument vector.
+ */
+int
+getopt_long(nargc, nargv, options, long_options, idx)
+	int nargc;
+	char * const *nargv;
+	const char *options;
+	const struct option *long_options;
+	int *idx;
+{
+
+	return (getopt_internal(nargc, nargv, options, long_options, idx,
+	    FLAG_PERMUTE));
+}
+
+/*
+ * getopt_long_only --
+ *	Parse argc/argv argument vector.
+ */
+int
+getopt_long_only(nargc, nargv, options, long_options, idx)
+	int nargc;
+	char * const *nargv;
+	const char *options;
+	const struct option *long_options;
+	int *idx;
+{
+
+	return (getopt_internal(nargc, nargv, options, long_options, idx,
+	    FLAG_PERMUTE|FLAG_LONGONLY));
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/getsubopt.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/getsubopt.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/getsubopt.c	(revision 2404)
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getsubopt.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/getsubopt.c,v 1.6 2004/02/23 03:30:02 ache Exp $");
+
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * The SVID interface to getsubopt provides no way of figuring out which
+ * part of the suboptions list wasn't matched.  This makes error messages
+ * tricky...  The extern variable suboptarg is a pointer to the token
+ * which didn't match.
+ */
+char *suboptarg;
+
+int
+getsubopt(optionp, tokens, valuep)
+	char **optionp, **valuep;
+	char * const *tokens;
+{
+	int cnt;
+	char *p;
+
+	suboptarg = *valuep = NULL;
+
+	if (!optionp || !*optionp)
+		return(-1);
+
+	/* skip leading white-space, commas */
+	for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+
+	if (!*p) {
+		*optionp = p;
+		return(-1);
+	}
+
+	/* save the start of the token, and skip the rest of the token. */
+	for (suboptarg = p;
+	    *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';);
+
+	if (*p) {
+		/*
+		 * If there's an equals sign, set the value pointer, and
+		 * skip over the value part of the token.  Terminate the
+		 * token.
+		 */
+		if (*p == '=') {
+			*p = '\0';
+			for (*valuep = ++p;
+			    *p && *p != ',' && *p != ' ' && *p != '\t'; ++p);
+			if (*p)
+				*p++ = '\0';
+		} else
+			*p++ = '\0';
+		/* Skip any whitespace or commas after this token. */
+		for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+	}
+
+	/* set optionp for next round. */
+	*optionp = p;
+
+	for (cnt = 0; *tokens; ++tokens, ++cnt)
+		if (!strcmp(suboptarg, *tokens))
+			return(cnt);
+	return(-1);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/hcreate.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/hcreate.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/hcreate.c	(revision 2404)
@@ -0,0 +1,185 @@
+/* $NetBSD: hcreate.c,v 1.2 2001/02/19 21:26:04 ross Exp $ */
+
+/*
+ * Copyright (c) 2001 Christopher G. Demetriou
+ * 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 for the
+ *          NetBSD Project.  See http://www.netbsd.org/ for
+ *          information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ * 
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+ */
+
+/*
+ * hcreate() / hsearch() / hdestroy()
+ *
+ * SysV/XPG4 hash table functions.
+ *
+ * Implementation done based on NetBSD manual page and Solaris manual page,
+ * plus my own personal experience about how they're supposed to work.
+ *
+ * I tried to look at Knuth (as cited by the Solaris manual page), but
+ * nobody had a copy in the office, so...
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: hcreate.c,v 1.2 2001/02/19 21:26:04 ross Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/hcreate.c,v 1.3 2002/06/27 13:18:27 deischen Exp $");
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <errno.h>
+#include <search.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * DO NOT MAKE THIS STRUCTURE LARGER THAN 32 BYTES (4 ptrs on 64-bit
+ * ptr machine) without adjusting MAX_BUCKETS_LG2 below.
+ */
+struct internal_entry {
+	SLIST_ENTRY(internal_entry) link;
+	ENTRY ent;
+};
+SLIST_HEAD(internal_head, internal_entry);
+
+#define	MIN_BUCKETS_LG2	4
+#define	MIN_BUCKETS	(1 << MIN_BUCKETS_LG2)
+
+/*
+ * max * sizeof internal_entry must fit into size_t.
+ * assumes internal_entry is <= 32 (2^5) bytes.
+ */
+#define	MAX_BUCKETS_LG2	(sizeof (size_t) * 8 - 1 - 5)
+#define	MAX_BUCKETS	((size_t)1 << MAX_BUCKETS_LG2)
+
+/* Default hash function, from db/hash/hash_func.c */
+extern u_int32_t (*__default_hash)(const void *, size_t);
+
+static struct internal_head *htable;
+static size_t htablesize;
+
+int
+hcreate(size_t nel)
+{
+	size_t idx;
+	unsigned int p2;
+
+	/* Make sure this this isn't called when a table already exists. */
+	if (htable != NULL) {
+		errno = EINVAL;
+		return 0;
+	}
+
+	/* If nel is too small, make it min sized. */
+	if (nel < MIN_BUCKETS)
+		nel = MIN_BUCKETS;
+
+	/* If it's too large, cap it. */
+	if (nel > MAX_BUCKETS)
+		nel = MAX_BUCKETS;
+
+	/* If it's is not a power of two in size, round up. */
+	if ((nel & (nel - 1)) != 0) {
+		for (p2 = 0; nel != 0; p2++)
+			nel >>= 1;
+		nel = 1 << p2;
+	}
+	
+	/* Allocate the table. */
+	htablesize = nel;
+	htable = malloc(htablesize * sizeof htable[0]);
+	if (htable == NULL) {
+		errno = ENOMEM;
+		return 0;
+	}
+
+	/* Initialize it. */
+	for (idx = 0; idx < htablesize; idx++)
+		SLIST_INIT(&htable[idx]);
+
+	return 1;
+}
+
+void
+hdestroy(void)
+{
+	struct internal_entry *ie;
+	size_t idx;
+
+	if (htable == NULL)
+		return;
+
+	for (idx = 0; idx < htablesize; idx++) {
+		while (!SLIST_EMPTY(&htable[idx])) {
+			ie = SLIST_FIRST(&htable[idx]);
+			SLIST_REMOVE_HEAD(&htable[idx], link);
+			free(ie->ent.key);
+			free(ie);
+		}
+	}
+	free(htable);
+	htable = NULL;
+}
+
+ENTRY *
+hsearch(ENTRY item, ACTION action)
+{
+	struct internal_head *head;
+	struct internal_entry *ie;
+	uint32_t hashval;
+	size_t len;
+
+	len = strlen(item.key);
+	hashval = (*__default_hash)(item.key, len);
+
+	head = &htable[hashval & (htablesize - 1)];
+	ie = SLIST_FIRST(head);
+	while (ie != NULL) {
+		if (strcmp(ie->ent.key, item.key) == 0)
+			break;
+		ie = SLIST_NEXT(ie, link);
+	}
+
+	if (ie != NULL)
+		return &ie->ent;
+	else if (action == FIND)
+		return NULL;
+
+	ie = malloc(sizeof *ie);
+	if (ie == NULL)
+		return NULL;
+	ie->ent.key = item.key;
+	ie->ent.data = item.data;
+
+	SLIST_INSERT_HEAD(head, ie, link);
+	return &ie->ent;
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/heapsort.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/heapsort.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/heapsort.c	(revision 2404)
@@ -0,0 +1,185 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ronnie Kon at Mindcraft Inc., Kevin Lew and Elmer Yglesias.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)heapsort.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/heapsort.c,v 1.4 2002/03/21 22:48:41 obrien Exp $");
+
+#include <errno.h>
+#include <stddef.h>
+#include <stdlib.h>
+
+/*
+ * Swap two areas of size number of bytes.  Although qsort(3) permits random
+ * blocks of memory to be sorted, sorting pointers is almost certainly the
+ * common case (and, were it not, could easily be made so).  Regardless, it
+ * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
+ * arithmetic gets lost in the time required for comparison function calls.
+ */
+#define	SWAP(a, b, count, size, tmp) { \
+	count = size; \
+	do { \
+		tmp = *a; \
+		*a++ = *b; \
+		*b++ = tmp; \
+	} while (--count); \
+}
+
+/* Copy one block of size size to another. */
+#define COPY(a, b, count, size, tmp1, tmp2) { \
+	count = size; \
+	tmp1 = a; \
+	tmp2 = b; \
+	do { \
+		*tmp1++ = *tmp2++; \
+	} while (--count); \
+}
+
+/*
+ * Build the list into a heap, where a heap is defined such that for
+ * the records K1 ... KN, Kj/2 >= Kj for 1 <= j/2 <= j <= N.
+ *
+ * There two cases.  If j == nmemb, select largest of Ki and Kj.  If
+ * j < nmemb, select largest of Ki, Kj and Kj+1.
+ */
+#define CREATE(initval, nmemb, par_i, child_i, par, child, size, count, tmp) { \
+	for (par_i = initval; (child_i = par_i * 2) <= nmemb; \
+	    par_i = child_i) { \
+		child = base + child_i * size; \
+		if (child_i < nmemb && compar(child, child + size) < 0) { \
+			child += size; \
+			++child_i; \
+		} \
+		par = base + par_i * size; \
+		if (compar(child, par) <= 0) \
+			break; \
+		SWAP(par, child, count, size, tmp); \
+	} \
+}
+
+/*
+ * Select the top of the heap and 'heapify'.  Since by far the most expensive
+ * action is the call to the compar function, a considerable optimization
+ * in the average case can be achieved due to the fact that k, the displaced
+ * elememt, is ususally quite small, so it would be preferable to first
+ * heapify, always maintaining the invariant that the larger child is copied
+ * over its parent's record.
+ *
+ * Then, starting from the *bottom* of the heap, finding k's correct place,
+ * again maintianing the invariant.  As a result of the invariant no element
+ * is 'lost' when k is assigned its correct place in the heap.
+ *
+ * The time savings from this optimization are on the order of 15-20% for the
+ * average case. See Knuth, Vol. 3, page 158, problem 18.
+ *
+ * XXX Don't break the #define SELECT line, below.  Reiser cpp gets upset.
+ */
+#define SELECT(par_i, child_i, nmemb, par, child, size, k, count, tmp1, tmp2) { \
+	for (par_i = 1; (child_i = par_i * 2) <= nmemb; par_i = child_i) { \
+		child = base + child_i * size; \
+		if (child_i < nmemb && compar(child, child + size) < 0) { \
+			child += size; \
+			++child_i; \
+		} \
+		par = base + par_i * size; \
+		COPY(par, child, count, size, tmp1, tmp2); \
+	} \
+	for (;;) { \
+		child_i = par_i; \
+		par_i = child_i / 2; \
+		child = base + child_i * size; \
+		par = base + par_i * size; \
+		if (child_i == 1 || compar(k, par) < 0) { \
+			COPY(child, k, count, size, tmp1, tmp2); \
+			break; \
+		} \
+		COPY(child, par, count, size, tmp1, tmp2); \
+	} \
+}
+
+/*
+ * Heapsort -- Knuth, Vol. 3, page 145.  Runs in O (N lg N), both average
+ * and worst.  While heapsort is faster than the worst case of quicksort,
+ * the BSD quicksort does median selection so that the chance of finding
+ * a data set that will trigger the worst case is nonexistent.  Heapsort's
+ * only advantage over quicksort is that it requires little additional memory.
+ */
+int
+heapsort(vbase, nmemb, size, compar)
+	void *vbase;
+	size_t nmemb, size;
+	int (*compar)(const void *, const void *);
+{
+	int cnt, i, j, l;
+	char tmp, *tmp1, *tmp2;
+	char *base, *k, *p, *t;
+
+	if (nmemb <= 1)
+		return (0);
+
+	if (!size) {
+		errno = EINVAL;
+		return (-1);
+	}
+
+	if ((k = malloc(size)) == NULL)
+		return (-1);
+
+	/*
+	 * Items are numbered from 1 to nmemb, so offset from size bytes
+	 * below the starting address.
+	 */
+	base = (char *)vbase - size;
+
+	for (l = nmemb / 2 + 1; --l;)
+		CREATE(l, nmemb, i, j, t, p, size, cnt, tmp);
+
+	/*
+	 * For each element of the heap, save the largest element into its
+	 * final slot, save the displaced element (k), then recreate the
+	 * heap.
+	 */
+	while (nmemb > 1) {
+		COPY(k, base + nmemb * size, cnt, size, tmp1, tmp2);
+		COPY(base + nmemb * size, base + size, cnt, size, tmp1, tmp2);
+		--nmemb;
+		SELECT(i, j, nmemb, t, p, size, k, cnt, tmp1, tmp2);
+	}
+	free(k);
+	return (0);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/imaxabs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/imaxabs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/imaxabs.c	(revision 2404)
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/imaxabs.c,v 1.1 2001/11/15 02:05:03 mike Exp $");
+
+#include <inttypes.h>
+
+intmax_t
+imaxabs(intmax_t j)
+{
+	return (j < 0 ? -j : j);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/imaxdiv.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/imaxdiv.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/imaxdiv.c	(revision 2404)
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/imaxdiv.c,v 1.1 2001/11/15 02:05:03 mike Exp $");
+
+#include <inttypes.h>
+
+/* See comments in div.c for implementation details. */
+imaxdiv_t
+imaxdiv(intmax_t numer, intmax_t denom)
+{
+	imaxdiv_t retval;
+
+	retval.quot = numer / denom;
+	retval.rem = numer % denom;
+	if (numer >= 0 && retval.rem < 0) {
+		retval.quot++;
+		retval.rem -= denom;
+	}
+	return (retval);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/insque.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/insque.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/insque.c	(revision 2404)
@@ -0,0 +1,47 @@
+/*
+ * Initial implementation:
+ * Copyright (c) 2002 Robert Drehmel
+ * All rights reserved.
+ *
+ * As long as the above copyright statement and this notice remain
+ * unchanged, you can do what ever you want with this file. 
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/insque.c,v 1.3 2003/01/04 07:34:41 tjr Exp $");
+
+#define	_SEARCH_PRIVATE
+#include <search.h>
+#ifdef DEBUG
+#include <stdio.h>
+#else
+#include <stdlib.h>	/* for NULL */
+#endif
+
+void
+insque(void *element, void *pred)
+{
+	struct que_elem *prev, *next, *elem;
+
+	elem = (struct que_elem *)element;
+	prev = (struct que_elem *)pred;
+
+	if (prev == NULL) {
+		elem->prev = elem->next = NULL;
+		return;
+	}
+
+	next = prev->next;
+	if (next != NULL) {
+#ifdef DEBUG
+		if (next->prev != prev) {
+			fprintf(stderr, "insque: Inconsistency detected:"
+			    " next(%p)->prev(%p) != prev(%p)\n",
+			    next, next->prev, prev);
+		}
+#endif
+		next->prev = elem;
+	}
+	prev->next = elem;
+	elem->prev = prev;
+	elem->next = next;
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/llabs.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/llabs.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/llabs.c	(revision 2404)
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/llabs.c,v 1.1 2001/11/15 02:05:03 mike Exp $");
+
+#include <stdlib.h>
+
+long long
+llabs(long long j)
+{
+	return (j < 0 ? -j : j);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/lldiv.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/lldiv.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/lldiv.c	(revision 2404)
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/lldiv.c,v 1.1 2001/11/15 02:05:03 mike Exp $");
+
+#include <stdlib.h>
+
+/* See comments in div.c for implementation details. */
+lldiv_t
+lldiv(long long numer, long long denom)
+{
+	lldiv_t retval;
+
+	retval.quot = numer / denom;
+	retval.rem = numer % denom;
+	if (numer >= 0 && retval.rem < 0) {
+		retval.quot++;
+		retval.rem -= denom;
+	}
+	return (retval);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/lsearch.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/lsearch.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/lsearch.c	(revision 2404)
@@ -0,0 +1,64 @@
+/*
+ * Initial implementation:
+ * Copyright (c) 2002 Robert Drehmel
+ * All rights reserved.
+ *
+ * As long as the above copyright statement and this notice remain
+ * unchanged, you can do what ever you want with this file. 
+ */
+#include <sys/types.h>
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/lsearch.c,v 1.1 2002/10/16 14:29:22 robert Exp $");
+
+#define	_SEARCH_PRIVATE
+#include <search.h>
+#include <stdint.h>	/* for uint8_t */
+#include <stdlib.h>	/* for NULL */
+#include <string.h>	/* for memcpy() prototype */
+
+static void *lwork(const void *, const void *, size_t *, size_t,
+    int (*)(const void *, const void *), int);
+
+void *lsearch(const void *key, void *base, size_t *nelp, size_t width,
+    int (*compar)(const void *, const void *))
+{
+
+	return (lwork(key, base, nelp, width, compar, 1));
+}
+
+void *lfind(const void *key, const void *base, size_t *nelp, size_t width,
+    int (*compar)(const void *, const void *))
+{
+
+	return (lwork(key, base, nelp, width, compar, 0));
+}
+
+static void *
+lwork(const void *key, const void *base, size_t *nelp, size_t width,
+    int (*compar)(const void *, const void *), int addelem)
+{
+	uint8_t *ep, *endp;
+
+	/*
+	 * Cast to an integer value first to avoid the warning for removing
+	 * 'const' via a cast.
+	 */
+	ep = (uint8_t *)(uintptr_t)base;
+	for (endp = (uint8_t *)(ep + width * *nelp); ep < endp; ep += width) {
+		if (compar(key, ep) == 0)
+			return (ep);
+	}
+
+	/* lfind() shall return when the key was not found. */
+	if (!addelem)
+		return (NULL);
+
+	/*
+	 * lsearch() adds the key to the end of the table and increments
+	 * the number of elements.
+	 */
+	memcpy(endp, key, width);
+	++*nelp;
+
+	return (endp);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/merge.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/merge.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/merge.c	(revision 2404)
@@ -0,0 +1,352 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Peter McIlroy.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)merge.c	8.2 (Berkeley) 2/14/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/merge.c,v 1.6 2002/03/21 22:48:42 obrien Exp $");
+
+/*
+ * Hybrid exponential search/linear search merge sort with hybrid
+ * natural/pairwise first pass.  Requires about .3% more comparisons
+ * for random data than LSMS with pairwise first pass alone.
+ * It works for objects as small as two bytes.
+ */
+
+#define NATURAL
+#define THRESHOLD 16	/* Best choice for natural merge cut-off. */
+
+/* #define NATURAL to get hybrid natural merge.
+ * (The default is pairwise merging.)
+ */
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void setup(u_char *, u_char *, size_t, size_t, int (*)());
+static void insertionsort(u_char *, size_t, size_t, int (*)());
+
+#define ISIZE sizeof(int)
+#define PSIZE sizeof(u_char *)
+#define ICOPY_LIST(src, dst, last)				\
+	do							\
+	*(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE;	\
+	while(src < last)
+#define ICOPY_ELT(src, dst, i)					\
+	do							\
+	*(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE;	\
+	while (i -= ISIZE)
+
+#define CCOPY_LIST(src, dst, last)		\
+	do					\
+		*dst++ = *src++;		\
+	while (src < last)
+#define CCOPY_ELT(src, dst, i)			\
+	do					\
+		*dst++ = *src++;		\
+	while (i -= 1)
+
+/*
+ * Find the next possible pointer head.  (Trickery for forcing an array
+ * to do double duty as a linked list when objects do not align with word
+ * boundaries.
+ */
+/* Assumption: PSIZE is a power of 2. */
+#define EVAL(p) (u_char **)						\
+	((u_char *)0 +							\
+	    (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1)))
+
+/*
+ * Arguments are as for qsort.
+ */
+int
+mergesort(base, nmemb, size, cmp)
+	void *base;
+	size_t nmemb;
+	size_t size;
+	int (*cmp)(const void *, const void *);
+{
+	int i, sense;
+	int big, iflag;
+	u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
+	u_char *list2, *list1, *p2, *p, *last, **p1;
+
+	if (size < PSIZE / 2) {		/* Pointers must fit into 2 * size. */
+		errno = EINVAL;
+		return (-1);
+	}
+
+	if (nmemb == 0)
+		return (0);
+
+	/*
+	 * XXX
+	 * Stupid subtraction for the Cray.
+	 */
+	iflag = 0;
+	if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
+		iflag = 1;
+
+	if ((list2 = malloc(nmemb * size + PSIZE)) == NULL)
+		return (-1);
+
+	list1 = base;
+	setup(list1, list2, nmemb, size, cmp);
+	last = list2 + nmemb * size;
+	i = big = 0;
+	while (*EVAL(list2) != last) {
+	    l2 = list1;
+	    p1 = EVAL(list1);
+	    for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) {
+	    	p2 = *EVAL(p2);
+	    	f1 = l2;
+	    	f2 = l1 = list1 + (p2 - list2);
+	    	if (p2 != last)
+	    		p2 = *EVAL(p2);
+	    	l2 = list1 + (p2 - list2);
+	    	while (f1 < l1 && f2 < l2) {
+	    		if ((*cmp)(f1, f2) <= 0) {
+	    			q = f2;
+	    			b = f1, t = l1;
+	    			sense = -1;
+	    		} else {
+	    			q = f1;
+	    			b = f2, t = l2;
+	    			sense = 0;
+	    		}
+	    		if (!big) {	/* here i = 0 */
+				while ((b += size) < t && cmp(q, b) >sense)
+	    				if (++i == 6) {
+	    					big = 1;
+	    					goto EXPONENTIAL;
+	    				}
+	    		} else {
+EXPONENTIAL:	    		for (i = size; ; i <<= 1)
+	    				if ((p = (b + i)) >= t) {
+	    					if ((p = t - size) > b &&
+						    (*cmp)(q, p) <= sense)
+	    						t = p;
+	    					else
+	    						b = p;
+	    					break;
+	    				} else if ((*cmp)(q, p) <= sense) {
+	    					t = p;
+	    					if (i == size)
+	    						big = 0;
+	    					goto FASTCASE;
+	    				} else
+	    					b = p;
+				while (t > b+size) {
+	    				i = (((t - b) / size) >> 1) * size;
+	    				if ((*cmp)(q, p = b + i) <= sense)
+	    					t = p;
+	    				else
+	    					b = p;
+	    			}
+	    			goto COPY;
+FASTCASE:	    		while (i > size)
+	    				if ((*cmp)(q,
+	    					p = b + (i >>= 1)) <= sense)
+	    					t = p;
+	    				else
+	    					b = p;
+COPY:	    			b = t;
+	    		}
+	    		i = size;
+	    		if (q == f1) {
+	    			if (iflag) {
+	    				ICOPY_LIST(f2, tp2, b);
+	    				ICOPY_ELT(f1, tp2, i);
+	    			} else {
+	    				CCOPY_LIST(f2, tp2, b);
+	    				CCOPY_ELT(f1, tp2, i);
+	    			}
+	    		} else {
+	    			if (iflag) {
+	    				ICOPY_LIST(f1, tp2, b);
+	    				ICOPY_ELT(f2, tp2, i);
+	    			} else {
+	    				CCOPY_LIST(f1, tp2, b);
+	    				CCOPY_ELT(f2, tp2, i);
+	    			}
+	    		}
+	    	}
+	    	if (f2 < l2) {
+	    		if (iflag)
+	    			ICOPY_LIST(f2, tp2, l2);
+	    		else
+	    			CCOPY_LIST(f2, tp2, l2);
+	    	} else if (f1 < l1) {
+	    		if (iflag)
+	    			ICOPY_LIST(f1, tp2, l1);
+	    		else
+	    			CCOPY_LIST(f1, tp2, l1);
+	    	}
+	    	*p1 = l2;
+	    }
+	    tp2 = list1;	/* swap list1, list2 */
+	    list1 = list2;
+	    list2 = tp2;
+	    last = list2 + nmemb*size;
+	}
+	if (base == list2) {
+		memmove(list2, list1, nmemb*size);
+		list2 = list1;
+	}
+	free(list2);
+	return (0);
+}
+
+#define	swap(a, b) {					\
+		s = b;					\
+		i = size;				\
+		do {					\
+			tmp = *a; *a++ = *s; *s++ = tmp; \
+		} while (--i);				\
+		a -= size;				\
+	}
+#define reverse(bot, top) {				\
+	s = top;					\
+	do {						\
+		i = size;				\
+		do {					\
+			tmp = *bot; *bot++ = *s; *s++ = tmp; \
+		} while (--i);				\
+		s -= size2;				\
+	} while(bot < s);				\
+}
+
+/*
+ * Optional hybrid natural/pairwise first pass.  Eats up list1 in runs of
+ * increasing order, list2 in a corresponding linked list.  Checks for runs
+ * when THRESHOLD/2 pairs compare with same sense.  (Only used when NATURAL
+ * is defined.  Otherwise simple pairwise merging is used.)
+ */
+void
+setup(list1, list2, n, size, cmp)
+	size_t n, size;
+	int (*cmp)(const void *, const void *);
+	u_char *list1, *list2;
+{
+	int i, length, size2, tmp, sense;
+	u_char *f1, *f2, *s, *l2, *last, *p2;
+
+	size2 = size*2;
+	if (n <= 5) {
+		insertionsort(list1, n, size, cmp);
+		*EVAL(list2) = (u_char*) list2 + n*size;
+		return;
+	}
+	/*
+	 * Avoid running pointers out of bounds; limit n to evens
+	 * for simplicity.
+	 */
+	i = 4 + (n & 1);
+	insertionsort(list1 + (n - i) * size, i, size, cmp);
+	last = list1 + size * (n - i);
+	*EVAL(list2 + (last - list1)) = list2 + n * size;
+
+#ifdef NATURAL
+	p2 = list2;
+	f1 = list1;
+	sense = (cmp(f1, f1 + size) > 0);
+	for (; f1 < last; sense = !sense) {
+		length = 2;
+					/* Find pairs with same sense. */
+		for (f2 = f1 + size2; f2 < last; f2 += size2) {
+			if ((cmp(f2, f2+ size) > 0) != sense)
+				break;
+			length += 2;
+		}
+		if (length < THRESHOLD) {		/* Pairwise merge */
+			do {
+				p2 = *EVAL(p2) = f1 + size2 - list1 + list2;
+				if (sense > 0)
+					swap (f1, f1 + size);
+			} while ((f1 += size2) < f2);
+		} else {				/* Natural merge */
+			l2 = f2;
+			for (f2 = f1 + size2; f2 < l2; f2 += size2) {
+				if ((cmp(f2-size, f2) > 0) != sense) {
+					p2 = *EVAL(p2) = f2 - list1 + list2;
+					if (sense > 0)
+						reverse(f1, f2-size);
+					f1 = f2;
+				}
+			}
+			if (sense > 0)
+				reverse (f1, f2-size);
+			f1 = f2;
+			if (f2 < last || cmp(f2 - size, f2) > 0)
+				p2 = *EVAL(p2) = f2 - list1 + list2;
+			else
+				p2 = *EVAL(p2) = list2 + n*size;
+		}
+	}
+#else		/* pairwise merge only. */
+	for (f1 = list1, p2 = list2; f1 < last; f1 += size2) {
+		p2 = *EVAL(p2) = p2 + size2;
+		if (cmp (f1, f1 + size) > 0)
+			swap(f1, f1 + size);
+	}
+#endif /* NATURAL */
+}
+
+/*
+ * This is to avoid out-of-bounds addresses in sorting the
+ * last 4 elements.
+ */
+static void
+insertionsort(a, n, size, cmp)
+	u_char *a;
+	size_t n, size;
+	int (*cmp)(const void *, const void *);
+{
+	u_char *ai, *s, *t, *u, tmp;
+	int i;
+
+	for (ai = a+size; --n >= 1; ai += size)
+		for (t = ai; t > a; t -= size) {
+			u = t - size;
+			if (cmp(u, t) <= 0)
+				break;
+			swap(u, t);
+		}
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/qsort.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/qsort.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/qsort.c	(revision 2404)
@@ -0,0 +1,197 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)qsort.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/qsort.c,v 1.12 2002/09/10 02:04:49 wollman Exp $");
+
+#include <stdlib.h>
+
+#ifdef I_AM_QSORT_R
+typedef int		 cmp_t(void *, const void *, const void *);
+#else
+typedef int		 cmp_t(const void *, const void *);
+#endif
+static inline char	*med3(char *, char *, char *, cmp_t *, void *);
+static inline void	 swapfunc(char *, char *, int, int);
+
+#define min(a, b)	(a) < (b) ? a : b
+
+/*
+ * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
+ */
+#define swapcode(TYPE, parmi, parmj, n) { 		\
+	long i = (n) / sizeof (TYPE); 			\
+	TYPE *pi = (TYPE *) (parmi); 		\
+	TYPE *pj = (TYPE *) (parmj); 		\
+	do { 						\
+		TYPE	t = *pi;		\
+		*pi++ = *pj;				\
+		*pj++ = t;				\
+        } while (--i > 0);				\
+}
+
+#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
+	es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
+
+static inline void
+swapfunc(a, b, n, swaptype)
+	char *a, *b;
+	int n, swaptype;
+{
+	if(swaptype <= 1)
+		swapcode(long, a, b, n)
+	else
+		swapcode(char, a, b, n)
+}
+
+#define swap(a, b)					\
+	if (swaptype == 0) {				\
+		long t = *(long *)(a);			\
+		*(long *)(a) = *(long *)(b);		\
+		*(long *)(b) = t;			\
+	} else						\
+		swapfunc(a, b, es, swaptype)
+
+#define vecswap(a, b, n) 	if ((n) > 0) swapfunc(a, b, n, swaptype)
+
+#ifdef I_AM_QSORT_R
+#define	CMP(t, x, y) (cmp((t), (x), (y)))
+#else
+#define	CMP(t, x, y) (cmp((x), (y)))
+#endif
+
+static inline char *
+med3(char *a, char *b, char *c, cmp_t *cmp, void *thunk
+#ifndef I_AM_QSORT_R
+__unused
+#endif
+)
+{
+	return CMP(thunk, a, b) < 0 ?
+	       (CMP(thunk, b, c) < 0 ? b : (CMP(thunk, a, c) < 0 ? c : a ))
+              :(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c ));
+}
+
+#ifdef I_AM_QSORT_R
+void
+qsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp)
+#else
+#define thunk NULL
+void
+qsort(void *a, size_t n, size_t es, cmp_t *cmp)
+#endif
+{
+	char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
+	int d, r, swaptype, swap_cnt;
+
+loop:	SWAPINIT(a, es);
+	swap_cnt = 0;
+	if (n < 7) {
+		for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
+			for (pl = pm; 
+			     pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
+			     pl -= es)
+				swap(pl, pl - es);
+		return;
+	}
+	pm = (char *)a + (n / 2) * es;
+	if (n > 7) {
+		pl = a;
+		pn = (char *)a + (n - 1) * es;
+		if (n > 40) {
+			d = (n / 8) * es;
+			pl = med3(pl, pl + d, pl + 2 * d, cmp, thunk);
+			pm = med3(pm - d, pm, pm + d, cmp, thunk);
+			pn = med3(pn - 2 * d, pn - d, pn, cmp, thunk);
+		}
+		pm = med3(pl, pm, pn, cmp, thunk);
+	}
+	swap(a, pm);
+	pa = pb = (char *)a + es;
+
+	pc = pd = (char *)a + (n - 1) * es;
+	for (;;) {
+		while (pb <= pc && (r = CMP(thunk, pb, a)) <= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap(pa, pb);
+				pa += es;
+			}
+			pb += es;
+		}
+		while (pb <= pc && (r = CMP(thunk, pc, a)) >= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap(pc, pd);
+				pd -= es;
+			}
+			pc -= es;
+		}
+		if (pb > pc)
+			break;
+		swap(pb, pc);
+		swap_cnt = 1;
+		pb += es;
+		pc -= es;
+	}
+	if (swap_cnt == 0) {  /* Switch to insertion sort */
+		for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
+			for (pl = pm; 
+			     pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
+			     pl -= es)
+				swap(pl, pl - es);
+		return;
+	}
+
+	pn = (char *)a + n * es;
+	r = min(pa - (char *)a, pb - pa);
+	vecswap(a, pb - r, r);
+	r = min(pd - pc, pn - pd - es);
+	vecswap(pb, pn - r, r);
+	if ((r = pb - pa) > es)
+#ifdef I_AM_QSORT_R
+		qsort_r(a, r / es, es, thunk, cmp);
+#else
+		qsort(a, r / es, es, cmp);
+#endif
+	if ((r = pd - pc) > es) {
+		/* Iterate rather than recurse to save stack space */
+		a = pn - r;
+		n = r / es;
+		goto loop;
+	}
+/*		qsort(pn - r, r / es, es, cmp);*/
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/qsort_r.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/qsort_r.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/qsort_r.c	(revision 2404)
@@ -0,0 +1,8 @@
+/*
+ * This file is in the public domain.  Originally written by Garrett
+ * A. Wollman.
+ *
+ * $FreeBSD: src/lib/libc/stdlib/qsort_r.c,v 1.1 2002/09/10 02:04:49 wollman Exp $
+ */
+#define I_AM_QSORT_R
+#include "qsort.c"
Index: /vendor/FreeBSD-libc/5.3/stdlib/radixsort.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/radixsort.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/radixsort.c	(revision 2404)
@@ -0,0 +1,331 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Peter McIlroy and by Dan Bernstein at New York University,
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)radixsort.c	8.2 (Berkeley) 4/28/95";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/radixsort.c,v 1.7 2003/11/11 04:59:23 kientzle Exp $");
+
+/*
+ * Radixsort routines.
+ *
+ * Program r_sort_a() is unstable but uses O(logN) extra memory for a stack.
+ * Use radixsort(a, n, trace, endchar) for this case.
+ *
+ * For stable sorting (using N extra pointers) use sradixsort(), which calls
+ * r_sort_b().
+ *
+ * For a description of this code, see D. McIlroy, P. McIlroy, K. Bostic,
+ * "Engineering Radix Sort".
+ */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <errno.h>
+
+typedef struct {
+	const u_char **sa;
+	int sn, si;
+} stack;
+
+static inline void simplesort
+(const u_char **, int, int, const u_char *, u_int);
+static void r_sort_a(const u_char **, int, int, const u_char *, u_int);
+static void r_sort_b(const u_char **, const u_char **, int, int,
+    const u_char *, u_int);
+
+#define	THRESHOLD	20		/* Divert to simplesort(). */
+#define	SIZE		512		/* Default stack size. */
+
+#define SETUP {								\
+	if (tab == NULL) {						\
+		tr = tr0;						\
+		for (c = 0; c < endch; c++)				\
+			tr0[c] = c + 1;					\
+		tr0[c] = 0;						\
+		for (c++; c < 256; c++)					\
+			tr0[c] = c;					\
+		endch = 0;						\
+	} else {							\
+		endch = tab[endch];					\
+		tr = tab;						\
+		if (endch != 0 && endch != 255) {			\
+			errno = EINVAL;					\
+			return (-1);					\
+		}							\
+	}								\
+}
+
+int
+radixsort(a, n, tab, endch)
+	const u_char **a, *tab;
+	int n;
+	u_int endch;
+{
+	const u_char *tr;
+	int c;
+	u_char tr0[256];
+
+	SETUP;
+	r_sort_a(a, n, 0, tr, endch);
+	return (0);
+}
+
+int
+sradixsort(a, n, tab, endch)
+	const u_char **a, *tab;
+	int n;
+	u_int endch;
+{
+	const u_char *tr, **ta;
+	int c;
+	u_char tr0[256];
+
+	SETUP;
+	if (n < THRESHOLD)
+		simplesort(a, n, 0, tr, endch);
+	else {
+		if ((ta = malloc(n * sizeof(a))) == NULL)
+			return (-1);
+		r_sort_b(a, ta, n, 0, tr, endch);
+		free(ta);
+	}
+	return (0);
+}
+
+#define empty(s)	(s >= sp)
+#define pop(a, n, i)	a = (--sp)->sa, n = sp->sn, i = sp->si
+#define push(a, n, i)	sp->sa = a, sp->sn = n, (sp++)->si = i
+#define swap(a, b, t)	t = a, a = b, b = t
+
+/* Unstable, in-place sort. */
+static void
+r_sort_a(a, n, i, tr, endch)
+	const u_char **a;
+	int n, i;
+	const u_char *tr;
+	u_int endch;
+{
+	static int count[256], nc, bmin;
+	int c;
+	const u_char **ak, *r;
+	stack s[SIZE], *sp, *sp0, *sp1, temp;
+	int *cp, bigc;
+	const u_char **an, *t, **aj, **top[256];
+
+	/* Set up stack. */
+	sp = s;
+	push(a, n, i);
+	while (!empty(s)) {
+		pop(a, n, i);
+		if (n < THRESHOLD) {
+			simplesort(a, n, i, tr, endch);
+			continue;
+		}
+		an = a + n;
+
+		/* Make character histogram. */
+		if (nc == 0) {
+			bmin = 255;	/* First occupied bin, excluding eos. */
+			for (ak = a; ak < an;) {
+				c = tr[(*ak++)[i]];
+				if (++count[c] == 1 && c != endch) {
+					if (c < bmin)
+						bmin = c;
+					nc++;
+				}
+			}
+			if (sp + nc > s + SIZE) {	/* Get more stack. */
+				r_sort_a(a, n, i, tr, endch);
+				continue;
+			}
+		}
+
+		/*
+		 * Special case: if all strings have the same
+		 * character at position i, move on to the next
+		 * character.
+		 */
+		if (nc == 1 && count[bmin] == n) {
+			push(a, n, i+1);
+			nc = count[bmin] = 0;
+			continue;
+		}
+
+		/*
+		 * Set top[]; push incompletely sorted bins onto stack.
+		 * top[] = pointers to last out-of-place element in bins.
+		 * count[] = counts of elements in bins.
+		 * Before permuting: top[c-1] + count[c] = top[c];
+		 * during deal: top[c] counts down to top[c-1].
+		 */
+		sp0 = sp1 = sp;		/* Stack position of biggest bin. */
+		bigc = 2;		/* Size of biggest bin. */
+		if (endch == 0)		/* Special case: set top[eos]. */
+			top[0] = ak = a + count[0];
+		else {
+			ak = a;
+			top[255] = an;
+		}
+		for (cp = count + bmin; nc > 0; cp++) {
+			while (*cp == 0)	/* Find next non-empty pile. */
+				cp++;
+			if (*cp > 1) {
+				if (*cp > bigc) {
+					bigc = *cp;
+					sp1 = sp;
+				}
+				push(ak, *cp, i+1);
+			}
+			top[cp-count] = ak += *cp;
+			nc--;
+		}
+		swap(*sp0, *sp1, temp);	/* Play it safe -- biggest bin last. */
+
+		/*
+		 * Permute misplacements home.  Already home: everything
+		 * before aj, and in bin[c], items from top[c] on.
+		 * Inner loop:
+		 *	r = next element to put in place;
+		 *	ak = top[r[i]] = location to put the next element.
+		 *	aj = bottom of 1st disordered bin.
+		 * Outer loop:
+		 *	Once the 1st disordered bin is done, ie. aj >= ak,
+		 *	aj<-aj + count[c] connects the bins in a linked list;
+		 *	reset count[c].
+		 */
+		for (aj = a; aj < an;  *aj = r, aj += count[c], count[c] = 0)
+			for (r = *aj;  aj < (ak = --top[c = tr[r[i]]]);)
+				swap(*ak, r, t);
+	}
+}
+
+/* Stable sort, requiring additional memory. */
+static void
+r_sort_b(a, ta, n, i, tr, endch)
+	const u_char **a, **ta;
+	int n, i;
+	const u_char *tr;
+	u_int endch;
+{
+	static int count[256], nc, bmin;
+	int c;
+	const u_char **ak, **ai;
+	stack s[512], *sp, *sp0, *sp1, temp;
+	const u_char **top[256];
+	int *cp, bigc;
+
+	sp = s;
+	push(a, n, i);
+	while (!empty(s)) {
+		pop(a, n, i);
+		if (n < THRESHOLD) {
+			simplesort(a, n, i, tr, endch);
+			continue;
+		}
+
+		if (nc == 0) {
+			bmin = 255;
+			for (ak = a + n; --ak >= a;) {
+				c = tr[(*ak)[i]];
+				if (++count[c] == 1 && c != endch) {
+					if (c < bmin)
+						bmin = c;
+					nc++;
+				}
+			}
+			if (sp + nc > s + SIZE) {
+				r_sort_b(a, ta, n, i, tr, endch);
+				continue;
+			}
+		}
+
+		sp0 = sp1 = sp;
+		bigc = 2;
+		if (endch == 0) {
+			top[0] = ak = a + count[0];
+			count[0] = 0;
+		} else {
+			ak = a;
+			top[255] = a + n;
+			count[255] = 0;
+		}
+		for (cp = count + bmin; nc > 0; cp++) {
+			while (*cp == 0)
+				cp++;
+			if ((c = *cp) > 1) {
+				if (c > bigc) {
+					bigc = c;
+					sp1 = sp;
+				}
+				push(ak, c, i+1);
+			}
+			top[cp-count] = ak += c;
+			*cp = 0;			/* Reset count[]. */
+			nc--;
+		}
+		swap(*sp0, *sp1, temp);
+
+		for (ak = ta + n, ai = a+n; ak > ta;)	/* Copy to temp. */
+			*--ak = *--ai;
+		for (ak = ta+n; --ak >= ta;)		/* Deal to piles. */
+			*--top[tr[(*ak)[i]]] = *ak;
+	}
+}
+
+static inline void
+simplesort(a, n, b, tr, endch)	/* insertion sort */
+	const u_char **a;
+	int n, b;
+	const u_char *tr;
+	u_int endch;
+{
+	u_char ch;
+	const u_char  **ak, **ai, *s, *t;
+
+	for (ak = a+1; --n >= 1; ak++)
+		for (ai = ak; ai > a; ai--) {
+			for (s = ai[0] + b, t = ai[-1] + b;
+			    (ch = tr[*s]) != endch; s++, t++)
+				if (ch != tr[*t])
+					break;
+			if (ch >= tr[*t])
+				break;
+			swap(ai[0], ai[-1], s);
+		}
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/rand.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/rand.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/rand.c	(revision 2404)
@@ -0,0 +1,172 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ *
+ * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rand.c	8.1 (Berkeley) 6/14/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/rand.c,v 1.15 2003/02/17 03:52:35 ache Exp $");
+
+#include "namespace.h"
+#include <sys/time.h>          /* for sranddev() */
+#include <sys/types.h>
+#include <fcntl.h>             /* for sranddev() */
+#include <stdlib.h>
+#include <unistd.h>            /* for sranddev() */
+#include "un-namespace.h"
+
+#ifdef TEST
+#include <stdio.h>
+#endif /* TEST */
+
+static int
+do_rand(unsigned long *ctx)
+{
+#ifdef  USE_WEAK_SEEDING
+/*
+ * Historic implementation compatibility.
+ * The random sequences do not vary much with the seed,
+ * even with overflowing.
+ */
+	return ((*ctx = *ctx * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
+#else   /* !USE_WEAK_SEEDING */
+/*
+ * Compute x = (7^5 * x) mod (2^31 - 1)
+ * wihout overflowing 31 bits:
+ *      (2^31 - 1) = 127773 * (7^5) + 2836
+ * From "Random number generators: good ones are hard to find",
+ * Park and Miller, Communications of the ACM, vol. 31, no. 10,
+ * October 1988, p. 1195.
+ */
+	long hi, lo, x;
+
+	/* Can't be initialized with 0, so use another value. */
+	if (*ctx == 0)
+		*ctx = 123459876;
+	hi = *ctx / 127773;
+	lo = *ctx % 127773;
+	x = 16807 * lo - 2836 * hi;
+	if (x < 0)
+		x += 0x7fffffff;
+	return ((*ctx = x) % ((u_long)RAND_MAX + 1));
+#endif  /* !USE_WEAK_SEEDING */
+}
+
+
+int
+rand_r(unsigned int *ctx)
+{
+	u_long val = (u_long) *ctx;
+	int r = do_rand(&val);
+
+	*ctx = (unsigned int) val;
+	return (r);
+}
+
+
+static u_long next = 1;
+
+int
+rand()
+{
+	return (do_rand(&next));
+}
+
+void
+srand(seed)
+u_int seed;
+{
+	next = seed;
+}
+
+
+/*
+ * sranddev:
+ *
+ * Many programs choose the seed value in a totally predictable manner.
+ * This often causes problems.  We seed the generator using the much more
+ * secure random(4) interface.
+ */
+void
+sranddev()
+{
+	int fd, done;
+
+	done = 0;
+	fd = _open("/dev/random", O_RDONLY, 0);
+	if (fd >= 0) {
+		if (_read(fd, (void *) &next, sizeof(next)) == sizeof(next))
+			done = 1;
+		_close(fd);
+	}
+
+	if (!done) {
+		struct timeval tv;
+		unsigned long junk;
+
+		gettimeofday(&tv, NULL);
+		srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
+	}
+}
+
+
+#ifdef TEST
+
+main()
+{
+    int i;
+    unsigned myseed;
+
+    printf("seeding rand with 0x19610910: \n");
+    srand(0x19610910);
+
+    printf("generating three pseudo-random numbers:\n");
+    for (i = 0; i < 3; i++)
+    {
+	printf("next random number = %d\n", rand());
+    }
+
+    printf("generating the same sequence with rand_r:\n");
+    myseed = 0x19610910;
+    for (i = 0; i < 3; i++)
+    {
+	printf("next random number = %d\n", rand_r(&myseed));
+    }
+
+    return 0;
+}
+
+#endif /* TEST */
+
Index: /vendor/FreeBSD-libc/5.3/stdlib/random.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/random.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/random.c	(revision 2404)
@@ -0,0 +1,506 @@
+/*
+ * Copyright (c) 1983, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)random.c	8.2 (Berkeley) 5/19/95";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/random.c,v 1.24 2004/01/20 03:02:18 das Exp $");
+
+#include "namespace.h"
+#include <sys/time.h>          /* for srandomdev() */
+#include <fcntl.h>             /* for srandomdev() */
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>            /* for srandomdev() */
+#include "un-namespace.h"
+
+/*
+ * random.c:
+ *
+ * An improved random number generation package.  In addition to the standard
+ * rand()/srand() like interface, this package also has a special state info
+ * interface.  The initstate() routine is called with a seed, an array of
+ * bytes, and a count of how many bytes are being passed in; this array is
+ * then initialized to contain information for random number generation with
+ * that much state information.  Good sizes for the amount of state
+ * information are 32, 64, 128, and 256 bytes.  The state can be switched by
+ * calling the setstate() routine with the same array as was initiallized
+ * with initstate().  By default, the package runs with 128 bytes of state
+ * information and generates far better random numbers than a linear
+ * congruential generator.  If the amount of state information is less than
+ * 32 bytes, a simple linear congruential R.N.G. is used.
+ *
+ * Internally, the state information is treated as an array of uint32_t's; the
+ * zeroeth element of the array is the type of R.N.G. being used (small
+ * integer); the remainder of the array is the state information for the
+ * R.N.G.  Thus, 32 bytes of state information will give 7 ints worth of
+ * state information, which will allow a degree seven polynomial.  (Note:
+ * the zeroeth word of state information also has some other information
+ * stored in it -- see setstate() for details).
+ *
+ * The random number generation technique is a linear feedback shift register
+ * approach, employing trinomials (since there are fewer terms to sum up that
+ * way).  In this approach, the least significant bit of all the numbers in
+ * the state table will act as a linear feedback shift register, and will
+ * have period 2^deg - 1 (where deg is the degree of the polynomial being
+ * used, assuming that the polynomial is irreducible and primitive).  The
+ * higher order bits will have longer periods, since their values are also
+ * influenced by pseudo-random carries out of the lower bits.  The total
+ * period of the generator is approximately deg*(2**deg - 1); thus doubling
+ * the amount of state information has a vast influence on the period of the
+ * generator.  Note: the deg*(2**deg - 1) is an approximation only good for
+ * large deg, when the period of the shift is the dominant factor.
+ * With deg equal to seven, the period is actually much longer than the
+ * 7*(2**7 - 1) predicted by this formula.
+ *
+ * Modified 28 December 1994 by Jacob S. Rosenberg.
+ * The following changes have been made:
+ * All references to the type u_int have been changed to unsigned long.
+ * All references to type int have been changed to type long.  Other
+ * cleanups have been made as well.  A warning for both initstate and
+ * setstate has been inserted to the effect that on Sparc platforms
+ * the 'arg_state' variable must be forced to begin on word boundaries.
+ * This can be easily done by casting a long integer array to char *.
+ * The overall logic has been left STRICTLY alone.  This software was
+ * tested on both a VAX and Sun SpacsStation with exactly the same
+ * results.  The new version and the original give IDENTICAL results.
+ * The new version is somewhat faster than the original.  As the
+ * documentation says:  "By default, the package runs with 128 bytes of
+ * state information and generates far better random numbers than a linear
+ * congruential generator.  If the amount of state information is less than
+ * 32 bytes, a simple linear congruential R.N.G. is used."  For a buffer of
+ * 128 bytes, this new version runs about 19 percent faster and for a 16
+ * byte buffer it is about 5 percent faster.
+ */
+
+/*
+ * For each of the currently supported random number generators, we have a
+ * break value on the amount of state information (you need at least this
+ * many bytes of state info to support this random number generator), a degree
+ * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
+ * the separation between the two lower order coefficients of the trinomial.
+ */
+#define	TYPE_0		0		/* linear congruential */
+#define	BREAK_0		8
+#define	DEG_0		0
+#define	SEP_0		0
+
+#define	TYPE_1		1		/* x**7 + x**3 + 1 */
+#define	BREAK_1		32
+#define	DEG_1		7
+#define	SEP_1		3
+
+#define	TYPE_2		2		/* x**15 + x + 1 */
+#define	BREAK_2		64
+#define	DEG_2		15
+#define	SEP_2		1
+
+#define	TYPE_3		3		/* x**31 + x**3 + 1 */
+#define	BREAK_3		128
+#define	DEG_3		31
+#define	SEP_3		3
+
+#define	TYPE_4		4		/* x**63 + x + 1 */
+#define	BREAK_4		256
+#define	DEG_4		63
+#define	SEP_4		1
+
+/*
+ * Array versions of the above information to make code run faster --
+ * relies on fact that TYPE_i == i.
+ */
+#define	MAX_TYPES	5		/* max number of types above */
+
+#ifdef  USE_WEAK_SEEDING
+#define NSHUFF 0
+#else   /* !USE_WEAK_SEEDING */
+#define NSHUFF 50       /* to drop some "seed -> 1st value" linearity */
+#endif  /* !USE_WEAK_SEEDING */
+
+static const int degrees[MAX_TYPES] =	{ DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
+static const int seps [MAX_TYPES] =	{ SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
+
+/*
+ * Initially, everything is set up as if from:
+ *
+ *	initstate(1, randtbl, 128);
+ *
+ * Note that this initialization takes advantage of the fact that srandom()
+ * advances the front and rear pointers 10*rand_deg times, and hence the
+ * rear pointer which starts at 0 will also end up at zero; thus the zeroeth
+ * element of the state information, which contains info about the current
+ * position of the rear pointer is just
+ *
+ *	MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
+ */
+
+static uint32_t randtbl[DEG_3 + 1] = {
+	TYPE_3,
+#ifdef  USE_WEAK_SEEDING
+/* Historic implementation compatibility */
+/* The random sequences do not vary much with the seed */
+	0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5,
+	0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
+	0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88,
+	0xe369735d, 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
+	0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, 0x8999220b,
+	0x27fb47b9,
+#else   /* !USE_WEAK_SEEDING */
+	0x991539b1, 0x16a5bce3, 0x6774a4cd, 0x3e01511e, 0x4e508aaa, 0x61048c05,
+	0xf5500617, 0x846b7115, 0x6a19892c, 0x896a97af, 0xdb48f936, 0x14898454,
+	0x37ffd106, 0xb58bff9c, 0x59e17104, 0xcf918a49, 0x09378c83, 0x52c7a471,
+	0x8d293ea9, 0x1f4fc301, 0xc3db71be, 0x39b44e1c, 0xf8a44ef9, 0x4c8b80b1,
+	0x19edc328, 0x87bf4bdd, 0xc9b240e5, 0xe9ee4b1b, 0x4382aee7, 0x535b6b41,
+	0xf3bec5da
+#endif  /* !USE_WEAK_SEEDING */
+};
+
+/*
+ * fptr and rptr are two pointers into the state info, a front and a rear
+ * pointer.  These two pointers are always rand_sep places aparts, as they
+ * cycle cyclically through the state information.  (Yes, this does mean we
+ * could get away with just one pointer, but the code for random() is more
+ * efficient this way).  The pointers are left positioned as they would be
+ * from the call
+ *
+ *	initstate(1, randtbl, 128);
+ *
+ * (The position of the rear pointer, rptr, is really 0 (as explained above
+ * in the initialization of randtbl) because the state table pointer is set
+ * to point to randtbl[1] (as explained below).
+ */
+static uint32_t *fptr = &randtbl[SEP_3 + 1];
+static uint32_t *rptr = &randtbl[1];
+
+/*
+ * The following things are the pointer to the state information table, the
+ * type of the current generator, the degree of the current polynomial being
+ * used, and the separation between the two pointers.  Note that for efficiency
+ * of random(), we remember the first location of the state information, not
+ * the zeroeth.  Hence it is valid to access state[-1], which is used to
+ * store the type of the R.N.G.  Also, we remember the last location, since
+ * this is more efficient than indexing every time to find the address of
+ * the last element to see if the front and rear pointers have wrapped.
+ */
+static uint32_t *state = &randtbl[1];
+static int rand_type = TYPE_3;
+static int rand_deg = DEG_3;
+static int rand_sep = SEP_3;
+static uint32_t *end_ptr = &randtbl[DEG_3 + 1];
+
+static inline uint32_t good_rand(int32_t);
+
+static inline uint32_t good_rand (x)
+	int32_t x;
+{
+#ifdef  USE_WEAK_SEEDING
+/*
+ * Historic implementation compatibility.
+ * The random sequences do not vary much with the seed,
+ * even with overflowing.
+ */
+	return (1103515245 * x + 12345);
+#else   /* !USE_WEAK_SEEDING */
+/*
+ * Compute x = (7^5 * x) mod (2^31 - 1)
+ * wihout overflowing 31 bits:
+ *      (2^31 - 1) = 127773 * (7^5) + 2836
+ * From "Random number generators: good ones are hard to find",
+ * Park and Miller, Communications of the ACM, vol. 31, no. 10,
+ * October 1988, p. 1195.
+ */
+	int32_t hi, lo;
+
+	/* Can't be initialized with 0, so use another value. */
+	if (x == 0)
+		x = 123459876;
+	hi = x / 127773;
+	lo = x % 127773;
+	x = 16807 * lo - 2836 * hi;
+	if (x < 0)
+		x += 0x7fffffff;
+	return (x);
+#endif  /* !USE_WEAK_SEEDING */
+}
+
+/*
+ * srandom:
+ *
+ * Initialize the random number generator based on the given seed.  If the
+ * type is the trivial no-state-information type, just remember the seed.
+ * Otherwise, initializes state[] based on the given "seed" via a linear
+ * congruential generator.  Then, the pointers are set to known locations
+ * that are exactly rand_sep places apart.  Lastly, it cycles the state
+ * information a given number of times to get rid of any initial dependencies
+ * introduced by the L.C.R.N.G.  Note that the initialization of randtbl[]
+ * for default usage relies on values produced by this routine.
+ */
+void
+srandom(x)
+	unsigned long x;
+{
+	int i, lim;
+
+	state[0] = (uint32_t)x;
+	if (rand_type == TYPE_0)
+		lim = NSHUFF;
+	else {
+		for (i = 1; i < rand_deg; i++)
+			state[i] = good_rand(state[i - 1]);
+		fptr = &state[rand_sep];
+		rptr = &state[0];
+		lim = 10 * rand_deg;
+	}
+	for (i = 0; i < lim; i++)
+		(void)random();
+}
+
+/*
+ * srandomdev:
+ *
+ * Many programs choose the seed value in a totally predictable manner.
+ * This often causes problems.  We seed the generator using the much more
+ * secure random(4) interface.  Note that this particular seeding
+ * procedure can generate states which are impossible to reproduce by
+ * calling srandom() with any value, since the succeeding terms in the
+ * state buffer are no longer derived from the LC algorithm applied to
+ * a fixed seed.
+ */
+void
+srandomdev()
+{
+	int fd, done;
+	size_t len;
+
+	if (rand_type == TYPE_0)
+		len = sizeof state[0];
+	else
+		len = rand_deg * sizeof state[0];
+
+	done = 0;
+	fd = _open("/dev/random", O_RDONLY, 0);
+	if (fd >= 0) {
+		if (_read(fd, (void *) state, len) == (ssize_t) len)
+			done = 1;
+		_close(fd);
+	}
+
+	if (!done) {
+		struct timeval tv;
+		unsigned long junk;
+
+		gettimeofday(&tv, NULL);
+		srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
+		return;
+	}
+
+	if (rand_type != TYPE_0) {
+		fptr = &state[rand_sep];
+		rptr = &state[0];
+	}
+}
+
+/*
+ * initstate:
+ *
+ * Initialize the state information in the given array of n bytes for future
+ * random number generation.  Based on the number of bytes we are given, and
+ * the break values for the different R.N.G.'s, we choose the best (largest)
+ * one we can and set things up for it.  srandom() is then called to
+ * initialize the state information.
+ *
+ * Note that on return from srandom(), we set state[-1] to be the type
+ * multiplexed with the current value of the rear pointer; this is so
+ * successive calls to initstate() won't lose this information and will be
+ * able to restart with setstate().
+ *
+ * Note: the first thing we do is save the current state, if any, just like
+ * setstate() so that it doesn't matter when initstate is called.
+ *
+ * Returns a pointer to the old state.
+ *
+ * Note: The Sparc platform requires that arg_state begin on an int
+ * word boundary; otherwise a bus error will occur. Even so, lint will
+ * complain about mis-alignment, but you should disregard these messages.
+ */
+char *
+initstate(seed, arg_state, n)
+	unsigned long seed;		/* seed for R.N.G. */
+	char *arg_state;		/* pointer to state array */
+	long n;				/* # bytes of state info */
+{
+	char *ostate = (char *)(&state[-1]);
+	uint32_t *int_arg_state = (uint32_t *)arg_state;
+
+	if (rand_type == TYPE_0)
+		state[-1] = rand_type;
+	else
+		state[-1] = MAX_TYPES * (rptr - state) + rand_type;
+	if (n < BREAK_0) {
+		(void)fprintf(stderr,
+		    "random: not enough state (%ld bytes); ignored.\n", n);
+		return(0);
+	}
+	if (n < BREAK_1) {
+		rand_type = TYPE_0;
+		rand_deg = DEG_0;
+		rand_sep = SEP_0;
+	} else if (n < BREAK_2) {
+		rand_type = TYPE_1;
+		rand_deg = DEG_1;
+		rand_sep = SEP_1;
+	} else if (n < BREAK_3) {
+		rand_type = TYPE_2;
+		rand_deg = DEG_2;
+		rand_sep = SEP_2;
+	} else if (n < BREAK_4) {
+		rand_type = TYPE_3;
+		rand_deg = DEG_3;
+		rand_sep = SEP_3;
+	} else {
+		rand_type = TYPE_4;
+		rand_deg = DEG_4;
+		rand_sep = SEP_4;
+	}
+	state = int_arg_state + 1; /* first location */
+	end_ptr = &state[rand_deg];	/* must set end_ptr before srandom */
+	srandom(seed);
+	if (rand_type == TYPE_0)
+		int_arg_state[0] = rand_type;
+	else
+		int_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type;
+	return(ostate);
+}
+
+/*
+ * setstate:
+ *
+ * Restore the state from the given state array.
+ *
+ * Note: it is important that we also remember the locations of the pointers
+ * in the current state information, and restore the locations of the pointers
+ * from the old state information.  This is done by multiplexing the pointer
+ * location into the zeroeth word of the state information.
+ *
+ * Note that due to the order in which things are done, it is OK to call
+ * setstate() with the same state as the current state.
+ *
+ * Returns a pointer to the old state information.
+ *
+ * Note: The Sparc platform requires that arg_state begin on an int
+ * word boundary; otherwise a bus error will occur. Even so, lint will
+ * complain about mis-alignment, but you should disregard these messages.
+ */
+char *
+setstate(arg_state)
+	char *arg_state;		/* pointer to state array */
+{
+	uint32_t *new_state = (uint32_t *)arg_state;
+	uint32_t type = new_state[0] % MAX_TYPES;
+	uint32_t rear = new_state[0] / MAX_TYPES;
+	char *ostate = (char *)(&state[-1]);
+
+	if (rand_type == TYPE_0)
+		state[-1] = rand_type;
+	else
+		state[-1] = MAX_TYPES * (rptr - state) + rand_type;
+	switch(type) {
+	case TYPE_0:
+	case TYPE_1:
+	case TYPE_2:
+	case TYPE_3:
+	case TYPE_4:
+		rand_type = type;
+		rand_deg = degrees[type];
+		rand_sep = seps[type];
+		break;
+	default:
+		(void)fprintf(stderr,
+		    "random: state info corrupted; not changed.\n");
+	}
+	state = new_state + 1;
+	if (rand_type != TYPE_0) {
+		rptr = &state[rear];
+		fptr = &state[(rear + rand_sep) % rand_deg];
+	}
+	end_ptr = &state[rand_deg];		/* set end_ptr too */
+	return(ostate);
+}
+
+/*
+ * random:
+ *
+ * If we are using the trivial TYPE_0 R.N.G., just do the old linear
+ * congruential bit.  Otherwise, we do our fancy trinomial stuff, which is
+ * the same in all the other cases due to all the global variables that have
+ * been set up.  The basic operation is to add the number at the rear pointer
+ * into the one at the front pointer.  Then both pointers are advanced to
+ * the next location cyclically in the table.  The value returned is the sum
+ * generated, reduced to 31 bits by throwing away the "least random" low bit.
+ *
+ * Note: the code takes advantage of the fact that both the front and
+ * rear pointers can't wrap on the same call by not testing the rear
+ * pointer if the front one has wrapped.
+ *
+ * Returns a 31-bit random number.
+ */
+long
+random()
+{
+	uint32_t i;
+	uint32_t *f, *r;
+
+	if (rand_type == TYPE_0) {
+		i = state[0];
+		state[0] = i = (good_rand(i)) & 0x7fffffff;
+	} else {
+		/*
+		 * Use local variables rather than static variables for speed.
+		 */
+		f = fptr; r = rptr;
+		*f += *r;
+		i = (*f >> 1) & 0x7fffffff;	/* chucking least random bit */
+		if (++f >= end_ptr) {
+			f = state;
+			++r;
+		}
+		else if (++r >= end_ptr) {
+			r = state;
+		}
+
+		fptr = f; rptr = r;
+	}
+	return((long)i);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/reallocf.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/reallocf.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/reallocf.c	(revision 2404)
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1998, M. Warner Losh <imp@freebsd.org>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/reallocf.c,v 1.4 2002/03/22 21:53:10 obrien Exp $");
+
+#include <stdlib.h>
+
+void *
+reallocf(void *ptr, size_t size)
+{
+	void *nptr;
+
+	nptr = realloc(ptr, size);
+	if (!nptr && ptr)
+		free(ptr);
+	return (nptr);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/remque.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/remque.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/remque.c	(revision 2404)
@@ -0,0 +1,30 @@
+/*
+ * Initial implementation:
+ * Copyright (c) 2002 Robert Drehmel
+ * All rights reserved.
+ *
+ * As long as the above copyright statement and this notice remain
+ * unchanged, you can do what ever you want with this file. 
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/remque.c,v 1.3 2003/01/04 07:34:41 tjr Exp $");
+
+#define	_SEARCH_PRIVATE
+#include <search.h>
+#include <stdlib.h>	/* for NULL */
+
+void
+remque(void *element)
+{
+	struct que_elem *prev, *next, *elem;
+
+	elem = (struct que_elem *)element;
+
+	prev = elem->prev;
+	next = elem->next;
+
+	if (prev != NULL)
+		prev->next = next;
+	if (next != NULL)
+		next->prev = prev;
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/strtoimax.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/strtoimax.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/strtoimax.c	(revision 2404)
@@ -0,0 +1,141 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "from @(#)strtol.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/strtoimax.c,v 1.9 2003/01/01 18:48:43 schweikh Exp $");
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+/*
+ * Convert a string to an intmax_t integer.
+ *
+ * Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+intmax_t
+strtoimax(const char * __restrict nptr, char ** __restrict endptr, int base)
+{
+	const char *s;
+	uintmax_t acc;
+	char c;
+	uintmax_t cutoff;
+	int neg, any, cutlim;
+
+	/*
+	 * Skip white space and pick up leading +/- sign if any.
+	 * If base is 0, allow 0x for hex and 0 for octal, else
+	 * assume decimal; if base is already 16, allow 0x.
+	 */
+	s = nptr;
+	do {
+		c = *s++;
+	} while (isspace((unsigned char)c));
+	if (c == '-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == '+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == '0' && (*s == 'x' || *s == 'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == '0' ? 8 : 10;
+	acc = any = 0;
+	if (base < 2 || base > 36)
+		goto noconv;
+
+	/*
+	 * Compute the cutoff value between legal numbers and illegal
+	 * numbers.  That is the largest legal value, divided by the
+	 * base.  An input number that is greater than this value, if
+	 * followed by a legal input character, is too big.  One that
+	 * is equal to this value may be valid or not; the limit
+	 * between valid and invalid numbers is then based on the last
+	 * digit.  For instance, if the range for intmax_t is
+	 * [-9223372036854775808..9223372036854775807] and the input base
+	 * is 10, cutoff will be set to 922337203685477580 and cutlim to
+	 * either 7 (neg==0) or 8 (neg==1), meaning that if we have
+	 * accumulated a value > 922337203685477580, or equal but the
+	 * next digit is > 7 (or 8), the number is too big, and we will
+	 * return a range error.
+	 *
+	 * Set 'any' if any `digits' consumed; make it negative to indicate
+	 * overflow.
+	 */
+	cutoff = neg ? (uintmax_t)-(INTMAX_MIN + INTMAX_MAX) + INTMAX_MAX
+	    : INTMAX_MAX;
+	cutlim = cutoff % base;
+	cutoff /= base;
+	for ( ; ; c = *s++) {
+		if (c >= '0' && c <= '9')
+			c -= '0';
+		else if (c >= 'A' && c <= 'Z')
+			c -= 'A' - 10;
+		else if (c >= 'a' && c <= 'z')
+			c -= 'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+			any = -1;
+		else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+	if (any < 0) {
+		acc = neg ? INTMAX_MIN : INTMAX_MAX;
+		errno = ERANGE;
+	} else if (!any) {
+noconv:
+		errno = EINVAL;
+	} else if (neg)
+		acc = -acc;
+	if (endptr != NULL)
+		*endptr = (char *)(any ? s - 1 : nptr);
+	return (acc);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/strtoumax.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/strtoumax.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/strtoumax.c	(revision 2404)
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "from @(#)strtoul.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/strtoumax.c,v 1.8 2002/09/06 11:23:59 tjr Exp $");
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+/*
+ * Convert a string to a uintmax_t integer.
+ *
+ * Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+uintmax_t
+strtoumax(const char * __restrict nptr, char ** __restrict endptr, int base)
+{
+	const char *s;
+	uintmax_t acc;
+	char c;
+	uintmax_t cutoff;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtoimax for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = *s++;
+	} while (isspace((unsigned char)c));
+	if (c == '-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == '+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == '0' && (*s == 'x' || *s == 'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == '0' ? 8 : 10;
+	acc = any = 0;
+	if (base < 2 || base > 36)
+		goto noconv;
+
+	cutoff = UINTMAX_MAX / base;
+	cutlim = UINTMAX_MAX % base;
+	for ( ; ; c = *s++) {
+		if (c >= '0' && c <= '9')
+			c -= '0';
+		else if (c >= 'A' && c <= 'Z')
+			c -= 'A' - 10;
+		else if (c >= 'a' && c <= 'z')
+			c -= 'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+			any = -1;
+		else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+	if (any < 0) {
+		acc = UINTMAX_MAX;
+		errno = ERANGE;
+	} else if (!any) {
+noconv:
+		errno = EINVAL;
+	} else if (neg)
+		acc = -acc;
+	if (endptr != NULL)
+		*endptr = (char *)(any ? s - 1 : nptr);
+	return (acc);
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/tdelete.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/tdelete.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/tdelete.c	(revision 2404)
@@ -0,0 +1,71 @@
+/*	$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $	*/
+
+/*
+ * Tree search generalized from Knuth (6.2.2) Algorithm T just like
+ * the AT&T man page says.
+ *
+ * The node_t structure is for internal use only, lint doesn't grok it.
+ *
+ * Written by reading the System V Interface Definition, not the code.
+ *
+ * Totally public domain.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/tdelete.c,v 1.6 2003/01/05 02:43:18 tjr Exp $");
+
+#define _SEARCH_PRIVATE
+#include <search.h>
+#include <stdlib.h>
+
+
+/*
+ * delete node with given key
+ *
+ * vkey:   key to be deleted
+ * vrootp: address of the root of the tree
+ * compar: function to carry out node comparisons
+ */
+void *
+tdelete(const void * __restrict vkey, void ** __restrict vrootp,
+    int (*compar)(const void *, const void *))
+{
+	node_t **rootp = (node_t **)vrootp;
+	node_t *p, *q, *r;
+	int cmp;
+
+	if (rootp == NULL || (p = *rootp) == NULL)
+		return NULL;
+
+	while ((cmp = (*compar)(vkey, (*rootp)->key)) != 0) {
+		p = *rootp;
+		rootp = (cmp < 0) ?
+		    &(*rootp)->llink :		/* follow llink branch */
+		    &(*rootp)->rlink;		/* follow rlink branch */
+		if (*rootp == NULL)
+			return NULL;		/* key not found */
+	}
+	r = (*rootp)->rlink;			/* D1: */
+	if ((q = (*rootp)->llink) == NULL)	/* Left NULL? */
+		q = r;
+	else if (r != NULL) {			/* Right link is NULL? */
+		if (r->llink == NULL) {		/* D2: Find successor */
+			r->llink = q;
+			q = r;
+		} else {			/* D3: Find NULL link */
+			for (q = r->llink; q->llink != NULL; q = r->llink)
+				r = q;
+			r->llink = q->rlink;
+			q->llink = (*rootp)->llink;
+			q->rlink = (*rootp)->rlink;
+		}
+	}
+	free(*rootp);				/* D4: Free node */
+	*rootp = q;				/* link parent to new node */
+	return p;
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/tfind.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/tfind.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/tfind.c	(revision 2404)
@@ -0,0 +1,48 @@
+/*	$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $	*/
+
+/*
+ * Tree search generalized from Knuth (6.2.2) Algorithm T just like
+ * the AT&T man page says.
+ *
+ * The node_t structure is for internal use only, lint doesn't grok it.
+ *
+ * Written by reading the System V Interface Definition, not the code.
+ *
+ * Totally public domain.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/tfind.c,v 1.5 2003/01/05 02:43:18 tjr Exp $");
+
+#define _SEARCH_PRIVATE
+#include <stdlib.h>
+#include <search.h>
+
+/* find a node, or return 0 */
+void *
+tfind(vkey, vrootp, compar)
+	const void *vkey;		/* key to be found */
+	void * const *vrootp;		/* address of the tree root */
+	int (*compar)(const void *, const void *);
+{
+	node_t **rootp = (node_t **)vrootp;
+
+	if (rootp == NULL)
+		return NULL;
+
+	while (*rootp != NULL) {		/* T1: */
+		int r;
+
+		if ((r = (*compar)(vkey, (*rootp)->key)) == 0)	/* T2: */
+			return *rootp;		/* key found */
+		rootp = (r < 0) ?
+		    &(*rootp)->llink :		/* T3: follow left branch */
+		    &(*rootp)->rlink;		/* T4: follow right branch */
+	}
+	return NULL;
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/tsearch.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/tsearch.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/tsearch.c	(revision 2404)
@@ -0,0 +1,58 @@
+/*	$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $	*/
+
+/*
+ * Tree search generalized from Knuth (6.2.2) Algorithm T just like
+ * the AT&T man page says.
+ *
+ * The node_t structure is for internal use only, lint doesn't grok it.
+ *
+ * Written by reading the System V Interface Definition, not the code.
+ *
+ * Totally public domain.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/tsearch.c,v 1.4 2003/01/05 02:43:18 tjr Exp $");
+
+#define _SEARCH_PRIVATE
+#include <search.h>
+#include <stdlib.h>
+
+/* find or insert datum into search tree */
+void *
+tsearch(vkey, vrootp, compar)
+	const void *vkey;		/* key to be located */
+	void **vrootp;			/* address of tree root */
+	int (*compar)(const void *, const void *);
+{
+	node_t *q;
+	node_t **rootp = (node_t **)vrootp;
+
+	if (rootp == NULL)
+		return NULL;
+
+	while (*rootp != NULL) {	/* Knuth's T1: */
+		int r;
+
+		if ((r = (*compar)(vkey, (*rootp)->key)) == 0)	/* T2: */
+			return *rootp;		/* we found it! */
+
+		rootp = (r < 0) ?
+		    &(*rootp)->llink :		/* T3: follow left branch */
+		    &(*rootp)->rlink;		/* T4: follow right branch */
+	}
+
+	q = malloc(sizeof(node_t));		/* T5: key not found */
+	if (q != 0) {				/* make new node */
+		*rootp = q;			/* link new node to old */
+		/* LINTED const castaway ok */
+		q->key = (void *)vkey;		/* initialize new node */
+		q->llink = q->rlink = NULL;
+	}
+	return q;
+}
Index: /vendor/FreeBSD-libc/5.3/stdlib/twalk.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdlib/twalk.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdlib/twalk.c	(revision 2404)
@@ -0,0 +1,58 @@
+/*	$NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $	*/
+
+/*
+ * Tree search generalized from Knuth (6.2.2) Algorithm T just like
+ * the AT&T man page says.
+ *
+ * The node_t structure is for internal use only, lint doesn't grok it.
+ *
+ * Written by reading the System V Interface Definition, not the code.
+ *
+ * Totally public domain.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/stdlib/twalk.c,v 1.5 2003/01/05 02:43:18 tjr Exp $");
+
+#define _SEARCH_PRIVATE
+#include <search.h>
+#include <stdlib.h>
+
+static void trecurse(const node_t *,
+    void (*action)(const void *, VISIT, int), int level);
+
+/* Walk the nodes of a tree */
+static void
+trecurse(root, action, level)
+	const node_t *root;	/* Root of the tree to be walked */
+	void (*action)(const void *, VISIT, int);
+	int level;
+{
+
+	if (root->llink == NULL && root->rlink == NULL)
+		(*action)(root, leaf, level);
+	else {
+		(*action)(root, preorder, level);
+		if (root->llink != NULL)
+			trecurse(root->llink, action, level + 1);
+		(*action)(root, postorder, level);
+		if (root->rlink != NULL)
+			trecurse(root->rlink, action, level + 1);
+		(*action)(root, endorder, level);
+	}
+}
+
+/* Walk the nodes of a tree */
+void
+twalk(vroot, action)
+	const void *vroot;	/* Root of the tree to be walked */
+	void (*action)(const void *, VISIT, int);
+{
+	if (vroot != NULL && action != NULL)
+		trecurse(vroot, action, 0);
+}
Index: /vendor/FreeBSD-libc/5.3/stdtime/difftime.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdtime/difftime.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdtime/difftime.c	(revision 2404)
@@ -0,0 +1,87 @@
+/*
+** This file is in the public domain, so clarified as of
+** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
+*/
+
+#include <sys/cdefs.h>
+#ifndef lint
+#ifndef NOID
+static char	elsieid[] __unused = "@(#)difftime.c	7.9";
+#endif /* !defined NOID */
+#endif /* !defined lint */
+__FBSDID("$FreeBSD: src/lib/libc/stdtime/difftime.c,v 1.8 2004/06/14 10:31:52 stefanf Exp $");
+
+/*LINTLIBRARY*/
+
+#include "namespace.h"
+#include "private.h"
+#include "un-namespace.h"
+
+/*
+** Algorithm courtesy Paul Eggert (eggert@twinsun.com).
+*/
+
+#ifdef HAVE_LONG_DOUBLE
+#define long_double	long double
+#endif /* defined HAVE_LONG_DOUBLE */
+#ifndef HAVE_LONG_DOUBLE
+#define long_double	double
+#endif /* !defined HAVE_LONG_DOUBLE */
+
+double
+difftime(time1, time0)
+const time_t	time1;
+const time_t	time0;
+{
+	time_t	delta;
+	time_t	hibit;
+
+	{
+		time_t		tt;
+		double		d;
+		long_double	ld;
+
+		if (sizeof tt < sizeof d)
+			return (double) time1 - (double) time0;
+		if (sizeof tt < sizeof ld)
+			return (long_double) time1 - (long_double) time0;
+	}
+	if (time1 < time0)
+		return -difftime(time0, time1);
+	/*
+	** As much as possible, avoid loss of precision
+	** by computing the difference before converting to double.
+	*/
+	delta = time1 - time0;
+	if (delta >= 0)
+		return delta;
+	/*
+	** Repair delta overflow.
+	*/
+	hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1);
+	/*
+	** The following expression rounds twice, which means
+	** the result may not be the closest to the true answer.
+	** For example, suppose time_t is 64-bit signed int,
+	** long_double is IEEE 754 double with default rounding,
+	** time1 = 9223372036854775807 and time0 = -1536.
+	** Then the true difference is 9223372036854777343,
+	** which rounds to 9223372036854777856
+	** with a total error of 513.
+	** But delta overflows to -9223372036854774273,
+	** which rounds to -9223372036854774784, and correcting
+	** this by subtracting 2 * (long_double) hibit
+	** (i.e. by adding 2**64 = 18446744073709551616)
+	** yields 9223372036854776832, which
+	** rounds to 9223372036854775808
+	** with a total error of 1535 instead.
+	** This problem occurs only with very large differences.
+	** It's too painful to fix this portably.
+	** We are not alone in this problem;
+	** some C compilers round twice when converting
+	** large unsigned types to small floating types,
+	** so if time_t is unsigned the "return delta" above
+	** has the same double-rounding problem with those compilers.
+	*/
+	return delta - 2 * (long_double) hibit;
+}
Index: /vendor/FreeBSD-libc/5.3/stdtime/private.h
===================================================================
--- /vendor/FreeBSD-libc/5.3/stdtime/private.h	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/stdtime/private.h	(revision 2404)
@@ -0,0 +1,260 @@
+#ifndef PRIVATE_H
+
+#define PRIVATE_H
+
+/*
+** This file is in the public domain, so clarified as of
+** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
+**
+** $FreeBSD: src/lib/libc/stdtime/private.h,v 1.10 2004/06/14 10:31:52 stefanf Exp $
+*/
+
+/* Stuff moved from Makefile.inc to reduce clutter */
+#ifndef TM_GMTOFF
+#define TM_GMTOFF	tm_gmtoff
+#define TM_ZONE		tm_zone
+#define STD_INSPIRED	1
+#define PCTS		1
+#define HAVE_LONG_DOUBLE 1
+#define HAVE_STRERROR	1
+#define	HAVE_UNISTD_H	1
+#define	LOCALE_HOME	_PATH_LOCALE
+#define TZDIR		"/usr/share/zoneinfo"
+#endif /* ndef TM_GMTOFF */
+
+/*
+** This header is for use ONLY with the time conversion code.
+** There is no guarantee that it will remain unchanged,
+** or that it will remain at all.
+** Do NOT copy it to any system include directory.
+** Thank you!
+*/
+
+/*
+** ID
+*/
+
+#ifndef lint
+#ifndef NOID
+/*
+static char	privatehid[] = "@(#)private.h	7.53";
+*/
+#endif /* !defined NOID */
+#endif /* !defined lint */
+
+/*
+** Defaults for preprocessor symbols.
+** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
+*/
+
+#ifndef HAVE_ADJTIME
+#define HAVE_ADJTIME		1
+#endif /* !defined HAVE_ADJTIME */
+
+#ifndef HAVE_GETTEXT
+#define HAVE_GETTEXT		0
+#endif /* !defined HAVE_GETTEXT */
+
+#ifndef HAVE_INCOMPATIBLE_CTIME_R
+#define HAVE_INCOMPATIBLE_CTIME_R	0
+#endif /* !defined INCOMPATIBLE_CTIME_R */
+
+#ifndef HAVE_SETTIMEOFDAY
+#define HAVE_SETTIMEOFDAY	3
+#endif /* !defined HAVE_SETTIMEOFDAY */
+
+#ifndef HAVE_STRERROR
+#define HAVE_STRERROR		1
+#endif /* !defined HAVE_STRERROR */
+
+#ifndef HAVE_SYMLINK
+#define HAVE_SYMLINK		1
+#endif /* !defined HAVE_SYMLINK */
+
+#ifndef HAVE_SYS_STAT_H
+#define HAVE_SYS_STAT_H		1
+#endif /* !defined HAVE_SYS_STAT_H */
+
+#ifndef HAVE_SYS_WAIT_H
+#define HAVE_SYS_WAIT_H		1
+#endif /* !defined HAVE_SYS_WAIT_H */
+
+#ifndef HAVE_UNISTD_H
+#define HAVE_UNISTD_H		1
+#endif /* !defined HAVE_UNISTD_H */
+
+#ifndef HAVE_UTMPX_H
+#define HAVE_UTMPX_H		0
+#endif /* !defined HAVE_UTMPX_H */
+
+#ifndef LOCALE_HOME
+#define LOCALE_HOME		"/usr/lib/locale"
+#endif /* !defined LOCALE_HOME */
+
+#if HAVE_INCOMPATIBLE_CTIME_R
+#define asctime_r _incompatible_asctime_r
+#define ctime_r _incompatible_ctime_r
+#endif /* HAVE_INCOMPATIBLE_CTIME_R */
+
+/*
+** Nested includes
+*/
+
+#include "sys/types.h"	/* for time_t */
+#include "stdio.h"
+#include "errno.h"
+#include "string.h"
+#include "limits.h"	/* for CHAR_BIT */
+#include "time.h"
+#include "stdlib.h"
+
+#if HAVE_GETTEXT - 0
+#include "libintl.h"
+#endif /* HAVE_GETTEXT - 0 */
+
+#if HAVE_SYS_WAIT_H - 0
+#include <sys/wait.h>	/* for WIFEXITED and WEXITSTATUS */
+#endif /* HAVE_SYS_WAIT_H - 0 */
+
+#ifndef WIFEXITED
+#define WIFEXITED(status)	(((status) & 0xff) == 0)
+#endif /* !defined WIFEXITED */
+#ifndef WEXITSTATUS
+#define WEXITSTATUS(status)	(((status) >> 8) & 0xff)
+#endif /* !defined WEXITSTATUS */
+
+#if HAVE_UNISTD_H - 0
+#include "unistd.h"	/* for F_OK and R_OK */
+#endif /* HAVE_UNISTD_H - 0 */
+
+#if !(HAVE_UNISTD_H - 0)
+#ifndef F_OK
+#define F_OK	0
+#endif /* !defined F_OK */
+#ifndef R_OK
+#define R_OK	4
+#endif /* !defined R_OK */
+#endif /* !(HAVE_UNISTD_H - 0) */
+
+/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
+#define is_digit(c) ((unsigned)(c) - '0' <= 9)
+
+/*
+** SunOS 4.1.1 headers lack FILENAME_MAX.
+*/
+
+#ifndef FILENAME_MAX
+
+#ifndef MAXPATHLEN
+#ifdef unix
+#include "sys/param.h"
+#endif /* defined unix */
+#endif /* !defined MAXPATHLEN */
+
+#ifdef MAXPATHLEN
+#define FILENAME_MAX	MAXPATHLEN
+#endif /* defined MAXPATHLEN */
+#ifndef MAXPATHLEN
+#define FILENAME_MAX	1024		/* Pure guesswork */
+#endif /* !defined MAXPATHLEN */
+
+#endif /* !defined FILENAME_MAX */
+
+/*
+** Private function declarations.
+*/
+char *	icalloc(int nelem, int elsize);
+char *	icatalloc(char * old, const char * new);
+char *	icpyalloc(const char * string);
+char *	imalloc(int n);
+void *	irealloc(void * pointer, int size);
+void	icfree(char * pointer);
+void	ifree(char * pointer);
+char *	scheck(const char *string, const char *format);
+
+
+/*
+** Finally, some convenience items.
+*/
+
+#ifndef TRUE
+#define TRUE	1
+#endif /* !defined TRUE */
+
+#ifndef FALSE
+#define FALSE	0
+#endif /* !defined FALSE */
+
+#ifndef TYPE_BIT
+#define TYPE_BIT(type)	(sizeof (type) * CHAR_BIT)
+#endif /* !defined TYPE_BIT */
+
+#ifndef TYPE_SIGNED
+#define TYPE_SIGNED(type) (((type) -1) < 0)
+#endif /* !defined TYPE_SIGNED */
+
+#ifndef INT_STRLEN_MAXIMUM
+/*
+** 302 / 1000 is log10(2.0) rounded up.
+** Subtract one for the sign bit if the type is signed;
+** add one for integer division truncation;
+** add one more for a minus sign if the type is signed.
+*/
+#define INT_STRLEN_MAXIMUM(type) \
+    ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
+#endif /* !defined INT_STRLEN_MAXIMUM */
+
+/*
+** INITIALIZE(x)
+*/
+
+#ifndef GNUC_or_lint
+#ifdef lint
+#define GNUC_or_lint
+#endif /* defined lint */
+#ifndef lint
+#ifdef __GNUC__
+#define GNUC_or_lint
+#endif /* defined __GNUC__ */
+#endif /* !defined lint */
+#endif /* !defined GNUC_or_lint */
+
+#ifndef INITIALIZE
+#ifdef GNUC_or_lint
+#define INITIALIZE(x)	((x) = 0)
+#endif /* defined GNUC_or_lint */
+#ifndef GNUC_or_lint
+#define INITIALIZE(x)
+#endif /* !defined GNUC_or_lint */
+#endif /* !defined INITIALIZE */
+
+/*
+** For the benefit of GNU folk...
+** `_(MSGID)' uses the current locale's message library string for MSGID.
+** The default is to use gettext if available, and use MSGID otherwise.
+*/
+
+#ifndef _
+#if HAVE_GETTEXT - 0
+#define _(msgid) gettext(msgid)
+#else /* !(HAVE_GETTEXT - 0) */
+#define _(msgid) msgid
+#endif /* !(HAVE_GETTEXT - 0) */
+#endif /* !defined _ */
+
+#ifndef TZ_DOMAIN
+#define TZ_DOMAIN "tz"
+#endif /* !defined TZ_DOMAIN */
+
+#if HAVE_INCOMPATIBLE_CTIME_R
+#undef asctime_r
+#undef ctime_r
+char *asctime_r(struct tm const *, char *);
+char *ctime_r(time_t const *, char *);
+#endif /* HAVE_INCOMPATIBLE_CTIME_R */
+
+/*
+** UNIX was a registered trademark of The Open Group in 2003.
+*/
+
+#endif /* !defined PRIVATE_H */
Index: /vendor/FreeBSD-libc/5.3/string/stpcpy.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/stpcpy.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/stpcpy.c	(revision 2404)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1999
+ *	David E. O'Brien
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcpy.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/stpcpy.c,v 1.1 2002/10/03 19:39:20 obrien Exp $");
+
+#include <string.h>
+
+char *
+stpcpy(char * to, const char * from)
+{
+
+	for (; (*to = *from); ++from, ++to);
+	return(to);
+}
Index: /vendor/FreeBSD-libc/5.3/string/strcasestr.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strcasestr.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strcasestr.c	(revision 2404)
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strcasestr.c,v 1.3 2002/03/21 18:44:54 obrien Exp $");
+
+#include <ctype.h>
+#include <string.h>
+
+/*
+ * Find the first occurrence of find in s, ignore case.
+ */
+char *
+strcasestr(s, find)
+	const char *s, *find;
+{
+	char c, sc;
+	size_t len;
+
+	if ((c = *find++) != 0) {
+		c = tolower((unsigned char)c);
+		len = strlen(find);
+		do {
+			do {
+				if ((sc = *s++) == 0)
+					return (NULL);
+			} while ((char)tolower((unsigned char)sc) != c);
+		} while (strncasecmp(s, find, len) != 0);
+		s--;
+	}
+	return ((char *)s);
+}
Index: /vendor/FreeBSD-libc/5.3/string/strlcat.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strlcat.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strlcat.c	(revision 2404)
@@ -0,0 +1,75 @@
+/*	$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $");
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strlcat.c,v 1.9 2003/05/01 19:03:14 nectar Exp $");
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left).  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(dst, src, siz)
+	char *dst;
+	const char *src;
+	size_t siz;
+{
+	char *d = dst;
+	const char *s = src;
+	size_t n = siz;
+	size_t dlen;
+
+	/* Find the end of dst and adjust bytes left but don't go past end */
+	while (n-- != 0 && *d != '\0')
+		d++;
+	dlen = d - dst;
+	n = siz - dlen;
+
+	if (n == 0)
+		return(dlen + strlen(s));
+	while (*s != '\0') {
+		if (n != 1) {
+			*d++ = *s;
+			n--;
+		}
+		s++;
+	}
+	*d = '\0';
+
+	return(dlen + (s - src));	/* count does not include NUL */
+}
Index: /vendor/FreeBSD-libc/5.3/string/strlcpy.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strlcpy.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strlcpy.c	(revision 2404)
@@ -0,0 +1,70 @@
+/*	$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $");
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strlcpy.c,v 1.7 2003/05/01 19:03:14 nectar Exp $");
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t strlcpy(dst, src, siz)
+	char *dst;
+	const char *src;
+	size_t siz;
+{
+	char *d = dst;
+	const char *s = src;
+	size_t n = siz;
+
+	/* Copy as many bytes as will fit */
+	if (n != 0 && --n != 0) {
+		do {
+			if ((*d++ = *s++) == 0)
+				break;
+		} while (--n != 0);
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src */
+	if (n == 0) {
+		if (siz != 0)
+			*d = '\0';		/* NUL-terminate dst */
+		while (*s++)
+			;
+	}
+
+	return(s - src - 1);	/* count does not include NUL */
+}
Index: /vendor/FreeBSD-libc/5.3/string/strmode.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strmode.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strmode.c	(revision 2404)
@@ -0,0 +1,154 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strmode.c	8.3 (Berkeley) 8/15/94";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strmode.c,v 1.4 2002/03/21 18:44:54 obrien Exp $");
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+
+void
+strmode(mode, p)
+	mode_t mode;
+	char *p;
+{
+	 /* print type */
+	switch (mode & S_IFMT) {
+	case S_IFDIR:			/* directory */
+		*p++ = 'd';
+		break;
+	case S_IFCHR:			/* character special */
+		*p++ = 'c';
+		break;
+	case S_IFBLK:			/* block special */
+		*p++ = 'b';
+		break;
+	case S_IFREG:			/* regular */
+		*p++ = '-';
+		break;
+	case S_IFLNK:			/* symbolic link */
+		*p++ = 'l';
+		break;
+	case S_IFSOCK:			/* socket */
+		*p++ = 's';
+		break;
+#ifdef S_IFIFO
+	case S_IFIFO:			/* fifo */
+		*p++ = 'p';
+		break;
+#endif
+#ifdef S_IFWHT
+	case S_IFWHT:			/* whiteout */
+		*p++ = 'w';
+		break;
+#endif
+	default:			/* unknown */
+		*p++ = '?';
+		break;
+	}
+	/* usr */
+	if (mode & S_IRUSR)
+		*p++ = 'r';
+	else
+		*p++ = '-';
+	if (mode & S_IWUSR)
+		*p++ = 'w';
+	else
+		*p++ = '-';
+	switch (mode & (S_IXUSR | S_ISUID)) {
+	case 0:
+		*p++ = '-';
+		break;
+	case S_IXUSR:
+		*p++ = 'x';
+		break;
+	case S_ISUID:
+		*p++ = 'S';
+		break;
+	case S_IXUSR | S_ISUID:
+		*p++ = 's';
+		break;
+	}
+	/* group */
+	if (mode & S_IRGRP)
+		*p++ = 'r';
+	else
+		*p++ = '-';
+	if (mode & S_IWGRP)
+		*p++ = 'w';
+	else
+		*p++ = '-';
+	switch (mode & (S_IXGRP | S_ISGID)) {
+	case 0:
+		*p++ = '-';
+		break;
+	case S_IXGRP:
+		*p++ = 'x';
+		break;
+	case S_ISGID:
+		*p++ = 'S';
+		break;
+	case S_IXGRP | S_ISGID:
+		*p++ = 's';
+		break;
+	}
+	/* other */
+	if (mode & S_IROTH)
+		*p++ = 'r';
+	else
+		*p++ = '-';
+	if (mode & S_IWOTH)
+		*p++ = 'w';
+	else
+		*p++ = '-';
+	switch (mode & (S_IXOTH | S_ISVTX)) {
+	case 0:
+		*p++ = '-';
+		break;
+	case S_IXOTH:
+		*p++ = 'x';
+		break;
+	case S_ISVTX:
+		*p++ = 'T';
+		break;
+	case S_IXOTH | S_ISVTX:
+		*p++ = 't';
+		break;
+	}
+	*p++ = ' ';		/* will be a '+' if ACL's implemented */
+	*p = '\0';
+}
Index: /vendor/FreeBSD-libc/5.3/string/strnstr.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strnstr.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strnstr.c	(revision 2404)
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strstr.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strnstr.c,v 1.2 2001/11/07 19:55:16 obrien Exp $");
+
+#include <string.h>
+
+/*
+ * Find the first occurrence of find in s, where the search is limited to the
+ * first slen characters of s.
+ */
+char *
+strnstr(s, find, slen)
+	const char *s;
+	const char *find;
+	size_t slen;
+{
+	char c, sc;
+	size_t len;
+
+	if ((c = *find++) != '\0') {
+		len = strlen(find);
+		do {
+			do {
+				if ((sc = *s++) == '\0' || slen-- < 1)
+					return (NULL);
+			} while (sc != c);
+			if (len > slen)
+				return (NULL);
+		} while (strncmp(s, find, len) != 0);
+		s--;
+	}
+	return ((char *)s);
+}
Index: /vendor/FreeBSD-libc/5.3/string/strsep.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strsep.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strsep.c	(revision 2404)
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strsep.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strsep.c,v 1.5 2002/03/21 18:44:54 obrien Exp $");
+
+#include <string.h>
+#include <stdio.h>
+
+/*
+ * Get next token from string *stringp, where tokens are possibly-empty
+ * strings separated by characters from delim.
+ *
+ * Writes NULs into the string at *stringp to end tokens.
+ * delim need not remain constant from call to call.
+ * On return, *stringp points past the last NUL written (if there might
+ * be further tokens), or is NULL (if there are definitely no more tokens).
+ *
+ * If *stringp is NULL, strsep returns NULL.
+ */
+char *
+strsep(stringp, delim)
+	char **stringp;
+	const char *delim;
+{
+	char *s;
+	const char *spanp;
+	int c, sc;
+	char *tok;
+
+	if ((s = *stringp) == NULL)
+		return (NULL);
+	for (tok = s;;) {
+		c = *s++;
+		spanp = delim;
+		do {
+			if ((sc = *spanp++) == c) {
+				if (c == 0)
+					s = NULL;
+				else
+					s[-1] = 0;
+				*stringp = s;
+				return (tok);
+			}
+		} while (sc != 0);
+	}
+	/* NOTREACHED */
+}
Index: /vendor/FreeBSD-libc/5.3/string/strsignal.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strsignal.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strsignal.c	(revision 2404)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strerror.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strsignal.c,v 1.4 2002/03/21 18:44:54 obrien Exp $");
+
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+char *
+strsignal(num)
+	int num;
+{
+#define	UPREFIX	"Unknown signal: "
+	static char ebuf[40] = UPREFIX;		/* 64-bit number + slop */
+	unsigned int signum;
+	char *p, *t;
+	char tmp[40];
+
+	signum = num;				/* convert to unsigned */
+	if (signum < sys_nsig)
+		return ((char *)sys_siglist[signum]);
+
+	/* Do this by hand, so we don't link to stdio(3). */
+	t = tmp;
+	if (num < 0)
+		signum = -signum;
+	do {
+		*t++ = "0123456789"[signum % 10];
+	} while (signum /= 10);
+	if (num < 0)
+		*t++ = '-';
+	for (p = ebuf + sizeof(UPREFIX) - 1;;) {
+		*p++ = *--t;
+		if (t <= tmp)
+			break;
+	}
+	*p = '\0';
+	return (ebuf);
+}
Index: /vendor/FreeBSD-libc/5.3/string/strspn.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strspn.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strspn.c	(revision 2404)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strspn.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strspn.c,v 1.4 2002/03/21 18:44:54 obrien Exp $");
+
+#include <string.h>
+
+/*
+ * Span the string s2 (skip characters that are in s2).
+ */
+size_t
+strspn(s1, s2)
+	const char *s1;
+	const char *s2;
+{
+	const char *p = s1, *spanp;
+	char c, sc;
+
+	/*
+	 * Skip any characters in s2, excluding the terminating \0.
+	 */
+cont:
+	c = *p++;
+	for (spanp = s2; (sc = *spanp++) != 0;)
+		if (sc == c)
+			goto cont;
+	return (p - 1 - s1);
+}
Index: /vendor/FreeBSD-libc/5.3/string/strtok.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/strtok.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/strtok.c	(revision 2404)
@@ -0,0 +1,140 @@
+/*-
+ * Copyright (c) 1998 Softweyr LLC.  All rights reserved.
+ *
+ * strtok_r, from Berkeley strtok
+ * Oct 13, 1998 by Wes Peters <wes@softweyr.com>
+ *
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notices, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notices, 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 Softweyr LLC, 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 SOFTWEYR LLC, 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 SOFTWEYR LLC, 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strtok.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/strtok.c,v 1.9 2002/09/07 02:53:19 tjr Exp $");
+
+#include <stddef.h>
+#ifdef DEBUG_STRTOK
+#include <stdio.h>
+#endif
+#include <string.h>
+
+char	*__strtok_r(char *, const char *, char **);
+
+__weak_reference(__strtok_r, strtok_r);
+
+char *
+__strtok_r(char *s, const char *delim, char **last)
+{
+	char *spanp, *tok;
+	int c, sc;
+
+	if (s == NULL && (s = *last) == NULL)
+		return (NULL);
+
+	/*
+	 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
+	 */
+cont:
+	c = *s++;
+	for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
+		if (c == sc)
+			goto cont;
+	}
+
+	if (c == 0) {		/* no non-delimiter characters */
+		*last = NULL;
+		return (NULL);
+	}
+	tok = s - 1;
+
+	/*
+	 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
+	 * Note that delim must have one NUL; we stop if we see that, too.
+	 */
+	for (;;) {
+		c = *s++;
+		spanp = (char *)delim;
+		do {
+			if ((sc = *spanp++) == c) {
+				if (c == 0)
+					s = NULL;
+				else
+					s[-1] = '\0';
+				*last = s;
+				return (tok);
+			}
+		} while (sc != 0);
+	}
+	/* NOTREACHED */
+}
+
+char *
+strtok(char *s, const char *delim)
+{
+	static char *last;
+
+	return (__strtok_r(s, delim, &last));
+}
+
+#ifdef DEBUG_STRTOK
+/*
+ * Test the tokenizer.
+ */
+int
+main(void)
+{
+	char blah[80], test[80];
+	char *brkb, *brkt, *phrase, *sep, *word;
+
+	sep = "\\/:;=-";
+	phrase = "foo";
+
+	printf("String tokenizer test:\n");
+	strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
+	for (word = strtok(test, sep); word; word = strtok(NULL, sep))
+		printf("Next word is \"%s\".\n", word);
+	strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
+
+	for (word = strtok_r(test, sep, &brkt); word;
+	    word = strtok_r(NULL, sep, &brkt)) {
+		strcpy(blah, "blah:blat:blab:blag");
+
+		for (phrase = strtok_r(blah, sep, &brkb); phrase;
+		    phrase = strtok_r(NULL, sep, &brkb))
+			printf("So far we're at %s:%s\n", word, phrase);
+	}
+
+	return (0);
+}
+
+#endif /* DEBUG_STRTOK */
Index: /vendor/FreeBSD-libc/5.3/string/wcscat.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcscat.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcscat.c	(revision 2404)
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *	citrus Id: wcscat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcscat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcscat.c,v 1.8 2002/09/26 09:28:55 tjr Exp $");
+
+#include <wchar.h>
+
+wchar_t *
+wcscat(s1, s2)
+	wchar_t * __restrict s1;
+	const wchar_t * __restrict s2;
+{
+	wchar_t *cp;
+
+	cp = s1;
+	while (*cp != L'\0')
+		cp++;
+	while ((*cp++ = *s2++) != L'\0')
+		;
+
+	return (s1);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcschr.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcschr.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcschr.c	(revision 2404)
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/wcschr.c,v 1.7 2002/10/23 10:47:47 tjr Exp $");
+
+#include <wchar.h>
+
+wchar_t *
+wcschr(const wchar_t *s, wchar_t c)
+{
+
+	while (*s != c && *s != L'\0')
+		s++;
+	if (*s == c)
+		return ((wchar_t *)s);
+	return (NULL);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcscmp.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcscmp.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcscmp.c	(revision 2404)
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcmp.c	8.1 (Berkeley) 6/4/93";
+#if 0
+__RCSID("$NetBSD: wcscmp.c,v 1.3 2001/01/05 12:13:12 itojun Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+__FBSDID("$FreeBSD: src/lib/libc/string/wcscmp.c,v 1.7 2002/10/23 11:08:40 tjr Exp $");
+
+#include <wchar.h>
+
+/*
+ * Compare strings.
+ */
+int
+wcscmp(s1, s2)
+	const wchar_t *s1, *s2;
+{
+
+	while (*s1 == *s2++)
+		if (*s1++ == 0)
+			return (0);
+	/* XXX assumes wchar_t = int */
+	return (*(const unsigned int *)s1 - *(const unsigned int *)--s2);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcscoll.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcscoll.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcscoll.c	(revision 2404)
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/wcscoll.c,v 1.3 2004/04/07 09:47:56 tjr Exp $");
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#include "collate.h"
+
+static char *__mbsdup(const wchar_t *);
+
+/*
+ * Placeholder implementation of wcscoll(). Attempts to use the single-byte
+ * collation ordering where possible, and falls back on wcscmp() in locales
+ * with extended character sets.
+ */
+int
+wcscoll(const wchar_t *ws1, const wchar_t *ws2)
+{
+	char *mbs1, *mbs2;
+	int diff, sverrno;
+
+	if (__collate_load_error || MB_CUR_MAX > 1)
+		/*
+		 * Locale has no special collating order, could not be
+		 * loaded, or has an extended character set; do a fast binary
+		 * comparison.
+		 */
+		return (wcscmp(ws1, ws2));
+
+	if ((mbs1 = __mbsdup(ws1)) == NULL || (mbs2 = __mbsdup(ws2)) == NULL) {
+		/*
+		 * Out of memory or illegal wide chars; fall back to wcscmp()
+		 * but leave errno indicating the error. Callers that don't
+		 * check for error will get a reasonable but often slightly
+		 * incorrect result.
+		 */
+		sverrno = errno;
+		free(mbs1);
+		errno = sverrno;
+		return (wcscmp(ws1, ws2));
+	}
+
+	diff = strcoll(mbs1, mbs2);
+	sverrno = errno;
+	free(mbs1);
+	free(mbs2);
+	errno = sverrno;
+
+	return (diff);
+}
+
+static char *
+__mbsdup(const wchar_t *ws)
+{
+	static const mbstate_t initial;
+	mbstate_t st;
+	const wchar_t *wcp;
+	size_t len;
+	char *mbs;
+
+	wcp = ws;
+	st = initial;
+	if ((len = wcsrtombs(NULL, &wcp, 0, &st)) == (size_t)-1)
+		return (NULL);
+	if ((mbs = malloc(len + 1)) == NULL)
+		return (NULL);
+	st = initial;
+	wcsrtombs(mbs, &ws, len + 1, &st);
+
+	return (mbs);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcscpy.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcscpy.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcscpy.c	(revision 2404)
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *	citrus Id: wcscpy.c,v 1.2 2000/12/21 04:51:09 itojun Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcscpy.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcscpy.c,v 1.8 2002/09/26 09:23:07 tjr Exp $");
+
+#include <wchar.h>
+
+wchar_t *
+wcscpy(s1, s2)
+	wchar_t * __restrict s1;
+	const wchar_t * __restrict s2;
+{
+	wchar_t *cp;
+
+	cp = s1;
+	while ((*cp++ = *s2++) != L'\0')
+		;
+
+	return (s1);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcscspn.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcscspn.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcscspn.c	(revision 2404)
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *	citrus Id: wcscspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcscspn.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcscspn.c,v 1.6 2002/09/21 00:29:23 tjr Exp $");
+
+#include <wchar.h>
+
+size_t
+wcscspn(s, set)
+	const wchar_t *s;
+	const wchar_t *set;
+{
+	const wchar_t *p;
+	const wchar_t *q;
+
+	p = s;
+	while (*p) {
+		q = set;
+		while (*q) {
+			if (*p == *q)
+				goto done;
+			q++;
+		}
+		p++;
+	}
+
+done:
+	return (p - s);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcslcat.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcslcat.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcslcat.c	(revision 2404)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
+ *
+ *	from OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcslcat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcslcat.c,v 1.6 2002/09/21 00:29:23 tjr Exp $");
+
+#include <sys/types.h>
+#include <wchar.h>
+
+/*
+ * Appends src to string dst of size siz (unlike wcsncat, siz is the
+ * full size of dst, not space left).  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns wcslen(initial dst) + wcslen(src); if retval >= siz,
+ * truncation occurred.
+ */
+size_t
+wcslcat(dst, src, siz)
+	wchar_t *dst;
+	const wchar_t *src;
+	size_t siz;
+{
+	wchar_t *d = dst;
+	const wchar_t *s = src;
+	size_t n = siz;
+	size_t dlen;
+
+	/* Find the end of dst and adjust bytes left but don't go past end */
+	while (*d != '\0' && n-- != 0)
+		d++;
+	dlen = d - dst;
+	n = siz - dlen;
+
+	if (n == 0)
+		return(dlen + wcslen(s));
+	while (*s != '\0') {
+		if (n != 1) {
+			*d++ = *s;
+			n--;
+		}
+		s++;
+	}
+	*d = '\0';
+
+	return(dlen + (s - src));	/* count does not include NUL */
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcslcpy.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcslcpy.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcslcpy.c	(revision 2404)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * 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. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
+ *
+ *	from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcslcpy.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcslcpy.c,v 1.6 2002/09/21 00:29:23 tjr Exp $");
+
+#include <sys/types.h>
+#include <wchar.h>
+
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns wcslen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+wcslcpy(dst, src, siz)
+	wchar_t *dst;
+	const wchar_t *src;
+	size_t siz;
+{
+	wchar_t *d = dst;
+	const wchar_t *s = src;
+	size_t n = siz;
+
+	/* Copy as many bytes as will fit */
+	if (n != 0 && --n != 0) {
+		do {
+			if ((*d++ = *s++) == 0)
+				break;
+		} while (--n != 0);
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src */
+	if (n == 0) {
+		if (siz != 0)
+			*d = '\0';		/* NUL-terminate dst */
+		while (*s++)
+			;
+	}
+
+	return(s - src - 1);	/* count does not include NUL */
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcslen.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcslen.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcslen.c	(revision 2404)
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *	citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcslen.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcslen.c,v 1.6 2002/09/21 00:29:23 tjr Exp $");
+
+#include <wchar.h>
+
+size_t
+wcslen(s)
+	const wchar_t *s;
+{
+	const wchar_t *p;
+
+	p = s;
+	while (*p)
+		p++;
+
+	return p - s;
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcsncat.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcsncat.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcsncat.c	(revision 2404)
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *	citrus Id: wcsncat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcsncat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcsncat.c,v 1.7 2002/09/21 00:29:23 tjr Exp $");
+
+#include <wchar.h>
+
+wchar_t *
+wcsncat(s1, s2, n)
+	wchar_t * __restrict s1;
+	const wchar_t * __restrict s2;
+	size_t n;
+{
+	wchar_t *p;
+	wchar_t *q;
+	const wchar_t *r;
+
+	p = s1;
+	while (*p)
+		p++;
+	q = p;
+	r = s2;
+	while (*r && n) {
+		*q++ = *r++;
+		n--;
+	}
+	*q = '\0';
+	return s1;
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcsncmp.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcsncmp.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcsncmp.c	(revision 2404)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. 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.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strncmp.c	8.1 (Berkeley) 6/4/93";
+__RCSID("$NetBSD: wcsncmp.c,v 1.3 2001/01/05 12:13:13 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcsncmp.c,v 1.7 2002/10/23 11:08:40 tjr Exp $");
+
+#include <wchar.h>
+
+int
+wcsncmp(s1, s2, n)
+	const wchar_t *s1, *s2;
+	size_t n;
+{
+
+	if (n == 0)
+		return (0);
+	do {
+		if (*s1 != *s2++) {
+			/* XXX assumes wchar_t = int */
+			return (*(const unsigned int *)s1 -
+			    *(const unsigned int *)--s2);
+		}
+		if (*s1++ == 0)
+			break;
+	} while (--n != 0);
+	return (0);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcsncpy.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcsncpy.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcsncpy.c	(revision 2404)
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strncpy.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/wcsncpy.c,v 1.9 2002/10/24 02:48:45 tjr Exp $");
+
+#include <wchar.h>
+
+/*
+ * Copy src to dst, truncating or null-padding to always copy n bytes.
+ * Return dst.
+ */
+wchar_t *
+wcsncpy(wchar_t * __restrict dst, const wchar_t * __restrict src, size_t n)
+{
+	if (n != 0) {
+		wchar_t *d = dst;
+		const wchar_t *s = src;
+
+		do {
+			if ((*d++ = *s++) == L'\0') {
+				/* NUL pad the remaining n-1 bytes */
+				while (--n != 0)
+					*d++ = L'\0';
+				break;
+			}
+		} while (--n != 0);
+	}
+	return (dst);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcspbrk.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcspbrk.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcspbrk.c	(revision 2404)
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *	citrus Id: wcspbrk.c,v 1.2 2000/12/21 05:07:25 itojun Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcspbrk.c,v 1.1 2000/12/23 23:14:37 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcspbrk.c,v 1.6 2002/09/21 00:29:23 tjr Exp $");
+
+#include <wchar.h>
+
+wchar_t *
+wcspbrk(s, set)
+	const wchar_t *s;
+	const wchar_t *set;
+{
+	const wchar_t *p;
+	const wchar_t *q;
+
+	p = s;
+	while (*p) {
+		q = set;
+		while (*q) {
+			if (*p == *q) {
+				/* LINTED interface specification */
+				return (wchar_t *)p;
+			}
+			q++;
+		}
+		p++;
+	}
+	return NULL;
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcsrchr.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcsrchr.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcsrchr.c	(revision 2404)
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/wcsrchr.c,v 1.7 2002/10/23 10:52:04 tjr Exp $");
+
+#include <wchar.h>
+
+wchar_t *
+wcsrchr(const wchar_t *s, wchar_t c)
+{
+	const wchar_t *last;
+
+	last = NULL;
+	for (;;) {
+		if (*s == c)
+			last = s;
+		if (*s == L'\0')
+			break;
+		s++;
+	}
+
+	return ((wchar_t *)last);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcsspn.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcsspn.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcsspn.c	(revision 2404)
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ *	citrus Id: wcsspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: wcsspn.c,v 1.1 2000/12/23 23:14:37 itojun Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD: src/lib/libc/string/wcsspn.c,v 1.7 2002/09/21 00:29:23 tjr Exp $");
+
+#include <wchar.h>
+
+size_t
+wcsspn(s, set)
+	const wchar_t *s;
+	const wchar_t *set;
+{
+	const wchar_t *p;
+	const wchar_t *q;
+
+	p = s;
+	while (*p) {
+		q = set;
+		while (*q) {
+			if (*p == *q)
+				break;
+			q++;
+		}
+		if (!*q)
+			goto done;
+		p++;
+	}
+
+done:
+	return (p - s);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcsstr.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcsstr.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcsstr.c	(revision 2404)
@@ -0,0 +1,67 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strstr.c	8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/wcsstr.c,v 1.8 2002/10/24 02:53:45 tjr Exp $");
+
+#include <wchar.h>
+
+/*
+ * Find the first occurrence of find in s.
+ */
+wchar_t *
+wcsstr(const wchar_t * __restrict s, const wchar_t * __restrict find)
+{
+	wchar_t c, sc;
+	size_t len;
+
+	if ((c = *find++) != 0) {
+		len = wcslen(find);
+		do {
+			do {
+				if ((sc = *s++) == L'\0')
+					return (NULL);
+			} while (sc != c);
+		} while (wcsncmp(s, find, len) != 0);
+		s--;
+	}
+	return ((wchar_t *)s);
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcstok.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcstok.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcstok.c	(revision 2404)
@@ -0,0 +1,90 @@
+/*-
+ * Copyright (c) 1998 Softweyr LLC.  All rights reserved.
+ *
+ * strtok_r, from Berkeley strtok
+ * Oct 13, 1998 by Wes Peters <wes@softweyr.com>
+ *
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notices, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notices, 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 Softweyr LLC, 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 SOFTWEYR LLC, 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 SOFTWEYR LLC, 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/wcstok.c,v 1.2 2003/03/12 06:41:49 tjr Exp $");
+
+#include <wchar.h>
+
+wchar_t *
+wcstok(wchar_t * __restrict s, const wchar_t * __restrict delim,
+    wchar_t ** __restrict last)
+{
+	const wchar_t *spanp;
+	wchar_t *tok;
+	wchar_t c, sc;
+
+	if (s == NULL && (s = *last) == NULL)
+		return (NULL);
+
+	/*
+	 * Skip (span) leading delimiters (s += wcsspn(s, delim), sort of).
+	 */
+cont:
+	c = *s++;
+	for (spanp = delim; (sc = *spanp++) != L'\0';) {
+		if (c == sc)
+			goto cont;
+	}
+
+	if (c == L'\0') {	/* no non-delimiter characters */
+		*last = NULL;
+		return (NULL);
+	}
+	tok = s - 1;
+
+	/*
+	 * Scan token (scan for delimiters: s += wcscspn(s, delim), sort of).
+	 * Note that delim must have one NUL; we stop if we see that, too.
+	 */
+	for (;;) {
+		c = *s++;
+		spanp = delim;
+		do {
+			if ((sc = *spanp++) == c) {
+				if (c == L'\0')
+					s = NULL;
+				else
+					s[-1] = L'\0';
+				*last = s;
+				return (tok);
+			}
+		} while (sc != L'\0');
+	}
+	/* NOTREACHED */
+}
Index: /vendor/FreeBSD-libc/5.3/string/wcswidth.c
===================================================================
--- /vendor/FreeBSD-libc/5.3/string/wcswidth.c	(revision 2404)
+++ /vendor/FreeBSD-libc/5.3/string/wcswidth.c	(revision 2404)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Paul Borman at Krystal Technologies.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/string/wcswidth.c,v 1.6 2002/08/20 02:06:28 ache Exp $");
+
+#include <wchar.h>
+
+int
+wcswidth(const wchar_t *pwcs, size_t n)
+{
+	wchar_t wc;
+	int len, l;
+
+	len = 0;
+	while (n-- > 0 && (wc = *pwcs++) != L'\0') {
+		if ((l = wcwidth(wc)) < 0)
+			return (-1);
+		len += l;
+	}
+	return (len);
+}
+
