+ PredIdx n;
+ for (n = 0; n < NUM_STRINGS(tterm); ++n) {
+ if (version_filter(STRING, n)
+ && !strcmp(name, strnames[n])) {
+ char *cap = tterm->Strings[n];
+ if (VALID_STRING(cap)) {
+ return cap;
+ }
+ break;
+ }
+ }
+ return ABSENT_STRING;
+}
+
+/*
+ * This is used to remove function-key labels from a termcap entry to
+ * make it smaller.
+ */
+static int
+kill_labels(TERMTYPE *tterm, int target)
+{
+ int n;
+ int result = 0;
+ char *cap;
+ char name[10];
+
+ for (n = 0; n <= 10; ++n) {
+ _nc_SPRINTF(name, _nc_SLIMIT(sizeof(name)) "lf%d", n);
+ if ((cap = find_string(tterm, name)) != ABSENT_STRING
+ && kill_string(tterm, cap)) {
+ target -= (int) (strlen(cap) + 5);
+ ++result;
+ if (target < 0)
+ break;
+ }
+ }
+ return result;
+}
+
+/*
+ * This is used to remove function-key definitions from a termcap entry to
+ * make it smaller.
+ */
+static int
+kill_fkeys(TERMTYPE *tterm, int target)
+{
+ int n;
+ int result = 0;
+ char *cap;
+ char name[10];
+
+ for (n = 60; n >= 0; --n) {
+ _nc_SPRINTF(name, _nc_SLIMIT(sizeof(name)) "kf%d", n);
+ if ((cap = find_string(tterm, name)) != ABSENT_STRING
+ && kill_string(tterm, cap)) {
+ target -= (int) (strlen(cap) + 5);
+ ++result;
+ if (target < 0)
+ break;
+ }
+ }
+ return result;
+}
+
+/*
+ * Check if the given acsc string is a 1-1 mapping, i.e., just-like-vt100.
+ * Also, since this is for termcap, we only care about the line-drawing map.
+ */
+#define isLine(c) (strchr("lmkjtuvwqxn", c) != 0)
+
+static bool
+one_one_mapping(const char *mapping)
+{
+ bool result = TRUE;
+
+ if (mapping != ABSENT_STRING) {
+ int n = 0;
+ while (mapping[n] != '\0') {
+ if (isLine(mapping[n]) &&
+ mapping[n] != mapping[n + 1]) {
+ result = FALSE;
+ break;
+ }
+ n += 2;
+ }
+ }
+ return result;
+}
+
+#define FMT_ENTRY() \
+ fmt_entry(tterm, pred, \
+ 0, \
+ suppress_untranslatable, \
+ infodump, numbers)
+
+#define SHOW_WHY PRINTF
+
+static bool
+purged_acs(TERMTYPE *tterm)
+{
+ bool result = FALSE;
+
+ if (VALID_STRING(acs_chars)) {
+ if (!one_one_mapping(acs_chars)) {
+ enter_alt_charset_mode = ABSENT_STRING;
+ exit_alt_charset_mode = ABSENT_STRING;
+ SHOW_WHY("# (rmacs/smacs removed for consistency)\n");
+ }
+ result = TRUE;
+ }
+ return result;
+}
+
+/*
+ * Dump a single entry.
+ */
+void
+dump_entry(TERMTYPE *tterm,
+ int suppress_untranslatable,
+ int limited,
+ int numbers,
+ PredFunc pred)
+{
+ TERMTYPE save_tterm;