1 /****************************************************************************
2 * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 * and: Thomas E. Dickey 1996 on *
33 ****************************************************************************/
35 #define __INTERNAL_CAPS_VISIBLE
36 #include <progs.priv.h>
38 #include "dump_entry.h"
39 #include "termsort.c" /* this C file is generated */
40 #include <parametrized.h> /* so is this */
42 MODULE_ID("$Id: dump_entry.c,v 1.70 2005/07/23 20:03:30 tom Exp $")
45 #define DISCARD(string) string = ABSENT_STRING
46 #define PRINTF (void) printf
54 static int tversion; /* terminfo version */
55 static int outform; /* output format to use */
56 static int sortmode; /* sort mode to use */
57 static int width = 60; /* max line width for listings */
58 static int column; /* current column, limited by 'width' */
59 static int oldcol; /* last value of column before wrap */
60 static bool pretty; /* true if we format if-then-else strings */
62 static char *save_sgr;
63 static char *save_acsc;
68 /* indirection pointers for implementing sort and display modes */
69 static const PredIdx *bool_indirect, *num_indirect, *str_indirect;
70 static NCURSES_CONST char *const *bool_names;
71 static NCURSES_CONST char *const *num_names;
72 static NCURSES_CONST char *const *str_names;
74 static const char *separator, *trailer;
76 /* cover various ports and variants of terminfo */
77 #define V_ALLCAPS 0 /* all capabilities (SVr4, XSI, ncurses) */
78 #define V_SVR1 1 /* SVR1, Ultrix */
79 #define V_HPUX 2 /* HP/UX */
80 #define V_AIX 3 /* AIX */
81 #define V_BSD 4 /* BSD */
84 #define OBSOLETE(n) (!_nc_user_definable && (n[0] == 'O' && n[1] == 'T'))
86 #define OBSOLETE(n) (n[0] == 'O' && n[1] == 'T')
89 #define isObsolete(f,n) ((f == F_TERMINFO || f == F_VARIABLE) && OBSOLETE(n))
92 #define BoolIndirect(j) ((j >= BOOLCOUNT) ? (j) : ((sortmode == S_NOSORT) ? j : bool_indirect[j]))
93 #define NumIndirect(j) ((j >= NUMCOUNT) ? (j) : ((sortmode == S_NOSORT) ? j : num_indirect[j]))
94 #define StrIndirect(j) ((j >= STRCOUNT) ? (j) : ((sortmode == S_NOSORT) ? j : str_indirect[j]))
96 #define BoolIndirect(j) ((sortmode == S_NOSORT) ? (j) : bool_indirect[j])
97 #define NumIndirect(j) ((sortmode == S_NOSORT) ? (j) : num_indirect[j])
98 #define StrIndirect(j) ((sortmode == S_NOSORT) ? (j) : str_indirect[j])
102 strncpy_DYN(DYNBUF * dst, const char *src, size_t need)
104 size_t want = need + dst->used + 1;
105 if (want > dst->size) {
106 dst->size += (want + 1024); /* be generous */
107 dst->text = typeRealloc(char, dst->size, dst->text);
109 (void) strncpy(dst->text + dst->used, src, need);
111 dst->text[dst->used] = 0;
115 strcpy_DYN(DYNBUF * dst, const char *src)
121 strncpy_DYN(dst, src, strlen(src));
137 _nc_leaks_dump_entry(void)
145 nametrans(const char *name)
146 /* translate a capability name from termcap to terminfo */
148 const struct name_table_entry *np;
150 if ((np = _nc_find_entry(name, _nc_get_hash_table(0))) != 0)
151 switch (np->nte_type) {
153 if (bool_from_termcap[np->nte_index])
154 return (boolcodes[np->nte_index]);
158 if (num_from_termcap[np->nte_index])
159 return (numcodes[np->nte_index]);
163 if (str_from_termcap[np->nte_index])
164 return (strcodes[np->nte_index]);
172 dump_init(const char *version, int mode, int sort, int twidth, int traceval,
174 /* set up for entry display */
181 tversion = V_ALLCAPS;
182 else if (!strcmp(version, "SVr1") || !strcmp(version, "SVR1")
183 || !strcmp(version, "Ultrix"))
185 else if (!strcmp(version, "HP"))
187 else if (!strcmp(version, "AIX"))
189 else if (!strcmp(version, "BSD"))
192 tversion = V_ALLCAPS;
194 /* implement display modes */
195 switch (outform = mode) {
198 bool_names = boolnames;
199 num_names = numnames;
200 str_names = strnames;
201 separator = twidth ? ", " : ",";
206 bool_names = boolfnames;
207 num_names = numfnames;
208 str_names = strfnames;
209 separator = twidth ? ", " : ",";
215 bool_names = boolcodes;
216 num_names = numcodes;
217 str_names = strcodes;
223 /* implement sort modes */
224 switch (sortmode = sort) {
227 (void) fprintf(stderr,
228 "%s: sorting by term structure order\n", _nc_progname);
233 (void) fprintf(stderr,
234 "%s: sorting by terminfo name order\n", _nc_progname);
235 bool_indirect = bool_terminfo_sort;
236 num_indirect = num_terminfo_sort;
237 str_indirect = str_terminfo_sort;
242 (void) fprintf(stderr,
243 "%s: sorting by C variable order\n", _nc_progname);
244 bool_indirect = bool_variable_sort;
245 num_indirect = num_variable_sort;
246 str_indirect = str_variable_sort;
251 (void) fprintf(stderr,
252 "%s: sorting by termcap name order\n", _nc_progname);
253 bool_indirect = bool_termcap_sort;
254 num_indirect = num_termcap_sort;
255 str_indirect = str_termcap_sort;
260 (void) fprintf(stderr,
261 "%s: width = %d, tversion = %d, outform = %d\n",
262 _nc_progname, width, tversion, outform);
265 static TERMTYPE *cur_type;
268 dump_predicate(PredType type, PredIdx idx)
269 /* predicate function to use for ordinary decompilation */
273 return (cur_type->Booleans[idx] == FALSE)
274 ? FAIL : cur_type->Booleans[idx];
277 return (cur_type->Numbers[idx] == ABSENT_NUMERIC)
278 ? FAIL : cur_type->Numbers[idx];
281 return (cur_type->Strings[idx] != ABSENT_STRING)
285 return (FALSE); /* pacify compiler */
288 static void set_obsolete_termcaps(TERMTYPE *tp);
290 /* is this the index of a function key string? */
291 #define FNKEY(i) (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))
294 * If we configure with a different Caps file, the offsets into the arrays
295 * will change. So we use an address expression.
297 #define BOOL_IDX(name) (&(name) - &(CUR Booleans[0]))
298 #define NUM_IDX(name) (&(name) - &(CUR Numbers[0]))
299 #define STR_IDX(name) (&(name) - &(CUR Strings[0]))
302 version_filter(PredType type, PredIdx idx)
303 /* filter out capabilities we may want to suppress */
306 case V_ALLCAPS: /* SVr4, XSI Curses */
309 case V_SVR1: /* System V Release 1, Ultrix */
312 return ((idx <= BOOL_IDX(xon_xoff)) ? TRUE : FALSE);
314 return ((idx <= NUM_IDX(width_status_line)) ? TRUE : FALSE);
316 return ((idx <= STR_IDX(prtr_non)) ? TRUE : FALSE);
320 case V_HPUX: /* Hewlett-Packard */
323 return ((idx <= BOOL_IDX(xon_xoff)) ? TRUE : FALSE);
325 return ((idx <= NUM_IDX(label_width)) ? TRUE : FALSE);
327 if (idx <= STR_IDX(prtr_non))
329 else if (FNKEY(idx)) /* function keys */
331 else if (idx == STR_IDX(plab_norm)
332 || idx == STR_IDX(label_on)
333 || idx == STR_IDX(label_off))
340 case V_AIX: /* AIX */
343 return ((idx <= BOOL_IDX(xon_xoff)) ? TRUE : FALSE);
345 return ((idx <= NUM_IDX(width_status_line)) ? TRUE : FALSE);
347 if (idx <= STR_IDX(prtr_non))
349 else if (FNKEY(idx)) /* function keys */
356 case V_BSD: /* BSD */
359 return bool_from_termcap[idx];
361 return num_from_termcap[idx];
363 return str_from_termcap[idx];
368 return (FALSE); /* pacify the compiler */
375 strcpy_DYN(&outbuf, trailer);
380 wrap_concat(const char *src)
382 int need = strlen(src);
383 int want = strlen(separator) + need;
386 && column + want > width) {
389 strcpy_DYN(&outbuf, src);
390 strcpy_DYN(&outbuf, separator);
394 #define IGNORE_SEP_TRAIL(first,last,sep_trail) \
395 if ((size_t)(last - first) > sizeof(sep_trail)-1 \
396 && !strncmp(first, sep_trail, sizeof(sep_trail)-1)) \
397 first += sizeof(sep_trail)-2
399 /* Returns the nominal length of the buffer assuming it is termcap format,
400 * i.e., the continuation sequence is treated as a single character ":".
402 * There are several implementations of termcap which read the text into a
403 * fixed-size buffer. Generally they strip the newlines from the text, but may
404 * not do it until after the buffer is read. Also, "tc=" resolution may be
405 * expanded in the same buffer. This function is useful for measuring the size
406 * of the best fixed-buffer implementation; the worst case may be much worse.
408 #ifdef TEST_TERMCAP_LENGTH
410 termcap_length(const char *src)
412 static const char pattern[] = ":\\\n\t:";
415 const char *const t = src + strlen(src);
417 while (*src != '\0') {
418 IGNORE_SEP_TRAIL(src, t, pattern);
425 #define termcap_length(src) strlen(src)
429 fmt_complex(char *src, int level)
433 bool if_then = strstr(src, "%?") != 0;
434 bool params = !if_then && (strlen(src) > 50) && (strstr(src, "%p") != 0);
436 while (*src != '\0') {
440 strncpy_DYN(&tmpbuf, src++, 1);
446 case 't': /* "then" */
447 case 'e': /* "else" */
450 tmpbuf.text[tmpbuf.used - 1] = '\n';
451 /* treat a "%e%?" as else-if, on the same level */
452 if (!strncmp(src, "e%?", 3)) {
453 for (n = 0; n < level; n++)
454 strncpy_DYN(&tmpbuf, "\t", 1);
455 strncpy_DYN(&tmpbuf, "%", 1);
456 strncpy_DYN(&tmpbuf, src, 3);
459 for (n = 0; n <= level; n++)
460 strncpy_DYN(&tmpbuf, "\t", 1);
461 strncpy_DYN(&tmpbuf, "%", 1);
462 strncpy_DYN(&tmpbuf, src, 1);
464 src = fmt_complex(src, level + 1);
465 } else if (level == 1) {
466 _nc_warning("%%%c without %%?", *src);
472 case ';': /* "endif" */
476 tmpbuf.text[tmpbuf.used - 1] = '\n';
477 for (n = 0; n < level; n++)
478 strncpy_DYN(&tmpbuf, "\t", 1);
479 strncpy_DYN(&tmpbuf, "%", 1);
480 strncpy_DYN(&tmpbuf, src++, 1);
483 _nc_warning("%%; without %%?");
487 if (percent && params) {
488 tmpbuf.text[tmpbuf.used - 1] = '\n';
489 for (n = 0; n <= level; n++)
490 strncpy_DYN(&tmpbuf, "\t", 1);
491 strncpy_DYN(&tmpbuf, "%", 1);
499 strncpy_DYN(&tmpbuf, src++, 1);
504 #define SAME_CAP(n,cap) (&tterm->Strings[n] == &cap)
507 fmt_entry(TERMTYPE *tterm,
510 bool suppress_untranslatable,
515 char buffer[MAX_TERMINFO_LENGTH];
517 NCURSES_CONST char *name;
519 PredIdx num_bools = 0;
520 PredIdx num_values = 0;
521 PredIdx num_strings = 0;
524 #define WRAP_CONCAT \
525 wrap_concat(buffer); \
528 len = 12; /* terminfo file-header */
532 pred = dump_predicate;
535 strcpy_DYN(&outbuf, 0);
537 column = INDENT; /* FIXME: workaround to prevent empty lines */
539 strcpy_DYN(&outbuf, tterm->term_names);
540 strcpy_DYN(&outbuf, separator);
541 column = outbuf.used;
545 for_each_boolean(j, tterm) {
547 name = ExtBoolname(tterm, i, bool_names);
549 if (!version_filter(BOOLEAN, i))
551 else if (isObsolete(outform, name))
554 predval = pred(BOOLEAN, i);
555 if (predval != FAIL) {
556 (void) strcpy(buffer, name);
558 (void) strcat(buffer, "@");
559 else if (i + 1 > num_bools)
565 if (column != INDENT)
568 for_each_number(j, tterm) {
570 name = ExtNumname(tterm, i, num_names);
572 if (!version_filter(NUMBER, i))
574 else if (isObsolete(outform, name))
577 predval = pred(NUMBER, i);
578 if (predval != FAIL) {
579 if (tterm->Numbers[i] < 0) {
580 sprintf(buffer, "%s@", name);
582 sprintf(buffer, "%s#%d", name, tterm->Numbers[i]);
583 if (i + 1 > num_values)
590 if (column != INDENT)
595 + strlen(tterm->term_names) + 1;
601 if (outform == F_TERMCAP) {
602 if (termcap_reset != ABSENT_STRING) {
603 if (init_3string != ABSENT_STRING
604 && !strcmp(init_3string, termcap_reset))
605 DISCARD(init_3string);
607 if (reset_2string != ABSENT_STRING
608 && !strcmp(reset_2string, termcap_reset))
609 DISCARD(reset_2string);
613 for_each_string(j, tterm) {
615 name = ExtStrname(tterm, i, str_names);
616 capability = tterm->Strings[i];
618 if (!version_filter(STRING, i))
620 else if (isObsolete(outform, name))
625 * Extended names can be longer than 2 characters, but termcap programs
626 * cannot read those (filter them out).
628 if (outform == F_TERMCAP && (strlen(name) > 2))
632 if (outform == F_TERMCAP) {
634 * Some older versions of vi want rmir/smir to be defined
635 * for ich/ich1 to work. If they're not defined, force
636 * them to be output as defined and empty.
638 if (PRESENT(insert_character) || PRESENT(parm_ich)) {
639 if (SAME_CAP(i, enter_insert_mode)
640 && enter_insert_mode == ABSENT_STRING) {
641 (void) strcpy(buffer, "im=");
646 if (SAME_CAP(i, exit_insert_mode)
647 && exit_insert_mode == ABSENT_STRING) {
648 (void) strcpy(buffer, "ei=");
654 * termcap applications such as screen will be confused if sgr0
655 * is translated to a string containing rmacs. Filter that out.
657 if (PRESENT(exit_attribute_mode)) {
658 if (SAME_CAP(i, exit_attribute_mode)) {
660 char *my_sgr = set_attributes;
662 set_attributes = save_sgr;
664 trimmed_sgr0 = _nc_trim_sgr0(tterm);
665 if (strcmp(capability, trimmed_sgr0))
666 capability = trimmed_sgr0;
668 set_attributes = my_sgr;
673 predval = pred(STRING, i);
676 if (predval != FAIL) {
677 if (capability != ABSENT_STRING
678 && i + 1 > num_strings)
681 if (!VALID_STRING(capability)) {
682 sprintf(buffer, "%s@", name);
684 } else if (outform == F_TERMCAP || outform == F_TCONVERR) {
685 int params = ((i < (int) SIZEOF(parametrized))
688 char *srccap = _nc_tic_expand(capability, TRUE, numbers);
689 char *cv = _nc_infotocap(name, srccap, params);
692 if (outform == F_TCONVERR) {
693 sprintf(buffer, "%s=!!! %s WILL NOT CONVERT !!!",
695 } else if (suppress_untranslatable) {
698 char *s = srccap, *d = buffer;
699 sprintf(d, "..%s=", name);
701 while ((*d = *s++) != 0) {
705 } else if (*d == '\\') {
712 sprintf(buffer, "%s=%s", name, cv);
714 len += strlen(capability) + 1;
717 char *src = _nc_tic_expand(capability,
718 outform == F_TERMINFO, numbers);
720 strcpy_DYN(&tmpbuf, 0);
721 strcpy_DYN(&tmpbuf, name);
722 strcpy_DYN(&tmpbuf, "=");
724 && (outform == F_TERMINFO
725 || outform == F_VARIABLE)) {
728 strcpy_DYN(&tmpbuf, src);
730 len += strlen(capability) + 1;
731 wrap_concat(tmpbuf.text);
735 /* e.g., trimmed_sgr0 */
736 if (capability != tterm->Strings[i])
739 len += num_strings * 2;
742 * This piece of code should be an effective inverse of the functions
743 * postprocess_terminfo and postprocess_terminfo in parse_entry.c.
744 * Much more work should be done on this to support dumping termcaps.
746 if (tversion == V_HPUX) {
748 (void) sprintf(buffer, "meml=%s", memory_lock);
752 (void) sprintf(buffer, "memu=%s", memory_unlock);
755 } else if (tversion == V_AIX) {
756 if (VALID_STRING(acs_chars)) {
758 const char *acstrans = "lqkxjmwuvtn";
760 char *tp, *sp, boxchars[11];
763 for (cp = acstrans; *cp; cp++) {
764 sp = strchr(acs_chars, *cp);
775 (void) strcpy(buffer, "box1=");
776 (void) strcat(buffer, _nc_tic_expand(boxchars,
777 outform == F_TERMINFO, numbers));
784 * kludge: trim off trailer to avoid an extra blank line
785 * in infocmp -u output when there are no string differences
788 bool trimmed = FALSE;
791 && outbuf.text[j - 1] == '\t'
792 && outbuf.text[j - 2] == '\n') {
796 && outbuf.text[j - 1] == ':'
797 && outbuf.text[j - 2] == '\t'
798 && outbuf.text[j - 3] == '\n'
799 && outbuf.text[j - 4] == '\\') {
804 outbuf.text[outbuf.used] = '\0';
809 fprintf(stderr, "num_bools = %d\n", num_bools);
810 fprintf(stderr, "num_values = %d\n", num_values);
811 fprintf(stderr, "num_strings = %d\n", num_strings);
812 fprintf(stderr, "term_names=%s, len=%d, strlen(outbuf)=%d, outbuf=%s\n",
813 tterm->term_names, len, outbuf.used, outbuf.text);
816 * Here's where we use infodump to trigger a more stringent length check
817 * for termcap-translation purposes.
818 * Return the length of the raw entry, without tc= expansions,
819 * It gives an idea of which entries are deadly to even *scan past*,
820 * as opposed to *use*.
822 return (infodump ? len : (int) termcap_length(outbuf.text));
826 kill_string(TERMTYPE *tterm, char *cap)
829 for (n = 0; n < NUM_STRINGS(tterm); ++n) {
830 if (cap == tterm->Strings[n]) {
831 tterm->Strings[n] = ABSENT_STRING;
839 find_string(TERMTYPE *tterm, char *name)
842 for (n = 0; n < NUM_STRINGS(tterm); ++n) {
843 if (version_filter(STRING, n)
844 && !strcmp(name, strnames[n])) {
845 char *cap = tterm->Strings[n];
846 if (VALID_STRING(cap)) {
852 return ABSENT_STRING;
856 * This is used to remove function-key labels from a termcap entry to
860 kill_labels(TERMTYPE *tterm, int target)
867 for (n = 0; n <= 10; ++n) {
868 sprintf(name, "lf%d", n);
869 if ((cap = find_string(tterm, name)) != ABSENT_STRING
870 && kill_string(tterm, cap)) {
871 target -= (strlen(cap) + 5);
881 * This is used to remove function-key definitions from a termcap entry to
885 kill_fkeys(TERMTYPE *tterm, int target)
892 for (n = 60; n >= 0; --n) {
893 sprintf(name, "kf%d", n);
894 if ((cap = find_string(tterm, name)) != ABSENT_STRING
895 && kill_string(tterm, cap)) {
896 target -= (strlen(cap) + 5);
905 #define FMT_ENTRY() \
906 fmt_entry(tterm, pred, \
907 (already_used > 0), \
908 suppress_untranslatable, \
911 #define SHOW_WHY if (!already_used) PRINTF
914 dump_entry(TERMTYPE *tterm,
915 bool suppress_untranslatable,
920 /* dump a single entry */
926 if (outform == F_TERMCAP || outform == F_TCONVERR) {
927 critlen = MAX_TERMCAP_LENGTH;
928 legend = "older termcap";
930 set_obsolete_termcaps(tterm);
932 critlen = MAX_TERMINFO_LENGTH;
936 critlen -= already_used;
938 save_sgr = set_attributes;
939 save_acsc = acs_chars;
941 if (((len = FMT_ENTRY()) > critlen)
943 if (!suppress_untranslatable) {
944 SHOW_WHY("# (untranslatable capabilities removed to fit entry within %d bytes)\n",
946 suppress_untranslatable = TRUE;
948 if ((len = FMT_ENTRY()) > critlen) {
950 * We pick on sgr because it's a nice long string capability that
951 * is really just an optimization hack. Another good candidate is
952 * acsc since it is both long and unused by BSD termcap.
954 bool changed = FALSE;
958 * Extended names are most likely function-key definitions. Drop
962 for (n = STRCOUNT; n < NUM_STRINGS(tterm); n++) {
963 char *name = ExtStrname(tterm, n, strnames);
965 if (VALID_STRING(tterm->Strings[n])) {
966 set_attributes = ABSENT_STRING;
967 /* we remove long names anyway - only report the short */
968 if (strlen(name) <= 2) {
969 SHOW_WHY("# (%s removed to fit entry within %d bytes)\n",
974 if ((len = FMT_ENTRY()) <= critlen)
979 if (VALID_STRING(set_attributes)) {
980 set_attributes = ABSENT_STRING;
981 SHOW_WHY("# (sgr removed to fit entry within %d bytes)\n",
985 if (!changed || ((len = FMT_ENTRY()) > critlen)) {
986 if (VALID_STRING(acs_chars)) {
987 acs_chars = ABSENT_STRING;
988 SHOW_WHY("# (acsc removed to fit entry within %d bytes)\n",
993 if (!changed || ((len = FMT_ENTRY()) > critlen)) {
994 int oldversion = tversion;
997 SHOW_WHY("# (terminfo-only capabilities suppressed to fit entry within %d bytes)\n",
1002 && kill_labels(tterm, len - critlen)) {
1003 SHOW_WHY("# (some labels capabilities suppressed to fit entry within %d bytes)\n",
1008 && kill_fkeys(tterm, len - critlen)) {
1009 SHOW_WHY("# (some function-key capabilities suppressed to fit entry within %d bytes)\n",
1013 if (len > critlen && !already_used) {
1014 (void) fprintf(stderr,
1015 "warning: %s entry is %d bytes long\n",
1016 _nc_first_name(tterm->term_names),
1018 SHOW_WHY("# WARNING: this entry, %d bytes long, may core-dump %s libraries!\n",
1019 already_used + len, legend);
1021 tversion = oldversion;
1023 set_attributes = save_sgr;
1024 acs_chars = save_acsc;
1028 (void) fputs(outbuf.text, stdout);
1033 dump_uses(const char *name, bool infodump)
1034 /* dump "use=" clauses in the appropriate format */
1036 char buffer[MAX_TERMINFO_LENGTH];
1038 strcpy_DYN(&outbuf, 0);
1039 (void) sprintf(buffer, "%s%s", infodump ? "use=" : "tc=", name);
1040 wrap_concat(buffer);
1041 (void) fputs(outbuf.text, stdout);
1046 compare_entry(void (*hook) (PredType t, PredIdx i, const char *name),
1047 TERMTYPE *tp GCC_UNUSED,
1049 /* compare two entries */
1052 NCURSES_CONST char *name;
1055 fputs(" comparing booleans.\n", stdout);
1056 for_each_boolean(j, tp) {
1057 i = BoolIndirect(j);
1058 name = ExtBoolname(tp, i, bool_names);
1060 if (isObsolete(outform, name))
1063 (*hook) (CMP_BOOLEAN, i, name);
1067 fputs(" comparing numbers.\n", stdout);
1068 for_each_number(j, tp) {
1070 name = ExtNumname(tp, i, num_names);
1072 if (isObsolete(outform, name))
1075 (*hook) (CMP_NUMBER, i, name);
1079 fputs(" comparing strings.\n", stdout);
1080 for_each_string(j, tp) {
1082 name = ExtStrname(tp, i, str_names);
1084 if (isObsolete(outform, name))
1087 (*hook) (CMP_STRING, i, name);
1090 /* (void) fputs(" comparing use entries.\n", stdout); */
1091 (*hook) (CMP_USE, 0, "use");
1095 #define NOTSET(s) ((s) == 0)
1098 * This bit of legerdemain turns all the terminfo variable names into
1099 * references to locations in the arrays Booleans, Numbers, and Strings ---
1100 * precisely what's needed.
1106 set_obsolete_termcaps(TERMTYPE *tp)
1108 #include "capdefaults.c"
1112 * Convert an alternate-character-set string to canonical form: sorted and
1116 repair_acsc(TERMTYPE *tp)
1118 if (VALID_STRING(acs_chars)) {
1124 bool fix_needed = FALSE;
1126 for (n = 0, source = 0; acs_chars[n] != 0; n++) {
1127 target = acs_chars[n];
1128 if (source >= target) {
1133 if (acs_chars[n + 1])
1137 memset(mapped, 0, sizeof(mapped));
1138 for (n = 0; acs_chars[n] != 0; n++) {
1139 source = acs_chars[n];
1140 if ((target = (unsigned char) acs_chars[n + 1]) != 0) {
1141 mapped[source] = target;
1147 for (n = m = 0; n < sizeof(mapped); n++) {
1150 acs_chars[m++] = mapped[n];
1154 acs_chars[m++] = extra; /* garbage in, garbage out */