summaryrefslogtreecommitdiff
path: root/lib/libterminfo
diff options
context:
space:
mode:
authorroy <roy@NetBSD.org>2020-03-30 00:09:06 +0000
committerroy <roy@NetBSD.org>2020-03-30 00:09:06 +0000
commit73c06c098d3af8a1724e430cd166989642f01073 (patch)
treec674f974828ef38e476f5023f03d7f1425c8ab79 /lib/libterminfo
parentca62326e366e72865d5e15bd10f55acb42baac87 (diff)
terminfo: v3 records should create v3 aliases
Diffstat (limited to 'lib/libterminfo')
-rw-r--r--lib/libterminfo/compile.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/libterminfo/compile.c b/lib/libterminfo/compile.c
index d24ca7a317a..262675b9b78 100644
--- a/lib/libterminfo/compile.c
+++ b/lib/libterminfo/compile.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compile.c,v 1.22 2020/03/29 21:46:22 roy Exp $ */
+/* $NetBSD: compile.c,v 1.23 2020/03/30 00:09:06 roy Exp $ */
/*
* Copyright (c) 2009, 2010, 2011, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: compile.c,v 1.22 2020/03/29 21:46:22 roy Exp $");
+__RCSID("$NetBSD: compile.c,v 1.23 2020/03/30 00:09:06 roy Exp $");
#if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
@@ -67,7 +67,7 @@ dowarn(int flags, const char *fmt, ...)
int
_ti_promote(TIC *tic)
{
- char *obuf, type, flag;
+ char *obuf, type, flag, *buf, *delim, *name, *nbuf;
const char *cap, *code, *str;
size_t n, entries, strl;
uint16_t ind;
@@ -84,6 +84,28 @@ _ti_promote(TIC *tic)
}
free(obuf);
+ n = 0;
+ obuf = buf = tic->alias;
+ tic->alias = NULL;
+ while (buf != NULL) {
+ delim = strchr(buf, '|');
+ if (delim != NULL)
+ *delim++ = '\0';
+ name = _ti_getname(tic->rtype, buf);
+ strl = strlen(name) + 1;
+ nbuf = realloc(tic->alias, n + strl);
+ if (nbuf == NULL) {
+ free(name);
+ return -1;
+ }
+ tic->alias = nbuf;
+ memcpy(tic->alias + n, name, strl);
+ n += strl;
+ free(name);
+ buf = delim;
+ }
+ free(obuf);
+
obuf = tic->nums.buf;
cap = obuf;
entries = tic->nums.entries;