+ } else if (PRESENT(cap)) {
+ _nc_warning("sgr(%d) missing, but %s present", num, name);
+ }
+}
+
+#define CHECK_SGR(num,name) check_sgr(tp, zero, num, name, #name)
+
+/* other sanity-checks (things that we don't want in the normal
+ * logic that reads a terminfo entry)
+ */
+static void
+check_termtype(TERMTYPE * tp)
+{
+ bool conflict = FALSE;
+ unsigned j, k;
+ char fkeys[STRCOUNT];
+
+ /*
+ * A terminal entry may contain more than one keycode assigned to
+ * a given string (e.g., KEY_END and KEY_LL). But curses will only
+ * return one (the last one assigned).
+ */
+ memset(fkeys, 0, sizeof(fkeys));
+ for (j = 0; _nc_tinfo_fkeys[j].code; j++) {
+ char *a = tp->Strings[_nc_tinfo_fkeys[j].offset];
+ bool first = TRUE;
+ if (!VALID_STRING(a))
+ continue;
+ for (k = j + 1; _nc_tinfo_fkeys[k].code; k++) {
+ char *b = tp->Strings[_nc_tinfo_fkeys[k].offset];
+ if (!VALID_STRING(b)
+ || fkeys[k])
+ continue;
+ if (!strcmp(a, b)) {
+ fkeys[j] = 1;
+ fkeys[k] = 1;
+ if (first) {
+ if (!conflict) {
+ _nc_warning("Conflicting key definitions (using the last)");
+ conflict = TRUE;
+ }
+ fprintf(stderr, "... %s is the same as %s",
+ keyname(_nc_tinfo_fkeys[j].code),
+ keyname(_nc_tinfo_fkeys[k].code));
+ first = FALSE;
+ } else {
+ fprintf(stderr, ", %s",
+ keyname(_nc_tinfo_fkeys[k].code));
+ }
+ }
+ }
+ if (!first)
+ fprintf(stderr, "\n");
+ }
+
+ for (j = 0; j < NUM_STRINGS(tp); j++) {
+ char *a = tp->Strings[j];
+ if (VALID_STRING(a))
+ check_params(tp, ExtStrname(tp, j, strnames), a);
+ }
+
+ /*
+ * Quick check for color. We could also check if the ANSI versus
+ * non-ANSI strings are misused.
+ */
+ if ((max_colors > 0) != (max_pairs > 0)
+ || ((max_colors > max_pairs) && (initialize_pair == 0)))
+ _nc_warning("inconsistent values for max_colors (%d) and max_pairs (%d)",
+ max_colors, max_pairs);
+
+ PAIRED(set_foreground, set_background);
+ PAIRED(set_a_foreground, set_a_background);
+
+ /*
+ * These may be mismatched because the terminal description relies on
+ * restoring the cursor visibility by resetting it.
+ */
+ ANDMISSING(cursor_invisible, cursor_normal);
+ ANDMISSING(cursor_visible, cursor_normal);
+
+ if (PRESENT(cursor_visible) && PRESENT(cursor_normal)
+ && !strcmp(cursor_visible, cursor_normal))
+ _nc_warning("cursor_visible is same as cursor_normal");
+
+ /*
+ * From XSI & O'Reilly, we gather that sc/rc are required if csr is
+ * given, because the cursor position after the scrolling operation is
+ * performed is undefined.
+ */
+ ANDMISSING(change_scroll_region, save_cursor);
+ ANDMISSING(change_scroll_region, restore_cursor);
+
+ tparm_errs = 0;
+ if (PRESENT(set_attributes)) {
+ char *zero = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ zero = strdup(zero);
+ CHECK_SGR(1, enter_standout_mode);
+ CHECK_SGR(2, enter_underline_mode);
+ CHECK_SGR(3, enter_reverse_mode);
+ CHECK_SGR(4, enter_blink_mode);
+ CHECK_SGR(5, enter_dim_mode);
+ CHECK_SGR(6, enter_bold_mode);
+ CHECK_SGR(7, enter_secure_mode);
+ CHECK_SGR(8, enter_protected_mode);
+ CHECK_SGR(9, enter_alt_charset_mode);
+ free(zero);
+ if (tparm_errs)
+ _nc_warning("stack error in sgr string");
+ }
+
+ /*
+ * Some standard applications (e.g., vi) and some non-curses
+ * applications (e.g., jove) get confused if we have both ich1 and
+ * smir/rmir. Let's be nice and warn about that, too, even though
+ * ncurses handles it.
+ */
+ if ((PRESENT(enter_insert_mode) || PRESENT(exit_insert_mode))
+ && PRESENT(parm_ich)) {
+ _nc_warning("non-curses applications may be confused by ich1 with smir/rmir");
+ }
+
+ /*
+ * Finally, do the non-verbose checks
+ */
+ if (save_check_termtype != 0)
+ save_check_termtype(tp);