Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libterminfo Use structures so we know how long each desc...



details:   https://anonhg.NetBSD.org/src/rev/460ee2032856
branches:  trunk
changeset: 752021:460ee2032856
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Feb 11 13:11:47 2010 +0000

description:
Use structures so we know how long each description is.

diffstat:

 lib/libterminfo/Makefile |  15 ++++++---------
 lib/libterminfo/term.c   |  19 +++++++++++--------
 2 files changed, 17 insertions(+), 17 deletions(-)

diffs (100 lines):

diff -r e0fab9b1203d -r 460ee2032856 lib/libterminfo/Makefile
--- a/lib/libterminfo/Makefile  Thu Feb 11 13:09:57 2010 +0000
+++ b/lib/libterminfo/Makefile  Thu Feb 11 13:11:47 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.5 2010/02/11 00:27:09 roy Exp $
+#      $NetBSD: Makefile,v 1.6 2010/02/11 13:11:47 roy Exp $
 
 USE_SHLIBDIR=  yes
 
@@ -12,15 +12,11 @@
 INCS=          term.h
 INCSDIR=       /usr/include
 
-.include <bsd.own.mk>
+.PHONY:        rescue.c
 
-rescue.c: ${NETBSDSRCDIR}/share/terminfo/terminfo
-               @echo "static const char *rescue_terms[] = {" >$@
-               ${TOOL_TIC} -Sx ${NETBSDSRCDIR}/share/terminfo/terminfo \
-                   ansi dumb vt100 vt220 wsvt25 >>$@
-               @echo " NULL," >>$@
-               @echo " NULL" >>$@
-               @echo "};" >>$@
+rescue.c:
+               tic -Sx ${NETBSDSRCDIR}/share/terminfo/terminfo \
+                   ansi dumb vt100 vt220 wsvt25 >$@
 
 term.c: rescue.c
 
@@ -58,6 +54,7 @@
 
 gen: hash man
 
+.include <bsd.own.mk>
 .include <bsd.shlib.mk>
 
 .if ${MKLINKLIB} != "no"
diff -r e0fab9b1203d -r 460ee2032856 lib/libterminfo/term.c
--- a/lib/libterminfo/term.c    Thu Feb 11 13:09:57 2010 +0000
+++ b/lib/libterminfo/term.c    Thu Feb 11 13:11:47 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.6 2010/02/11 09:42:03 roy Exp $ */
+/* $NetBSD: term.c,v 1.7 2010/02/11 13:11:47 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: term.c,v 1.6 2010/02/11 09:42:03 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.7 2010/02/11 13:11:47 roy Exp $");
 
 #include <sys/stat.h>
 
@@ -91,7 +91,7 @@
        term->_area = malloc(term->_arealen);
        if (term->_area == NULL)
                goto err;
-       memcpy(term->_area, cap, term->_arealen);
+       memcpy(term->_area, cap, term->_arealen);
 
        cap = term->_area;
        len = le16dec(cap);
@@ -296,7 +296,8 @@
 {
        int r;
        char *e, h[PATH_MAX];
-       const char **p;
+       size_t i;
+       const struct compiled_term *t;
 
        _DIAGASSERT(term != NULL);
        _DIAGASSERT(name != NULL);
@@ -320,11 +321,13 @@
        if (r == 1)
                return 1;
 
-       for (p = rescue_terms; *p != NULL; p++, p++)
-               if (strcmp(name, *p) == 0) {
-                       r = _ti_readterm(term, *(p + 1), 4096, flags);
+       for (i = 0; i < __arraycount(compiled_terms); i++) {
+               t = &compiled_terms[i];
+               if (strcmp(name, t->name) == 0) {
+                       r = _ti_readterm(term, t->cap, t->caplen, flags);
                        break;
                }
+       }
 
        return r;
 }
@@ -334,7 +337,7 @@
 {
 
        _DIAGASSERT(term != NULL);
-       
+
        free(term->_area);
        term->_area = NULL;
        free(term->strs);



Home | Main Index | Thread Index | Old Index