Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Switch terminfo(3) to cdb(5).
details: https://anonhg.NetBSD.org/src/rev/e581c140092f
branches: trunk
changeset: 779579:e581c140092f
user: joerg <joerg%NetBSD.org@localhost>
date: Sun Jun 03 23:19:09 2012 +0000
description:
Switch terminfo(3) to cdb(5).
diffstat:
distrib/amd64/cdroms/Makefile.cdrom | 4 +-
distrib/i386/cdroms/Makefile.cdrom | 4 +-
distrib/sets/lists/base/mi | 5 +-
distrib/sets/lists/tests/mi | 5 +-
distrib/sparc64/cdroms/installcd/Makefile | 4 +-
distrib/sparc64/instfs/list | 4 +-
lib/libterminfo/Makefile.hash | 4 +-
lib/libterminfo/compile.c | 11 +-
lib/libterminfo/term.c | 92 ++++++++++--------
lib/libterminfo/term_private.h | 19 ++-
lib/libterminfo/terminfo.5.in | 14 +-
share/man/man7/hier.7 | 8 +-
share/terminfo/Makefile | 12 +-
tests/lib/libcurses/Makefile | 12 +-
tests/lib/libcurses/director/director.c | 10 +-
usr.bin/tic/tic.1 | 10 +-
usr.bin/tic/tic.c | 151 +++++++++++++++--------------
17 files changed, 195 insertions(+), 174 deletions(-)
diffs (truncated from 844 to 300 lines):
diff -r 42e4cd678f2c -r e581c140092f distrib/amd64/cdroms/Makefile.cdrom
--- a/distrib/amd64/cdroms/Makefile.cdrom Sun Jun 03 21:42:44 2012 +0000
+++ b/distrib/amd64/cdroms/Makefile.cdrom Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.cdrom,v 1.6 2011/06/21 21:49:22 joerg Exp $
+# $NetBSD: Makefile.cdrom,v 1.7 2012/06/03 23:19:09 joerg Exp $
.include <bsd.own.mk>
@@ -53,7 +53,7 @@
CDRUNTIME+= ./usr/sbin/chroot
CDRUNTIME+= ./usr/sbin/installboot
CDRUNTIME+= ./usr/sbin/wiconfig
-CDRUNTIME+= ./usr/share/misc/terminfo.db
+CDRUNTIME+= ./usr/share/misc/terminfo.cdb
CDRUNTIME+= ./usr/share/locale
image_md_pre:
diff -r 42e4cd678f2c -r e581c140092f distrib/i386/cdroms/Makefile.cdrom
--- a/distrib/i386/cdroms/Makefile.cdrom Sun Jun 03 21:42:44 2012 +0000
+++ b/distrib/i386/cdroms/Makefile.cdrom Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.cdrom,v 1.26 2011/06/21 21:49:23 joerg Exp $
+# $NetBSD: Makefile.cdrom,v 1.27 2012/06/03 23:19:09 joerg Exp $
.include <bsd.own.mk>
@@ -53,7 +53,7 @@
CDRUNTIME+= ./usr/sbin/chroot
CDRUNTIME+= ./usr/sbin/installboot
CDRUNTIME+= ./usr/sbin/wiconfig
-CDRUNTIME+= ./usr/share/misc/terminfo.db
+CDRUNTIME+= ./usr/share/misc/terminfo.cdb
CDRUNTIME+= ./usr/share/locale
image_md_pre:
diff -r 42e4cd678f2c -r e581c140092f distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi Sun Jun 03 21:42:44 2012 +0000
+++ b/distrib/sets/lists/base/mi Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.995 2012/06/01 13:19:38 nonaka Exp $
+# $NetBSD: mi,v 1.996 2012/06/03 23:19:09 joerg Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -3773,7 +3773,8 @@
./usr/share/misc/more.help base-obsolete obsolete
./usr/share/misc/nslookup.help base-obsolete obsolete
./usr/share/misc/terminfo base-terminfo-share share
-./usr/share/misc/terminfo.db base-terminfo-share share
+./usr/share/misc/terminfo.cdb base-terminfo-share share
+./usr/share/misc/terminfo.db base-obsolete obsolete
./usr/share/misc/units.lib base-reference-share share
./usr/share/misc/usb_hid_usages base-reference-share share
./usr/share/misc/vgrindefs.db base-groff-share share
diff -r 42e4cd678f2c -r e581c140092f distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jun 03 21:42:44 2012 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.471 2012/06/01 10:52:38 skrll Exp $
+# $NetBSD: mi,v 1.472 2012/06/03 23:19:10 joerg Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -2510,7 +2510,8 @@
./usr/tests/lib/libcrypt/t_crypt tests-lib-tests
./usr/tests/lib/libcurses tests-lib-tests
./usr/tests/lib/libcurses/.terminfo.db tests-obsolete obsolete
-./usr/tests/lib/libcurses/terminfo.db tests-lib-tests atf
+./usr/tests/lib/libcurses/terminfo.cdb tests-lib-tests atf
+./usr/tests/lib/libcurses/terminfo.db tests-obsolete obsolete
./usr/tests/lib/libcurses/Atffile tests-lib-tests atf
./usr/tests/lib/libcurses/check_files tests-lib-tests
./usr/tests/lib/libcurses/check_files/addch.chk tests-lib-tests atf
diff -r 42e4cd678f2c -r e581c140092f distrib/sparc64/cdroms/installcd/Makefile
--- a/distrib/sparc64/cdroms/installcd/Makefile Sun Jun 03 21:42:44 2012 +0000
+++ b/distrib/sparc64/cdroms/installcd/Makefile Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.14 2012/01/15 22:34:34 jmcneill Exp $
+# $NetBSD: Makefile,v 1.15 2012/06/03 23:19:10 joerg Exp $
CDBASE= sparc64cd # gives ${CDBASE}.iso
CDRELEASE= true # include $RELEASEDIR/$MACHINE
@@ -56,7 +56,7 @@
CDRUNTIME+= ./usr/sbin/installboot
CDRUNTIME+= ./usr/sbin/pppd
CDRUNTIME+= ./usr/sbin/wiconfig
-CDRUNTIME+= ./usr/share/misc/terminfo.db
+CDRUNTIME+= ./usr/share/misc/terminfo.cdb
CDRUNTIME+= ./usr/share/locale
image_md_pre:
diff -r 42e4cd678f2c -r e581c140092f distrib/sparc64/instfs/list
--- a/distrib/sparc64/instfs/list Sun Jun 03 21:42:44 2012 +0000
+++ b/distrib/sparc64/instfs/list Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: list,v 1.24 2011/07/03 23:11:34 tron Exp $
+# $NetBSD: list,v 1.25 2012/06/03 23:19:10 joerg Exp $
SRCDIRS bin sbin libexec external/bsd/less/bin usr.bin usr.sbin
@@ -85,7 +85,7 @@
COPY ${NETBSDSRCDIR}/etc/netconfig etc/netconfig
COPY ${DISTRIBDIR}/common/protocols etc/protocols
COPY ${DISTRIBDIR}/common/services etc/services
-COPY ${DESTDIR}/usr/share/misc/terminfo.db usr/share/misc/terminfo.db
+COPY ${DESTDIR}/usr/share/misc/terminfo.cdb usr/share/misc/terminfo.cdb
# we need the boot block in /usr/mdec + the arch specific extras
COPY ${DESTDIR}/usr/mdec/binstall usr/mdec/binstall 555
diff -r 42e4cd678f2c -r e581c140092f lib/libterminfo/Makefile.hash
--- a/lib/libterminfo/Makefile.hash Sun Jun 03 21:42:44 2012 +0000
+++ b/lib/libterminfo/Makefile.hash Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.hash,v 1.4 2011/11/03 07:19:39 joerg Exp $
+# $NetBSD: Makefile.hash,v 1.5 2012/06/03 23:19:10 joerg Exp $
SCRIPT_ENV= \
TOOL_AWK=${TOOL_AWK:Q} \
@@ -22,6 +22,8 @@
@echo "Generating compiled terminfo descriptions"
${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} > ${.TARGET}
+compiled_terms.c: ${TOOL_TIC}
+
DPSRCS+= hash.c termcap_hash.c compiled_terms.c
CLEANFILES+= hash.c termcap_hash.c compiled_terms.c
diff -r 42e4cd678f2c -r e581c140092f lib/libterminfo/compile.c
--- a/lib/libterminfo/compile.c Sun Jun 03 21:42:44 2012 +0000
+++ b/lib/libterminfo/compile.c Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compile.c,v 1.7 2012/06/01 12:08:40 joerg Exp $ */
+/* $NetBSD: compile.c,v 1.8 2012/06/03 23:19:10 joerg Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: compile.c,v 1.7 2012/06/01 12:08:40 joerg Exp $");
+__RCSID("$NetBSD: compile.c,v 1.8 2012/06/03 23:19:10 joerg Exp $");
#if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
@@ -239,12 +239,7 @@
return -1;
cap = *buf;
- if (alen == 0 && dlen == 0 && tic->flags.bufpos == 0 &&
- tic->nums.bufpos == 0 && tic->strs.bufpos == 0 &&
- tic->extras.bufpos == 0)
- *cap++ = 0; /* alias */
- else
- *cap++ = 2; /* version */
+ *cap++ = 1;
le16enc(cap, len);
cap += sizeof(uint16_t);
memcpy(cap, tic->name, len);
diff -r 42e4cd678f2c -r e581c140092f lib/libterminfo/term.c
--- a/lib/libterminfo/term.c Sun Jun 03 21:42:44 2012 +0000
+++ b/lib/libterminfo/term.c Sun Jun 03 23:19:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.14 2012/06/01 12:02:36 joerg Exp $ */
+/* $NetBSD: term.c,v 1.15 2012/06/03 23:19:10 joerg Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,16 +28,16 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: term.c,v 1.14 2012/06/01 12:02:36 joerg Exp $");
+__RCSID("$NetBSD: term.c,v 1.15 2012/06/03 23:19:10 joerg Exp $");
#include <sys/stat.h>
#include <assert.h>
+#include <cdbr.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
-#include <ndbm.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -62,8 +62,8 @@
TERMUSERDEF *ud;
ver = *cap++;
- /* Only read version 1 and 2 structures */
- if (ver != 1 && ver != 2) {
+ /* Only read version 1 structures */
+ if (ver != 1) {
errno = EINVAL;
return -1;
}
@@ -89,17 +89,13 @@
cap += sizeof(uint16_t);
term->name = cap;
cap += len;
- if (ver == 1)
+ len = le16dec(cap);
+ cap += sizeof(uint16_t);
+ if (len == 0)
term->_alias = NULL;
else {
- len = le16dec(cap);
- cap += sizeof(uint16_t);
- if (len == 0)
- term->_alias = NULL;
- else {
- term->_alias = cap;
- cap += len;
- }
+ term->_alias = cap;
+ cap += len;
}
len = le16dec(cap);
cap += sizeof(uint16_t);
@@ -215,41 +211,55 @@
static int
_ti_dbgetterm(TERMINAL *term, const char *path, const char *name, int flags)
{
- DBM *db;
- datum dt;
- char *p;
+ struct cdbr *db;
+ const void *data;
+ char *db_name;
+ const uint8_t *data8;
+ size_t len, klen;
int r;
- db = dbm_open(path, O_RDONLY, 0644);
+ if (asprintf(&db_name, "%s.cdb", path) < 0)
+ return -1;
+
+ db = cdbr_open(db_name, CDBR_DEFAULT);
+ free(db_name);
if (db == NULL)
return -1;
+
+ klen = strlen(name) + 1;
+ if (cdbr_find(db, name, klen, &data, &len) == -1)
+ goto fail;
+ data8 = data;
+ if (len == 0)
+ goto fail;
+ /* Check for alias first, fall through to processing normal entries. */
+ if (data8[0] == 2) {
+ if (klen + 7 >= len || le16dec(data8 + 5) != klen)
+ goto fail;
+ if (memcmp(data8 + 7, name, klen))
+ goto fail;
+ if (cdbr_get(db, le32dec(data8 + 1), &data, &len))
+ goto fail;
+ data8 = data;
+ if (data8[0] != 1)
+ goto fail;
+ } else if (data8[0] != 1)
+ goto fail;
+ else if (klen + 3 >= len || le16dec(data8 + 1) != klen)
+ goto fail;
+ else if (memcmp(data8 + 3, name, klen))
+ goto fail;
+
strlcpy(database, path, sizeof(database));
_ti_database = database;
- dt.dptr = (void *)__UNCONST(name);
- dt.dsize = strlen(name);
- dt = dbm_fetch(db, dt);
- if (dt.dptr == NULL) {
- dbm_close(db);
- return 0;
- }
- for (;;) {
- p = (char *)dt.dptr;
- if (*p++ != 0) /* not alias */
- break;
- dt.dsize = le16dec(p) - 1;
- p += sizeof(uint16_t);
- dt.dptr = p;
- dt = dbm_fetch(db, dt);
- if (dt.dptr == NULL) {
- dbm_close(db);
- return 0;
- }
- }
-
- r = _ti_readterm(term, (char *)dt.dptr, dt.dsize, flags);
- dbm_close(db);
+ r = _ti_readterm(term, data, len, flags);
+ cdbr_close(db);
return r;
+
+ fail:
Home |
Main Index |
Thread Index |
Old Index