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-2003 *
33 ****************************************************************************/
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 #define __INTERNAL_CAPS_VISIBLE
45 #include <curses.priv.h>
49 #include <term_entry.h>
51 MODULE_ID("$Id: parse_entry.c,v 1.60 2003/11/08 21:57:09 tom Exp $")
54 static short const parametrized[] =
57 #include <parametrized.h>
60 static void postprocess_termcap(TERMTYPE *, bool);
61 static void postprocess_terminfo(TERMTYPE *);
62 static struct name_table_entry const *lookup_fullname(const char *name);
66 static struct name_table_entry const *
67 _nc_extend_names(ENTRY * entryp, char *name, int token_type)
69 static struct name_table_entry temp;
70 TERMTYPE *tp = &(entryp->tterm);
74 unsigned first, last, n;
80 last = tp->ext_Booleans;
81 offset = tp->ext_Booleans;
82 tindex = tp->num_Booleans;
85 first = tp->ext_Booleans;
86 last = tp->ext_Numbers + first;
87 offset = tp->ext_Booleans + tp->ext_Numbers;
88 tindex = tp->num_Numbers;
91 first = tp->ext_Booleans + tp->ext_Numbers;
92 last = tp->ext_Strings + first;
93 offset = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
94 tindex = tp->num_Strings;
97 actual = NUM_EXT_NAMES(tp);
98 for (n = 0; n < actual; n++) {
99 if (!strcmp(name, tp->ext_Names[n])) {
100 if (n > (unsigned) (tp->ext_Booleans + tp->ext_Numbers)) {
102 } else if (n > tp->ext_Booleans) {
105 token_type = BOOLEAN;
107 return _nc_extend_names(entryp, name, token_type);
110 /* Well, we are given a cancel for a name that we don't recognize */
111 return _nc_extend_names(entryp, name, STRING);
116 /* Adjust the 'offset' (insertion-point) to keep the lists of extended
119 for (n = first, found = FALSE; n < last; n++) {
120 int cmp = strcmp(tp->ext_Names[n], name);
126 switch (token_type) {
141 switch (token_type) {
143 tp->ext_Booleans += 1;
144 tp->num_Booleans += 1;
145 tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
146 for (last = tp->num_Booleans - 1; last > tindex; last--)
147 tp->Booleans[last] = tp->Booleans[last - 1];
150 tp->ext_Numbers += 1;
151 tp->num_Numbers += 1;
152 tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
153 for (last = tp->num_Numbers - 1; last > tindex; last--)
154 tp->Numbers[last] = tp->Numbers[last - 1];
157 tp->ext_Strings += 1;
158 tp->num_Strings += 1;
159 tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
160 for (last = tp->num_Strings - 1; last > tindex; last--)
161 tp->Strings[last] = tp->Strings[last - 1];
164 actual = NUM_EXT_NAMES(tp);
165 tp->ext_Names = typeRealloc(char *, actual, tp->ext_Names);
166 while (--actual > offset)
167 tp->ext_Names[actual] = tp->ext_Names[actual - 1];
168 tp->ext_Names[offset] = _nc_save_str(name);
171 temp.nte_name = tp->ext_Names[offset];
172 temp.nte_type = token_type;
173 temp.nte_index = tindex;
178 #endif /* NCURSES_XNAMES */
182 * _nc_parse_entry(entry, literal, silent)
184 * Compile one entry. Doesn't try to resolve use or tc capabilities.
186 * found-forward-use = FALSE
187 * re-initialise internal arrays
189 * if the token was not a name in column 1, complain and die
190 * save names in entry's string table
191 * while (get_token() is not EOF and not NAMES)
192 * check for existence and type-correctness
193 * enter cap into structure
195 * save string in entry's string table
199 #define BAD_TC_USAGE if (!bad_tc_usage) \
200 { bad_tc_usage = TRUE; \
201 _nc_warning("Legacy termcap allows only a trailing tc= clause"); }
204 _nc_parse_entry(struct entry *entryp, int literal, bool silent)
207 struct name_table_entry const *entry_ptr;
209 bool bad_tc_usage = FALSE;
211 token_type = _nc_get_token(silent);
213 if (token_type == EOF)
215 if (token_type != NAMES)
216 _nc_err_abort("Entry does not start with terminal names in column one");
218 _nc_init_entry(&entryp->tterm);
220 entryp->cstart = _nc_comment_start;
221 entryp->cend = _nc_comment_end;
222 entryp->startline = _nc_start_line;
223 DEBUG(2, ("Comment range is %ld to %ld", entryp->cstart, entryp->cend));
226 * Strip off the 2-character termcap name, if present. Originally termcap
227 * used that as an indexing aid. We can retain 2-character terminfo names,
228 * but note that they would be lost if we translate to/from termcap. This
229 * feature is supposedly obsolete since "newer" BSD implementations do not
230 * use it; however our reference for this feature is SunOS 4.x, which
231 * implemented it. Note that the resulting terminal type was never the
232 * 2-character name, but was instead the first alias after that.
234 ptr = _nc_curr_token.tk_name;
235 if (_nc_syntax == SYN_TERMCAP) {
238 _nc_curr_token.tk_name[2] = '\0';
242 entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
244 DEBUG(1, ("Starting '%s'", ptr));
247 * We do this because the one-token lookahead in the parse loop
248 * results in the terminal type getting prematurely set to correspond
249 * to that of the next entry.
251 _nc_set_type(_nc_first_name(entryp->tterm.term_names));
253 /* check for overly-long names and aliases */
254 for (base = entryp->tterm.term_names; (ptr = strchr(base, '|')) != 0;
256 if (ptr - base > MAX_ALIAS) {
257 _nc_warning("%s `%.*s' may be too long",
258 (base == entryp->tterm.term_names)
261 (int) (ptr - base), base);
267 for (token_type = _nc_get_token(silent);
268 token_type != EOF && token_type != NAMES;
269 token_type = _nc_get_token(silent)) {
270 bool is_use = (strcmp(_nc_curr_token.tk_name, "use") == 0);
271 bool is_tc = !is_use && (strcmp(_nc_curr_token.tk_name, "tc") == 0);
272 if (is_use || is_tc) {
273 entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring);
274 entryp->uses[entryp->nuses].line = _nc_curr_line;
276 if (entryp->nuses > 1 && is_tc) {
280 /* normal token lookup */
281 entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
282 _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
285 * Our kluge to handle aliasing. The reason it's done
286 * this ugly way, with a linear search, is so the hashing
287 * machinery doesn't have to be made really complicated
288 * (also we get better warnings this way). No point in
289 * making this case fast, aliased caps aren't common now
290 * and will get rarer.
292 if (entry_ptr == NOTFOUND) {
293 const struct alias *ap;
295 if (_nc_syntax == SYN_TERMCAP) {
296 if (entryp->nuses != 0) {
299 for (ap = _nc_capalias_table; ap->from; ap++)
300 if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
301 if (ap->to == (char *) 0) {
302 _nc_warning("%s (%s termcap extension) ignored",
303 ap->from, ap->source);
307 entry_ptr = _nc_find_entry(ap->to, _nc_cap_hash_table);
308 if (entry_ptr && !silent)
309 _nc_warning("%s (%s termcap extension) aliased to %s",
310 ap->from, ap->source, ap->to);
313 } else { /* if (_nc_syntax == SYN_TERMINFO) */
314 for (ap = _nc_infoalias_table; ap->from; ap++)
315 if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
316 if (ap->to == (char *) 0) {
317 _nc_warning("%s (%s terminfo extension) ignored",
318 ap->from, ap->source);
322 entry_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
323 if (entry_ptr && !silent)
324 _nc_warning("%s (%s terminfo extension) aliased to %s",
325 ap->from, ap->source, ap->to);
329 if (entry_ptr == NOTFOUND) {
330 entry_ptr = lookup_fullname(_nc_curr_token.tk_name);
336 * If we have extended-names active, we will automatically
337 * define a name based on its context.
339 if (entry_ptr == NOTFOUND
340 && _nc_user_definable
341 && (entry_ptr = _nc_extend_names(entryp,
342 _nc_curr_token.tk_name,
344 if (_nc_tracing >= DEBUG_LEVEL(1))
345 _nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
347 #endif /* NCURSES_XNAMES */
349 /* can't find this cap name, not even as an alias */
350 if (entry_ptr == NOTFOUND) {
352 _nc_warning("unknown capability '%s'",
353 _nc_curr_token.tk_name);
357 /* deal with bad type/value combinations. */
358 if (token_type != CANCEL && entry_ptr->nte_type != token_type) {
360 * Nasty special cases here handle situations in which type
361 * information can resolve name clashes. Normal lookup
362 * finds the last instance in the capability table of a
363 * given name, regardless of type. find_type_entry looks
364 * for a first matching instance with given type. So as
365 * long as all ambiguous names occur in pairs of distinct
366 * type, this will do the job.
369 /* tell max_attributes from arrow_key_map */
370 if (token_type == NUMBER && !strcmp("ma", _nc_curr_token.tk_name))
371 entry_ptr = _nc_find_type_entry("ma", NUMBER,
372 _nc_get_table(_nc_syntax
375 /* map terminfo's string MT to MT */
376 else if (token_type == STRING && !strcmp("MT", _nc_curr_token.tk_name))
377 entry_ptr = _nc_find_type_entry("MT", STRING,
378 _nc_get_table(_nc_syntax
381 /* treat strings without following "=" as empty strings */
382 else if (token_type == BOOLEAN && entry_ptr->nte_type == STRING)
384 /* we couldn't recover; skip this token */
387 const char *type_name;
388 switch (entry_ptr->nte_type) {
390 type_name = "boolean";
393 type_name = "string";
396 type_name = "numeric";
399 type_name = "unknown";
402 _nc_warning("wrong type used for %s capability '%s'",
403 type_name, _nc_curr_token.tk_name);
409 /* now we know that the type/value combination is OK */
410 switch (token_type) {
412 switch (entry_ptr->nte_type) {
414 entryp->tterm.Booleans[entry_ptr->nte_index] = CANCELLED_BOOLEAN;
418 entryp->tterm.Numbers[entry_ptr->nte_index] = CANCELLED_NUMERIC;
422 entryp->tterm.Strings[entry_ptr->nte_index] = CANCELLED_STRING;
428 entryp->tterm.Booleans[entry_ptr->nte_index] = TRUE;
432 entryp->tterm.Numbers[entry_ptr->nte_index] =
433 _nc_curr_token.tk_valnumber;
437 ptr = _nc_curr_token.tk_valstring;
438 if (_nc_syntax == SYN_TERMCAP)
439 ptr = _nc_captoinfo(_nc_curr_token.tk_name,
441 parametrized[entry_ptr->nte_index]);
442 entryp->tterm.Strings[entry_ptr->nte_index] = _nc_save_str(ptr);
447 _nc_warning("unknown token type");
448 _nc_panic_mode((_nc_syntax == SYN_TERMCAP) ? ':' : ',');
451 } /* end else cur_token.name != "use" */
453 continue; /* cannot have a label w/o statement */
454 } /* endwhile (not EOF and not NAMES) */
456 _nc_push_token(token_type);
457 _nc_set_type(_nc_first_name(entryp->tterm.term_names));
460 * Try to deduce as much as possible from extension capabilities
461 * (this includes obsolete BSD capabilities). Sigh...it would be more
462 * space-efficient to call this after use resolution, but it has
463 * to be done before entry allocation is wrapped up.
466 if (_nc_syntax == SYN_TERMCAP) {
467 bool has_base_entry = FALSE;
471 * Don't insert defaults if this is a `+' entry meant only
472 * for inclusion in other entries (not sure termcap ever
473 * had these, actually).
475 if (strchr(entryp->tterm.term_names, '+'))
476 has_base_entry = TRUE;
479 * Otherwise, look for a base entry that will already
480 * have picked up defaults via translation.
482 for (i = 0; i < entryp->nuses; i++)
483 if (!strchr((char *) entryp->uses[i].name, '+'))
484 has_base_entry = TRUE;
486 postprocess_termcap(&entryp->tterm, has_base_entry);
488 postprocess_terminfo(&entryp->tterm);
490 _nc_wrap_entry(entryp, FALSE);
496 _nc_capcmp(const char *s, const char *t)
497 /* compare two string capabilities, stripping out padding */
505 if (s[0] == '$' && s[1] == '<') {
507 if (!(isdigit(UChar(*s))
515 if (t[0] == '$' && t[1] == '<') {
517 if (!(isdigit(UChar(*t))
525 /* we've now pushed s and t past any padding they were pointing at */
527 if (*s == '\0' && *t == '\0')
533 /* else *s == *t but one is not NUL, so continue */
539 append_acs0(string_desc * dst, int code, int src)
546 _nc_safe_strcat(dst, temp);
551 append_acs(string_desc * dst, int code, char *src)
553 if (src != 0 && strlen(src) == 1) {
554 append_acs0(dst, code, *src);
559 * The ko capability, if present, consists of a comma-separated capability
560 * list. For each capability, we may assume there is a keycap that sends the
561 * string which is the value of that capability.
567 static assoc const ko_xlate[] =
569 {"al", "kil1"}, /* insert line key -> KEY_IL */
570 {"bt", "kcbt"}, /* back tab -> KEY_BTAB */
571 {"cd", "ked"}, /* clear-to-eos key -> KEY_EOL */
572 {"ce", "kel"}, /* clear-to-eol key -> KEY_EOS */
573 {"cl", "kclr"}, /* clear key -> KEY_CLEAR */
574 {"ct", "tbc"}, /* clear all tabs -> KEY_CATAB */
575 {"dc", "kdch1"}, /* delete char -> KEY_DC */
576 {"dl", "kdl1"}, /* delete line -> KEY_DL */
577 {"do", "kcud1"}, /* down key -> KEY_DOWN */
578 {"ei", "krmir"}, /* exit insert key -> KEY_EIC */
579 {"ho", "khome"}, /* home key -> KEY_HOME */
580 {"ic", "kich1"}, /* insert char key -> KEY_IC */
581 {"im", "kIC"}, /* insert-mode key -> KEY_SIC */
582 {"le", "kcub1"}, /* le key -> KEY_LEFT */
583 {"nd", "kcuf1"}, /* nd key -> KEY_RIGHT */
584 {"nl", "kent"}, /* new line key -> KEY_ENTER */
585 {"st", "khts"}, /* set-tab key -> KEY_STAB */
586 {"ta", CANCELLED_STRING},
587 {"up", "kcuu1"}, /* up-arrow key -> KEY_UP */
588 {(char *) 0, (char *) 0},
592 * This routine fills in string caps that either had defaults under
593 * termcap or can be manufactured from obsolete termcap capabilities.
594 * It was lifted from Ross Ridge's mytinfo package.
597 static const char C_CR[] = "\r";
598 static const char C_LF[] = "\n";
599 static const char C_BS[] = "\b";
600 static const char C_HT[] = "\t";
603 * Note that WANTED and PRESENT are not simple inverses! If a capability
604 * has been explicitly cancelled, it's not considered WANTED.
606 #define WANTED(s) ((s) == ABSENT_STRING)
607 #define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
610 * This bit of legerdemain turns all the terminfo variable names into
611 * references to locations in the arrays Booleans, Numbers, and Strings ---
612 * precisely what's needed.
619 postprocess_termcap(TERMTYPE * tp, bool has_base)
621 char buf[MAX_LINE * 2 + 2];
625 * TERMCAP DEFAULTS AND OBSOLETE-CAPABILITY TRANSLATIONS
627 * This first part of the code is the functional inverse of the
628 * fragment in capdefaults.c.
629 * ----------------------------------------------------------------------
632 /* if there was a tc entry, assume we picked up defaults via that */
634 if (WANTED(init_3string) && termcap_init2)
635 init_3string = _nc_save_str(termcap_init2);
637 if (WANTED(reset_2string) && termcap_reset)
638 reset_2string = _nc_save_str(termcap_reset);
640 if (WANTED(carriage_return)) {
641 if (carriage_return_delay > 0) {
642 sprintf(buf, "%s$<%d>", C_CR, carriage_return_delay);
643 carriage_return = _nc_save_str(buf);
645 carriage_return = _nc_save_str(C_CR);
647 if (WANTED(cursor_left)) {
648 if (backspace_delay > 0) {
649 sprintf(buf, "%s$<%d>", C_BS, backspace_delay);
650 cursor_left = _nc_save_str(buf);
651 } else if (backspaces_with_bs == 1)
652 cursor_left = _nc_save_str(C_BS);
653 else if (PRESENT(backspace_if_not_bs))
654 cursor_left = backspace_if_not_bs;
656 /* vi doesn't use "do", but it does seems to use nl (or '\n') instead */
657 if (WANTED(cursor_down)) {
658 if (PRESENT(linefeed_if_not_lf))
659 cursor_down = linefeed_if_not_lf;
660 else if (linefeed_is_newline != 1) {
661 if (new_line_delay > 0) {
662 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
663 cursor_down = _nc_save_str(buf);
665 cursor_down = _nc_save_str(C_LF);
668 if (WANTED(scroll_forward) && crt_no_scrolling != 1) {
669 if (PRESENT(linefeed_if_not_lf))
670 cursor_down = linefeed_if_not_lf;
671 else if (linefeed_is_newline != 1) {
672 if (new_line_delay > 0) {
673 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
674 scroll_forward = _nc_save_str(buf);
676 scroll_forward = _nc_save_str(C_LF);
679 if (WANTED(newline)) {
680 if (linefeed_is_newline == 1) {
681 if (new_line_delay > 0) {
682 sprintf(buf, "%s$<%d>", C_LF, new_line_delay);
683 newline = _nc_save_str(buf);
685 newline = _nc_save_str(C_LF);
686 } else if (PRESENT(carriage_return) && PRESENT(scroll_forward)) {
687 _nc_str_init(&result, buf, sizeof(buf));
688 if (_nc_safe_strcat(&result, carriage_return)
689 && _nc_safe_strcat(&result, scroll_forward))
690 newline = _nc_save_str(buf);
691 } else if (PRESENT(carriage_return) && PRESENT(cursor_down)) {
692 _nc_str_init(&result, buf, sizeof(buf));
693 if (_nc_safe_strcat(&result, carriage_return)
694 && _nc_safe_strcat(&result, cursor_down))
695 newline = _nc_save_str(buf);
701 * Inverse of capdefaults.c code ends here.
702 * ----------------------------------------------------------------------
704 * TERMCAP-TO TERMINFO MAPPINGS FOR SOURCE TRANSLATION
706 * These translations will *not* be inverted by tgetent().
711 * We wait until now to decide if we've got a working cr because even
712 * one that doesn't work can be used for newline. Unfortunately the
713 * space allocated for it is wasted.
715 if (return_does_clr_eol == 1 || no_correctly_working_cr == 1)
716 carriage_return = ABSENT_STRING;
719 * Supposedly most termcap entries have ta now and '\t' is no longer a
720 * default, but it doesn't seem to be true...
723 if (horizontal_tab_delay > 0) {
724 sprintf(buf, "%s$<%d>", C_HT, horizontal_tab_delay);
725 tab = _nc_save_str(buf);
727 tab = _nc_save_str(C_HT);
729 if (init_tabs == ABSENT_NUMERIC && has_hardware_tabs == TRUE)
733 * Assume we can beep with ^G unless we're given bl@.
736 bell = _nc_save_str("\007");
740 * Translate the old termcap :pt: capability to it#8 + ht=\t
742 if (has_hardware_tabs == TRUE) {
743 if (init_tabs != 8 && init_tabs != ABSENT_NUMERIC)
744 _nc_warning("hardware tabs with a width other than 8: %d", init_tabs);
746 if (tab && _nc_capcmp(tab, C_HT))
747 _nc_warning("hardware tabs with a non-^I tab string %s",
751 tab = _nc_save_str(C_HT);
757 * Now translate the ko capability, if there is one. This
758 * isn't from mytinfo...
760 if (PRESENT(other_non_function_keys)) {
761 char *base = other_non_function_keys;
763 struct name_table_entry const *from_ptr;
764 struct name_table_entry const *to_ptr;
766 char buf2[MAX_TERMINFO_LENGTH];
769 /* we're going to use this for a special case later */
770 dp = strchr(other_non_function_keys, 'i');
771 foundim = (dp != 0) && (dp[1] == 'm');
773 /* look at each comma-separated capability in the ko string... */
774 for (base = other_non_function_keys;
775 (cp = strchr(base, ',')) != 0;
777 size_t len = cp - base;
779 for (ap = ko_xlate; ap->from; ap++)
780 if (len == strlen(ap->from)
781 && strncmp(ap->from, base, len) == 0)
784 _nc_warning("unknown capability `%.*s' in ko string",
787 } else if (ap->to == CANCELLED_STRING) /* ignore it */
790 /* now we know we found a match in ko_table, so... */
792 from_ptr = _nc_find_entry(ap->from, _nc_cap_hash_table);
793 to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
795 if (!from_ptr || !to_ptr) /* should never happen! */
796 _nc_err_abort("ko translation table is invalid, I give up");
798 if (WANTED(tp->Strings[from_ptr->nte_index])) {
799 _nc_warning("no value for ko capability %s", ap->from);
803 if (tp->Strings[to_ptr->nte_index]) {
804 /* There's no point in warning about it if it's the same
805 * string; that's just an inefficiency.
808 tp->Strings[from_ptr->nte_index],
809 tp->Strings[to_ptr->nte_index]) != 0)
810 _nc_warning("%s (%s) already has an explicit value %s, ignoring ko",
812 _nc_visbuf(tp->Strings[to_ptr->nte_index]));
817 * The magic moment -- copy the mapped key string over,
818 * stripping out padding.
820 for (dp = buf2, bp = tp->Strings[from_ptr->nte_index]; *bp; bp++) {
821 if (bp[0] == '$' && bp[1] == '<') {
822 while (*bp && *bp != '>') {
830 tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
834 * Note: ko=im and ko=ic both want to grab the `Insert'
835 * keycap. There's a kich1 but no ksmir, so the ic capability
836 * got mapped to kich1 and im to kIC to avoid a collision.
837 * If the description has im but not ic, hack kIC back to kich1.
839 if (foundim && WANTED(key_ic) && key_sic) {
841 key_sic = ABSENT_STRING;
847 if (WANTED(key_backspace))
848 key_backspace = _nc_save_str(C_BS);
849 if (WANTED(key_left))
850 key_left = _nc_save_str(C_BS);
851 if (WANTED(key_down))
852 key_down = _nc_save_str(C_LF);
857 * Translate XENIX forms characters.
859 if (PRESENT(acs_ulcorner) ||
860 PRESENT(acs_llcorner) ||
861 PRESENT(acs_urcorner) ||
862 PRESENT(acs_lrcorner) ||
867 PRESENT(acs_hline) ||
868 PRESENT(acs_vline) ||
870 char buf2[MAX_TERMCAP_LENGTH];
872 _nc_str_init(&result, buf2, sizeof(buf2));
873 _nc_safe_strcat(&result, acs_chars);
875 append_acs(&result, 'j', acs_lrcorner);
876 append_acs(&result, 'k', acs_urcorner);
877 append_acs(&result, 'l', acs_ulcorner);
878 append_acs(&result, 'm', acs_llcorner);
879 append_acs(&result, 'n', acs_plus);
880 append_acs(&result, 'q', acs_hline);
881 append_acs(&result, 't', acs_ltee);
882 append_acs(&result, 'u', acs_rtee);
883 append_acs(&result, 'v', acs_btee);
884 append_acs(&result, 'w', acs_ttee);
885 append_acs(&result, 'x', acs_vline);
888 acs_chars = _nc_save_str(buf2);
889 _nc_warning("acsc string synthesized from XENIX capabilities");
891 } else if (acs_chars == 0
892 && enter_alt_charset_mode != 0
893 && exit_alt_charset_mode != 0) {
894 acs_chars = _nc_save_str(VT_ACSC);
899 postprocess_terminfo(TERMTYPE * tp)
902 * TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION
903 * ----------------------------------------------------------------------
907 * Translate AIX forms characters.
909 if (PRESENT(box_chars_1)) {
910 char buf2[MAX_TERMCAP_LENGTH];
913 _nc_str_init(&result, buf2, sizeof(buf2));
914 _nc_safe_strcat(&result, acs_chars);
916 append_acs0(&result, 'l', box_chars_1[0]); /* ACS_ULCORNER */
917 append_acs0(&result, 'q', box_chars_1[1]); /* ACS_HLINE */
918 append_acs0(&result, 'k', box_chars_1[2]); /* ACS_URCORNER */
919 append_acs0(&result, 'x', box_chars_1[3]); /* ACS_VLINE */
920 append_acs0(&result, 'j', box_chars_1[4]); /* ACS_LRCORNER */
921 append_acs0(&result, 'm', box_chars_1[5]); /* ACS_LLCORNER */
922 append_acs0(&result, 'w', box_chars_1[6]); /* ACS_TTEE */
923 append_acs0(&result, 'u', box_chars_1[7]); /* ACS_RTEE */
924 append_acs0(&result, 'v', box_chars_1[8]); /* ACS_BTEE */
925 append_acs0(&result, 't', box_chars_1[9]); /* ACS_LTEE */
926 append_acs0(&result, 'n', box_chars_1[10]); /* ACS_PLUS */
929 acs_chars = _nc_save_str(buf2);
930 _nc_warning("acsc string synthesized from AIX capabilities");
931 box_chars_1 = ABSENT_STRING;
935 * ----------------------------------------------------------------------
940 * Do a linear search through the terminfo tables to find a given full-name.
941 * We don't expect to do this often, so there's no hashing function.
943 * In effect, this scans through the 3 lists of full-names, and looks them
944 * up in _nc_info_table, which is organized so that the nte_index fields are
945 * sorted, but the nte_type fields are not necessarily grouped together.
947 static struct name_table_entry const *
948 lookup_fullname(const char *find)
954 NCURSES_CONST char *const *names;
970 for (count = 0; names[count] != 0; count++) {
971 if (!strcmp(names[count], find)) {
972 struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
973 while (entry_ptr->nte_type != state
974 || entry_ptr->nte_index != count)
982 /* parse_entry.c ends here */