Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src terminfo: v3 records should create v3 aliases
details: https://anonhg.NetBSD.org/src/rev/70f8066d5bf2
branches: trunk
changeset: 1008651:70f8066d5bf2
user: roy <roy%NetBSD.org@localhost>
date: Mon Mar 30 00:09:06 2020 +0000
description:
terminfo: v3 records should create v3 aliases
diffstat:
lib/libterminfo/compile.c | 28 ++++++++++++++++-
usr.bin/tic/tic.c | 71 ++++++++++++++++++++++++++++------------------
2 files changed, 68 insertions(+), 31 deletions(-)
diffs (179 lines):
diff -r 9f9c2e112bbc -r 70f8066d5bf2 lib/libterminfo/compile.c
--- a/lib/libterminfo/compile.c Mon Mar 30 00:01:57 2020 +0000
+++ b/lib/libterminfo/compile.c Mon Mar 30 00:09:06 2020 +0000
@@ -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 @@
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 @@
}
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;
diff -r 9f9c2e112bbc -r 70f8066d5bf2 usr.bin/tic/tic.c
--- a/usr.bin/tic/tic.c Mon Mar 30 00:01:57 2020 +0000
+++ b/usr.bin/tic/tic.c Mon Mar 30 00:09:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tic.c,v 1.39 2020/03/29 21:54:03 roy Exp $ */
+/* $NetBSD: tic.c,v 1.40 2020/03/30 00:09:06 roy Exp $ */
/*
* Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tic.c,v 1.39 2020/03/29 21:54:03 roy Exp $");
+__RCSID("$NetBSD: tic.c,v 1.40 2020/03/30 00:09:06 roy Exp $");
#include <sys/types.h>
#include <sys/queue.h>
@@ -179,10 +179,37 @@
return term;
}
+static void
+alias_terms(TERM *term)
+{
+ char *p, *e, *alias;
+
+ /* Create aliased terms */
+ if (term->tic->alias == NULL)
+ return;
+
+ alias = p = estrdup(term->tic->alias);
+ while (p != NULL && *p != '\0') {
+ e = strchr(p, '|');
+ if (e != NULL)
+ *e++ = '\0';
+ /* No need to lengthcheck the alias because the main
+ * terminfo description already stores all the aliases
+ * in the same length field as the alias. */
+ if (find_term(p) != NULL) {
+ dowarn("%s: has alias for already assigned"
+ " term %s", term->tic->name, p);
+ } else {
+ store_term(p, term);
+ }
+ p = e;
+ }
+ free(alias);
+}
+
static int
process_entry(TBUF *buf, int flags)
{
- char *p, *e, *alias;
TERM *term;
TIC *tic;
TBUF sbuf = *buf;
@@ -208,27 +235,7 @@
}
term = store_term(tic->name, NULL);
term->tic = tic;
-
- /* Create aliased terms */
- if (tic->alias != NULL) {
- alias = p = estrdup(tic->alias);
- while (p != NULL && *p != '\0') {
- e = strchr(p, '|');
- if (e != NULL)
- *e++ = '\0';
- /* No need to lengthcheck the alias because the main
- * terminfo description already stores all the aliases
- * in the same length field as the alias. */
- if (find_term(p) != NULL) {
- dowarn("%s: has alias for already assigned"
- " term %s", tic->name, p);
- } else {
- store_term(p, term);
- }
- p = e;
- }
- free(alias);
- }
+ alias_terms(term);
if (tic->rtype == TERMINFO_RTYPE)
return process_entry(&sbuf, flags | TIC_COMPAT_V1);
@@ -356,6 +363,11 @@
tic->name = _ti_getname(TERMINFO_RTYPE, rtic->name);
if (tic->name == NULL)
goto err;
+ if (rtic->alias != NULL) {
+ tic->alias = strdup(rtic->alias);
+ if (tic->alias == NULL)
+ goto err;
+ }
if (rtic->desc != NULL) {
tic->desc = strdup(rtic->desc);
if (tic->desc == NULL)
@@ -375,10 +387,12 @@
goto err;
term = store_term(tic->name, NULL);
- if (term != NULL) {
- term->tic = tic;
- return 0;
- }
+ if (term == NULL)
+ goto err;
+
+ term->tic = tic;
+ alias_terms(term);
+ return 0;
err:
free(tic->flags.buf);
@@ -386,6 +400,7 @@
free(tic->strs.buf);
free(tic->extras.buf);
free(tic->desc);
+ free(tic->alias);
free(tic->name);
free(tic);
return -1;
Home |
Main Index |
Thread Index |
Old Index