CVS commit: src/usr.bin/tic

2020-03-29 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Mar 29 21:54:03 UTC 2020

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
tic: Duplicate and promote v1 records when merging a v3 record

When this occurs, tic merges the matching v1 record into the original v1.

The screen-256color record by itself doesn't have any numerics bigger
than a short, but the xterm+256setaf record does.

The screen-256color record is now as it was before the recent terminfo2.cdb
merge into terminfo.cdb.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.38 src/usr.bin/tic/tic.c:1.39
--- src/usr.bin/tic/tic.c:1.38	Sat Mar 28 15:37:04 2020
+++ src/usr.bin/tic/tic.c	Sun Mar 29 21:54:03 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.38 2020/03/28 15:37:04 roy Exp $ */
+/* $NetBSD: tic.c,v 1.39 2020/03/29 21:54:03 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.38 2020/03/28 15:37:04 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.39 2020/03/29 21:54:03 roy Exp $");
 
 #include 
 #include 
@@ -51,6 +51,7 @@ __RCSID("$NetBSD: tic.c,v 1.38 2020/03/2
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -141,6 +142,22 @@ find_term(const char *name)
 }
 
 static TERM *
+find_newest_term(const char *name)
+{
+	char *lname;
+	TERM *term;
+
+	lname = _ti_getname(TERMINFO_RTYPE, name);
+	if (lname == NULL)
+		return NULL;
+	term = find_term(lname);
+	free(lname);
+	if (term == NULL)
+		term = find_term(name);
+	return term;
+}
+
+static TERM *
 store_term(const char *name, TERM *base_term)
 {
 	TERM *term;
@@ -228,24 +245,9 @@ merge(TIC *rtic, TIC *utic, int flags)
 	int num;
 	size_t n;
 
-	/* Promote record type if needed. */
-	if (rtic->rtype < utic->rtype) {
-		char *obuf = rtic->nums.buf;
-
-		cap = rtic->nums.buf;
-		rtic->nums.buf = NULL;
-		rtic->nums.buflen = rtic->nums.bufpos = 0;
-		for (n = rtic->nums.entries; n > 0; n--) {
-			ind = _ti_decode_16(&cap);
-			num = _ti_decode_num(&cap, rtic->rtype);
-			if (VALID_NUMERIC(num) &&
-			!_ti_encode_buf_id_num(&rtic->nums, ind, num,
-			_ti_numsize(utic)))
-err(EXIT_FAILURE, "encode num");
-		}
-		rtic->rtype = utic->rtype;
-		free(obuf);
-	}
+	if (rtic->rtype < utic->rtype)
+		errx(EXIT_FAILURE, "merge rtype diff (%s:%d into %s:%d)",
+		utic->name, utic->rtype, rtic->name, rtic->rtype);
 
 	cap = utic->flags.buf;
 	for (n = utic->flags.entries; n > 0; n--) {
@@ -318,20 +320,95 @@ merge(TIC *rtic, TIC *utic, int flags)
 	}
 }
 
+static int
+dup_tbuf(TBUF *dst, const TBUF *src)
+{
+
+	if (src->buflen == 0)
+		return 0;
+	dst->buf = malloc(src->buflen);
+	if (dst->buf == NULL)
+		return -1;
+	dst->buflen = src->buflen;
+	memcpy(dst->buf, src->buf, dst->buflen);
+	dst->bufpos = src->bufpos;
+	dst->entries = src->entries;
+	return 0;
+}
+
+static int
+promote(TIC *rtic, TIC *utic)
+{
+	TERM *nrterm = find_newest_term(rtic->name);
+	TERM *nuterm = find_newest_term(utic->name);
+	TERM *term;
+	TIC *tic;
+
+	if (nrterm == NULL || nuterm == NULL)
+		return -1;
+	if (nrterm->tic->rtype >= nuterm->tic->rtype)
+		return 0;
+
+	tic = calloc(1, sizeof(*tic));
+	if (tic == NULL)
+		return -1;
+
+	tic->name = _ti_getname(TERMINFO_RTYPE, rtic->name);
+	if (tic->name == NULL)
+		goto err;
+	if (rtic->desc != NULL) {
+		tic->desc = strdup(rtic->desc);
+		if (tic->desc == NULL)
+			goto err;
+	}
+
+	tic->rtype = rtic->rtype;
+	if (dup_tbuf(&tic->flags, &rtic->flags) == -1)
+		goto err;
+	if (dup_tbuf(&tic->nums, &rtic->nums) == -1)
+		goto err;
+	if (dup_tbuf(&tic->strs, &rtic->strs) == -1)
+		goto err;
+	if (dup_tbuf(&tic->extras, &rtic->extras) == -1)
+		goto err;
+	if (_ti_promote(tic) == -1)
+		goto err;
+
+	term = store_term(tic->name, NULL);
+	if (term != NULL) {
+		term->tic = tic;
+		return 0;
+	}
+
+err:
+	free(tic->flags.buf);
+	free(tic->nums.buf);
+	free(tic->strs.buf);
+	free(tic->extras.buf);
+	free(tic->desc);
+	free(tic->name);
+	free(tic);
+	return -1;
+}
+
 static size_t
 merge_use(int flags)
 {
 	size_t skipped, merged, memn;
 	const char *cap;
+	char *name, *basename;
 	uint16_t num;
 	TIC *rtic, *utic;
-	TERM *term, *uterm;;
+	TERM *term, *uterm;
+	bool promoted;
 
 	skipped = merged = 0;
 	STAILQ_FOREACH(term, &terms, next) {
 		if (term->base_term != NULL)
 			continue;
 		rtic = term->tic;
+		basename = _ti_getname(TERMINFO_RTYPE_O1, rtic->name);
+		promoted = false;
 		while ((cap = _ti_find_extra(rtic, &rtic->extras, "use"))
 		!= NULL) {
 			if (*cap++ != 's') {
@@ -339,11 +416,19 @@ merge_use(int flags)
 break;
 			}
 			cap += sizeof(uint16_t);
-			if (strcmp(rtic->name, cap) == 0) {
+			if (strcmp(basename, cap) == 0) {
 dowarn("%s: uses itself", rtic->name);
 goto remove;
 			}
-			

CVS commit: src/usr.bin/tic

2020-03-28 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Mar 28 15:37:04 UTC 2020

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
tic: free the old buffer after promoting the record type


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.37 src/usr.bin/tic/tic.c:1.38
--- src/usr.bin/tic/tic.c:1.37	Sat Mar 28 15:22:27 2020
+++ src/usr.bin/tic/tic.c	Sat Mar 28 15:37:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.37 2020/03/28 15:22:27 roy Exp $ */
+/* $NetBSD: tic.c,v 1.38 2020/03/28 15:37:04 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.37 2020/03/28 15:22:27 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.38 2020/03/28 15:37:04 roy Exp $");
 
 #include 
 #include 
@@ -230,6 +230,8 @@ merge(TIC *rtic, TIC *utic, int flags)
 
 	/* Promote record type if needed. */
 	if (rtic->rtype < utic->rtype) {
+		char *obuf = rtic->nums.buf;
+
 		cap = rtic->nums.buf;
 		rtic->nums.buf = NULL;
 		rtic->nums.buflen = rtic->nums.bufpos = 0;
@@ -242,6 +244,7 @@ merge(TIC *rtic, TIC *utic, int flags)
 err(EXIT_FAILURE, "encode num");
 		}
 		rtic->rtype = utic->rtype;
+		free(obuf);
 	}
 
 	cap = utic->flags.buf;



CVS commit: src/usr.bin/tic

2020-03-28 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Mar 28 15:22:27 UTC 2020

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
tic: use EXIT_FAILURE rather than magic numbers


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.36 src/usr.bin/tic/tic.c:1.37
--- src/usr.bin/tic/tic.c:1.36	Sat Mar 28 15:20:30 2020
+++ src/usr.bin/tic/tic.c	Sat Mar 28 15:22:27 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.36 2020/03/28 15:20:30 roy Exp $ */
+/* $NetBSD: tic.c,v 1.37 2020/03/28 15:22:27 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.36 2020/03/28 15:20:30 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.37 2020/03/28 15:22:27 roy Exp $");
 
 #include 
 #include 
@@ -92,7 +92,7 @@ grow_tbuf(TBUF *tbuf, size_t len)
 
 	buf = _ti_grow_tbuf(tbuf, len);
 	if (buf == NULL)
-		err(1, "_ti_grow_tbuf");
+		err(EXIT_FAILURE, "_ti_grow_tbuf");
 	return buf;
 }
 
@@ -112,7 +112,7 @@ save_term(struct cdbw *db, TERM *term)
 		_ti_encode_32(&cap, term->base_term->id);
 		_ti_encode_count_str(&cap, term->name, slen);
 		if (cdbw_put(db, term->name, slen, buf, len))
-			err(1, "cdbw_put");
+			err(EXIT_FAILURE, "cdbw_put");
 		free(buf);
 		return 0;
 	}
@@ -122,9 +122,9 @@ save_term(struct cdbw *db, TERM *term)
 		return -1;
 
 	if (cdbw_put_data(db, buf, len, &term->id))
-		err(1, "cdbw_put_data");
+		err(EXIT_FAILURE, "cdbw_put_data");
 	if (cdbw_put_key(db, term->name, slen, term->id))
-		err(1, "cdbw_put_key");
+		err(EXIT_FAILURE, "cdbw_put_key");
 	free(buf);
 	return 0;
 }
@@ -239,7 +239,7 @@ merge(TIC *rtic, TIC *utic, int flags)
 			if (VALID_NUMERIC(num) &&
 			!_ti_encode_buf_id_num(&rtic->nums, ind, num,
 			_ti_numsize(utic)))
-err(1, "encode num");
+err(EXIT_FAILURE, "encode num");
 		}
 		rtic->rtype = utic->rtype;
 	}
@@ -252,7 +252,7 @@ merge(TIC *rtic, TIC *utic, int flags)
 		_ti_find_cap(rtic, &rtic->flags, 'f', ind) == NULL)
 		{
 			if (!_ti_encode_buf_id_flags(&rtic->flags, ind, flag))
-err(1, "encode flag");
+err(EXIT_FAILURE, "encode flag");
 		}
 	}
 
@@ -265,7 +265,7 @@ merge(TIC *rtic, TIC *utic, int flags)
 		{
 			if (!_ti_encode_buf_id_num(&rtic->nums, ind, num,
 			_ti_numsize(rtic)))
-err(1, "encode num");
+err(EXIT_FAILURE, "encode num");
 		}
 	}
 
@@ -278,7 +278,7 @@ merge(TIC *rtic, TIC *utic, int flags)
 		{
 			if (!_ti_encode_buf_id_count_str(&rtic->strs, ind, cap,
 			len))
-err(1, "encode str");
+err(EXIT_FAILURE, "encode str");
 		}
 		cap += len;
 	}
@@ -463,7 +463,7 @@ write_database(const char *dbname)
 
 	db = cdbw_open();
 	if (db == NULL)
-		err(1, "cdbw_open failed");
+		err(EXIT_FAILURE, "cdbw_open failed");
 	/* Save the terms */
 	STAILQ_FOREACH(term, &terms, next)
 		save_term(db, term);
@@ -471,15 +471,18 @@ write_database(const char *dbname)
 	easprintf(&tmp_dbname, "%s.XX", dbname);
 	fd = mkstemp(tmp_dbname);
 	if (fd == -1)
-		err(1, "creating temporary database %s failed", tmp_dbname);
+		err(EXIT_FAILURE,
+		"creating temporary database %s failed", tmp_dbname);
 	if (cdbw_output(db, fd, "NetBSD terminfo", cdbw_stable_seeder))
-		err(1, "writing temporary database %s failed", tmp_dbname);
+		err(EXIT_FAILURE,
+		"writing temporary database %s failed", tmp_dbname);
 	if (fchmod(fd, DEFFILEMODE))
-		err(1, "fchmod failed");
+		err(EXIT_FAILURE, "fchmod failed");
 	if (close(fd))
-		err(1, "writing temporary database %s failed", tmp_dbname);
+		err(EXIT_FAILURE,
+		"writing temporary database %s failed", tmp_dbname);
 	if (rename(tmp_dbname, dbname))
-		err(1, "renaming %s to %s failed", tmp_dbname, dbname);
+		err(EXIT_FAILURE, "renaming %s to %s failed", tmp_dbname, dbname);
 	free(tmp_dbname);
 	cdbw_close(db);
 }
@@ -533,7 +536,7 @@ main(int argc, char **argv)
 	source = argv[optind++];
 	f = fopen(source, "r");
 	if (f == NULL)
-		err(1, "fopen: %s", source);
+		err(EXIT_FAILURE, "fopen: %s", source);
 
 	hcreate(HASH_SIZE);
 



CVS commit: src/usr.bin/tic

2020-03-28 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Mar 28 15:20:30 UTC 2020

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.35 src/usr.bin/tic/tic.c:1.36
--- src/usr.bin/tic/tic.c:1.35	Sat Mar 28 15:19:56 2020
+++ src/usr.bin/tic/tic.c	Sat Mar 28 15:20:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.35 2020/03/28 15:19:56 roy Exp $ */
+/* $NetBSD: tic.c,v 1.36 2020/03/28 15:20:30 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.35 2020/03/28 15:19:56 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.36 2020/03/28 15:20:30 roy Exp $");
 
 #include 
 #include 
@@ -279,7 +279,6 @@ merge(TIC *rtic, TIC *utic, int flags)
 			if (!_ti_encode_buf_id_count_str(&rtic->strs, ind, cap,
 			len))
 err(1, "encode str");
-
 		}
 		cap += len;
 	}



CVS commit: src/usr.bin/tic

2020-03-28 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Mar 28 15:19:56 UTC 2020

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
tic: promote record type when merging newer into older


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.34 src/usr.bin/tic/tic.c:1.35
--- src/usr.bin/tic/tic.c:1.34	Fri Mar 27 17:42:36 2020
+++ src/usr.bin/tic/tic.c	Sat Mar 28 15:19:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.34 2020/03/27 17:42:36 christos Exp $ */
+/* $NetBSD: tic.c,v 1.35 2020/03/28 15:19:56 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.34 2020/03/27 17:42:36 christos Exp $");
+__RCSID("$NetBSD: tic.c,v 1.35 2020/03/28 15:19:56 roy Exp $");
 
 #include 
 #include 
@@ -228,6 +228,22 @@ merge(TIC *rtic, TIC *utic, int flags)
 	int num;
 	size_t n;
 
+	/* Promote record type if needed. */
+	if (rtic->rtype < utic->rtype) {
+		cap = rtic->nums.buf;
+		rtic->nums.buf = NULL;
+		rtic->nums.buflen = rtic->nums.bufpos = 0;
+		for (n = rtic->nums.entries; n > 0; n--) {
+			ind = _ti_decode_16(&cap);
+			num = _ti_decode_num(&cap, rtic->rtype);
+			if (VALID_NUMERIC(num) &&
+			!_ti_encode_buf_id_num(&rtic->nums, ind, num,
+			_ti_numsize(utic)))
+err(1, "encode num");
+		}
+		rtic->rtype = utic->rtype;
+	}
+
 	cap = utic->flags.buf;
 	for (n = utic->flags.entries; n > 0; n--) {
 		ind = _ti_decode_16(&cap);



CVS commit: src/usr.bin/tic

2020-03-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Mar 27 17:42:36 UTC 2020

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Use the new functions and add more error checking.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.33 src/usr.bin/tic/tic.c:1.34
--- src/usr.bin/tic/tic.c:1.33	Fri Mar 27 11:11:57 2020
+++ src/usr.bin/tic/tic.c	Fri Mar 27 13:42:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.33 2020/03/27 15:11:57 christos Exp $ */
+/* $NetBSD: tic.c,v 1.34 2020/03/27 17:42:36 christos Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.33 2020/03/27 15:11:57 christos Exp $");
+__RCSID("$NetBSD: tic.c,v 1.34 2020/03/27 17:42:36 christos Exp $");
 
 #include 
 #include 
@@ -104,12 +104,13 @@ save_term(struct cdbw *db, TERM *term)
 	size_t slen = strlen(term->name) + 1;
 
 	if (term->base_term != NULL) {
-		len = (ssize_t)slen + 7;
+		char *cap;
+		len = (ssize_t)(1 + sizeof(uint32_t) + sizeof(uint16_t) + slen);
 		buf = emalloc(len);
-		buf[0] = TERMINFO_ALIAS;
-		le32enc(buf + 1, term->base_term->id);
-		le16enc(buf + 5, slen);
-		memcpy(buf + 7, term->name, slen);
+		cap = (char *)buf;
+		*cap++ = TERMINFO_ALIAS;
+		_ti_encode_32(&cap, term->base_term->id);
+		_ti_encode_count_str(&cap, term->name, slen);
 		if (cdbw_put(db, term->name, slen, buf, len))
 			err(1, "cdbw_put");
 		free(buf);
@@ -229,63 +230,47 @@ merge(TIC *rtic, TIC *utic, int flags)
 
 	cap = utic->flags.buf;
 	for (n = utic->flags.entries; n > 0; n--) {
-		ind = le16dec(cap);
-		cap += sizeof(uint16_t);
+		ind = _ti_decode_16(&cap);
 		flag = *cap++;
 		if (VALID_BOOLEAN(flag) &&
 		_ti_find_cap(rtic, &rtic->flags, 'f', ind) == NULL)
 		{
-			_ti_grow_tbuf(&rtic->flags, sizeof(uint16_t) + 1);
-			le16enc(rtic->flags.buf + rtic->flags.bufpos, ind);
-			rtic->flags.bufpos += sizeof(uint16_t);
-			rtic->flags.buf[rtic->flags.bufpos++] = flag;
-			rtic->flags.entries++;
+			if (!_ti_encode_buf_id_flags(&rtic->flags, ind, flag))
+err(1, "encode flag");
 		}
 	}
 
 	cap = utic->nums.buf;
 	for (n = utic->nums.entries; n > 0; n--) {
-		ind = le16dec(cap);
-		cap += sizeof(uint16_t);
-		num = _ti_decode_num(utic->rtype, &cap);
+		ind = _ti_decode_16(&cap);
+		num = _ti_decode_num(&cap, utic->rtype);
 		if (VALID_NUMERIC(num) &&
 		_ti_find_cap(rtic, &rtic->nums, 'n', ind) == NULL)
 		{
-			grow_tbuf(&rtic->nums, sizeof(uint16_t) +
-			_ti_numsize(rtic));
-			le16enc(rtic->nums.buf + rtic->nums.bufpos, ind);
-			rtic->nums.bufpos += sizeof(uint16_t);
-			_ti_encode_num(rtic, &rtic->nums, num);
-			rtic->nums.entries++;
+			if (!_ti_encode_buf_id_num(&rtic->nums, ind, num,
+			_ti_numsize(rtic)))
+err(1, "encode num");
 		}
 	}
 
 	cap = utic->strs.buf;
 	for (n = utic->strs.entries; n > 0; n--) {
-		ind = le16dec(cap);
-		cap += sizeof(uint16_t);
-		len = le16dec(cap);
-		cap += sizeof(uint16_t);
+		ind = _ti_decode_16(&cap);
+		len = _ti_decode_16(&cap);
 		if (len > 0 &&
 		_ti_find_cap(rtic, &rtic->strs, 's', ind) == NULL)
 		{
-			grow_tbuf(&rtic->strs, (sizeof(uint16_t) * 2) + len);
-			le16enc(rtic->strs.buf + rtic->strs.bufpos, ind);
-			rtic->strs.bufpos += sizeof(uint16_t);
-			le16enc(rtic->strs.buf + rtic->strs.bufpos, len);
-			rtic->strs.bufpos += sizeof(uint16_t);
-			memcpy(rtic->strs.buf + rtic->strs.bufpos,
-			cap, len);
-			rtic->strs.bufpos += len;
-			rtic->strs.entries++;
+			if (!_ti_encode_buf_id_count_str(&rtic->strs, ind, cap,
+			len))
+err(1, "encode str");
+
 		}
 		cap += len;
 	}
 
 	cap = utic->extras.buf;
 	for (n = utic->extras.entries; n > 0; n--) {
-		num = le16dec(cap);
-		cap += sizeof(uint16_t);
+		num = _ti_decode_16(&cap);
 		code = cap;
 		cap += num;
 		type = *cap++;
@@ -298,13 +283,12 @@ merge(TIC *rtic, TIC *utic, int flags)
 continue;
 			break;
 		case 'n':
-			num = _ti_decode_num(utic->rtype, &cap);
+			num = _ti_decode_num(&cap, utic->rtype);
 			if (!VALID_NUMERIC(num))
 continue;
 			break;
 		case 's':
-			num = le16dec(cap);
-			cap += sizeof(uint16_t);
+			num = _ti_decode_16(&cap);
 			str = cap;
 			cap += num;
 			if (num == 0)
@@ -320,7 +304,7 @@ static size_t
 merge_use(int flags)
 {
 	size_t skipped, merged, memn;
-	char *cap, *scap;
+	const char *cap;
 	uint16_t num;
 	TIC *rtic, *utic;
 	TERM *term, *uterm;;
@@ -368,10 +352,11 @@ merge_use(int flags)
 dowarn("%s: use no longer exists - impossible",
 	rtic->name);
 			else {
-scap = cap - (4 + sizeof(uint16_t));
+char *scap = __UNCONST(
+cap - (4 + sizeof(uint16_t)));
 cap++;
-num = le16dec(cap);
-cap += sizeof(uint16_t) + num;
+num = _ti_decode_16(&cap);
+cap += num;
 memn = rtic->extra

CVS commit: src/usr.bin/tic

2017-10-02 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Oct  2 21:53:55 UTC 2017

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
unistd.h for close.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.30 src/usr.bin/tic/tic.c:1.31
--- src/usr.bin/tic/tic.c:1.30	Fri May  5 12:21:28 2017
+++ src/usr.bin/tic/tic.c	Mon Oct  2 21:53:55 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.30 2017/05/05 12:21:28 christos Exp $ */
+/* $NetBSD: tic.c,v 1.31 2017/10/02 21:53:55 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.30 2017/05/05 12:21:28 christos Exp $");
+__RCSID("$NetBSD: tic.c,v 1.31 2017/10/02 21:53:55 joerg Exp $");
 
 #include 
 #include 
@@ -56,6 +56,7 @@ __RCSID("$NetBSD: tic.c,v 1.30 2017/05/0
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define	HASH_SIZE	16384	/* 2012-06-01: 3600 entries */



CVS commit: src/usr.bin/tic

2017-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May  5 12:21:28 UTC 2017

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
fix the tools build. reported by Utkarsh Anand


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.29 src/usr.bin/tic/tic.c:1.30
--- src/usr.bin/tic/tic.c:1.29	Thu May  4 10:07:33 2017
+++ src/usr.bin/tic/tic.c	Fri May  5 08:21:28 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.29 2017/05/04 14:07:33 roy Exp $ */
+/* $NetBSD: tic.c,v 1.30 2017/05/05 12:21:28 christos Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.29 2017/05/04 14:07:33 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.30 2017/05/05 12:21:28 christos Exp $");
 
 #include 
 #include 
@@ -587,7 +587,13 @@ main(int argc, char **argv)
 		free(term->name);
 		free(term);
 	}
+#ifndef HAVE_NBTOOL_CONFIG_H
+	/*
+	 * hdestroy1 is not standard but we don't really care if we
+	 * leak in the tools version
+	 */
 	hdestroy1(free, NULL);
+#endif
 
 	return EXIT_SUCCESS;
 }



CVS commit: src/usr.bin/tic

2017-05-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu May  4 14:07:33 UTC 2017

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Remove __VALGRIND__ guard  just clean up.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.28 src/usr.bin/tic/tic.c:1.29
--- src/usr.bin/tic/tic.c:1.28	Thu May  4 13:53:36 2017
+++ src/usr.bin/tic/tic.c	Thu May  4 14:07:33 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.28 2017/05/04 13:53:36 roy Exp $ */
+/* $NetBSD: tic.c,v 1.29 2017/05/04 14:07:33 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.28 2017/05/04 13:53:36 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.29 2017/05/04 14:07:33 roy Exp $");
 
 #include 
 #include 
@@ -483,6 +483,7 @@ main(int argc, char **argv)
 	size_t buflen;
 	ssize_t len;
 	TBUF tbuf;
+	struct term *term;
 
 	cflag = sflag = 0;
 	ofile = NULL;
@@ -578,7 +579,6 @@ main(int argc, char **argv)
 		fprintf(stderr, "%zu entries and %zu aliases written to %s\n",
 		nterm, nalias, dbname);
 
-#ifdef __VALGRIND__
 	if (ofile == NULL)
 		free(dbname);
 	while ((term = STAILQ_FIRST(&terms)) != NULL) {
@@ -588,7 +588,6 @@ main(int argc, char **argv)
 		free(term);
 	}
 	hdestroy1(free, NULL);
-#endif
 
 	return EXIT_SUCCESS;
 }



CVS commit: src/usr.bin/tic

2017-05-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu May  4 13:53:36 UTC 2017

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Whitespace and formatting.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.27 src/usr.bin/tic/tic.c:1.28
--- src/usr.bin/tic/tic.c:1.27	Tue Jan 10 21:15:23 2017
+++ src/usr.bin/tic/tic.c	Thu May  4 13:53:36 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.27 2017/01/10 21:15:23 christos Exp $ */
+/* $NetBSD: tic.c,v 1.28 2017/05/04 13:53:36 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.27 2017/01/10 21:15:23 christos Exp $");
+__RCSID("$NetBSD: tic.c,v 1.28 2017/05/04 13:53:36 roy Exp $");
 
 #include 
 #include 
@@ -527,7 +527,7 @@ main(int argc, char **argv)
 	hcreate(HASH_SIZE);
 
 	buf = tbuf.buf = NULL;
-	buflen = tbuf.buflen = tbuf.bufpos = 0;	
+	buflen = tbuf.buflen = tbuf.bufpos = 0;
 	while ((len = getline(&buf, &buflen, f)) != -1) {
 		/* Skip comments */
 		if (*buf == '#')
@@ -539,9 +539,9 @@ main(int argc, char **argv)
 			continue;
 		}
 		/*
-		  If the first char is space not a space then we have a
-		  new entry, so process it.
-		*/
+		 * If the first char is space not a space then we have a
+		 * new entry, so process it.
+		 */
 		if (!isspace((unsigned char)*buf) && tbuf.bufpos != 0)
 			process_entry(&tbuf, flags);
 



CVS commit: src/usr.bin/tic

2017-02-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Feb 22 13:43:15 UTC 2017

Modified Files:
src/usr.bin/tic: tic.1

Log Message:
Fix spelling of "discovered"


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/tic/tic.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.12 src/usr.bin/tic/tic.1:1.13
--- src/usr.bin/tic/tic.1:1.12	Tue Mar 18 18:20:45 2014
+++ src/usr.bin/tic/tic.1	Wed Feb 22 13:43:15 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tic.1,v 1.12 2014/03/18 18:20:45 riastradh Exp $
+.\"	$NetBSD: tic.1,v 1.13 2017/02/22 13:43:15 abhinav Exp $
 .\"
 .\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -77,7 +77,7 @@ discovers a
 capability, the terminal description for
 .Va term
 is merged in.
-Capabilities do not overwrite previously disovered ones and capabilities
+Capabilities do not overwrite previously discovered ones and capabilities
 ending with @ are marked as absent so the terminal does not inherit the
 capability from
 .Sy use Ns d



CVS commit: src/usr.bin/tic

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 21:15:23 UTC 2017

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
need  for DEFFILEMODE etc.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.26 src/usr.bin/tic/tic.c:1.27
--- src/usr.bin/tic/tic.c:1.26	Thu Nov 24 12:12:23 2016
+++ src/usr.bin/tic/tic.c	Tue Jan 10 16:15:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.26 2016/11/24 17:12:23 christos Exp $ */
+/* $NetBSD: tic.c,v 1.27 2017/01/10 21:15:23 christos Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,10 +32,11 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.26 2016/11/24 17:12:23 christos Exp $");
+__RCSID("$NetBSD: tic.c,v 1.27 2017/01/10 21:15:23 christos Exp $");
 
 #include 
 #include 
+#include 
 
 #if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
 #include 



CVS commit: src/usr.bin/tic

2016-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 24 17:12:23 UTC 2016

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
fix leak.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.25 src/usr.bin/tic/tic.c:1.26
--- src/usr.bin/tic/tic.c:1.25	Wed Feb 24 07:01:44 2016
+++ src/usr.bin/tic/tic.c	Thu Nov 24 12:12:23 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.25 2016/02/24 12:01:44 roy Exp $ */
+/* $NetBSD: tic.c,v 1.26 2016/11/24 17:12:23 christos Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.25 2016/02/24 12:01:44 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.26 2016/11/24 17:12:23 christos Exp $");
 
 #include 
 #include 
@@ -110,6 +110,7 @@ save_term(struct cdbw *db, TERM *term)
 		memcpy(buf + 7, term->name, slen);
 		if (cdbw_put(db, term->name, slen, buf, len))
 			err(1, "cdbw_put");
+		free(buf);
 		return 0;
 	}
 



CVS commit: src/usr.bin/tic

2016-02-24 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Feb 24 12:01:44 UTC 2016

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
White space police.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.24 src/usr.bin/tic/tic.c:1.25
--- src/usr.bin/tic/tic.c:1.24	Sun Jul 20 20:20:16 2014
+++ src/usr.bin/tic/tic.c	Wed Feb 24 12:01:44 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.24 2014/07/20 20:20:16 christos Exp $ */
+/* $NetBSD: tic.c,v 1.25 2016/02/24 12:01:44 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.24 2014/07/20 20:20:16 christos Exp $");
+__RCSID("$NetBSD: tic.c,v 1.25 2016/02/24 12:01:44 roy Exp $");
 
 #include 
 #include 
@@ -164,7 +164,7 @@ process_entry(TBUF *buf, int flags)
 	char *p, *e, *alias;
 	TERM *term;
 	TIC *tic;
-	
+
 	if (buf->bufpos == 0)
 		return 0;
 	/* Terminate the string */
@@ -204,7 +204,7 @@ process_entry(TBUF *buf, int flags)
 		}
 		free(alias);
 	}
-	
+
 	return 0;
 }
 
@@ -419,7 +419,7 @@ print_dump(int argc, char **argv)
 printf("\t\t\"");
 col = 16;
 			}
-			
+
 			col += printf("\\%03o", (uint8_t)buf[j]);
 			if (col > 75) {
 printf("\"%s\n",
@@ -542,7 +542,7 @@ main(int argc, char **argv)
 		*/
 		if (!isspace((unsigned char)*buf) && tbuf.bufpos != 0)
 			process_entry(&tbuf, flags);
-		
+
 		/* Grow the buffer if needed */
 		grow_tbuf(&tbuf, len);
 		/* Append the string */
@@ -588,6 +588,5 @@ main(int argc, char **argv)
 	hdestroy1(free, NULL);
 #endif
 
-
 	return EXIT_SUCCESS;
 }



CVS commit: src/usr.bin/tic

2014-07-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jul 20 20:20:16 UTC 2014

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
use hdestroy1 now that hdestroy does not free the key.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.23 src/usr.bin/tic/tic.c:1.24
--- src/usr.bin/tic/tic.c:1.23	Sat Dec  8 18:29:28 2012
+++ src/usr.bin/tic/tic.c	Sun Jul 20 16:20:16 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.23 2012/12/08 23:29:28 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.24 2014/07/20 20:20:16 christos Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.23 2012/12/08 23:29:28 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.24 2014/07/20 20:20:16 christos Exp $");
 
 #include 
 #include 
@@ -585,7 +585,7 @@ main(int argc, char **argv)
 		free(term->name);
 		free(term);
 	}
-	hdestroy();
+	hdestroy1(free, NULL);
 #endif
 
 



CVS commit: src/usr.bin/tic

2012-12-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Dec  8 23:29:28 UTC 2012

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Revert, there is a more fundamental issue with util.h.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.22 src/usr.bin/tic/tic.c:1.23
--- src/usr.bin/tic/tic.c:1.22	Sat Dec  8 21:04:27 2012
+++ src/usr.bin/tic/tic.c	Sat Dec  8 23:29:28 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.22 2012/12/08 21:04:27 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.23 2012/12/08 23:29:28 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.22 2012/12/08 21:04:27 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.23 2012/12/08 23:29:28 joerg Exp $");
 
 #include 
 #include 
@@ -40,9 +40,6 @@ __RCSID("$NetBSD: tic.c,v 1.22 2012/12/0
 #if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
 #include 
 #endif
-#if !HAVE_NBTOOL_CONFIG_H
-#include 
-#endif
 
 #include 
 #include 
@@ -58,6 +55,7 @@ __RCSID("$NetBSD: tic.c,v 1.22 2012/12/0
 #include 
 #include 
 #include 
+#include 
 
 #define	HASH_SIZE	16384	/* 2012-06-01: 3600 entries */
 



CVS commit: src/usr.bin/tic

2012-12-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Dec  8 21:04:27 UTC 2012

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Use util.h only in the native case.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.21 src/usr.bin/tic/tic.c:1.22
--- src/usr.bin/tic/tic.c:1.21	Thu Nov 29 23:01:16 2012
+++ src/usr.bin/tic/tic.c	Sat Dec  8 21:04:27 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.21 2012/11/29 23:01:16 mbalmer Exp $ */
+/* $NetBSD: tic.c,v 1.22 2012/12/08 21:04:27 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.21 2012/11/29 23:01:16 mbalmer Exp $");
+__RCSID("$NetBSD: tic.c,v 1.22 2012/12/08 21:04:27 joerg Exp $");
 
 #include 
 #include 
@@ -40,6 +40,9 @@ __RCSID("$NetBSD: tic.c,v 1.21 2012/11/2
 #if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
 #include 
 #endif
+#if !HAVE_NBTOOL_CONFIG_H
+#include 
+#endif
 
 #include 
 #include 
@@ -55,7 +58,6 @@ __RCSID("$NetBSD: tic.c,v 1.21 2012/11/2
 #include 
 #include 
 #include 
-#include 
 
 #define	HASH_SIZE	16384	/* 2012-06-01: 3600 entries */
 



CVS commit: src/usr.bin/tic

2012-11-29 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Thu Nov 29 23:01:16 UTC 2012

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Remove an obsolete (and incomprehensible) comment.  Discussed with and ok
Roy Marples, Joerg Sonnenberger.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.20 src/usr.bin/tic/tic.c:1.21
--- src/usr.bin/tic/tic.c:1.20	Sun Jun  3 23:19:11 2012
+++ src/usr.bin/tic/tic.c	Thu Nov 29 23:01:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.20 2012/06/03 23:19:11 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.21 2012/11/29 23:01:16 mbalmer Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.20 2012/06/03 23:19:11 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.21 2012/11/29 23:01:16 mbalmer Exp $");
 
 #include 
 #include 
@@ -59,9 +59,6 @@ __RCSID("$NetBSD: tic.c,v 1.20 2012/06/0
 
 #define	HASH_SIZE	16384	/* 2012-06-01: 3600 entries */
 
-/* We store the full list of terminals we have instead of iterating
-   through the database as the sequential iterator doesn't work
-   the the data size stored changes N amount which ours will. */
 typedef struct term {
 	STAILQ_ENTRY(term) next;
 	char *name;



CVS commit: src/usr.bin/tic

2012-05-31 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu May 31 21:01:06 UTC 2012

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Maintain nalias and nterm on the fly.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.17 src/usr.bin/tic/tic.c:1.18
--- src/usr.bin/tic/tic.c:1.17	Thu May 31 20:40:05 2012
+++ src/usr.bin/tic/tic.c	Thu May 31 21:01:06 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.17 2012/05/31 20:40:05 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.18 2012/05/31 21:01:06 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.17 2012/05/31 20:40:05 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.18 2012/05/31 21:01:06 joerg Exp $");
 
 #include 
 #include 
@@ -73,6 +73,7 @@ static SLIST_HEAD(, term) terms = SLIST_
 static int error_exit;
 static int Sflag;
 static char *dbname;
+static size_t nterm, nalias;
 
 static void
 do_unlink(void)
@@ -149,6 +150,12 @@ store_term(const char *name, char type)
 	elem.key = estrdup(name);
 	elem.data = term;
 	hsearch(elem, ENTER);
+
+	if (type == 'a')
+		nalias++;
+	else
+		nterm++;
+
 	return term;
 }
 
@@ -443,7 +450,7 @@ main(int argc, char **argv)
 	char *source, *p, *buf, *ofile;
 	FILE *f;
 	DBM *db;
-	size_t buflen, nterm, nalias;
+	size_t buflen;
 	ssize_t len;
 	TBUF tbuf;
 	TERM *term;
@@ -546,17 +553,11 @@ main(int argc, char **argv)
 
 	if (cflag)
 		return error_exit;
-	
+
 	/* Save the terms */
-	nterm = nalias = 0;
-	SLIST_FOREACH(term, &terms, next) {
+	SLIST_FOREACH(term, &terms, next)
 		save_term(db, term);
-		if (term->type == 'a')
-			nalias++;
-		else
-			nterm++;
-	}
-	
+
 	/* done! */
 	dbm_close(db);
 



CVS commit: src/usr.bin/tic

2012-05-31 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu May 31 20:40:05 UTC 2012

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
One more strdup -> estrdup.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.16 src/usr.bin/tic/tic.c:1.17
--- src/usr.bin/tic/tic.c:1.16	Thu May 31 20:38:19 2012
+++ src/usr.bin/tic/tic.c	Thu May 31 20:40:05 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.16 2012/05/31 20:38:19 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.17 2012/05/31 20:40:05 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.16 2012/05/31 20:38:19 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.17 2012/05/31 20:40:05 joerg Exp $");
 
 #include 
 #include 
@@ -183,7 +183,7 @@ process_entry(TBUF *buf, int flags)
 
 	/* Create aliased terms */
 	if (tic->alias != NULL) {
-		alias = p = strdup(tic->alias);
+		alias = p = estrdup(tic->alias);
 		while (p != NULL && *p != '\0') {
 			e = strchr(p, '|');
 			if (e != NULL)



CVS commit: src/usr.bin/tic

2012-05-31 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu May 31 20:38:19 UTC 2012

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Use e* from util.h.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.15 src/usr.bin/tic/tic.c:1.16
--- src/usr.bin/tic/tic.c:1.15	Thu May 31 20:10:06 2012
+++ src/usr.bin/tic/tic.c	Thu May 31 20:38:19 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.15 2012/05/31 20:10:06 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.16 2012/05/31 20:38:19 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.15 2012/05/31 20:10:06 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.16 2012/05/31 20:38:19 joerg Exp $");
 
 #include 
 #include 
@@ -142,13 +142,9 @@ store_term(const char *name, char type)
 	TERM *term;
 	ENTRY elem;
 
-	term = calloc(1, sizeof(*term));
-	if (term == NULL)
-		errx(1, "malloc");
-	term->name = strdup(name);
+	term = ecalloc(1, sizeof(*term));
+	term->name = estrdup(name);
 	term->type = type;
-	if (term->name == NULL)
-		errx(1, "malloc");
 	SLIST_INSERT_HEAD(&terms, term, next);
 	elem.key = estrdup(name);
 	elem.data = term;
@@ -197,12 +193,8 @@ process_entry(TBUF *buf, int flags)
 " term %s", tic->name, p);
 			} else {
 term = store_term(p, 'a');
-term->tic = calloc(sizeof(*term->tic), 1);
-if (term->tic == NULL)
-	err(1, "malloc");
-term->tic->name = strdup(tic->name);
-if (term->tic->name == NULL)
-	err(1, "malloc");
+term->tic = ecalloc(sizeof(*term->tic), 1);
+term->tic->name = estrdup(tic->name);
 			}
 			p = e;
 		}
@@ -499,9 +491,7 @@ main(int argc, char **argv)
 		if (ofile == NULL)
 			ofile = source;
 		len = strlen(ofile) + 9;
-		dbname = malloc(len + 4); /* For adding .db after open */
-		if (dbname == NULL)
-			err(1, "malloc");
+		dbname = emalloc(len + 4); /* For adding .db after open */
 		snprintf(dbname, len, "%s.tmp", ofile);
 		db = dbm_open(dbname, O_CREAT | O_RDWR | O_TRUNC, DEFFILEMODE);
 		if (db == NULL)
@@ -571,11 +561,7 @@ main(int argc, char **argv)
 	dbm_close(db);
 
 	/* Rename the tmp db to the real one now */
-	len = strlen(ofile) + 4;
-	p = malloc(len);
-	if (p == NULL)
-		err(1, "malloc");
-	snprintf(p, len, "%s.db", ofile);
+	easprintf(&p, "%s.db", ofile);
 	if (rename(dbname, p) == -1)
 		err(1, "rename");
 	free(dbname);
@@ -584,6 +570,7 @@ main(int argc, char **argv)
 	if (sflag != 0)
 		fprintf(stderr, "%zu entries and %zu aliases written to %s\n",
 		nterm, nalias, p);
+	free(p);
 
 	hdestroy();
 



CVS commit: src/usr.bin/tic

2012-05-31 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu May 31 20:10:06 UTC 2012

Modified Files:
src/usr.bin/tic: Makefile tic.c

Log Message:
Replace linear lookup with hash table, reducing runtime by 60%.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/tic/Makefile
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/Makefile
diff -u src/usr.bin/tic/Makefile:1.1 src/usr.bin/tic/Makefile:1.2
--- src/usr.bin/tic/Makefile:1.1	Wed Feb  3 15:16:32 2010
+++ src/usr.bin/tic/Makefile	Thu May 31 20:10:06 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2010/02/03 15:16:32 roy Exp $
+#	$NetBSD: Makefile,v 1.2 2012/05/31 20:10:06 joerg Exp $
 
 PROG=		tic
 WARNS=		4
@@ -6,8 +6,8 @@ WARNS=		4
 CPPFLAGS+=	-I${.CURDIR}/../../lib/libterminfo
 
 .ifndef HOSTPROG
-LDADD+=		-lterminfo
-DPADD+=		${LIBTERMINFO}
+LDADD+=		-lterminfo -lutil
+DPADD+=		${LIBTERMINFO} ${LIBUTIL}
 .endif
 
 .include 

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.14 src/usr.bin/tic/tic.c:1.15
--- src/usr.bin/tic/tic.c:1.14	Thu May 31 19:56:32 2012
+++ src/usr.bin/tic/tic.c	Thu May 31 20:10:06 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.14 2012/05/31 19:56:32 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.15 2012/05/31 20:10:06 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.14 2012/05/31 19:56:32 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.15 2012/05/31 20:10:06 joerg Exp $");
 
 #include 
 #include 
@@ -48,12 +48,16 @@ __RCSID("$NetBSD: tic.c,v 1.14 2012/05/3
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+
+#define	HASH_SIZE	16384	/* 2012-06-01: 3600 entries */
 
 /* We store the full list of terminals we have instead of iterating
through the database as the sequential iterator doesn't work
@@ -124,19 +128,19 @@ save_term(DBM *db, TERM *term)
 static TERM *
 find_term(const char *name)
 {
-	TERM *term;
+	ENTRY elem, *elemp;
 
-	SLIST_FOREACH(term, &terms, next) {
-		if (strcmp(term->name, name) == 0)
-			return term;
-	}
-	return NULL;
+	elem.key = __UNCONST(name);
+	elem.data = NULL;
+	elemp = hsearch(elem, FIND);
+	return elemp ? (TERM *)elemp->data : NULL;
 }
 
 static TERM *
 store_term(const char *name, char type)
 {
 	TERM *term;
+	ENTRY elem;
 
 	term = calloc(1, sizeof(*term));
 	if (term == NULL)
@@ -146,6 +150,9 @@ store_term(const char *name, char type)
 	if (term->name == NULL)
 		errx(1, "malloc");
 	SLIST_INSERT_HEAD(&terms, term, next);
+	elem.key = estrdup(name);
+	elem.data = term;
+	hsearch(elem, ENTER);
 	return term;
 }
 
@@ -508,6 +515,8 @@ main(int argc, char **argv)
 	} else
 		db = NULL; /* satisfy gcc warning */
 
+	hcreate(HASH_SIZE);
+
 	buf = NULL;
 	buflen = tbuf.buflen = tbuf.bufpos = 0;	
 	while ((len = getline(&buf, &buflen, f)) != -1) {
@@ -576,5 +585,7 @@ main(int argc, char **argv)
 		fprintf(stderr, "%zu entries and %zu aliases written to %s\n",
 		nterm, nalias, p);
 
+	hdestroy();
+
 	return EXIT_SUCCESS;
 }



CVS commit: src/usr.bin/tic

2012-05-31 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu May 31 19:56:32 UTC 2012

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Use queue(3)


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.13 src/usr.bin/tic/tic.c:1.14
--- src/usr.bin/tic/tic.c:1.13	Thu May 31 19:00:41 2012
+++ src/usr.bin/tic/tic.c	Thu May 31 19:56:32 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.13 2012/05/31 19:00:41 joerg Exp $ */
+/* $NetBSD: tic.c,v 1.14 2012/05/31 19:56:32 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,9 +32,10 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.13 2012/05/31 19:00:41 joerg Exp $");
+__RCSID("$NetBSD: tic.c,v 1.14 2012/05/31 19:56:32 joerg Exp $");
 
 #include 
+#include 
 
 #if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
 #include 
@@ -58,12 +59,12 @@ __RCSID("$NetBSD: tic.c,v 1.13 2012/05/3
through the database as the sequential iterator doesn't work
the the data size stored changes N amount which ours will. */
 typedef struct term {
-	struct term *next;
+	SLIST_ENTRY(term) next;
 	char *name;
 	char type;
 	TIC *tic;
 } TERM;
-static TERM *terms;
+static SLIST_HEAD(, term) terms = SLIST_HEAD_INITIALIZER(terms);
 
 static int error_exit;
 static int Sflag;
@@ -124,10 +125,11 @@ static TERM *
 find_term(const char *name)
 {
 	TERM *term;
-	
-	for (term = terms; term != NULL; term = term->next)
+
+	SLIST_FOREACH(term, &terms, next) {
 		if (strcmp(term->name, name) == 0)
 			return term;
+	}
 	return NULL;
 }
 
@@ -143,8 +145,7 @@ store_term(const char *name, char type)
 	term->type = type;
 	if (term->name == NULL)
 		errx(1, "malloc");
-	term->next = terms;
-	terms = term;
+	SLIST_INSERT_HEAD(&terms, term, next);
 	return term;
 }
 
@@ -311,7 +312,7 @@ merge_use(int flags)
 	TERM *term, *uterm;;
 
 	skipped = merged = 0;
-	for (term = terms; term != NULL; term = term->next) {
+	SLIST_FOREACH(term, &terms, next) {
 		if (term->type == 'a')
 			continue;
 		rtic = term->tic;
@@ -549,7 +550,7 @@ main(int argc, char **argv)
 	
 	/* Save the terms */
 	nterm = nalias = 0;
-	for (term = terms; term != NULL; term = term->next) {
+	SLIST_FOREACH(term, &terms, next) {
 		save_term(db, term);
 		if (term->type == 'a')
 			nalias++;



CVS commit: src/usr.bin/tic

2012-05-31 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu May 31 19:00:41 UTC 2012

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Prefer __printflike.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.12 src/usr.bin/tic/tic.c:1.13
--- src/usr.bin/tic/tic.c:1.12	Wed Nov  9 07:40:27 2011
+++ src/usr.bin/tic/tic.c	Thu May 31 19:00:41 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.12 2011/11/09 07:40:27 roy Exp $ */
+/* $NetBSD: tic.c,v 1.13 2012/05/31 19:00:41 joerg Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.12 2011/11/09 07:40:27 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.13 2012/05/31 19:00:41 joerg Exp $");
 
 #include 
 
@@ -77,7 +77,7 @@ do_unlink(void)
 		unlink(dbname);
 }
 
-static void __attribute__((__format__(__printf__, 1, 2)))
+static void __printflike(1, 2)
 dowarn(const char *fmt, ...)
 {
 	va_list va;



CVS commit: src/usr.bin/tic

2011-11-08 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Nov  9 07:40:28 UTC 2011

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Replace fgetln(3) with the more standard getline(3)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.11 src/usr.bin/tic/tic.c:1.12
--- src/usr.bin/tic/tic.c:1.11	Thu Nov  3 10:12:57 2011
+++ src/usr.bin/tic/tic.c	Wed Nov  9 07:40:27 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.11 2011/11/03 10:12:57 roy Exp $ */
+/* $NetBSD: tic.c,v 1.12 2011/11/09 07:40:27 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.11 2011/11/03 10:12:57 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.12 2011/11/09 07:40:27 roy Exp $");
 
 #include 
 
@@ -443,7 +443,8 @@ main(int argc, char **argv)
 	char *source, *p, *buf, *ofile;
 	FILE *f;
 	DBM *db;
-	size_t len, buflen, nterm, nalias;
+	size_t buflen, nterm, nalias;
+	ssize_t len;
 	TBUF tbuf;
 	TERM *term;
 
@@ -506,12 +507,13 @@ main(int argc, char **argv)
 	} else
 		db = NULL; /* satisfy gcc warning */
 
-	tbuf.buflen = tbuf.bufpos = 0;	
-	while ((buf = fgetln(f, &buflen)) != NULL) {
+	buf = NULL;
+	buflen = tbuf.buflen = tbuf.bufpos = 0;	
+	while ((len = getline(&buf, &buflen, f)) != -1) {
 		/* Skip comments */
 		if (*buf == '#')
 			continue;
-		if (buf[buflen - 1] != '\n') {
+		if (buf[len - 1] != '\n') {
 			process_entry(&tbuf, flags);
 			dowarn("last line is not a comment"
 			" and does not end with a newline");
@@ -525,10 +527,10 @@ main(int argc, char **argv)
 			process_entry(&tbuf, flags);
 		
 		/* Grow the buffer if needed */
-		grow_tbuf(&tbuf, buflen);
+		grow_tbuf(&tbuf, len);
 		/* Append the string */
-		memcpy(tbuf.buf + tbuf.bufpos, buf, buflen);
-		tbuf.bufpos += buflen;
+		memcpy(tbuf.buf + tbuf.bufpos, buf, len);
+		tbuf.bufpos += len;
 	}
 	/* Process the last entry if not done already */
 	process_entry(&tbuf, flags);



CVS commit: src/usr.bin/tic

2011-11-03 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Nov  3 10:12:58 UTC 2011

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Use memmove as we are effectively moving memory from left to right so
that the use=foo capability is removed when merging foo.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.10 src/usr.bin/tic/tic.c:1.11
--- src/usr.bin/tic/tic.c:1.10	Mon Feb 22 23:05:39 2010
+++ src/usr.bin/tic/tic.c	Thu Nov  3 10:12:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.10 2010/02/22 23:05:39 roy Exp $ */
+/* $NetBSD: tic.c,v 1.11 2011/11/03 10:12:57 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.10 2010/02/22 23:05:39 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.11 2011/11/03 10:12:57 roy Exp $");
 
 #include 
 
@@ -357,7 +357,7 @@ merge_use(int flags)
 cap += sizeof(uint16_t) + num;
 memn = rtic->extras.bufpos -
 (cap - rtic->extras.buf);
-memcpy(scap, cap, memn);
+memmove(scap, cap, memn);
 rtic->extras.bufpos -= cap - scap;
 cap = scap;
 rtic->extras.entries--;



CVS commit: src/usr.bin/tic

2011-11-02 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Nov  2 19:21:49 UTC 2011

Modified Files:
src/usr.bin/tic: tic.1

Log Message:
Fix a couple of mis-spellings of "descriptions"


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/tic/tic.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.8 src/usr.bin/tic/tic.1:1.9
--- src/usr.bin/tic/tic.1:1.8	Thu Feb 11 13:44:14 2010
+++ src/usr.bin/tic/tic.1	Wed Nov  2 19:21:49 2011
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tic.1,v 1.8 2010/02/11 13:44:14 wiz Exp $
+.\"	$NetBSD: tic.1,v 1.9 2011/11/02 19:21:49 pgoyette Exp $
 .\"
 .\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -62,9 +62,9 @@ instead of
 For
 .Ar term1 , term2 , ...
 output a C structure containing name, compiled description, and compiled size.
-This can be used to embed terminal descriptons into a program.
+This can be used to embed terminal descriptions into a program.
 .It Fl s
-Display the number of terminal descritions written to the database.
+Display the number of terminal descriptions written to the database.
 .It Fl x
 Include non standard capabilities defined in the
 .Ar source .



CVS commit: src/usr.bin/tic

2010-02-19 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Feb 20 06:20:46 UTC 2010

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
One more time - do this correctly.

Thanks, joerg.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.8 src/usr.bin/tic/tic.c:1.9
--- src/usr.bin/tic/tic.c:1.8	Sat Feb 20 06:15:06 2010
+++ src/usr.bin/tic/tic.c	Sat Feb 20 06:20:46 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.8 2010/02/20 06:15:06 pgoyette Exp $ */
+/* $NetBSD: tic.c,v 1.9 2010/02/20 06:20:46 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,11 +32,11 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.8 2010/02/20 06:15:06 pgoyette Exp $");
+__RCSID("$NetBSD: tic.c,v 1.9 2010/02/20 06:20:46 pgoyette Exp $");
 
 #include 
 
-#ifdef HAVE_SYS_ENDIAN_H
+#if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
 #include 
 #endif
 



CVS commit: src/usr.bin/tic

2010-02-19 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Feb 20 06:15:06 UTC 2010

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Wrap the include of sys/endian.h in #ifdef HAVE_SYS_ENDIAN_H to avoid
build issues on systems that don't have a sys/endian.h

Pointed out by joerg@


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.7 src/usr.bin/tic/tic.c:1.8
--- src/usr.bin/tic/tic.c:1.7	Sat Feb 20 06:08:01 2010
+++ src/usr.bin/tic/tic.c	Sat Feb 20 06:15:06 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.7 2010/02/20 06:08:01 pgoyette Exp $ */
+/* $NetBSD: tic.c,v 1.8 2010/02/20 06:15:06 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,10 +32,13 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.7 2010/02/20 06:08:01 pgoyette Exp $");
+__RCSID("$NetBSD: tic.c,v 1.8 2010/02/20 06:15:06 pgoyette Exp $");
 
 #include 
+
+#ifdef HAVE_SYS_ENDIAN_H
 #include 
+#endif
 
 #include 
 #include 



CVS commit: src/usr.bin/tic

2010-02-19 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Feb 20 06:08:01 UTC 2010

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
Since tic is a host tool, we need to include host system header to get
definitions of le16dec() and le16enc().

Solves PR bin/42747 from Henning Petersen


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.6 src/usr.bin/tic/tic.c:1.7
--- src/usr.bin/tic/tic.c:1.6	Thu Feb 11 13:09:57 2010
+++ src/usr.bin/tic/tic.c	Sat Feb 20 06:08:01 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.6 2010/02/11 13:09:57 roy Exp $ */
+/* $NetBSD: tic.c,v 1.7 2010/02/20 06:08:01 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,9 +32,10 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.6 2010/02/11 13:09:57 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.7 2010/02/20 06:08:01 pgoyette Exp $");
 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/usr.bin/tic

2010-02-11 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Feb 11 13:44:14 UTC 2010

Modified Files:
src/usr.bin/tic: tic.1

Log Message:
Oxford serial comma.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/tic/tic.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.7 src/usr.bin/tic/tic.1:1.8
--- src/usr.bin/tic/tic.1:1.7	Thu Feb 11 13:09:57 2010
+++ src/usr.bin/tic/tic.1	Thu Feb 11 13:44:14 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tic.1,v 1.7 2010/02/11 13:09:57 roy Exp $
+.\"	$NetBSD: tic.1,v 1.8 2010/02/11 13:44:14 wiz Exp $
 .\"
 .\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -61,7 +61,7 @@
 .It Fl S
 For
 .Ar term1 , term2 , ...
-output a C structure containing name, compiled description and compiled size.
+output a C structure containing name, compiled description, and compiled size.
 This can be used to embed terminal descriptons into a program.
 .It Fl s
 Display the number of terminal descritions written to the database.



CVS commit: src/usr.bin/tic

2010-02-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Feb 11 13:09:57 UTC 2010

Modified Files:
src/usr.bin/tic: tic.1 tic.c

Log Message:
Change -S to output C structures to make life easier.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/tic/tic.1
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.6 src/usr.bin/tic/tic.1:1.7
--- src/usr.bin/tic/tic.1:1.6	Thu Feb 11 07:00:46 2010
+++ src/usr.bin/tic/tic.1	Thu Feb 11 13:09:57 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tic.1,v 1.6 2010/02/11 07:00:46 wiz Exp $
+.\"	$NetBSD: tic.1,v 1.7 2010/02/11 13:09:57 roy Exp $
 .\"
 .\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 10, 2010
+.Dd February 11, 2010
 .Dt TIC 1
 .Os
 .Sh NAME
@@ -61,8 +61,8 @@
 .It Fl S
 For
 .Ar term1 , term2 , ...
-output the terminal name followed by the compiled
-description as strings.
+output a C structure containing name, compiled description and compiled size.
+This can be used to embed terminal descriptons into a program.
 .It Fl s
 Display the number of terminal descritions written to the database.
 .It Fl x

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.5 src/usr.bin/tic/tic.c:1.6
--- src/usr.bin/tic/tic.c:1.5	Thu Feb 11 00:24:46 2010
+++ src/usr.bin/tic/tic.c	Thu Feb 11 13:09:57 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.5 2010/02/11 00:24:46 roy Exp $ */
+/* $NetBSD: tic.c,v 1.6 2010/02/11 13:09:57 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.5 2010/02/11 00:24:46 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.6 2010/02/11 13:09:57 roy Exp $");
 
 #include 
 
@@ -81,7 +81,7 @@
 static TERM *terms;
 
 static int error_exit;
-static int aflag, xflag;
+static int Sflag, aflag, xflag;
 static char *dbname;
 
 static TBUF scratch;
@@ -198,7 +198,7 @@
 	if (strcmp(id, "use") != 0) {
 		if (find_extra(&tic->extras, id) != NULL)
 			return 0;
-		if (xflag == 0) {
+		if (!xflag) {
 			if (wrn != 0)
 dowarn("%s: %s: unknown capability",
 tic->name, id);
@@ -247,11 +247,11 @@
 	scratch.bufpos = 0;
 	tic = &term->tic;
 	len = strlen(tic->name) + 1;
-	if (tic->alias == NULL)
+	if (tic->alias == NULL || Sflag)
 		alen = 0;
 	else
 		alen = strlen(tic->alias) + 1;
-	if (tic->desc == NULL)
+	if (tic->desc == NULL || Sflag)
 		dlen = 0;
 	else
 		dlen = strlen(tic->desc) + 1;
@@ -276,13 +276,13 @@
 	if (term->type != 'a') {
 		le16enc(cap, alen);
 		cap += sizeof(uint16_t);
-		if (tic->alias != NULL) {
+		if (tic->alias != NULL && !Sflag) {
 			memcpy(cap, tic->alias, alen);
 			cap += alen;
 		}
 		le16enc(cap, dlen);
 		cap += sizeof(uint16_t);
-		if (tic->desc != NULL) {
+		if (tic->desc != NULL && !Sflag) {
 			memcpy(cap, tic->desc, dlen);
 			cap += dlen;
 		}
@@ -563,12 +563,12 @@
 		*cap++ = '\0';
 
 		/* Skip commented caps */
-		if (aflag == 0 && capstart[0] == '.')
+		if (!aflag && capstart[0] == '.')
 			continue;
 
 		/* Obsolete entries */
 		if (capstart[0] == 'O' && capstart[1] == 'T') {
-			if (xflag == 0)
+			if (!xflag)
 continue;
 			capstart += 2;
 		}
@@ -891,8 +891,15 @@
 	int i, n;
 	size_t j, col;
 
-	n = 0;
+	printf("struct compiled_term {\n");
+	printf("\tconst char *name;\n");
+	printf("\tconst char *cap;\n");
+	printf("\tsize_t caplen;\n");
+	printf("};\n\n");
+
+	printf("const struct compiled_term compiled_terms[] = {\n");
 
+	n = 0;
 	for (i = 0; i < argc; i++) {
 		term = find_term(argv[i]);
 		if (term == NULL) {
@@ -907,12 +914,13 @@
 		if (buf == NULL)
 			continue;
 
-		printf("\t\"%s\",\n", argv[i]);
+		printf("\t{\n");
+		printf("\t\t\"%s\",\n", argv[i]);
 		n++;
 		for (j = 0, col = 0; j < buf->bufpos; j++) {
 			if (col == 0) {
-printf("\t\"");
-col = 8;
+printf("\t\t\"");
+col = 16;
 			}
 			
 			col += printf("\\%03o", (uint8_t)buf->buf[j]);
@@ -923,8 +931,14 @@
 			}
 		}
 		if (col != 0)
-		printf("\",\n");
+			printf("\",\n");
+		printf("\t\t%zu\n", buf->bufpos);
+		printf("\t}");
+		if (i + 1 < argc)
+			printf(",");
+		printf("\n");
 	}
+	printf("};\n");
 
 	return n;
 }
@@ -932,7 +946,7 @@
 int
 main(int argc, char **argv)
 {
-	int ch, Sflag, cflag, sflag;
+	int ch, cflag, sflag;
 	char *source, *p, *buf, *ofile;
 	FILE *f;
 	DBM *db;
@@ -964,7 +978,7 @@
 		break;
 	case '?': /* FALLTHROUGH */
 	default:
-		fprintf(stderr, "usage: %s [-Sacsx] [-o file] source\n",
+		fprintf(stderr, "usage: %s [-acSsx] [-o file] source\n",
 			getprogname());
 		return EXIT_FAILURE;
 	}
@@ -975,7 +989,7 @@
 	f = fopen(source, "r");
 	if (f == NULL)
 		err(1, "fopen: %s", source);
-	if (cflag == 0 

CVS commit: src/usr.bin/tic

2010-02-10 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Feb 11 07:00:46 UTC 2010

Modified Files:
src/usr.bin/tic: tic.1

Log Message:
Sort options (standard order is 0-9AaBbCc...).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/tic/tic.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.5 src/usr.bin/tic/tic.1:1.6
--- src/usr.bin/tic/tic.1:1.5	Thu Feb 11 00:24:46 2010
+++ src/usr.bin/tic/tic.1	Thu Feb 11 07:00:46 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tic.1,v 1.5 2010/02/11 00:24:46 roy Exp $
+.\"	$NetBSD: tic.1,v 1.6 2010/02/11 07:00:46 wiz Exp $
 .\"
 .\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -35,7 +35,7 @@
 .Nd terminfo compiler
 .Sh SYNOPSIS
 .Nm tic
-.Op Fl Sacsx
+.Op Fl acSsx
 .Op Fl o Ar file
 .Ar source
 .Op Ar term1 term2 ...
@@ -49,11 +49,6 @@
 .Pp
 The following options are available:
 .Bl -tag -width Fl
-.It Fl S
-For
-.Ar term1 , term2 , ...
-output the terminal name followed by the compiled
-description as strings.
 .It Fl a
 Do not discard commented out capabilities.
 .It Fl c
@@ -63,6 +58,11 @@
 .Ar file Ns .db
 instead of
 .Ar source Ns .db .
+.It Fl S
+For
+.Ar term1 , term2 , ...
+output the terminal name followed by the compiled
+description as strings.
 .It Fl s
 Display the number of terminal descritions written to the database.
 .It Fl x



CVS commit: src/usr.bin/tic

2010-02-10 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Feb 11 00:24:46 UTC 2010

Modified Files:
src/usr.bin/tic: tic.1 tic.c

Log Message:
tic -S now outputs the specified terminal names and compiled descriptions
as C strings so we can embed them into libterminfo.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/tic/tic.1 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.4 src/usr.bin/tic/tic.1:1.5
--- src/usr.bin/tic/tic.1:1.4	Fri Feb  5 16:54:11 2010
+++ src/usr.bin/tic/tic.1	Thu Feb 11 00:24:46 2010
@@ -1,6 +1,6 @@
-.\"	$NetBSD: tic.1,v 1.4 2010/02/05 16:54:11 roy Exp $
+.\"	$NetBSD: tic.1,v 1.5 2010/02/11 00:24:46 roy Exp $
 .\"
-.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
+.\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
 .\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 5, 2010
+.Dd February 10, 2010
 .Dt TIC 1
 .Os
 .Sh NAME
@@ -35,9 +35,10 @@
 .Nd terminfo compiler
 .Sh SYNOPSIS
 .Nm tic
-.Op Fl acsx
+.Op Fl Sacsx
 .Op Fl o Ar file
 .Ar source
+.Op Ar term1 term2 ...
 .Sh DESCRIPTION
 The
 .Nm
@@ -48,6 +49,11 @@
 .Pp
 The following options are available:
 .Bl -tag -width Fl
+.It Fl S
+For
+.Ar term1 , term2 , ...
+output the terminal name followed by the compiled
+description as strings.
 .It Fl a
 Do not discard commented out capabilities.
 .It Fl c
Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.4 src/usr.bin/tic/tic.c:1.5
--- src/usr.bin/tic/tic.c:1.4	Fri Feb  5 16:36:09 2010
+++ src/usr.bin/tic/tic.c	Thu Feb 11 00:24:46 2010
@@ -1,7 +1,7 @@
-/* $NetBSD: tic.c,v 1.4 2010/02/05 16:36:09 roy Exp $ */
+/* $NetBSD: tic.c,v 1.5 2010/02/11 00:24:46 roy Exp $ */
 
 /*
- * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Roy Marples.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.4 2010/02/05 16:36:09 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.5 2010/02/11 00:24:46 roy Exp $");
 
 #include 
 
@@ -237,12 +237,11 @@
 	return 1;
 }
 
-static int
-save_term(DBM *db, TERM *term)
+static TBUF *
+flatten_term(TERM *term)
 {
 	size_t buflen, len, alen, dlen;
 	char *cap;
-	datum key, value;
 	TIC *tic;
 
 	scratch.bufpos = 0;
@@ -258,7 +257,7 @@
 		dlen = strlen(tic->desc) + 1;
 	buflen = sizeof(char) +
 	sizeof(uint16_t) + len +
-	//sizeof(uint16_t) + alen +
+	sizeof(uint16_t) + alen +
 	sizeof(uint16_t) + dlen +
 	(sizeof(uint16_t) * 2) + tic->flags.bufpos +
 	(sizeof(uint16_t) * 2) + tic->nums.bufpos +
@@ -336,11 +335,25 @@
 			cap += tic->extras.bufpos;
 		}
 	}
+	scratch.bufpos = cap - scratch.buf;
+
+	return &scratch;
+}
+
+static int
+save_term(DBM *db, TERM *term)
+{
+	TBUF *buf;
+	datum key, value;
+
+	buf = flatten_term(term);
+	if (buf == NULL)
+		return -1;
 
 	key.dptr = term->name;
 	key.dsize = strlen(term->name);
 	value.dptr = scratch.buf;
-	value.dsize = cap - scratch.buf;
+	value.dsize = scratch.bufpos;
 	if (dbm_store(db, key, value, DBM_REPLACE) == -1)
 		err(1, "dbm_store");
 	return 0;
@@ -870,10 +883,56 @@
 	return merged;
 }
 
+static int
+print_dump(int argc, char **argv)
+{
+	TERM *term;
+	TBUF *buf;
+	int i, n;
+	size_t j, col;
+
+	n = 0;
+
+	for (i = 0; i < argc; i++) {
+		term = find_term(argv[i]);
+		if (term == NULL) {
+			warnx("%s: no description for terminal", argv[i]);
+			continue;
+		}
+		if (term->type == 'a') {
+			warnx("%s: cannot dump alias", argv[i]);
+			continue;
+		}
+		buf = flatten_term(term);
+		if (buf == NULL)
+			continue;
+
+		printf("\t\"%s\",\n", argv[i]);
+		n++;
+		for (j = 0, col = 0; j < buf->bufpos; j++) {
+			if (col == 0) {
+printf("\t\"");
+col = 8;
+			}
+			
+			col += printf("\\%03o", (uint8_t)buf->buf[j]);
+			if (col > 75) {
+printf("\"%s\n",
+j + 1 == buf->bufpos ? "," : "");
+col = 0;
+			}
+		}
+		if (col != 0)
+		printf("\",\n");
+	}
+
+	return n;
+}
+
 int
 main(int argc, char **argv)
 {
-	int ch, cflag, sflag;
+	int ch, Sflag, cflag, sflag;
 	char *source, *p, *buf, *ofile;
 	FILE *f;
 	DBM *db;
@@ -883,8 +942,11 @@
 
 	cflag = sflag = 0;
 	ofile = NULL;
-	while ((ch = getopt(argc, argv, "aco:sx")) != -1)
+	while ((ch = getopt(argc, argv, "Saco:sx")) != -1)
 	switch (ch) {
+	case 'S':
+		Sflag = 1;
+		break;
 	case 'a':
 		aflag = 1;
 		break;
@@ -902,7 +964,7 @@
 		break;
 	case '?': /* FALLTHROUGH */
 	default:
-		fprintf(stderr, "usage: %s [-acsx] [-o file] source\n",
+		fprintf(stderr, "usage: %s [-Sacsx] [-o file] source\n",
 			getprogname());
 	

CVS commit: src/usr.bin/tic

2010-02-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Feb  5 16:54:12 UTC 2010

Modified Files:
src/usr.bin/tic: tic.1

Log Message:
Fix year.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/tic/tic.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.3 src/usr.bin/tic/tic.1:1.4
--- src/usr.bin/tic/tic.1:1.3	Fri Feb  5 16:36:09 2010
+++ src/usr.bin/tic/tic.1	Fri Feb  5 16:54:11 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tic.1,v 1.3 2010/02/05 16:36:09 roy Exp $
+.\"	$NetBSD: tic.1,v 1.4 2010/02/05 16:54:11 roy Exp $
 .\"
 .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 5, 2009
+.Dd February 5, 2010
 .Dt TIC 1
 .Os
 .Sh NAME



CVS commit: src/usr.bin/tic

2010-02-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Feb  5 16:36:09 UTC 2010

Modified Files:
src/usr.bin/tic: tic.1 tic.c

Log Message:
Note that -a no longer sets -x.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/tic/tic.1
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.2 src/usr.bin/tic/tic.1:1.3
--- src/usr.bin/tic/tic.1:1.2	Wed Feb  3 15:51:09 2010
+++ src/usr.bin/tic/tic.1	Fri Feb  5 16:36:09 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tic.1,v 1.2 2010/02/03 15:51:09 wiz Exp $
+.\"	$NetBSD: tic.1,v 1.3 2010/02/05 16:36:09 roy Exp $
 .\"
 .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 17, 2009
+.Dd February 5, 2009
 .Dt TIC 1
 .Os
 .Sh NAME
@@ -50,11 +50,6 @@
 .Bl -tag -width Fl
 .It Fl a
 Do not discard commented out capabilities.
-This also sets the
-.Fl x
-flag as
-.Nm
-retains commented out capabilities as non standard.
 .It Fl c
 Only check for errors, don't write the final database.
 .It Fl o Ar file

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.3 src/usr.bin/tic/tic.c:1.4
--- src/usr.bin/tic/tic.c:1.3	Fri Feb  5 14:40:07 2010
+++ src/usr.bin/tic/tic.c	Fri Feb  5 16:36:09 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.3 2010/02/05 14:40:07 he Exp $ */
+/* $NetBSD: tic.c,v 1.4 2010/02/05 16:36:09 roy Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.3 2010/02/05 14:40:07 he Exp $");
+__RCSID("$NetBSD: tic.c,v 1.4 2010/02/05 16:36:09 roy Exp $");
 
 #include 
 
@@ -886,20 +886,19 @@
 	while ((ch = getopt(argc, argv, "aco:sx")) != -1)
 	switch (ch) {
 	case 'a':
-		aflag++;
-		xflag++;
+		aflag = 1;
 		break;
 	case 'c':
-		cflag++;
+		cflag = 1;
 		break;
 	case 'o':
 		ofile = optarg;
 		break;
 	case 's':
-		sflag++;
+		sflag = 1;
 		break;
 	case 'x':
-		xflag++;
+		xflag = 1;
 		break;
 	case '?': /* FALLTHROUGH */
 	default:



CVS commit: src/usr.bin/tic

2010-02-05 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Fri Feb  5 14:40:07 UTC 2010

Modified Files:
src/usr.bin/tic: tic.c

Log Message:
More adaptation for ports where char is unsigned char.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/tic/tic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.c
diff -u src/usr.bin/tic/tic.c:1.2 src/usr.bin/tic/tic.c:1.3
--- src/usr.bin/tic/tic.c:1.2	Fri Feb  5 12:31:56 2010
+++ src/usr.bin/tic/tic.c	Fri Feb  5 14:40:07 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.2 2010/02/05 12:31:56 roy Exp $ */
+/* $NetBSD: tic.c,v 1.3 2010/02/05 14:40:07 he Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: tic.c,v 1.2 2010/02/05 12:31:56 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.3 2010/02/05 14:40:07 he Exp $");
 
 #include 
 
@@ -471,7 +471,8 @@
 static int
 process_entry(TBUF *buf)
 {
-	char *cap, *capstart, *p, *e, *name, *desc, *alias, flag;
+	char *cap, *capstart, *p, *e, *name, *desc, *alias;
+	signed char flag;
 	long num;
 	int slash;
 	ssize_t ind;



CVS commit: src/usr.bin/tic

2010-02-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb  3 15:51:09 UTC 2010

Modified Files:
src/usr.bin/tic: tic.1

Log Message:
Use Ex for EXIT STATUS section. Put Ns on same line as previous,
to make clearer what happens.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/tic/tic.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tic/tic.1
diff -u src/usr.bin/tic/tic.1:1.1 src/usr.bin/tic/tic.1:1.2
--- src/usr.bin/tic/tic.1:1.1	Wed Feb  3 15:16:32 2010
+++ src/usr.bin/tic/tic.1	Wed Feb  3 15:51:09 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: tic.1,v 1.1 2010/02/03 15:16:32 roy Exp $
+.\"	$NetBSD: tic.1,v 1.2 2010/02/03 15:51:09 wiz Exp $
 .\"
 .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -59,11 +59,9 @@
 Only check for errors, don't write the final database.
 .It Fl o Ar file
 Write the database to
-.Ar file
-.Ns .db
+.Ar file Ns .db
 instead of
-.Ar source
-.Ns .db.
+.Ar source Ns .db .
 .It Fl s
 Display the number of terminal descritions written to the database.
 .It Fl x
@@ -84,9 +82,7 @@
 .Sy use Ns d
 terminals.
 .Sh EXIT STATUS
-The
-.Nm
-utility exits 0 on success, and >0 if an error occurs.
+.Ex -std tic
 .Sh EXAMPLES
 To maintain your private terminfo definitions, if the system supplied
 ones do not support your terminal: