+static void
+dump_numeric(int val, char *buf)
+/* display the value of a numeric capability */
+{
+ switch (val) {
+ case ABSENT_NUMERIC:
+ _nc_STRCPY(buf, s_absent, MAX_STRING);
+ break;
+ case CANCELLED_NUMERIC:
+ _nc_STRCPY(buf, s_cancel, MAX_STRING);
+ break;
+ default:
+ _nc_SPRINTF(buf, _nc_SLIMIT(MAX_STRING) "%d", val);
+ break;
+ }
+}
+
+static void
+dump_string(char *val, char *buf)
+/* display the value of a string capability */
+{
+ if (val == ABSENT_STRING)
+ _nc_STRCPY(buf, s_absent, MAX_STRING);
+ else if (val == CANCELLED_STRING)
+ _nc_STRCPY(buf, s_cancel, MAX_STRING);
+ else {
+ _nc_SPRINTF(buf, _nc_SLIMIT(MAX_STRING)
+ "'%.*s'", MAX_STRING - 3, TIC_EXPAND(val));
+ }
+}
+
+/*
+ * Show "comparing..." message for the given terminal names.
+ */
+static void
+show_comparing(char **names)
+{
+ if (itrace) {
+ switch (compare) {
+ case C_DIFFERENCE:
+ (void) fprintf(stderr, "%s: dumping differences\n", _nc_progname);
+ break;
+
+ case C_COMMON:
+ (void) fprintf(stderr, "%s: dumping common capabilities\n", _nc_progname);
+ break;
+
+ case C_NAND:
+ (void) fprintf(stderr, "%s: dumping differences\n", _nc_progname);
+ break;
+ }
+ }
+ if (*names) {
+ printf("comparing %s", *names++);
+ if (*names) {
+ printf(" to %s", *names++);
+ while (*names) {
+ printf(", %s", *names++);
+ }
+ }
+ printf(".\n");
+ }
+}
+
+/*
+ * ncurses stores two types of non-standard capabilities:
+ * a) capabilities listed past the "STOP-HERE" comment in the Caps file.
+ * These are used in the terminfo source file to provide data for termcaps,
+ * e.g., when there is no equivalent capability in terminfo, as well as for
+ * widely-used non-standard capabilities.
+ * b) user-definable capabilities, via "tic -x".
+ *
+ * However, if "-x" is omitted from the tic command, both types of
+ * non-standard capability are not loaded into the terminfo database. This
+ * macro is used for limit-checks against the symbols that tic uses to omit
+ * the two types of non-standard entry.
+ */
+#if NCURSES_XNAMES
+#define check_user_definable(n,limit) if (!_nc_user_definable && (n) > (limit)) break
+#else
+#define check_user_definable(n,limit) if ((n) > (limit)) break
+#endif
+
+/*
+ * Use these macros to simplify loops on C_COMMON and C_NAND:
+ */
+#define for_each_entry() while (entries[extra].tterm.term_names)
+#define next_entry (&(entries[extra++].tterm))
+
+static void
+compare_predicate(PredType type, PredIdx idx, const char *name)
+/* predicate function to use for entry difference reports */
+{
+ ENTRY *e1 = &entries[0];
+ ENTRY *e2 = &entries[1];
+ char buf1[MAX_STRING];
+ char buf2[MAX_STRING];
+ int b1, b2;
+ int n1, n2;
+ char *s1, *s2;
+ bool found;
+ int extra = 1;
+
+ switch (type) {
+ case CMP_BOOLEAN:
+ check_user_definable(idx, BOOLWRITE);
+ b1 = e1->tterm.Booleans[idx];
+ switch (compare) {
+ case C_DIFFERENCE:
+ b2 = next_entry->Booleans[idx];
+ if (!(no_boolean(b1) && no_boolean(b2)) && (b1 != b2))
+ (void) printf("\t%s: %s%s%s.\n",
+ name,
+ dump_boolean(b1),
+ bool_sep,
+ dump_boolean(b2));
+ break;
+
+ case C_COMMON:
+ if (b1 != ABSENT_BOOLEAN) {
+ found = TRUE;
+ for_each_entry() {
+ b2 = next_entry->Booleans[idx];
+ if (b1 != b2) {
+ found = FALSE;