/****************************************************************************
- * Copyright 2020-2021,2022 Thomas E. Dickey *
+ * Copyright 2020-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 <dump_entry.h>
-MODULE_ID("$Id: infocmp.c,v 1.155 2022/09/03 23:28:48 tom Exp $")
+MODULE_ID("$Id: infocmp.c,v 1.159 2023/12/02 17:29:01 tom Exp $")
#define MAX_STRING 1024 /* maximum formatted string */
}
static bool
-no_string(char *value)
+no_string(const char *const value)
{
bool result = (value == ABSENT_STRING);
if (!strcmp(s_absent, s_cancel))
* unlike numbers and strings, whose cancelled/absent state is
* recorded in the terminfo database.
*/
- for (ep = &entries[1]; ep < entries + termcount; ep++)
- if (ep->tterm.Booleans[idx] == TRUE) {
- is_set = entries[0].tterm.Booleans[idx];
- break;
+ if (idx < NUM_BOOLEANS(&(entries[0].tterm))) {
+ for (ep = &entries[1]; ep < entries + termcount; ep++) {
+ if (idx < NUM_BOOLEANS(&(ep->tterm))
+ && ep->tterm.Booleans[idx] == TRUE) {
+ is_set = entries[0].tterm.Booleans[idx];
+ break;
+ }
}
- if (is_set != entries[0].tterm.Booleans[idx])
- return (!is_set);
- else
- return (FAIL);
+ if (is_set != entries[0].tterm.Booleans[idx])
+ return (!is_set);
+ }
+ return (FAIL);
}
case NUMBER:
* capability gets the first non-default value found
* in the sequence of use entries'.
*/
- for (ep = &entries[1]; ep < entries + termcount; ep++)
- if (VALID_NUMERIC(ep->tterm.Numbers[idx])) {
- value = ep->tterm.Numbers[idx];
- break;
- }
+ if (idx < NUM_NUMBERS(&(entries[0].tterm))) {
+ for (ep = &entries[1]; ep < entries + termcount; ep++)
+ if (idx < NUM_NUMBERS(&(ep->tterm))
+ && VALID_NUMERIC(ep->tterm.Numbers[idx])) {
+ value = ep->tterm.Numbers[idx];
+ break;
+ }
- if (value != entries[0].tterm.Numbers[idx])
- return (value != ABSENT_NUMERIC);
- else
- return (FAIL);
+ if (value != entries[0].tterm.Numbers[idx])
+ return (value != ABSENT_NUMERIC);
+ }
+ return (FAIL);
}
case STRING:
* capability gets the first non-default value found
* in the sequence of use entries'.
*/
- for (ep = &entries[1]; ep < entries + termcount; ep++)
- if (ep->tterm.Strings[idx]) {
- usestr = ep->tterm.Strings[idx];
- break;
- }
+ if (idx < NUM_STRINGS(&(entries[0].tterm))) {
+ for (ep = &entries[1]; ep < entries + termcount; ep++)
+ if (idx < NUM_STRINGS(&(ep->tterm))
+ && ep->tterm.Strings[idx]) {
+ usestr = ep->tterm.Strings[idx];
+ break;
+ }
- if (usestr == ABSENT_STRING && termstr == ABSENT_STRING)
- return (FAIL);
- else if (!usestr || !termstr || capcmp(idx, usestr, termstr))
- return (TRUE);
- else
- return (FAIL);
+ if (usestr == ABSENT_STRING && termstr == ABSENT_STRING)
+ return (FAIL);
+ else if (!usestr || !termstr || capcmp(idx, usestr, termstr))
+ return (TRUE);
+ }
+ return (FAIL);
}
}
sizeof(buf2));
_nc_STRNCPY(buf3, sp + csi, len);
buf3[len] = '\0';
- len += (size_t) csi + 1;
expansion = lookup_params(std_modes, buf2, buf3);
}
sizeof(buf2));
_nc_STRNCPY(buf3, sp + csi + 1, len);
buf3[len] = '\0';
- len += (size_t) csi + 2;
expansion = lookup_params(private_modes, buf2, buf3);
}
}
#if NCURSES_XNAMES
- if (termcount > 1)
- _nc_align_termtype(&entries[0].tterm, &entries[1].tterm);
+ if (termcount > 1) {
+ /*
+ * User-defined capabilities in different terminal descriptions
+ * may have the same name/type but different indices. Line up
+ * the names to use comparable indices. We may have more than two
+ * entries to compare when processing the "-u" option.
+ */
+ for (c = 1; c < termcount; ++c)
+ _nc_align_termtype(&entries[c].tterm, &entries[0].tterm);
+ }
#endif
/* dump as C initializer for the terminal type */