1 /****************************************************************************
2 * Copyright (c) 1998-2001,2002 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 ****************************************************************************/
35 * parse_entry.c -- compile one terminfo or termcap entry
37 * Get an exact in-core representation of an entry. Don't
38 * try to resolve use or tc capabilities, that is someone
39 * else's job. Depends on the lexical analyzer to get tokens
40 * from the input stream.
43 #define __INTERNAL_CAPS_VISIBLE
44 #include <curses.priv.h>
48 #include <term_entry.h>
50 MODULE_ID("$Id: parse_entry.c,v 1.57 2002/08/31 17:02:02 tom Exp $")
53 static short const parametrized[] =
56 #include <parametrized.h>
59 static void postprocess_termcap(TERMTYPE *, bool);
60 static void postprocess_terminfo(TERMTYPE *);
61 static struct name_table_entry const *lookup_fullname(const char *name);
65 static struct name_table_entry const *
66 _nc_extend_names(ENTRY * entryp, char *name, int token_type)
68 static struct name_table_entry temp;
69 TERMTYPE *tp = &(entryp->tterm);
73 unsigned first, last, n;
79 last = tp->ext_Booleans;
80 offset = tp->ext_Booleans;
81 tindex = tp->num_Booleans;
84 first = tp->ext_Booleans;
85 last = tp->ext_Numbers + first;
86 offset = tp->ext_Booleans + tp->ext_Numbers;
87 tindex = tp->num_Numbers;
90 first = tp->ext_Booleans + tp->ext_Numbers;
91 last = tp->ext_Strings + first;
92 offset = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
93 tindex = tp->num_Strings;
96 actual = NUM_EXT_NAMES(tp);
97 for (n = 0; n < actual; n++) {
98 if (!strcmp(name, tp->ext_Names[n])) {
99 if (n > (unsigned) (tp->ext_Booleans + tp->ext_Numbers)) {
101 } else if (n > tp->ext_Booleans) {
104 token_type = BOOLEAN;
106 return _nc_extend_names(entryp, name, token_type);
109 /* Well, we are given a cancel for a name that we don't recognize */
110 return _nc_extend_names(entryp, name, STRING);
115 /* Adjust the 'offset' (insertion-point) to keep the lists of extended
118 for (n = first, found = FALSE; n < last; n++) {
119 int cmp = strcmp(tp->ext_Names[n], name);
125 switch (token_type) {
140 switch (token_type) {
142 tp->ext_Booleans += 1;
143 tp->num_Booleans += 1;
144 tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
145 for (last = tp->num_Booleans - 1; last > tindex; last--)
146 tp->Booleans[last] = tp->Booleans[last - 1];
149 tp->ext_Numbers += 1;
150 tp->num_Numbers += 1;
151 tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
152 for (last = tp->num_Numbers - 1; last > tindex; last--)
153 tp->Numbers[last] = tp->Numbers[last - 1];
156 tp->ext_Strings += 1;
157 tp->num_Strings += 1;
158 tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
159 for (last = tp->num_Strings - 1; last > tindex; last--)
160 tp->Strings[last] = tp->Strings[last - 1];
163 actual = NUM_EXT_NAMES(tp);
164 tp->ext_Names = typeRealloc(char *, actual, tp->ext_Names);
165 while (--actual > offset)
166 tp->ext_Names[actual] = tp->ext_Names[actual - 1];
167 tp->ext_Names[offset] = _nc_save_str(name);
170 temp.nte_name = tp->ext_Names[offset];
171 temp.nte_type = token_type;
172 temp.nte_index = tindex;
177 #endif /* NCURSES_XNAMES */
181 * _nc_parse_entry(entry, literal, silent)
183 * Compile one entry. Doesn't try to resolve use or tc capabilities.
185 * found-forward-use = FALSE
186 * re-initialise internal arrays
188 * if the token was not a name in column 1, complain and die
189 * save names in entry's string table
190 * while (get_token() is not EOF and not NAMES)
191 * check for existance and type-correctness
192 * enter cap into structure
194 * save string in entry's string table
200 (struct entry *entryp, int literal, bool silent)
203 struct name_table_entry const *entry_ptr;
206 token_type = _nc_get_token(silent);
208 if (token_type == EOF)
210 if (token_type != NAMES)
211 _nc_err_abort("Entry does not start with terminal names in column one");
213 _nc_init_entry(&entryp->tterm);
215 entryp->cstart = _nc_comment_start;
216 entryp->cend = _nc_comment_end;
217 entryp->startline = _nc_start_line;
218 DEBUG(2, ("Comment range is %ld to %ld", entryp->cstart, entryp->cend));
220 /* junk the 2-character termcap name, if present */
221 ptr = _nc_curr_token.tk_name;
223 ptr = _nc_curr_token.tk_name + 3;
224 _nc_curr_token.tk_name[2] = '\0';
227 entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
229 DEBUG(1, ("Starting '%s'", ptr));
232 * We do this because the one-token lookahead in the parse loop
233 * results in the terminal type getting prematurely set to correspond
234 * to that of the next entry.
236 _nc_set_type(_nc_first_name(entryp->tterm.term_names));
238 /* check for overly-long names and aliases */
239 for (base = entryp->tterm.term_names; (ptr = strchr(base, '|')) != 0;
241 if (ptr - base > MAX_ALIAS) {
242 _nc_warning("%s `%.*s' may be too long",
243 (base == entryp->tterm.term_names)
246 (int) (ptr - base), base);
252 for (token_type = _nc_get_token(silent);
253 token_type != EOF && token_type != NAMES;
254 token_type = _nc_get_token(silent)) {
255 if (strcmp(_nc_curr_token.tk_name, "use") == 0
256 || strcmp(_nc_curr_token.tk_name, "tc") == 0) {
257 entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring);
258 entryp->uses[entryp->nuses].line = _nc_curr_line;
261 /* normal token lookup */
262 entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
263 _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
266 * Our kluge to handle aliasing. The reason it's done
267 * this ugly way, with a linear search, is so the hashing
268 * machinery doesn't have to be made really complicated
269 * (also we get better warnings this way). No point in
270 * making this case fast, aliased caps aren't common now
271 * and will get rarer.
273 if (entry_ptr == NOTFOUND) {
274 const struct alias *ap;
276 if (_nc_syntax == SYN_TERMCAP) {
277 for (ap = _nc_capalias_table; ap->from; ap++)
278 if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
279 if (ap->to == (char *) 0) {
280 _nc_warning("%s (%s termcap extension) ignored",
281 ap->from, ap->source);
285 entry_ptr = _nc_find_entry(ap->to, _nc_cap_hash_table);
286 if (entry_ptr && !silent)
287 _nc_warning("%s (%s termcap extension) aliased to %s",
288 ap->from, ap->source, ap->to);
291 } else { /* if (_nc_syntax == SYN_TERMINFO) */
292 for (ap = _nc_infoalias_table; ap->from; ap++)
293 if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
294 if (ap->to == (char *) 0) {
295 _nc_warning("%s (%s terminfo extension) ignored",
296 ap->from, ap->source);
300 entry_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
301 if (entry_ptr && !silent)
302 _nc_warning("%s (%s terminfo extension) aliased to %s",
303 ap->from, ap->source, ap->to);
307 if (entry_ptr == NOTFOUND) {
308 entry_ptr = lookup_fullname(_nc_curr_token.tk_name);
314 * If we have extended-names active, we will automatically
315 * define a name based on its context.
317 if (entry_ptr == NOTFOUND
318 && _nc_user_definable
319 && (entry_ptr = _nc_extend_names(entryp,
320 _nc_curr_token.tk_name,
322 if (_nc_tracing >= DEBUG_LEVEL(1))
323 _nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
325 #endif /* NCURSES_XNAMES */
327 /* can't find this cap name, not even as an alias */
328 if (entry_ptr == NOTFOUND) {
330 _nc_warning("unknown capability '%s'",
331 _nc_curr_token.tk_name);
335 /* deal with bad type/value combinations. */
336 if (token_type != CANCEL && entry_ptr->nte_type != token_type) {
338 * Nasty special cases here handle situations in which type
339 * information can resolve name clashes. Normal lookup
340 * finds the last instance in the capability table of a
341 * given name, regardless of type. find_type_entry looks
342 * for a first matching instance with given type. So as
343 * long as all ambiguous names occur in pairs of distinct
344 * type, this will do the job.
347 /* tell max_attributes from arrow_key_map */
348 if (token_type == NUMBER && !strcmp("ma", _nc_curr_token.tk_name))
349 entry_ptr = _nc_find_type_entry("ma", NUMBER,
350 _nc_get_table(_nc_syntax
353 /* map terminfo's string MT to MT */
354 else if (token_type == STRING && !strcmp("MT", _nc_curr_token.tk_name))
355 entry_ptr = _nc_find_type_entry("MT", STRING,
356 _nc_get_table(_nc_syntax
359 /* treat strings without following "=" as empty strings */
360 else if (token_type == BOOLEAN && entry_ptr->nte_type == STRING)
362 /* we couldn't recover; skip this token */
365 const char *type_name;
366 switch (entry_ptr->nte_type) {
368 type_name = "boolean";
371 type_name = "string";
374 type_name = "numeric";
377 type_name = "unknown";
380 _nc_warning("wrong type used for %s capability '%s'",
381 type_name, _nc_curr_token.tk_name);
387 /* now we know that the type/value combination is OK */
388 switch (token_type) {
390 switch (entry_ptr->nte_type) {
392 entryp->tterm.Booleans[entry_ptr->nte_index] = CANCELLED_BOOLEAN;
396 entryp->tterm.Numbers[entry_ptr->nte_index] = CANCELLED_NUMERIC;
400 entryp->tterm.Strings[entry_ptr->nte_index] = CANCELLED_STRING;
406 entryp->tterm.Booleans[entry_ptr->nte_index] = TRUE;
410 entryp->tterm.Numbers[entry_ptr->nte_index] =
411 _nc_curr_token.tk_valnumber;
415 ptr = _nc_curr_token.tk_valstring;
416 if (_nc_syntax == SYN_TERMCAP)
417 ptr = _nc_captoinfo(_nc_curr_token.tk_name,
419 parametrized[entry_ptr->nte_index]);
420 entryp->tterm.Strings[entry_ptr->nte_index] = _nc_save_str(ptr);
425 _nc_warning("unknown token type");
426 _nc_panic_mode((_nc_syntax == SYN_TERMCAP) ? ':' : ',');
429 } /* end else cur_token.name != "use" */
431 continue; /* cannot have a label w/o statement */
432 } /* endwhile (not EOF and not NAMES) */
434 _nc_push_token(token_type);
435 _nc_set_type(_nc_first_name(entryp->tterm.term_names));
438 * Try to deduce as much as possible from extension capabilities
439 * (this includes obsolete BSD capabilities). Sigh...it would be more
440 * space-efficient to call this after use resolution, but it has
441 * to be done before entry allocation is wrapped up.
444 if (_nc_syntax == SYN_TERMCAP) {
445 bool has_base_entry = FALSE;
449 * Don't insert defaults if this is a `+' entry meant only
450 * for inclusion in other entries (not sure termcap ever
451 * had these, actually).
453 if (strchr(entryp->tterm.term_names, '+'))
454 has_base_entry = TRUE;
457 * Otherwise, look for a base entry that will already
458 * have picked up defaults via translation.
460 for (i = 0; i < entryp->nuses; i++)
461 if (!strchr((char *) entryp->uses[i].name, '+'))
462 has_base_entry = TRUE;
464 postprocess_termcap(&entryp->tterm, has_base_entry);
466 postprocess_terminfo(&entryp->tterm);
468 _nc_wrap_entry(entryp, FALSE);
474 _nc_capcmp(const char *s, const char *t)
475 /* compare two string capabilities, stripping out padding */
483 if (s[0] == '$' && s[1] == '<') {
485 if (!(isdigit(UChar(*s))
493 if (t[0] == '$' && t[1] == '<') {
495 if (!(isdigit(UChar(*t))
503 /* we've now pushed s and t past any padding they were pointing at */
505 if (*s == '\0' && *t == '\0')
511 /* else *s == *t but one is not NUL, so continue */
517 append_acs0(string_desc * dst, int code, int src)
524 _nc_safe_strcat(dst, temp);
529 append_acs(string_desc * dst, int code, char *src)
531 if (src != 0 && strlen(src) == 1) {
532 append_acs0(dst, code, *src);
537 * The ko capability, if present, consists of a comma-separated capability
538 * list. For each capability, we may assume there is a keycap that sends the
539 * string which is the value of that capability.
545 static assoc const ko_xlate[] =
547 {"al", "kil1"}, /* insert line key -> KEY_IL */
548 {"bt", "kcbt"}, /* back tab -> KEY_BTAB */
549 {"cd", "ked"}, /* clear-to-eos key -> KEY_EOL */
550 {"ce", "kel"}, /* clear-to-eol key -> KEY_EOS */
551 {"cl", "kclr"}, /* clear key -> KEY_CLEAR */
552 {"ct", "tbc"}, /* clear all tabs -> KEY_CATAB */
553 {"dc", "kdch1"}, /* delete char -> KEY_DC */
554 {"dl", "kdl1"}, /* delete line -> KEY_DL */
555 {"do", "kcud1"}, /* down key -> KEY_DOWN */
556 {"ei", "krmir"}, /* exit insert key -> KEY_EIC */
557 {"ho", "khome"}, /* home key -> KEY_HOME */
558 {"ic", "kich1"}, /* insert char key -> KEY_IC */
559 {"im", "kIC"}, /* insert-mode key -> KEY_SIC */
560 {"le", "kcub1"}, /* le key -> KEY_LEFT */
561 {"nd", "kcuf1"}, /* nd key -> KEY_RIGHT */
562 {"nl", "kent"}, /* new line key -> KEY_ENTER */
563 {"st", "khts"}, /* set-tab key -> KEY_STAB */
564 {"ta", CANCELLED_STRING},
565 {"up", "kcuu1"}, /* up-arrow key -> KEY_UP */
566 {(char *) 0, (char *) 0},
570 * This routine fills in string caps that either had defaults under
571 * termcap or can be manufactured from obsolete termcap capabilities.
572 * It was lifted from Ross Ridge's mytinfo package.
575 static const char C_CR[] = "\r";
576 static const char C_LF[] = "\n";
577 static const char C_BS[] = "\b";
578 static const char C_HT[] = "\t";
581 * Note that WANTED and PRESENT are not simple inverses! If a capability
582 * has been explicitly cancelled, it's not considered WANTED.
584 #define WANTED(s) ((s) == ABSENT_STRING)
585 #define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
588 * This bit of legerdemain turns all the terminfo variable names into
589 * references to locations in the arrays Booleans, Numbers, and Strings ---
590 * precisely what's needed.
597 postprocess_termcap(TERMTYPE * tp, bool has_base)
599 char buf[MAX_LINE * 2 + 2];
603 * TERMCAP DEFAULTS AND OBSOLETE-CAPABILITY TRANSLATIONS
605 * This first part of the code is the functional inverse of the
606 * fragment in capdefaults.c.
607 * ----------------------------------------------------------------------
610 /* if there was a tc entry, assume we picked up defaults via that */
612 if (WANTED(init_3string) && termcap_init2)
613 init_3string = _nc_save_str(termcap_init2);
615 if (WANTED(reset_2string) && termcap_reset)
616 reset_2string = _nc_save_str(termcap_reset);
618 if (WANTED(carriage_return)) {
619 if (carriage_return_delay > 0) {
620 sprintf(buf, "%s$<%d>", C_CR, carriage_return_delay);
621 carriage_return = _nc_save_str(buf);
623 carriage_return = _nc_save_str(C_CR);
625 if (WANTED(cursor_left)) {
626 if (backspace_delay > 0) {
627 sprintf(buf, "%s$<%d>", C_BS, backspace_delay);
628 cursor_left = _nc_save_str(buf);
629 } else if (backspaces_with_bs == 1)
630 cursor_left = _nc_save_str(C_BS);
631 else if (PRESENT(backspace_if_not_bs))
632 cursor_left = backspace_if_not_bs;
634 /* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
635 if (WANTED(cursor_down)) {
636 if (PRESENT(linefeed_if_not_lf))
637 cursor_down = linefeed_if_not_lf;
638 else if (linefeed_is_newline != 1) {
639 if (new_line_delay > 0) {
640 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
641 cursor_down = _nc_save_str(buf);
643 cursor_down = _nc_save_str(C_LF);
646 if (WANTED(scroll_forward) && crt_no_scrolling != 1) {
647 if (PRESENT(linefeed_if_not_lf))
648 cursor_down = linefeed_if_not_lf;
649 else if (linefeed_is_newline != 1) {
650 if (new_line_delay > 0) {
651 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
652 scroll_forward = _nc_save_str(buf);
654 scroll_forward = _nc_save_str(C_LF);
657 if (WANTED(newline)) {
658 if (linefeed_is_newline == 1) {
659 if (new_line_delay > 0) {
660 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
661 newline = _nc_save_str(buf);
663 newline = _nc_save_str(C_LF);
664 } else if (PRESENT(carriage_return) && PRESENT(scroll_forward)) {
665 _nc_str_init(&result, buf, sizeof(buf));
666 if (_nc_safe_strcat(&result, carriage_return)
667 && _nc_safe_strcat(&result, scroll_forward))
668 newline = _nc_save_str(buf);
669 } else if (PRESENT(carriage_return) && PRESENT(cursor_down)) {
670 _nc_str_init(&result, buf, sizeof(buf));
671 if (_nc_safe_strcat(&result, carriage_return)
672 && _nc_safe_strcat(&result, cursor_down))
673 newline = _nc_save_str(buf);
679 * Inverse of capdefaults.c code ends here.
680 * ----------------------------------------------------------------------
682 * TERMCAP-TO TERMINFO MAPPINGS FOR SOURCE TRANSLATION
684 * These translations will *not* be inverted by tgetent().
689 * We wait until now to decide if we've got a working cr because even
690 * one that doesn't work can be used for newline. Unfortunately the
691 * space allocated for it is wasted.
693 if (return_does_clr_eol == 1 || no_correctly_working_cr == 1)
694 carriage_return = ABSENT_STRING;
697 * Supposedly most termcap entries have ta now and '\t' is no longer a
698 * default, but it doesn't seem to be true...
701 if (horizontal_tab_delay > 0) {
702 sprintf(buf, "%s$<%d>", C_HT, horizontal_tab_delay);
703 tab = _nc_save_str(buf);
705 tab = _nc_save_str(C_HT);
707 if (init_tabs == ABSENT_NUMERIC && has_hardware_tabs == TRUE)
711 * Assume we can beep with ^G unless we're given bl@.
714 bell = _nc_save_str("\007");
718 * Translate the old termcap :pt: capability to it#8 + ht=\t
720 if (has_hardware_tabs == TRUE) {
721 if (init_tabs != 8 && init_tabs != ABSENT_NUMERIC)
722 _nc_warning("hardware tabs with a width other than 8: %d", init_tabs);
724 if (tab && _nc_capcmp(tab, C_HT))
725 _nc_warning("hardware tabs with a non-^I tab string %s",
729 tab = _nc_save_str(C_HT);
735 * Now translate the ko capability, if there is one. This
736 * isn't from mytinfo...
738 if (PRESENT(other_non_function_keys)) {
739 char *base = other_non_function_keys;
741 struct name_table_entry const *from_ptr;
742 struct name_table_entry const *to_ptr;
744 char buf2[MAX_TERMINFO_LENGTH];
747 /* we're going to use this for a special case later */
748 dp = strchr(other_non_function_keys, 'i');
749 foundim = (dp != 0) && (dp[1] == 'm');
751 /* look at each comma-separated capability in the ko string... */
752 for (base = other_non_function_keys;
753 (cp = strchr(base, ',')) != 0;
755 size_t len = cp - base;
757 for (ap = ko_xlate; ap->from; ap++)
758 if (len == strlen(ap->from)
759 && strncmp(ap->from, base, len) == 0)
762 _nc_warning("unknown capability `%.*s' in ko string",
765 } else if (ap->to == CANCELLED_STRING) /* ignore it */
768 /* now we know we found a match in ko_table, so... */
770 from_ptr = _nc_find_entry(ap->from, _nc_cap_hash_table);
771 to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
773 if (!from_ptr || !to_ptr) /* should never happen! */
774 _nc_err_abort("ko translation table is invalid, I give up");
776 if (WANTED(tp->Strings[from_ptr->nte_index])) {
777 _nc_warning("no value for ko capability %s", ap->from);
781 if (tp->Strings[to_ptr->nte_index]) {
782 /* There's no point in warning about it if it's the same
783 * string; that's just an inefficiency.
786 tp->Strings[from_ptr->nte_index],
787 tp->Strings[to_ptr->nte_index]) != 0)
788 _nc_warning("%s (%s) already has an explicit value %s, ignoring ko",
790 _nc_visbuf(tp->Strings[to_ptr->nte_index]));
795 * The magic moment -- copy the mapped key string over,
796 * stripping out padding.
798 for (dp = buf2, bp = tp->Strings[from_ptr->nte_index]; *bp; bp++) {
799 if (bp[0] == '$' && bp[1] == '<') {
800 while (*bp && *bp != '>') {
808 tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
812 * Note: ko=im and ko=ic both want to grab the `Insert'
813 * keycap. There's a kich1 but no ksmir, so the ic capability
814 * got mapped to kich1 and im to kIC to avoid a collision.
815 * If the description has im but not ic, hack kIC back to kich1.
817 if (foundim && WANTED(key_ic) && key_sic) {
819 key_sic = ABSENT_STRING;
825 if (WANTED(key_backspace))
826 key_backspace = _nc_save_str(C_BS);
827 if (WANTED(key_left))
828 key_left = _nc_save_str(C_BS);
829 if (WANTED(key_down))
830 key_down = _nc_save_str(C_LF);
835 * Translate XENIX forms characters.
837 if (PRESENT(acs_ulcorner) ||
838 PRESENT(acs_llcorner) ||
839 PRESENT(acs_urcorner) ||
840 PRESENT(acs_lrcorner) ||
845 PRESENT(acs_hline) ||
846 PRESENT(acs_vline) ||
848 char buf2[MAX_TERMCAP_LENGTH];
850 _nc_str_init(&result, buf2, sizeof(buf2));
851 _nc_safe_strcat(&result, acs_chars);
853 append_acs(&result, 'j', acs_lrcorner);
854 append_acs(&result, 'k', acs_urcorner);
855 append_acs(&result, 'l', acs_ulcorner);
856 append_acs(&result, 'm', acs_llcorner);
857 append_acs(&result, 'n', acs_plus);
858 append_acs(&result, 'q', acs_hline);
859 append_acs(&result, 't', acs_ltee);
860 append_acs(&result, 'u', acs_rtee);
861 append_acs(&result, 'v', acs_btee);
862 append_acs(&result, 'w', acs_ttee);
863 append_acs(&result, 'x', acs_vline);
866 acs_chars = _nc_save_str(buf2);
867 _nc_warning("acsc string synthesized from XENIX capabilities");
869 } else if (acs_chars == 0
870 && enter_alt_charset_mode != 0
871 && exit_alt_charset_mode != 0) {
872 acs_chars = _nc_save_str(VT_ACSC);
877 postprocess_terminfo(TERMTYPE * tp)
880 * TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION
881 * ----------------------------------------------------------------------
885 * Translate AIX forms characters.
887 if (PRESENT(box_chars_1)) {
888 char buf2[MAX_TERMCAP_LENGTH];
891 _nc_str_init(&result, buf2, sizeof(buf2));
892 _nc_safe_strcat(&result, acs_chars);
894 append_acs0(&result, 'l', box_chars_1[0]); /* ACS_ULCORNER */
895 append_acs0(&result, 'q', box_chars_1[1]); /* ACS_HLINE */
896 append_acs0(&result, 'k', box_chars_1[2]); /* ACS_URCORNER */
897 append_acs0(&result, 'x', box_chars_1[3]); /* ACS_VLINE */
898 append_acs0(&result, 'j', box_chars_1[4]); /* ACS_LRCORNER */
899 append_acs0(&result, 'm', box_chars_1[5]); /* ACS_LLCORNER */
900 append_acs0(&result, 'w', box_chars_1[6]); /* ACS_TTEE */
901 append_acs0(&result, 'u', box_chars_1[7]); /* ACS_RTEE */
902 append_acs0(&result, 'v', box_chars_1[8]); /* ACS_BTEE */
903 append_acs0(&result, 't', box_chars_1[9]); /* ACS_LTEE */
904 append_acs0(&result, 'n', box_chars_1[10]); /* ACS_PLUS */
907 acs_chars = _nc_save_str(buf2);
908 _nc_warning("acsc string synthesized from AIX capabilities");
909 box_chars_1 = ABSENT_STRING;
913 * ----------------------------------------------------------------------
918 * Do a linear search through the terminfo tables to find a given full-name.
919 * We don't expect to do this often, so there's no hashing function.
921 * In effect, this scans through the 3 lists of full-names, and looks them
922 * up in _nc_info_table, which is organized so that the nte_index fields are
923 * sorted, but the nte_type fields are not necessarily grouped together.
925 static struct name_table_entry const *
926 lookup_fullname(const char *find)
932 NCURSES_CONST char *const *names;
948 for (count = 0; names[count] != 0; count++) {
949 if (!strcmp(names[count], find)) {
950 struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
951 while (entry_ptr->nte_type != state
952 || entry_ptr->nte_index != count)
960 /* parse_entry.c ends here */