infocmp: don't crash when a terminfo description does not have an alias
This commit is contained in:
parent
aa67024947
commit
721f832e4d
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: infocmp.c,v 1.16 2020/03/30 00:22:18 roy Exp $ */
|
||||
/* $NetBSD: infocmp.c,v 1.17 2020/03/31 12:44:15 roy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc.
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: infocmp.c,v 1.16 2020/03/30 00:22:18 roy Exp $");
|
||||
__RCSID("$NetBSD: infocmp.c,v 1.17 2020/03/31 12:44:15 roy Exp $");
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@ -715,8 +715,6 @@ main(int argc, char **argv)
|
||||
use_terms(t, argc - optind, argv + optind);
|
||||
|
||||
if ((optind + 1 != argc && nflag == 0) || uflag != 0) {
|
||||
char *alias, *aliascpy, *delim;
|
||||
|
||||
if (uflag == 0)
|
||||
printf("# Reconstructed from %s\n",
|
||||
_ti_database == NULL ?
|
||||
@ -726,24 +724,28 @@ main(int argc, char **argv)
|
||||
if (term != NULL)
|
||||
*term = '\0';
|
||||
printf("%s", t->name);
|
||||
alias = aliascpy = estrdup(t->_alias);
|
||||
while (alias != NULL && *alias != '\0') {
|
||||
putchar('|');
|
||||
delim = strchr(alias, TERMINFO_VDELIM);
|
||||
if (delim != NULL)
|
||||
*delim++ = '\0';
|
||||
printf("%s", alias);
|
||||
if (delim != NULL) {
|
||||
while (*delim != '\0' && *delim != '|')
|
||||
delim++;
|
||||
if (*delim == '\0')
|
||||
if (t->_alias != NULL) {
|
||||
char *alias, *aliascpy, *delim;
|
||||
|
||||
alias = aliascpy = estrdup(t->_alias);
|
||||
while (alias != NULL && *alias != '\0') {
|
||||
putchar('|');
|
||||
delim = strchr(alias, TERMINFO_VDELIM);
|
||||
if (delim != NULL)
|
||||
*delim++ = '\0';
|
||||
printf("%s", alias);
|
||||
if (delim != NULL) {
|
||||
while (*delim != '\0' && *delim != '|')
|
||||
delim++;
|
||||
if (*delim == '\0')
|
||||
alias = NULL;
|
||||
else
|
||||
alias = delim + 1;
|
||||
} else
|
||||
alias = NULL;
|
||||
else
|
||||
alias = delim + 1;
|
||||
} else
|
||||
alias = NULL;
|
||||
}
|
||||
free(aliascpy);
|
||||
}
|
||||
free(aliascpy);
|
||||
if (t->desc != NULL && *t->desc != '\0')
|
||||
printf("|%s", t->desc);
|
||||
printf(",\n");
|
||||
|
Loading…
Reference in New Issue
Block a user