1 /****************************************************************************
2 * Copyright (c) 1999 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 ****************************************************************************/
36 * parse_entry.c -- compile one terminfo or termcap entry
38 * Get an exact in-core representation of an entry. Don't
39 * try to resolve use or tc capabilities, that is someone
40 * else's job. Depends on the lexical analyzer to get tokens
41 * from the input stream.
44 #include <curses.priv.h>
48 #define __INTERNAL_CAPS_VISIBLE
49 #include <term_entry.h>
51 MODULE_ID("$Id: parse_entry.c,v 1.39 1999/03/01 02:28:51 tom Exp $")
54 static short const parametrized[] = { 0 };
56 #include <parametrized.h>
59 struct token _nc_curr_token;
61 static void postprocess_termcap(TERMTYPE *, bool);
62 static void postprocess_terminfo(TERMTYPE *);
63 static struct name_table_entry const * lookup_fullname(const char *name);
67 static struct name_table_entry const *
68 _nc_extend_names(ENTRY *entryp, char *name, int token_type)
70 static struct name_table_entry temp;
71 TERMTYPE *tp = &(entryp->tterm);
75 unsigned first, last, n;
81 last = tp->ext_Booleans;
82 offset = tp->ext_Booleans;
83 tindex = tp->num_Booleans;
86 first = tp->ext_Booleans;
87 last = tp->ext_Numbers + first;
88 offset = tp->ext_Booleans + tp->ext_Numbers;
89 tindex = tp->num_Numbers;
92 first = tp->ext_Booleans + tp->ext_Numbers;
93 last = tp->ext_Strings + first;
94 offset = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
95 tindex = tp->num_Strings;
98 actual = NUM_EXT_NAMES(tp);
99 for (n = 0; n < actual; n++) {
100 if (!strcmp(name, tp->ext_Names[n])) {
101 if (n > (unsigned)(tp->ext_Booleans + tp->ext_Numbers)) {
103 } else if (n > tp->ext_Booleans) {
106 token_type = BOOLEAN;
108 return _nc_extend_names(entryp, name, token_type);
111 /* Well, we are given a cancel for a name that we don't recognize */
112 return _nc_extend_names(entryp, name, STRING);
117 /* Adjust the 'offset' (insertion-point) to keep the lists of extended
120 for (n = first, found = FALSE; n < last; n++) {
121 int cmp = strcmp(tp->ext_Names[n], name);
127 switch (token_type) {
128 case BOOLEAN: tindex += BOOLCOUNT; break;
129 case NUMBER: tindex += NUMCOUNT; break;
130 case STRING: tindex += STRCOUNT; break;
136 switch (token_type) {
138 tp->ext_Booleans += 1;
139 tp->num_Booleans += 1;
140 tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
141 for (last = tp->num_Booleans-1; last > tindex; last--)
142 tp->Booleans[last] = tp->Booleans[last-1];
145 tp->ext_Numbers += 1;
146 tp->num_Numbers += 1;
147 tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
148 for (last = tp->num_Numbers-1; last > tindex; last--)
149 tp->Numbers[last] = tp->Numbers[last-1];
152 tp->ext_Strings += 1;
153 tp->num_Strings += 1;
154 tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
155 for (last = tp->num_Strings-1; last > tindex; last--)
156 tp->Strings[last] = tp->Strings[last-1];
159 actual = NUM_EXT_NAMES(tp);
160 tp->ext_Names = typeRealloc(char *, actual, tp->ext_Names);
161 while (--actual > offset)
162 tp->ext_Names[actual] = tp->ext_Names[actual-1];
163 tp->ext_Names[offset] = _nc_save_str(name);
166 temp.nte_name = tp->ext_Names[offset];
167 temp.nte_type = token_type;
168 temp.nte_index = tindex;
173 #endif /* NCURSES_XNAMES */
177 * _nc_parse_entry(entry, literal, silent)
179 * Compile one entry. Doesn't try to resolve use or tc capabilities.
181 * found-forward-use = FALSE
182 * re-initialise internal arrays
184 * if the token was not a name in column 1, complain and die
185 * save names in entry's string table
186 * while (get_token() is not EOF and not NAMES)
187 * check for existance and type-correctness
188 * enter cap into structure
190 * save string in entry's string table
194 int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
197 struct name_table_entry const *entry_ptr;
198 char *ptr, namecpy[MAX_NAME_SIZE+1];
200 token_type = _nc_get_token();
202 if (token_type == EOF)
204 if (token_type != NAMES)
205 _nc_err_abort("Entry does not start with terminal names in column one");
207 _nc_init_entry(&entryp->tterm);
209 entryp->cstart = _nc_comment_start;
210 entryp->cend = _nc_comment_end;
211 entryp->startline = _nc_start_line;
212 DEBUG(2, ("Comment range is %ld to %ld", entryp->cstart, entryp->cend));
214 /* junk the 2-character termcap name, if present */
215 ptr = _nc_curr_token.tk_name;
218 ptr = _nc_curr_token.tk_name + 3;
219 _nc_curr_token.tk_name[2] = '\0';
222 entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
224 DEBUG(1, ("Starting '%s'", ptr));
227 * We do this because the one-token lookahead in the parse loop
228 * results in the terminal type getting prematurely set to correspond
229 * to that of the next entry.
231 _nc_set_type(_nc_first_name(entryp->tterm.term_names));
233 /* check for overly-long names and aliases */
234 (void) strncpy(namecpy, entryp->tterm.term_names, MAX_NAME_SIZE);
235 namecpy[MAX_NAME_SIZE] = '\0';
236 if ((ptr = strrchr(namecpy, '|')) != (char *)0)
238 ptr = strtok(namecpy, "|");
239 if (strlen(ptr) > MAX_ALIAS)
240 _nc_warning("primary name may be too long");
241 while ((ptr = strtok((char *)0, "|")) != (char *)0)
242 if (strlen(ptr) > MAX_ALIAS)
243 _nc_warning("alias `%s' may be too long", ptr);
247 for (token_type = _nc_get_token();
248 token_type != EOF && token_type != NAMES;
249 token_type = _nc_get_token())
251 if (strcmp(_nc_curr_token.tk_name, "use") == 0
252 || strcmp(_nc_curr_token.tk_name, "tc") == 0) {
253 entryp->uses[entryp->nuses].parent = (void *)_nc_save_str(_nc_curr_token.tk_valstring);
254 entryp->uses[entryp->nuses].line = _nc_curr_line;
257 /* normal token lookup */
258 entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
259 _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
262 * Our kluge to handle aliasing. The reason it's done
263 * this ugly way, with a linear search, is so the hashing
264 * machinery doesn't have to be made really complicated
265 * (also we get better warnings this way). No point in
266 * making this case fast, aliased caps aren't common now
267 * and will get rarer.
269 if (entry_ptr == NOTFOUND)
271 const struct alias *ap;
273 if (_nc_syntax == SYN_TERMCAP)
275 for (ap = _nc_capalias_table; ap->from; ap++)
276 if (strcmp(ap->from, _nc_curr_token.tk_name) == 0)
278 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", ap->from, ap->source, ap->to);
291 else /* if (_nc_syntax == SYN_TERMINFO) */
293 for (ap = _nc_infoalias_table; ap->from; ap++)
294 if (strcmp(ap->from, _nc_curr_token.tk_name) == 0)
296 if (ap->to == (char *)0)
298 _nc_warning("%s (%s terminfo extension) ignored",
299 ap->from, ap->source);
303 entry_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
304 if (entry_ptr && !silent)
305 _nc_warning("%s (%s terminfo extension) aliased to %s", ap->from, ap->source, ap->to);
309 if (entry_ptr == NOTFOUND) {
310 entry_ptr = lookup_fullname(_nc_curr_token.tk_name);
317 * If we have extended-names active, we will automatically
318 * define a name based on its context.
320 if (entry_ptr == NOTFOUND
321 && _nc_user_definable
322 && (entry_ptr = _nc_extend_names(entryp, _nc_curr_token.tk_name, token_type)) != 0) {
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)
339 * Nasty special cases here handle situations in which type
340 * information can resolve name clashes. Normal lookup
341 * finds the last instance in the capability table of a
342 * given name, regardless of type. find_type_entry looks
343 * for a first matching instance with given type. So as
344 * long as all ambiguous names occur in pairs of distinct
345 * type, this will do the job.
348 /* tell max_attributes from arrow_key_map */
349 if (token_type == NUMBER && !strcmp("ma", _nc_curr_token.tk_name))
350 entry_ptr = _nc_find_type_entry("ma", NUMBER,
351 _nc_get_table(_nc_syntax != 0));
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 != 0));
358 /* treat strings without following "=" as empty strings */
359 else if (token_type==BOOLEAN && entry_ptr->nte_type==STRING)
361 /* we couldn't recover; skip this token */
366 const char *type_name;
367 switch (entry_ptr->nte_type)
370 type_name = "boolean";
373 type_name = "string";
376 type_name = "numeric";
379 type_name = "unknown";
382 _nc_warning("wrong type used for %s capability '%s'",
383 type_name, _nc_curr_token.tk_name);
389 /* now we know that the type/value combination is OK */
390 switch (token_type) {
392 switch (entry_ptr->nte_type) {
394 entryp->tterm.Booleans[entry_ptr->nte_index] = CANCELLED_BOOLEAN;
398 entryp->tterm.Numbers[entry_ptr->nte_index] = CANCELLED_NUMERIC;
402 entryp->tterm.Strings[entry_ptr->nte_index] = CANCELLED_STRING;
408 entryp->tterm.Booleans[entry_ptr->nte_index] = TRUE;
412 entryp->tterm.Numbers[entry_ptr->nte_index] =
413 _nc_curr_token.tk_valnumber;
417 ptr = _nc_curr_token.tk_valstring;
418 if (_nc_syntax==SYN_TERMCAP)
419 ptr = _nc_captoinfo(_nc_curr_token.tk_name,
421 parametrized[entry_ptr->nte_index]);
422 entryp->tterm.Strings[entry_ptr->nte_index] = _nc_save_str(ptr);
427 _nc_warning("unknown token type");
428 _nc_panic_mode((_nc_syntax==SYN_TERMCAP) ? ':' : ',');
431 } /* end else cur_token.name != "use" */
433 continue; /* cannot have a label w/o statement */
434 } /* endwhile (not EOF and not NAMES) */
436 _nc_push_token(token_type);
437 _nc_set_type(_nc_first_name(entryp->tterm.term_names));
440 * Try to deduce as much as possible from extension capabilities
441 * (this includes obsolete BSD capabilities). Sigh...it would be more
442 * space-efficient to call this after use resolution, but it has
443 * to be done before entry allocation is wrapped up.
446 if (_nc_syntax == SYN_TERMCAP)
448 bool has_base_entry = FALSE;
452 * Don't insert defaults if this is a `+' entry meant only
453 * for inclusion in other entries (not sure termcap ever
454 * had these, actually).
456 if (strchr(entryp->tterm.term_names, '+'))
457 has_base_entry = TRUE;
460 * Otherwise, look for a base entry that will already
461 * have picked up defaults via translation.
463 for (i = 0; i < entryp->nuses; i++)
464 if (!strchr((char *)entryp->uses[i].parent, '+'))
465 has_base_entry = TRUE;
467 postprocess_termcap(&entryp->tterm, has_base_entry);
470 postprocess_terminfo(&entryp->tterm);
472 _nc_wrap_entry(entryp);
477 int _nc_capcmp(const char *s, const char *t)
478 /* compare two string capabilities, stripping out padding */
487 if (s[0] == '$' && s[1] == '<')
490 if (!(isdigit(*s) || *s=='.' || *s=='*' || *s=='/' || *s=='>'))
494 if (t[0] == '$' && t[1] == '<')
497 if (!(isdigit(*t) || *t=='.' || *t=='*' || *t=='/' || *t=='>'))
501 /* we've now pushed s and t past any padding they were pointing at */
503 if (*s == '\0' && *t == '\0')
509 /* else *s == *t but one is not NUL, so continue */
515 * The ko capability, if present, consists of a comma-separated capability
516 * list. For each capability, we may assume there is a keycap that sends the
517 * string which is the value of that capability.
519 typedef struct {const char *from; const char *to;} assoc;
520 static assoc const ko_xlate[] =
522 {"al", "kil1"}, /* insert line key -> KEY_IL */
523 {"bt", "kcbt"}, /* back tab -> KEY_BTAB */
524 {"cd", "ked"}, /* clear-to-eos key -> KEY_EOL */
525 {"ce", "kel"}, /* clear-to-eol key -> KEY_EOS */
526 {"cl", "kclr"}, /* clear key -> KEY_CLEAR */
527 {"ct", "tbc"}, /* clear all tabs -> KEY_CATAB */
528 {"dc", "kdch1"}, /* delete char -> KEY_DC */
529 {"dl", "kdl1"}, /* delete line -> KEY_DL */
530 {"do", "kcud1"}, /* down key -> KEY_DOWN */
531 {"ei", "krmir"}, /* exit insert key -> KEY_EIC */
532 {"ho", "khome"}, /* home key -> KEY_HOME */
533 {"ic", "kich1"}, /* insert char key -> KEY_IC */
534 {"im", "kIC"}, /* insert-mode key -> KEY_SIC */
535 {"le", "kcub1"}, /* le key -> KEY_LEFT */
536 {"nd", "kcuf1"}, /* nd key -> KEY_RIGHT */
537 {"nl", "kent"}, /* new line key -> KEY_ENTER */
538 {"st", "khts"}, /* set-tab key -> KEY_STAB */
539 {"ta", CANCELLED_STRING},
540 {"up", "kcuu1"}, /* up-arrow key -> KEY_UP */
541 {(char *)0, (char *)0},
545 * This routine fills in string caps that either had defaults under
546 * termcap or can be manufactured from obsolete termcap capabilities.
547 * It was lifted from Ross Ridge's mytinfo package.
550 static const char C_CR[] = "\r";
551 static const char C_LF[] = "\n";
552 static const char C_BS[] = "\b";
553 static const char C_HT[] = "\t";
556 * Note that WANTED and PRESENT are not simple inverses! If a capability
557 * has been explicitly cancelled, it's not considered WANTED.
559 #define WANTED(s) ((s) == ABSENT_STRING)
560 #define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
563 * This bit of legerdemain turns all the terminfo variable names into
564 * references to locations in the arrays Booleans, Numbers, and Strings ---
565 * precisely what's needed.
572 void postprocess_termcap(TERMTYPE *tp, bool has_base)
574 char buf[MAX_LINE * 2 + 2];
577 * TERMCAP DEFAULTS AND OBSOLETE-CAPABILITY TRANSLATIONS
579 * This first part of the code is the functional inverse of the
580 * fragment in capdefaults.c.
581 * ----------------------------------------------------------------------
584 /* if there was a tc entry, assume we picked up defaults via that */
587 if (WANTED(init_3string) && termcap_init2)
588 init_3string = _nc_save_str(termcap_init2);
590 if (WANTED(reset_2string) && termcap_reset)
591 reset_2string = _nc_save_str(termcap_reset);
593 if (WANTED(carriage_return)) {
594 if (carriage_return_delay > 0) {
595 sprintf(buf, "%s$<%d>", C_CR, carriage_return_delay);
596 carriage_return = _nc_save_str(buf);
598 carriage_return = _nc_save_str(C_CR);
600 if (WANTED(cursor_left)) {
601 if (backspace_delay > 0) {
602 sprintf(buf, "%s$<%d>", C_BS, backspace_delay);
603 cursor_left = _nc_save_str(buf);
604 } else if (backspaces_with_bs == 1)
605 cursor_left = _nc_save_str(C_BS);
606 else if (PRESENT(backspace_if_not_bs))
607 cursor_left = backspace_if_not_bs;
609 /* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
610 if (WANTED(cursor_down)) {
611 if (PRESENT(linefeed_if_not_lf))
612 cursor_down = linefeed_if_not_lf;
613 else if (linefeed_is_newline != 1) {
614 if (new_line_delay > 0) {
615 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
616 cursor_down = _nc_save_str(buf);
618 cursor_down = _nc_save_str(C_LF);
621 if (WANTED(scroll_forward) && crt_no_scrolling != 1) {
622 if (PRESENT(linefeed_if_not_lf))
623 cursor_down = linefeed_if_not_lf;
624 else if (linefeed_is_newline != 1) {
625 if (new_line_delay > 0) {
626 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
627 scroll_forward = _nc_save_str(buf);
629 scroll_forward = _nc_save_str(C_LF);
632 if (WANTED(newline)) {
633 if (linefeed_is_newline == 1) {
634 if (new_line_delay > 0) {
635 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
636 newline = _nc_save_str(buf);
638 newline = _nc_save_str(C_LF);
639 } else if (PRESENT(carriage_return) && PRESENT(scroll_forward)) {
640 strncpy(buf, carriage_return, MAX_LINE-2);
641 buf[MAX_LINE-1] = '\0';
642 strncat(buf, scroll_forward, MAX_LINE-strlen(buf)-1);
643 buf[MAX_LINE] = '\0';
644 newline = _nc_save_str(buf);
645 } else if (PRESENT(carriage_return) && PRESENT(cursor_down)) {
646 strncpy(buf, carriage_return, MAX_LINE-2);
647 buf[MAX_LINE-1] = '\0';
648 strncat(buf, cursor_down, MAX_LINE-strlen(buf)-1);
649 buf[MAX_LINE] = '\0';
650 newline = _nc_save_str(buf);
656 * Inverse of capdefaults.c code ends here.
657 * ----------------------------------------------------------------------
659 * TERMCAP-TO TERMINFO MAPPINGS FOR SOURCE TRANSLATION
661 * These translations will *not* be inverted by tgetent().
667 * We wait until now to decide if we've got a working cr because even
668 * one that doesn't work can be used for newline. Unfortunately the
669 * space allocated for it is wasted.
671 if (return_does_clr_eol == 1 || no_correctly_working_cr == 1)
672 carriage_return = ABSENT_STRING;
675 * Supposedly most termcap entries have ta now and '\t' is no longer a
676 * default, but it doesn't seem to be true...
679 if (horizontal_tab_delay > 0) {
680 sprintf(buf, "%s$<%d>", C_HT, horizontal_tab_delay);
681 tab = _nc_save_str(buf);
683 tab = _nc_save_str(C_HT);
685 if (init_tabs == ABSENT_NUMERIC && has_hardware_tabs == TRUE)
689 * Assume we can beep with ^G unless we're given bl@.
692 bell = _nc_save_str("\007");
696 * Translate the old termcap :pt: capability to it#8 + ht=\t
698 if (has_hardware_tabs == TRUE) {
699 if (init_tabs != 8 && init_tabs != ABSENT_NUMERIC)
700 _nc_warning("hardware tabs with a width other than 8: %d", init_tabs);
703 if (tab && _nc_capcmp(tab, C_HT))
704 _nc_warning("hardware tabs with a non-^I tab string %s",
709 tab = _nc_save_str(C_HT);
715 * Now translate the ko capability, if there is one. This
716 * isn't from mytinfo...
718 if (PRESENT(other_non_function_keys))
720 char *dp, *cp = strtok(other_non_function_keys, ",");
721 struct name_table_entry const *from_ptr;
722 struct name_table_entry const *to_ptr;
724 char buf2[MAX_TERMINFO_LENGTH];
727 /* we're going to use this for a special case later */
728 dp = strchr(other_non_function_keys, 'i');
729 foundim = dp && dp[1] == 'm';
731 /* look at each comma-separated capability in the ko string... */
733 for (ap = ko_xlate; ap->from; ap++)
734 if (strcmp(ap->from, cp) == 0)
738 _nc_warning("unknown capability `%s' in ko string", cp);
741 else if (ap->to == CANCELLED_STRING) /* ignore it */
744 /* now we know we found a match in ko_table, so... */
746 from_ptr = _nc_find_entry(ap->from, _nc_cap_hash_table);
747 to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
749 if (!from_ptr || !to_ptr) /* should never happen! */
750 _nc_err_abort("ko translation table is invalid, I give up");
752 if (WANTED(tp->Strings[from_ptr->nte_index]))
754 _nc_warning("no value for ko capability %s", ap->from);
758 if (tp->Strings[to_ptr->nte_index])
760 /* There's no point in warning about it if it's the same
761 * string; that's just an inefficiency.
764 tp->Strings[from_ptr->nte_index],
765 tp->Strings[to_ptr->nte_index]) != 0)
766 _nc_warning("%s (%s) already has an explicit value %s, ignoring ko",
768 _nc_visbuf(tp->Strings[to_ptr->nte_index]) );
773 * The magic moment -- copy the mapped key string over,
774 * stripping out padding.
777 for (cp = tp->Strings[from_ptr->nte_index]; *cp; cp++)
779 if (cp[0] == '$' && cp[1] == '<')
781 while (*cp && *cp != '>')
792 tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
794 ((cp = strtok((char *)0, ",")) != 0);
797 * Note: ko=im and ko=ic both want to grab the `Insert'
798 * keycap. There's a kich1 but no ksmir, so the ic capability
799 * got mapped to kich1 and im to kIC to avoid a collision.
800 * If the description has im but not ic, hack kIC back to kich1.
802 if (foundim && WANTED(key_ic) && key_sic)
805 key_sic = ABSENT_STRING;
811 if (WANTED(key_backspace))
812 key_backspace = _nc_save_str(C_BS);
813 if (WANTED(key_left))
814 key_left = _nc_save_str(C_BS);
815 if (WANTED(key_down))
816 key_down = _nc_save_str(C_LF);
820 * Translate XENIX forms characters.
822 if (PRESENT(acs_ulcorner) ||
823 PRESENT(acs_llcorner) ||
824 PRESENT(acs_urcorner) ||
825 PRESENT(acs_lrcorner) ||
830 PRESENT(acs_hline) ||
831 PRESENT(acs_vline) ||
834 char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
838 (void)strcpy(bp, acs_chars);
842 if (acs_ulcorner && acs_ulcorner[1] == '\0')
845 *bp++ = *acs_ulcorner;
847 if (acs_llcorner && acs_llcorner[1] == '\0')
850 *bp++ = *acs_llcorner;
852 if (acs_urcorner && acs_urcorner[1] == '\0')
855 *bp++ = *acs_urcorner;
857 if (acs_lrcorner && acs_lrcorner[1] == '\0')
860 *bp++ = *acs_lrcorner;
862 if (acs_ltee && acs_ltee[1] == '\0')
867 if (acs_rtee && acs_rtee[1] == '\0')
872 if (acs_btee && acs_btee[1] == '\0')
877 if (acs_ttee && acs_ttee[1] == '\0')
882 if (acs_hline && acs_hline[1] == '\0')
887 if (acs_vline && acs_vline[1] == '\0')
895 strcpy(bp, acs_plus);
896 bp = buf2 + strlen(buf2);
902 acs_chars = _nc_save_str(buf2);
903 _nc_warning("acsc string synthesized from XENIX capabilities");
906 else if (acs_chars == 0
907 && enter_alt_charset_mode != 0
908 && exit_alt_charset_mode != 0)
910 acs_chars = _nc_save_str("``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~");
915 void postprocess_terminfo(TERMTYPE *tp)
918 * TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION
919 * ----------------------------------------------------------------------
923 * Translate AIX forms characters.
925 if (PRESENT(box_chars_1))
927 char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
931 (void)strcpy(bp, acs_chars);
935 if (box_chars_1[0]) /* ACS_ULCORNER */
938 *bp++ = box_chars_1[0];
940 if (box_chars_1[1]) /* ACS_HLINE */
943 *bp++ = box_chars_1[1];
945 if (box_chars_1[2]) /* ACS_URCORNER */
948 *bp++ = box_chars_1[2];
950 if (box_chars_1[3]) /* ACS_VLINE */
953 *bp++ = box_chars_1[3];
955 if (box_chars_1[4]) /* ACS_LRCORNER */
958 *bp++ = box_chars_1[4];
960 if (box_chars_1[5]) /* ACS_LLCORNER */
963 *bp++ = box_chars_1[5];
965 if (box_chars_1[6]) /* ACS_TTEE */
968 *bp++ = box_chars_1[6];
970 if (box_chars_1[7]) /* ACS_RTEE */
973 *bp++ = box_chars_1[7];
975 if (box_chars_1[8]) /* ACS_BTEE */
978 *bp++ = box_chars_1[8];
980 if (box_chars_1[9]) /* ACS_LTEE */
983 *bp++ = box_chars_1[9];
985 if (box_chars_1[10]) /* ACS_PLUS */
988 *bp++ = box_chars_1[10];
994 acs_chars = _nc_save_str(buf2);
995 _nc_warning("acsc string synthesized from AIX capabilities");
996 box_chars_1 = ABSENT_STRING;
1000 * ----------------------------------------------------------------------
1005 * Do a linear search through the terminfo tables to find a given full-name.
1006 * We don't expect to do this often, so there's no hashing function.
1008 * In effect, this scans through the 3 lists of full-names, and looks them
1009 * up in _nc_info_table, which is organized so that the nte_index fields are
1010 * sorted, but the nte_type fields are not necessarily grouped together.
1013 struct name_table_entry const * lookup_fullname(const char *find)
1019 NCURSES_CONST char *const *names;
1035 for (count = 0; names[count] != 0; count++) {
1036 if (!strcmp(names[count], find)) {
1037 struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
1038 while (entry_ptr->nte_type != state
1039 || entry_ptr->nte_index != count)
1047 /* parse_entry.c ends here */