1 /****************************************************************************
2  * Copyright 2020 Thomas E. Dickey                                          *
3  * Copyright 1998-2000,2008 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 /* $Id: capdefaults.c,v 1.15 2020/02/02 23:34:34 tom Exp $ */
37 
38     /*
39      * Compute obsolete capabilities.  The reason this is an include file is
40      * that the two places where it's needed want the macros to generate
41      * offsets to different structures.  See the file Caps for explanations of
42      * these conversions.
43      *
44      * Note:  This code is the functional inverse of the first part of
45      * postprocess_termcap().
46      */
47 {
48     char *strp;
49     short capval;
50 
51 #define EXTRACT_DELAY(str) \
52     	(short) (strp = strchr(str, '*'), strp ? atoi(strp+1) : 0)
53 
54     /* current (4.4BSD) capabilities marked obsolete */
55     if (VALID_STRING(carriage_return)
56 	&& (capval = EXTRACT_DELAY(carriage_return)))
57 	carriage_return_delay = capval;
58     if (VALID_STRING(newline) && (capval = EXTRACT_DELAY(newline)))
59 	new_line_delay = capval;
60 
61     /* current (4.4BSD) capabilities not obsolete */
62     if (!VALID_STRING(termcap_init2) && VALID_STRING(init_3string)) {
63 	termcap_init2 = init_3string;
64 	init_3string = ABSENT_STRING;
65     }
66     if (!VALID_STRING(termcap_reset)
67      && VALID_STRING(reset_2string)
68      && !VALID_STRING(reset_1string)
69      && !VALID_STRING(reset_3string)) {
70 	termcap_reset = reset_2string;
71 	reset_2string = ABSENT_STRING;
72     }
73     if (magic_cookie_glitch_ul == ABSENT_NUMERIC
74 	&& magic_cookie_glitch != ABSENT_NUMERIC
75 	&& VALID_STRING(enter_underline_mode))
76 	magic_cookie_glitch_ul = magic_cookie_glitch;
77 
78     /* totally obsolete capabilities */
79     linefeed_is_newline = (char) (VALID_STRING(newline)
80 				  && (strcmp("\n", newline) == 0));
81     if (VALID_STRING(cursor_left)
82 	&& (capval = EXTRACT_DELAY(cursor_left)))
83 	backspace_delay = capval;
84     if (VALID_STRING(tab) && (capval = EXTRACT_DELAY(tab)))
85 	horizontal_tab_delay = capval;
86 #undef EXTRACT_DELAY
87 }
88