1 /****************************************************************************
2 * Copyright (c) 1998-2002,2003 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.66 2003/05/24 22:43:59 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 */
65 /* indirection pointers for implementing sort and display modes */
66 static const int *bool_indirect
, *num_indirect
, *str_indirect
;
67 static NCURSES_CONST
char *const *bool_names
;
68 static NCURSES_CONST
char *const *num_names
;
69 static NCURSES_CONST
char *const *str_names
;
71 static const char *separator
, *trailer
;
73 /* cover various ports and variants of terminfo */
74 #define V_ALLCAPS 0 /* all capabilities (SVr4, XSI, ncurses) */
75 #define V_SVR1 1 /* SVR1, Ultrix */
76 #define V_HPUX 2 /* HP/UX */
77 #define V_AIX 3 /* AIX */
78 #define V_BSD 4 /* BSD */
81 #define OBSOLETE(n) (!_nc_user_definable && (n[0] == 'O' && n[1] == 'T'))
83 #define OBSOLETE(n) (n[0] == 'O' && n[1] == 'T')
86 #define isObsolete(f,n) ((f == F_TERMINFO || f == F_VARIABLE) && OBSOLETE(n))
89 #define BoolIndirect(j) ((j >= BOOLCOUNT) ? (j) : ((sortmode == S_NOSORT) ? j : bool_indirect[j]))
90 #define NumIndirect(j) ((j >= NUMCOUNT) ? (j) : ((sortmode == S_NOSORT) ? j : num_indirect[j]))
91 #define StrIndirect(j) ((j >= STRCOUNT) ? (j) : ((sortmode == S_NOSORT) ? j : str_indirect[j]))
93 #define BoolIndirect(j) ((sortmode == S_NOSORT) ? (j) : bool_indirect[j])
94 #define NumIndirect(j) ((sortmode == S_NOSORT) ? (j) : num_indirect[j])
95 #define StrIndirect(j) ((sortmode == S_NOSORT) ? (j) : str_indirect[j])
99 strncpy_DYN(DYNBUF
* dst
, const char *src
, size_t need
)
101 size_t want
= need
+ dst
->used
+ 1;
102 if (want
> dst
->size
) {
103 dst
->size
+= (want
+ 1024); /* be generous */
104 dst
->text
= typeRealloc(char, dst
->size
, dst
->text
);
106 (void) strncpy(dst
->text
+ dst
->used
, src
, need
);
108 dst
->text
[dst
->used
] = 0;
112 strcpy_DYN(DYNBUF
* dst
, const char *src
)
118 strncpy_DYN(dst
, src
, strlen(src
));
134 _nc_leaks_dump_entry(void)
142 nametrans(const char *name
)
143 /* translate a capability name from termcap to terminfo */
145 const struct name_table_entry
*np
;
147 if ((np
= _nc_find_entry(name
, _nc_get_hash_table(0))) != 0)
148 switch (np
->nte_type
) {
150 if (bool_from_termcap
[np
->nte_index
])
151 return (boolcodes
[np
->nte_index
]);
155 if (num_from_termcap
[np
->nte_index
])
156 return (numcodes
[np
->nte_index
]);
160 if (str_from_termcap
[np
->nte_index
])
161 return (strcodes
[np
->nte_index
]);
169 dump_init(const char *version
, int mode
, int sort
, int twidth
, int traceval
,
171 /* set up for entry display */
178 tversion
= V_ALLCAPS
;
179 else if (!strcmp(version
, "SVr1") || !strcmp(version
, "SVR1")
180 || !strcmp(version
, "Ultrix"))
182 else if (!strcmp(version
, "HP"))
184 else if (!strcmp(version
, "AIX"))
186 else if (!strcmp(version
, "BSD"))
189 tversion
= V_ALLCAPS
;
191 /* implement display modes */
192 switch (outform
= mode
) {
195 bool_names
= boolnames
;
196 num_names
= numnames
;
197 str_names
= strnames
;
198 separator
= twidth
? ", " : ",";
203 bool_names
= boolfnames
;
204 num_names
= numfnames
;
205 str_names
= strfnames
;
206 separator
= twidth
? ", " : ",";
212 bool_names
= boolcodes
;
213 num_names
= numcodes
;
214 str_names
= strcodes
;
220 /* implement sort modes */
221 switch (sortmode
= sort
) {
224 (void) fprintf(stderr
,
225 "%s: sorting by term structure order\n", _nc_progname
);
230 (void) fprintf(stderr
,
231 "%s: sorting by terminfo name order\n", _nc_progname
);
232 bool_indirect
= bool_terminfo_sort
;
233 num_indirect
= num_terminfo_sort
;
234 str_indirect
= str_terminfo_sort
;
239 (void) fprintf(stderr
,
240 "%s: sorting by C variable order\n", _nc_progname
);
241 bool_indirect
= bool_variable_sort
;
242 num_indirect
= num_variable_sort
;
243 str_indirect
= str_variable_sort
;
248 (void) fprintf(stderr
,
249 "%s: sorting by termcap name order\n", _nc_progname
);
250 bool_indirect
= bool_termcap_sort
;
251 num_indirect
= num_termcap_sort
;
252 str_indirect
= str_termcap_sort
;
257 (void) fprintf(stderr
,
258 "%s: width = %d, tversion = %d, outform = %d\n",
259 _nc_progname
, width
, tversion
, outform
);
262 static TERMTYPE
*cur_type
;
265 dump_predicate(int type
, int idx
)
266 /* predicate function to use for ordinary decompilation */
270 return (cur_type
->Booleans
[idx
] == FALSE
)
271 ? FAIL
: cur_type
->Booleans
[idx
];
274 return (cur_type
->Numbers
[idx
] == ABSENT_NUMERIC
)
275 ? FAIL
: cur_type
->Numbers
[idx
];
278 return (cur_type
->Strings
[idx
] != ABSENT_STRING
)
282 return (FALSE
); /* pacify compiler */
285 static void set_obsolete_termcaps(TERMTYPE
* tp
);
287 /* is this the index of a function key string? */
288 #define FNKEY(i) (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))
291 * If we configure with a different Caps file, the offsets into the arrays
292 * will change. So we use an address expression.
294 #define BOOL_IDX(name) (&(name) - &(CUR Booleans[0]))
295 #define NUM_IDX(name) (&(name) - &(CUR Numbers[0]))
296 #define STR_IDX(name) (&(name) - &(CUR Strings[0]))
299 version_filter(int type
, int idx
)
300 /* filter out capabilities we may want to suppress */
303 case V_ALLCAPS
: /* SVr4, XSI Curses */
306 case V_SVR1
: /* System V Release 1, Ultrix */
309 return ((idx
<= BOOL_IDX(xon_xoff
)) ? TRUE
: FALSE
);
311 return ((idx
<= NUM_IDX(width_status_line
)) ? TRUE
: FALSE
);
313 return ((idx
<= STR_IDX(prtr_non
)) ? TRUE
: FALSE
);
317 case V_HPUX
: /* Hewlett-Packard */
320 return ((idx
<= BOOL_IDX(xon_xoff
)) ? TRUE
: FALSE
);
322 return ((idx
<= NUM_IDX(label_width
)) ? TRUE
: FALSE
);
324 if (idx
<= STR_IDX(prtr_non
))
326 else if (FNKEY(idx
)) /* function keys */
328 else if (idx
== STR_IDX(plab_norm
)
329 || idx
== STR_IDX(label_on
)
330 || idx
== STR_IDX(label_off
))
337 case V_AIX
: /* AIX */
340 return ((idx
<= BOOL_IDX(xon_xoff
)) ? TRUE
: FALSE
);
342 return ((idx
<= NUM_IDX(width_status_line
)) ? TRUE
: FALSE
);
344 if (idx
<= STR_IDX(prtr_non
))
346 else if (FNKEY(idx
)) /* function keys */
353 case V_BSD
: /* BSD */
356 return bool_from_termcap
[idx
];
358 return num_from_termcap
[idx
];
360 return str_from_termcap
[idx
];
365 return (FALSE
); /* pacify the compiler */
372 strcpy_DYN(&outbuf
, trailer
);
377 wrap_concat(const char *src
)
379 int need
= strlen(src
);
380 int want
= strlen(separator
) + need
;
383 && column
+ want
> width
) {
386 strcpy_DYN(&outbuf
, src
);
387 strcpy_DYN(&outbuf
, separator
);
391 #define IGNORE_SEP_TRAIL(first,last,sep_trail) \
392 if ((size_t)(last - first) > sizeof(sep_trail)-1 \
393 && !strncmp(first, sep_trail, sizeof(sep_trail)-1)) \
394 first += sizeof(sep_trail)-2
396 /* Returns the nominal length of the buffer assuming it is termcap format,
397 * i.e., the continuation sequence is treated as a single character ":".
399 * There are several implementations of termcap which read the text into a
400 * fixed-size buffer. Generally they strip the newlines from the text, but may
401 * not do it until after the buffer is read. Also, "tc=" resolution may be
402 * expanded in the same buffer. This function is useful for measuring the size
403 * of the best fixed-buffer implementation; the worst case may be much worse.
405 #ifdef TEST_TERMCAP_LENGTH
407 termcap_length(const char *src
)
409 static const char pattern
[] = ":\\\n\t:";
412 const char *const t
= src
+ strlen(src
);
414 while (*src
!= '\0') {
415 IGNORE_SEP_TRAIL(src
, t
, pattern
);
422 #define termcap_length(src) strlen(src)
426 fmt_complex(char *src
, int level
)
430 bool if_then
= strstr(src
, "%?") != 0;
431 bool params
= !if_then
&& (strlen(src
) > 50) && (strstr(src
, "%p") != 0);
433 while (*src
!= '\0') {
437 strncpy_DYN(&tmpbuf
, src
++, 1);
443 case 't': /* "then" */
444 case 'e': /* "else" */
447 tmpbuf
.text
[tmpbuf
.used
- 1] = '\n';
448 /* treat a "%e%?" as else-if, on the same level */
449 if (!strncmp(src
, "e%?", 3)) {
450 for (n
= 0; n
< level
; n
++)
451 strncpy_DYN(&tmpbuf
, "\t", 1);
452 strncpy_DYN(&tmpbuf
, "%", 1);
453 strncpy_DYN(&tmpbuf
, src
, 3);
456 for (n
= 0; n
<= level
; n
++)
457 strncpy_DYN(&tmpbuf
, "\t", 1);
458 strncpy_DYN(&tmpbuf
, "%", 1);
459 strncpy_DYN(&tmpbuf
, src
, 1);
461 src
= fmt_complex(src
, level
+ 1);
462 } else if (level
== 1) {
463 _nc_warning("%%%c without %%?", *src
);
469 case ';': /* "endif" */
473 tmpbuf
.text
[tmpbuf
.used
- 1] = '\n';
474 for (n
= 0; n
< level
; n
++)
475 strncpy_DYN(&tmpbuf
, "\t", 1);
476 strncpy_DYN(&tmpbuf
, "%", 1);
477 strncpy_DYN(&tmpbuf
, src
++, 1);
480 _nc_warning("%%; without %%?");
484 if (percent
&& params
) {
485 tmpbuf
.text
[tmpbuf
.used
- 1] = '\n';
486 for (n
= 0; n
<= level
; n
++)
487 strncpy_DYN(&tmpbuf
, "\t", 1);
488 strncpy_DYN(&tmpbuf
, "%", 1);
496 strncpy_DYN(&tmpbuf
, src
++, 1);
502 fmt_entry(TERMTYPE
* tterm
,
503 int (*pred
) (int type
, int idx
),
505 bool suppress_untranslatable
,
510 char buffer
[MAX_TERMINFO_LENGTH
];
511 NCURSES_CONST
char *name
;
518 #define WRAP_CONCAT \
519 wrap_concat(buffer); \
522 len
= 12; /* terminfo file-header */
526 pred
= dump_predicate
;
529 strcpy_DYN(&outbuf
, 0);
531 column
= INDENT
; /* FIXME: workaround to prevent empty lines */
533 strcpy_DYN(&outbuf
, tterm
->term_names
);
534 strcpy_DYN(&outbuf
, separator
);
535 column
= outbuf
.used
;
539 for_each_boolean(j
, tterm
) {
541 name
= ExtBoolname(tterm
, i
, bool_names
);
543 if (!version_filter(BOOLEAN
, i
))
545 else if (isObsolete(outform
, name
))
548 predval
= pred(BOOLEAN
, i
);
549 if (predval
!= FAIL
) {
550 (void) strcpy(buffer
, name
);
552 (void) strcat(buffer
, "@");
553 else if (i
+ 1 > num_bools
)
559 if (column
!= INDENT
)
562 for_each_number(j
, tterm
) {
564 name
= ExtNumname(tterm
, i
, num_names
);
566 if (!version_filter(NUMBER
, i
))
568 else if (isObsolete(outform
, name
))
571 predval
= pred(NUMBER
, i
);
572 if (predval
!= FAIL
) {
573 if (tterm
->Numbers
[i
] < 0) {
574 sprintf(buffer
, "%s@", name
);
576 sprintf(buffer
, "%s#%d", name
, tterm
->Numbers
[i
]);
577 if (i
+ 1 > num_values
)
584 if (column
!= INDENT
)
589 + strlen(tterm
->term_names
) + 1;
595 if (outform
== F_TERMCAP
) {
596 if (termcap_reset
!= ABSENT_STRING
) {
597 if (init_3string
!= ABSENT_STRING
598 && !strcmp(init_3string
, termcap_reset
))
599 DISCARD(init_3string
);
601 if (reset_2string
!= ABSENT_STRING
602 && !strcmp(reset_2string
, termcap_reset
))
603 DISCARD(reset_2string
);
607 for_each_string(j
, tterm
) {
609 name
= ExtStrname(tterm
, i
, str_names
);
611 if (!version_filter(STRING
, i
))
613 else if (isObsolete(outform
, name
))
617 * Some older versions of vi want rmir/smir to be defined
618 * for ich/ich1 to work. If they're not defined, force
619 * them to be output as defined and empty.
621 if (outform
== F_TERMCAP
) {
622 if (insert_character
|| parm_ich
) {
623 if (&tterm
->Strings
[i
] == &enter_insert_mode
624 && enter_insert_mode
== ABSENT_STRING
) {
625 (void) strcpy(buffer
, "im=");
630 if (&tterm
->Strings
[i
] == &exit_insert_mode
631 && exit_insert_mode
== ABSENT_STRING
) {
632 (void) strcpy(buffer
, "ei=");
639 predval
= pred(STRING
, i
);
642 if (predval
!= FAIL
) {
643 if (tterm
->Strings
[i
] != ABSENT_STRING
644 && i
+ 1 > num_strings
)
647 if (!VALID_STRING(tterm
->Strings
[i
])) {
648 sprintf(buffer
, "%s@", name
);
650 } else if (outform
== F_TERMCAP
|| outform
== F_TCONVERR
) {
651 int params
= ((i
< (int) SIZEOF(parametrized
))
654 char *srccap
= _nc_tic_expand(tterm
->Strings
[i
], TRUE
, numbers
);
655 char *cv
= _nc_infotocap(name
, srccap
, params
);
658 if (outform
== F_TCONVERR
) {
659 sprintf(buffer
, "%s=!!! %s WILL NOT CONVERT !!!",
661 } else if (suppress_untranslatable
) {
664 char *s
= srccap
, *d
= buffer
;
665 sprintf(d
, "..%s=", name
);
667 while ((*d
= *s
++) != 0) {
671 } else if (*d
== '\\') {
678 sprintf(buffer
, "%s=%s", name
, cv
);
680 len
+= strlen(tterm
->Strings
[i
]) + 1;
683 char *src
= _nc_tic_expand(tterm
->Strings
[i
],
684 outform
== F_TERMINFO
, numbers
);
686 strcpy_DYN(&tmpbuf
, 0);
687 strcpy_DYN(&tmpbuf
, name
);
688 strcpy_DYN(&tmpbuf
, "=");
690 && (outform
== F_TERMINFO
691 || outform
== F_VARIABLE
)) {
694 strcpy_DYN(&tmpbuf
, src
);
696 len
+= strlen(tterm
->Strings
[i
]) + 1;
697 wrap_concat(tmpbuf
.text
);
702 len
+= num_strings
* 2;
705 * This piece of code should be an effective inverse of the functions
706 * postprocess_terminfo and postprocess_terminfo in parse_entry.c.
707 * Much more work should be done on this to support dumping termcaps.
709 if (tversion
== V_HPUX
) {
711 (void) sprintf(buffer
, "meml=%s", memory_lock
);
715 (void) sprintf(buffer
, "memu=%s", memory_unlock
);
718 } else if (tversion
== V_AIX
) {
719 if (VALID_STRING(acs_chars
)) {
721 const char *acstrans
= "lqkxjmwuvtn";
723 char *tp
, *sp
, boxchars
[11];
726 for (cp
= acstrans
; *cp
; cp
++) {
727 sp
= strchr(acs_chars
, *cp
);
738 (void) strcpy(buffer
, "box1=");
739 (void) strcat(buffer
, _nc_tic_expand(boxchars
,
740 outform
== F_TERMINFO
, numbers
));
747 * kludge: trim off trailer to avoid an extra blank line
748 * in infocmp -u output when there are no string differences
751 bool trimmed
= FALSE
;
754 && outbuf
.text
[j
- 1] == '\t'
755 && outbuf
.text
[j
- 2] == '\n') {
759 && outbuf
.text
[j
- 1] == ':'
760 && outbuf
.text
[j
- 2] == '\t'
761 && outbuf
.text
[j
- 3] == '\n'
762 && outbuf
.text
[j
- 4] == '\\') {
767 outbuf
.text
[outbuf
.used
] = '\0';
772 fprintf(stderr
, "num_bools = %d\n", num_bools
);
773 fprintf(stderr
, "num_values = %d\n", num_values
);
774 fprintf(stderr
, "num_strings = %d\n", num_strings
);
775 fprintf(stderr
, "term_names=%s, len=%d, strlen(outbuf)=%d, outbuf=%s\n",
776 tterm
->term_names
, len
, outbuf
.used
, outbuf
.text
);
779 * Here's where we use infodump to trigger a more stringent length check
780 * for termcap-translation purposes.
781 * Return the length of the raw entry, without tc= expansions,
782 * It gives an idea of which entries are deadly to even *scan past*,
783 * as opposed to *use*.
785 return (infodump
? len
: (int) termcap_length(outbuf
.text
));
789 kill_string(TERMTYPE
* tterm
, char *cap
)
792 for (n
= 0; n
< NUM_STRINGS(tterm
); ++n
) {
793 if (cap
== tterm
->Strings
[n
]) {
794 tterm
->Strings
[n
] = ABSENT_STRING
;
802 find_string(TERMTYPE
* tterm
, char *name
)
805 for (n
= 0; n
< NUM_STRINGS(tterm
); ++n
) {
806 if (version_filter(STRING
, n
)
807 && !strcmp(name
, strnames
[n
])) {
808 char *cap
= tterm
->Strings
[n
];
809 if (VALID_STRING(cap
)) {
815 return ABSENT_STRING
;
819 * This is used to remove function-key labels from a termcap entry to
823 kill_labels(TERMTYPE
* tterm
, int target
)
830 for (n
= 0; n
<= 10; ++n
) {
831 sprintf(name
, "lf%d", n
);
832 if ((cap
= find_string(tterm
, name
)) != ABSENT_STRING
833 && kill_string(tterm
, cap
)) {
834 target
-= (strlen(cap
) + 5);
844 * This is used to remove function-key definitions from a termcap entry to
848 kill_fkeys(TERMTYPE
* tterm
, int target
)
855 for (n
= 60; n
>= 0; --n
) {
856 sprintf(name
, "kf%d", n
);
857 if ((cap
= find_string(tterm
, name
)) != ABSENT_STRING
858 && kill_string(tterm
, cap
)) {
859 target
-= (strlen(cap
) + 5);
868 #define FMT_ENTRY() \
869 fmt_entry(tterm, pred, \
870 (already_used > 0), \
871 suppress_untranslatable, \
874 #define SHOW_WHY if (!already_used) PRINTF
877 dump_entry(TERMTYPE
* tterm
,
878 bool suppress_untranslatable
,
882 int (*pred
) (int type
, int idx
))
883 /* dump a single entry */
889 if (outform
== F_TERMCAP
|| outform
== F_TCONVERR
) {
890 critlen
= MAX_TERMCAP_LENGTH
;
891 legend
= "older termcap";
893 set_obsolete_termcaps(tterm
);
895 critlen
= MAX_TERMINFO_LENGTH
;
899 critlen
-= already_used
;
901 if (((len
= FMT_ENTRY()) > critlen
)
903 if (!suppress_untranslatable
) {
904 SHOW_WHY("# (untranslatable capabilities removed to fit entry within %d bytes)\n",
906 suppress_untranslatable
= TRUE
;
908 if ((len
= FMT_ENTRY()) > critlen
) {
910 * We pick on sgr because it's a nice long string capability that
911 * is really just an optimization hack. Another good candidate is
912 * acsc since it is both long and unused by BSD termcap.
914 char *oldsgr
= set_attributes
;
915 char *oldacsc
= acs_chars
;
916 bool changed
= FALSE
;
918 if (VALID_STRING(set_attributes
)) {
919 set_attributes
= ABSENT_STRING
;
920 SHOW_WHY("# (sgr removed to fit entry within %d bytes)\n",
924 if (!changed
|| ((len
= FMT_ENTRY()) > critlen
)) {
925 if (VALID_STRING(acs_chars
)) {
926 acs_chars
= ABSENT_STRING
;
927 SHOW_WHY("# (acsc removed to fit entry within %d bytes)\n",
932 if (!changed
|| ((len
= FMT_ENTRY()) > critlen
)) {
933 int oldversion
= tversion
;
936 SHOW_WHY("# (terminfo-only capabilities suppressed to fit entry within %d bytes)\n",
941 && kill_labels(tterm
, len
- critlen
)) {
942 SHOW_WHY("# (some labels capabilities suppressed to fit entry within %d bytes)\n",
947 && kill_fkeys(tterm
, len
- critlen
)) {
948 SHOW_WHY("# (some function-key capabilities suppressed to fit entry within %d bytes)\n",
952 if (len
> critlen
&& !already_used
) {
953 (void) fprintf(stderr
,
954 "warning: %s entry is %d bytes long\n",
955 _nc_first_name(tterm
->term_names
),
957 SHOW_WHY("# WARNING: this entry, %d bytes long, may core-dump %s libraries!\n",
958 already_used
+ len
, legend
);
960 tversion
= oldversion
;
962 set_attributes
= oldsgr
;
967 (void) fputs(outbuf
.text
, stdout
);
972 dump_uses(const char *name
, bool infodump
)
973 /* dump "use=" clauses in the appropriate format */
975 char buffer
[MAX_TERMINFO_LENGTH
];
977 strcpy_DYN(&outbuf
, 0);
978 (void) sprintf(buffer
, "%s%s", infodump
? "use=" : "tc=", name
);
980 (void) fputs(outbuf
.text
, stdout
);
985 compare_entry(void (*hook
) (int t
, int i
, const char *name
), TERMTYPE
* tp
986 GCC_UNUSED
, bool quiet
)
987 /* compare two entries */
990 NCURSES_CONST
char *name
;
993 fputs(" comparing booleans.\n", stdout
);
994 for_each_boolean(j
, tp
) {
996 name
= ExtBoolname(tp
, i
, bool_names
);
998 if (isObsolete(outform
, name
))
1001 (*hook
) (CMP_BOOLEAN
, i
, name
);
1005 fputs(" comparing numbers.\n", stdout
);
1006 for_each_number(j
, tp
) {
1008 name
= ExtNumname(tp
, i
, num_names
);
1010 if (isObsolete(outform
, name
))
1013 (*hook
) (CMP_NUMBER
, i
, name
);
1017 fputs(" comparing strings.\n", stdout
);
1018 for_each_string(j
, tp
) {
1020 name
= ExtStrname(tp
, i
, str_names
);
1022 if (isObsolete(outform
, name
))
1025 (*hook
) (CMP_STRING
, i
, name
);
1028 /* (void) fputs(" comparing use entries.\n", stdout); */
1029 (*hook
) (CMP_USE
, 0, "use");
1033 #define NOTSET(s) ((s) == 0)
1036 * This bit of legerdemain turns all the terminfo variable names into
1037 * references to locations in the arrays Booleans, Numbers, and Strings ---
1038 * precisely what's needed.
1044 set_obsolete_termcaps(TERMTYPE
* tp
)
1046 #include "capdefaults.c"
1050 * Convert an alternate-character-set string to canonical form: sorted and
1054 repair_acsc(TERMTYPE
* tp
)
1056 if (VALID_STRING(acs_chars
)) {
1062 bool fix_needed
= FALSE
;
1064 for (n
= 0, source
= 0; acs_chars
[n
] != 0; n
++) {
1065 target
= acs_chars
[n
];
1066 if (source
>= target
) {
1071 if (acs_chars
[n
+ 1])
1075 memset(mapped
, 0, sizeof(mapped
));
1076 for (n
= 0; acs_chars
[n
] != 0; n
++) {
1077 source
= acs_chars
[n
];
1078 if ((target
= (unsigned char) acs_chars
[n
+ 1]) != 0) {
1079 mapped
[source
] = target
;
1085 for (n
= m
= 0; n
< sizeof(mapped
); n
++) {
1088 acs_chars
[m
++] = mapped
[n
];
1092 acs_chars
[m
++] = extra
; /* garbage in, garbage out */