/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2022,2023 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#include <termsort.h> /* this C file is generated */
#include <parametrized.h> /* so is this */
-MODULE_ID("$Id: dump_entry.c,v 1.189 2021/09/04 10:29:59 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.196 2023/05/27 20:13:10 tom Exp $")
#define DISCARD(string) string = ABSENT_STRING
#define PRINTF (void) printf
indent_DYN(&tmpbuf, level + 1);
strncpy_DYN(&tmpbuf, "%", (size_t) 1);
}
- params = FALSE;
percent = FALSE;
break;
case ' ':
strcpy_DYN(&outbuf, 0);
if (content_only) {
- column = indent; /* FIXME: workaround to prevent empty lines */
+ column = indent; /* workaround to prevent empty lines */
} else {
strcpy_DYN(&outbuf, tterm->term_names);
}
static bool
-kill_string(TERMTYPE2 *tterm, char *cap)
+kill_string(TERMTYPE2 *tterm, const char *const cap)
{
unsigned n;
for (n = 0; n < NUM_STRINGS(tterm); ++n) {
save_sgr = set_attributes;
if ((FMT_ENTRY() > critlen)
+ && TcOutput()
&& limited) {
save_tterm = *tterm;
}
void
-dump_uses(const char *name, bool infodump)
+dump_uses(const char *value, bool infodump)
/* dump "use=" clauses in the appropriate format */
{
- char buffer[MAX_TERMINFO_LENGTH];
+ char buffer[MAX_TERMINFO_LENGTH + EXTRA_CAP];
+ int limit = (VALID_STRING(value) ? (int) strlen(value) : 0);
+ const char *cap = infodump ? "use" : "tc";
if (TcOutput())
trim_trailing();
+ if (limit == 0) {
+ _nc_warning("empty \"%s\" field", cap);
+ value = "";
+ } else if (limit > MAX_ALIAS) {
+ _nc_warning("\"%s\" field too long (%d), limit to %d",
+ cap, limit, MAX_ALIAS);
+ limit = MAX_ALIAS;
+ }
_nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer))
- "%s%s", infodump ? "use=" : "tc=", name);
+ "%s=%.*s", cap, limit, value);
wrap_concat1(buffer);
}
outbuf.used = (size_t) j;
} else if (!infodump && ch == '\\') {
outbuf.used = (size_t) j;
- } else if (ch == delim && (j == 0 || outbuf.text[j - 1] != '\\')) {
+ } else if (ch == delim && (outbuf.text[j - 1] != '\\')) {
outbuf.used = (size_t) (j + 1);
} else {
break;