]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/tinfo/comp_parse.c
ncurses 6.3 - patch 20220402
[ncurses.git] / ncurses / tinfo / comp_parse.c
1 /****************************************************************************
2  * Copyright 2018-2021,2022 Thomas E. Dickey                                *
3  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
4  *                                                                          *
5  * Permission is hereby granted, free of charge, to any person obtaining a  *
6  * copy of this software and associated documentation files (the            *
7  * "Software"), to deal in the Software without restriction, including      *
8  * without limitation the rights to use, copy, modify, merge, publish,      *
9  * distribute, distribute with modifications, sublicense, and/or sell       *
10  * copies of the Software, and to permit persons to whom the Software is    *
11  * furnished to do so, subject to the following conditions:                 *
12  *                                                                          *
13  * The above copyright notice and this permission notice shall be included  *
14  * in all copies or substantial portions of the Software.                   *
15  *                                                                          *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23  *                                                                          *
24  * Except as contained in this notice, the name(s) of the above copyright   *
25  * holders shall not be used in advertising or otherwise to promote the     *
26  * sale, use or other dealings in this Software without prior written       *
27  * authorization.                                                           *
28  ****************************************************************************/
29
30 /****************************************************************************
31  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
32  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
33  *     and: Thomas E. Dickey                        1996-on                 *
34  ****************************************************************************/
35
36 /*
37  *      comp_parse.c -- parser driver loop and use handling.
38  *
39  *      Use this code by calling _nc_read_entry_source() on as many source
40  *      files as you like (either terminfo or termcap syntax).  If you
41  *      want use-resolution, call _nc_resolve_uses2().  To free the list
42  *      storage, do _nc_free_entries().
43  */
44
45 #include <curses.priv.h>
46
47 #include <ctype.h>
48
49 #include <tic.h>
50
51 MODULE_ID("$Id: comp_parse.c,v 1.114 2022/04/02 22:13:54 tom Exp $")
52
53 static void sanity_check2(TERMTYPE2 *, bool);
54 NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2) (TERMTYPE2 *, bool) = sanity_check2;
55
56 static void fixup_acsc(TERMTYPE2 *, int);
57
58 static void
59 enqueue(ENTRY * ep)
60 /* add an entry to the in-core list */
61 {
62     ENTRY *newp = _nc_copy_entry(ep);
63
64     if (newp == 0)
65         _nc_err_abort(MSG_NO_MEMORY);
66
67     newp->last = _nc_tail;
68     _nc_tail = newp;
69
70     newp->next = 0;
71     if (newp->last)
72         newp->last->next = newp;
73 }
74
75 #define NAMEBUFFER_SIZE (MAX_NAME_SIZE + 2)
76
77 static char *
78 force_bar(char *dst, char *src)
79 {
80     if (strchr(src, '|') == 0) {
81         size_t len = strlen(src);
82         if (len > MAX_NAME_SIZE)
83             len = MAX_NAME_SIZE;
84         _nc_STRNCPY(dst, src, MAX_NAME_SIZE);
85         _nc_STRCPY(dst + len, "|", NAMEBUFFER_SIZE - len);
86         src = dst;
87     }
88     return src;
89 }
90 #define ForceBar(dst, src) ((strchr(src, '|') == 0) ? force_bar(dst, src) : src)
91
92 #if NCURSES_USE_TERMCAP && NCURSES_XNAMES
93 static char *
94 skip_index(char *name)
95 {
96     char *bar = strchr(name, '|');
97
98     if (bar != 0 && (bar - name) == 2)
99         name = bar + 1;
100
101     return name;
102 }
103 #endif
104
105 static bool
106 check_collisions(char *n1, char *n2, int counter)
107 {
108     char *pstart, *qstart, *pend, *qend;
109     char nc1[NAMEBUFFER_SIZE];
110     char nc2[NAMEBUFFER_SIZE];
111
112     n1 = ForceBar(nc1, n1);
113     n2 = ForceBar(nc2, n2);
114
115 #if NCURSES_USE_TERMCAP && NCURSES_XNAMES
116     if ((_nc_syntax == SYN_TERMCAP) && _nc_user_definable) {
117         n1 = skip_index(n1);
118         n2 = skip_index(n2);
119     }
120 #endif
121
122     for (pstart = n1; (pend = strchr(pstart, '|')); pstart = pend + 1) {
123         for (qstart = n2; (qend = strchr(qstart, '|')); qstart = qend + 1) {
124             if ((pend - pstart == qend - qstart)
125                 && memcmp(pstart, qstart, (size_t) (pend - pstart)) == 0) {
126                 if (counter > 0)
127                     (void) fprintf(stderr, "Name collision '%.*s' between\n",
128                                    (int) (pend - pstart), pstart);
129                 return (TRUE);
130             }
131         }
132     }
133
134     return (FALSE);
135 }
136
137 static char *
138 next_name(char *name)
139 {
140     if (*name != '\0')
141         ++name;
142     return name;
143 }
144
145 static char *
146 name_ending(char *name)
147 {
148     if (*name == '\0') {
149         name = 0;
150     } else {
151         while (*name != '\0' && *name != '|')
152             ++name;
153     }
154     return name;
155 }
156
157 /*
158  * Essentially, find the conflict reported in check_collisions() and remove
159  * it from the second name, unless that happens to be the last alias.
160  */
161 static bool
162 remove_collision(char *n1, char *n2)
163 {
164     char *p2 = n2;
165     char *pstart, *qstart, *pend, *qend;
166     bool removed = FALSE;
167
168 #if NCURSES_USE_TERMCAP && NCURSES_XNAMES
169     if ((_nc_syntax == SYN_TERMCAP) && _nc_user_definable) {
170         n1 = skip_index(n1);
171         p2 = n2 = skip_index(n2);
172     }
173 #endif
174
175     for (pstart = n1; (pend = name_ending(pstart)); pstart = next_name(pend)) {
176         for (qstart = n2; (qend = name_ending(qstart)); qstart = next_name(qend)) {
177             if ((pend - pstart == qend - qstart)
178                 && memcmp(pstart, qstart, (size_t) (pend - pstart)) == 0) {
179                 if (qstart != p2 || *qend == '|') {
180                     if (*qend == '|')
181                         ++qend;
182                     while ((*qstart++ = *qend++) != '\0') ;
183                     fprintf(stderr, "...now\t%s\n", p2);
184                     removed = TRUE;
185                 } else {
186                     fprintf(stderr, "Cannot remove alias '%.*s'\n",
187                             (int) (qend - qstart), qstart);
188                 }
189                 break;
190             }
191         }
192     }
193
194     return removed;
195 }
196
197 /* do any of the aliases in a pair of terminal names match? */
198 NCURSES_EXPORT(bool)
199 _nc_entry_match(char *n1, char *n2)
200 {
201     return check_collisions(n1, n2, 0);
202 }
203
204 /****************************************************************************
205  *
206  * Entry compiler and resolution logic
207  *
208  ****************************************************************************/
209
210 NCURSES_EXPORT(void)
211 _nc_read_entry_source(FILE *fp, char *buf,
212                       int literal, bool silent,
213                       bool(*hook) (ENTRY *))
214 /* slurp all entries in the given file into core */
215 {
216     ENTRY thisentry;
217     bool oldsuppress = _nc_suppress_warnings;
218     int immediate = 0;
219
220     if (silent)
221         _nc_suppress_warnings = TRUE;   /* shut the lexer up, too */
222
223     _nc_reset_input(fp, buf);
224     for (;;) {
225         memset(&thisentry, 0, sizeof(thisentry));
226         if (_nc_parse_entry(&thisentry, literal, silent) == ERR)
227             break;
228         if (!isalnum(UChar(thisentry.tterm.term_names[0])))
229             _nc_err_abort("terminal names must start with letter or digit");
230
231         /*
232          * This can be used for immediate compilation of entries with no "use="
233          * references to disk.  That avoids consuming a lot of memory when the
234          * resolution code could fetch entries off disk.
235          */
236         if (hook != NULLHOOK && (*hook) (&thisentry)) {
237             immediate++;
238         } else {
239             enqueue(&thisentry);
240             /*
241              * The enqueued entry is copied with _nc_copy_termtype(), so we can
242              * free some of the data from thisentry, i.e., the arrays.
243              */
244             FreeIfNeeded(thisentry.tterm.Booleans);
245             FreeIfNeeded(thisentry.tterm.Numbers);
246             FreeIfNeeded(thisentry.tterm.Strings);
247 #if NCURSES_XNAMES
248             FreeIfNeeded(thisentry.tterm.ext_Names);
249 #endif
250         }
251     }
252
253     if (_nc_tail) {
254         /* set up the head pointer */
255         for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last)
256             continue;
257
258         DEBUG(1, ("head = %s", _nc_head->tterm.term_names));
259         DEBUG(1, ("tail = %s", _nc_tail->tterm.term_names));
260     }
261 #ifdef TRACE
262     else if (!immediate)
263         DEBUG(1, ("no entries parsed"));
264 #endif
265
266     _nc_suppress_warnings = oldsuppress;
267 }
268
269 #if NCURSES_XNAMES
270 static unsigned
271 find_capname(TERMTYPE2 *p, const char *name)
272 {
273     unsigned num_names = NUM_EXT_NAMES(p);
274     unsigned n;
275     if (name != 0) {
276         for (n = 0; n < num_names; ++n) {
277             if (!strcmp(p->ext_Names[n], name))
278                 break;
279         }
280     } else {
281         n = num_names + 1;
282     }
283     return n;
284 }
285
286 static int
287 extended_captype(TERMTYPE2 *p, unsigned which)
288 {
289     int result = UNDEF;
290     unsigned limit = 0;
291     limit += p->ext_Booleans;
292     if (limit != 0 && which < limit) {
293         result = BOOLEAN;
294     } else {
295         limit += p->ext_Numbers;
296         if (limit != 0 && which < limit) {
297             result = NUMBER;
298         } else {
299             limit += p->ext_Strings;
300             if (limit != 0 && which < limit) {
301                 result = ((p->Strings[STRCOUNT + which] != CANCELLED_STRING)
302                           ? STRING
303                           : CANCEL);
304             } else if (which >= limit) {
305                 result = CANCEL;
306             }
307         }
308     }
309     return result;
310 }
311
312 static const char *
313 name_of_captype(int which)
314 {
315     const char *result = "?";
316     switch (which) {
317     case BOOLEAN:
318         result = "boolean";
319         break;
320     case NUMBER:
321         result = "number";
322         break;
323     case STRING:
324         result = "string";
325         break;
326     }
327     return result;
328 }
329
330 #define valid_TERMTYPE2(p) \
331         ((p) != 0 && \
332          (p)->term_names != 0 && \
333          (p)->ext_Names != 0)
334
335 /*
336  * Disallow changing the type of an extended capability when doing a "use"
337  * if one or the other is a string.
338  */
339 static int
340 invalid_merge(TERMTYPE2 *to, TERMTYPE2 *from)
341 {
342     int rc = FALSE;
343     if (valid_TERMTYPE2(to)
344         && valid_TERMTYPE2(from)) {
345         char *to_name = _nc_first_name(to->term_names);
346         char *from_name = strdup(_nc_first_name(from->term_names));
347         unsigned num_names = NUM_EXT_NAMES(from);
348         unsigned n;
349
350         for (n = 0; n < num_names; ++n) {
351             const char *capname = from->ext_Names[n];
352             int tt = extended_captype(to, find_capname(to, capname));
353             int tf = extended_captype(from, n);
354
355             if (tt <= STRING
356                 && tf <= STRING
357                 && (tt == STRING) != (tf == STRING)) {
358                 if (from_name != 0 && strcmp(to_name, from_name)) {
359                     _nc_warning("merge of %s to %s changes type of %s from %s to %s",
360                                 from_name,
361                                 to_name,
362                                 from->ext_Names[n],
363                                 name_of_captype(tf),
364                                 name_of_captype(tt));
365                 } else {
366                     _nc_warning("merge of %s changes type of %s from %s to %s",
367                                 to_name,
368                                 from->ext_Names[n],
369                                 name_of_captype(tf),
370                                 name_of_captype(tt));
371                 }
372                 rc = TRUE;
373             }
374         }
375         free(from_name);
376     }
377     return rc;
378 }
379 #define validate_merge(p, q) \
380         if (invalid_merge(&((p)->tterm), &((q)->tterm))) \
381                 return FALSE
382 #else
383 #define validate_merge(p, q)    /* nothing */
384 #endif
385
386 NCURSES_EXPORT(int)
387 _nc_resolve_uses2(bool fullresolve, bool literal)
388 /* try to resolve all use capabilities */
389 {
390     ENTRY *qp, *rp, *lastread = 0;
391     bool keepgoing;
392     unsigned i, j;
393     int unresolved, total_unresolved, multiples;
394
395     DEBUG(2, ("RESOLUTION BEGINNING"));
396
397     /*
398      * Check for multiple occurrences of the same name.
399      */
400     multiples = 0;
401     for_entry_list(qp) {
402         int matchcount = 0;
403
404         for_entry_list(rp) {
405             if (qp > rp
406                 && check_collisions(qp->tterm.term_names,
407                                     rp->tterm.term_names,
408                                     matchcount + 1)) {
409                 if (!matchcount++) {
410                     (void) fprintf(stderr, "\t%s\n", rp->tterm.term_names);
411                 }
412                 (void) fprintf(stderr, "and\t%s\n", qp->tterm.term_names);
413                 if (!remove_collision(rp->tterm.term_names,
414                                       qp->tterm.term_names)) {
415                     ++multiples;
416                 }
417             }
418         }
419     }
420     if (multiples > 0)
421         return (FALSE);
422
423     DEBUG(2, ("NO MULTIPLE NAME OCCURRENCES"));
424
425     /*
426      * First resolution stage: compute link pointers corresponding to names.
427      */
428     total_unresolved = 0;
429     _nc_curr_col = -1;
430     for_entry_list(qp) {
431         unresolved = 0;
432         for (i = 0; i < qp->nuses; i++) {
433             bool foundit;
434             char *child = _nc_first_name(qp->tterm.term_names);
435             char *lookfor = qp->uses[i].name;
436             long lookline = qp->uses[i].line;
437
438             if (lookfor == 0)
439                 continue;
440
441             foundit = FALSE;
442
443             _nc_set_type(child);
444
445             /* first, try to resolve from in-core records */
446             for_entry_list(rp) {
447                 if (rp != qp
448                     && _nc_name_match(rp->tterm.term_names, lookfor, "|")) {
449                     DEBUG(2, ("%s: resolving use=%s (in core)",
450                               child, lookfor));
451
452                     qp->uses[i].link = rp;
453                     foundit = TRUE;
454
455                     /* verify that there are no earlier uses */
456                     for (j = 0; j < i; ++j) {
457                         if (qp->uses[j].link != NULL
458                             && !strcmp(qp->uses[j].link->tterm.term_names,
459                                        rp->tterm.term_names)) {
460                             _nc_warning("duplicate use=%s", lookfor);
461                             break;
462                         }
463                     }
464                 }
465             }
466
467             /* if that didn't work, try to merge in a compiled entry */
468             if (!foundit) {
469                 TERMTYPE2 thisterm;
470                 char filename[PATH_MAX];
471
472                 memset(&thisterm, 0, sizeof(thisterm));
473                 if (_nc_read_entry2(lookfor, filename, &thisterm) == 1) {
474                     DEBUG(2, ("%s: resolving use=%s (compiled)",
475                               child, lookfor));
476
477                     TYPE_MALLOC(ENTRY, 1, rp);
478                     rp->tterm = thisterm;
479                     rp->nuses = 0;
480                     rp->next = lastread;
481                     lastread = rp;
482
483                     qp->uses[i].link = rp;
484                     foundit = TRUE;
485
486                     /* verify that there are no earlier uses */
487                     for (j = 0; j < i; ++j) {
488                         if (qp->uses[j].link != NULL
489                             && !strcmp(qp->uses[j].link->tterm.term_names,
490                                        rp->tterm.term_names)) {
491                             _nc_warning("duplicate use=%s", lookfor);
492                             break;
493                         }
494                     }
495                 }
496             }
497
498             /* no good, mark this one unresolvable and complain */
499             if (!foundit) {
500                 unresolved++;
501                 total_unresolved++;
502
503                 _nc_curr_line = (int) lookline;
504                 _nc_warning("resolution of use=%s failed", lookfor);
505                 qp->uses[i].link = 0;
506             }
507         }
508     }
509     if (total_unresolved) {
510         /* free entries read in off disk */
511         _nc_free_entries(lastread);
512         return (FALSE);
513     }
514
515     DEBUG(2, ("NAME RESOLUTION COMPLETED OK"));
516
517     /*
518      * OK, at this point all (char *) references in `name' members
519      * have been successfully converted to (ENTRY *) pointers in
520      * `link' members.  Time to do the actual merges.
521      */
522     if (fullresolve) {
523         do {
524             ENTRY merged;
525
526             keepgoing = FALSE;
527
528             for_entry_list(qp) {
529                 if (qp->nuses > 0) {
530                     DEBUG(2, ("%s: attempting merge",
531                               _nc_first_name(qp->tterm.term_names)));
532                     /*
533                      * If any of the use entries we're looking for is
534                      * incomplete, punt.  We'll catch this entry on a
535                      * subsequent pass.
536                      */
537                     for (i = 0; i < qp->nuses; i++)
538                         if (qp->uses[i].link
539                             && qp->uses[i].link->nuses) {
540                             DEBUG(2, ("%s: use entry %d unresolved",
541                                       _nc_first_name(qp->tterm.term_names), i));
542                             goto incomplete;
543                         }
544
545                     /*
546                      * First, make sure there is no garbage in the
547                      * merge block.  As a side effect, copy into
548                      * the merged entry the name field and string
549                      * table pointer.
550                      */
551                     _nc_copy_termtype2(&(merged.tterm), &(qp->tterm));
552
553                     /*
554                      * Now merge in each use entry in the proper
555                      * (reverse) order.
556                      */
557                     for (; qp->nuses; qp->nuses--) {
558                         validate_merge(&merged,
559                                        qp->uses[qp->nuses - 1].link);
560                         _nc_merge_entry(&merged,
561                                         qp->uses[qp->nuses - 1].link);
562                     }
563
564                     /*
565                      * Now merge in the original entry.
566                      */
567                     validate_merge(&merged, qp);
568                     _nc_merge_entry(&merged, qp);
569
570                     /*
571                      * Replace the original entry with the merged one.
572                      */
573                     FreeIfNeeded(qp->tterm.Booleans);
574                     FreeIfNeeded(qp->tterm.Numbers);
575                     FreeIfNeeded(qp->tterm.Strings);
576 #if NCURSES_XNAMES
577                     FreeIfNeeded(qp->tterm.ext_Names);
578 #endif
579                     qp->tterm = merged.tterm;
580                     _nc_wrap_entry(qp, TRUE);
581
582                     /*
583                      * We know every entry is resolvable because name resolution
584                      * didn't bomb.  So go back for another pass.
585                      */
586                     /* FALLTHRU */
587                   incomplete:
588                     keepgoing = TRUE;
589                 }
590             }
591         } while
592             (keepgoing);
593
594         DEBUG(2, ("MERGES COMPLETED OK"));
595     }
596
597     /*
598      * We'd like to free entries read in off disk at this point, but can't.
599      * The merge_entry() code doesn't copy the strings in the use entries,
600      * it just aliases them.  If this ever changes, do a
601      * free_entries(lastread) here.
602      */
603
604     DEBUG(2, ("RESOLUTION FINISHED"));
605
606     if (fullresolve) {
607         _nc_curr_col = -1;
608         for_entry_list(qp) {
609             _nc_curr_line = (int) qp->startline;
610             _nc_set_type(_nc_first_name(qp->tterm.term_names));
611             /*
612              * tic overrides this function pointer to provide more verbose
613              * checking.
614              */
615             if (_nc_check_termtype2 != sanity_check2) {
616                 SCREEN *save_SP = SP;
617                 SCREEN fake_sp;
618                 TERMINAL fake_tm;
619                 TERMINAL *save_tm = cur_term;
620
621                 /*
622                  * Setup so that tic can use ordinary terminfo interface to
623                  * obtain capability information.
624                  */
625                 memset(&fake_sp, 0, sizeof(fake_sp));
626                 memset(&fake_tm, 0, sizeof(fake_tm));
627                 fake_sp._term = &fake_tm;
628                 TerminalType(&fake_tm) = qp->tterm;
629                 _nc_set_screen(&fake_sp);
630                 set_curterm(&fake_tm);
631
632                 _nc_check_termtype2(&qp->tterm, literal);
633
634                 _nc_set_screen(save_SP);
635                 set_curterm(save_tm);
636             } else {
637                 fixup_acsc(&qp->tterm, literal);
638             }
639         }
640         DEBUG(2, ("SANITY CHECK FINISHED"));
641     }
642
643     return (TRUE);
644 }
645
646 /*
647  * This bit of legerdemain turns all the terminfo variable names into
648  * references to locations in the arrays Booleans, Numbers, and Strings ---
649  * precisely what's needed.
650  */
651
652 #undef CUR
653 #define CUR tp->
654
655 static void
656 fixup_acsc(TERMTYPE2 *tp, int literal)
657 {
658     if (!literal) {
659         if (acs_chars == ABSENT_STRING
660             && PRESENT(enter_alt_charset_mode)
661             && PRESENT(exit_alt_charset_mode))
662             acs_chars = strdup(VT_ACSC);
663     }
664 }
665
666 static void
667 sanity_check2(TERMTYPE2 *tp, bool literal)
668 {
669     if (!PRESENT(exit_attribute_mode)) {
670 #ifdef __UNUSED__               /* this casts too wide a net */
671         bool terminal_entry = !strchr(tp->term_names, '+');
672         if (terminal_entry &&
673             (PRESENT(set_attributes)
674              || PRESENT(enter_standout_mode)
675              || PRESENT(enter_underline_mode)
676              || PRESENT(enter_blink_mode)
677              || PRESENT(enter_bold_mode)
678              || PRESENT(enter_dim_mode)
679              || PRESENT(enter_secure_mode)
680              || PRESENT(enter_protected_mode)
681              || PRESENT(enter_reverse_mode)))
682             _nc_warning("no exit_attribute_mode");
683 #endif /* __UNUSED__ */
684         PAIRED(enter_standout_mode, exit_standout_mode);
685         PAIRED(enter_underline_mode, exit_underline_mode);
686 #if defined(enter_italics_mode) && defined(exit_italics_mode)
687         PAIRED(enter_italics_mode, exit_italics_mode);
688 #endif
689     }
690
691     /* we do this check/fix in postprocess_termcap(), but some packagers
692      * prefer to bypass it...
693      */
694     if (!literal) {
695         fixup_acsc(tp, literal);
696         ANDMISSING(enter_alt_charset_mode, acs_chars);
697         ANDMISSING(exit_alt_charset_mode, acs_chars);
698     }
699
700     /* listed in structure-member order of first argument */
701     PAIRED(enter_alt_charset_mode, exit_alt_charset_mode);
702     ANDMISSING(enter_blink_mode, exit_attribute_mode);
703     ANDMISSING(enter_bold_mode, exit_attribute_mode);
704     PAIRED(exit_ca_mode, enter_ca_mode);
705     PAIRED(enter_delete_mode, exit_delete_mode);
706     ANDMISSING(enter_dim_mode, exit_attribute_mode);
707     PAIRED(enter_insert_mode, exit_insert_mode);
708     ANDMISSING(enter_secure_mode, exit_attribute_mode);
709     ANDMISSING(enter_protected_mode, exit_attribute_mode);
710     ANDMISSING(enter_reverse_mode, exit_attribute_mode);
711     PAIRED(from_status_line, to_status_line);
712     PAIRED(meta_off, meta_on);
713
714     PAIRED(prtr_on, prtr_off);
715     PAIRED(save_cursor, restore_cursor);
716     PAIRED(enter_xon_mode, exit_xon_mode);
717     PAIRED(enter_am_mode, exit_am_mode);
718     ANDMISSING(label_off, label_on);
719 #if defined(display_clock) && defined(remove_clock)
720     PAIRED(display_clock, remove_clock);
721 #endif
722     ANDMISSING(set_color_pair, initialize_pair);
723 }
724
725 #if NO_LEAKS
726 NCURSES_EXPORT(void)
727 _nc_leaks_tic(void)
728 {
729     T((T_CALLED("_nc_free_tic()")));
730     _nc_globals.leak_checking = TRUE;
731     _nc_alloc_entry_leaks();
732     _nc_captoinfo_leaks();
733     _nc_comp_scan_leaks();
734 #if BROKEN_LINKER || USE_REENTRANT
735     _nc_names_leaks();
736     _nc_codes_leaks();
737 #endif
738     _nc_tic_expand(0, FALSE, 0);
739 }
740
741 NCURSES_EXPORT(void)
742 _nc_free_tic(int code)
743 {
744     _nc_leaks_tic();
745     exit_terminfo(code);
746 }
747 #endif