1: /* Interface from Emacs to terminfo.
2: Copyright (C) 1985 Richard M. Stallman.
3:
4: This file is part of GNU Emacs.
5:
6: GNU Emacs is distributed in the hope that it will be useful,
7: but WITHOUT ANY WARRANTY. No author or distributor
8: accepts responsibility to anyone for the consequences of using it
9: or for whether it serves any particular purpose or works at all,
10: unless he says so in writing. Refer to the GNU Emacs General Public
11: License for full details.
12:
13: Everyone is granted permission to copy, modify and redistribute
14: GNU Emacs, but only under the conditions described in the
15: GNU Emacs General Public License. A copy of this license is
16: supposed to have been given to you along with GNU Emacs so you
17: can know your rights and responsibilities. It should be in a
18: file named COPYING. Among other things, the copyright notice
19: and this notice must be preserved on all copies. */
20:
21: /* This is to avoid need to conditionalize interface to termcap. */
22:
23: #include "config.h"
24:
25: char UP, BC, PC;
26: short ospeed;
27:
28: #ifdef NO_ARG_ARRAY
29: tparam (string, outstring,
30: arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
31: char *string;
32: char *outstring;
33: int arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9;
34: {
35: char argp[10];
36: argp[0] = arg0; argp[1] = arg1; argp[2] = arg2;
37: argp[3] = arg3; argp[4] = arg4; argp[5] = arg5;
38: argp[6] = arg6; argp[7] = arg7; argp[8] = arg8;
39: argp[9] = arg9;
40: tparam1(string, outstring, &argp[0]);
41: }
42: #else /* no NO_ARG_ARRAY */
43: tparam (string, outstring, arg)
44: char *string;
45: char *outstring;
46: int arg;
47: {
48: tparam1 (string, outstring, &arg);
49: }
50: #endif /* no NO_ARG_ARRAY */
51:
52: #define todigit(c) ((c) - '0')
53:
54: /* Virtual TERMINFO machine */
55:
56: #define TO_REG(c) (((int) c) - ((int) 'a'))
57: #define REG(c) the_registers[TO_REG (c)]
58: #define PUSH(x) *--sp = ((int) x);
59: #define POP() *sp++
60:
61: #define UN_OP(op) \
62: *sp = op (*sp); \
63: continue
64:
65: #define BIN_OP(op) \
66: sp[1] = ((sp[0]) op (sp[1])); \
67: sp += 1; \
68: continue
69:
70: #define SEND(c) \
71: *outstring++ = ((char) c); \
72: continue
73:
74: #define SSEND(f) \
75: sprintf (outstring, f, POP ()); \
76: while (*outstring++ != '\0') ; \
77: outstring -= 1; \
78: continue
79:
80: tparam1 (string, outstring, argp)
81: register char *string;
82: register char *outstring;
83: int *argp;
84: { long the_registers[TO_REG ('z')];
85: long the_stack[50];
86: register long *sp = &the_stack[50];
87: register char c;
88: while ((c = *string++) != '\0')
89: switch (c)
90: {
91: case '%':
92: switch (c = *string++)
93: { case '%': SEND ('%');
94: case 'd': SSEND ("%d");
95: case '2':
96: string += 1;
97: SSEND ("%2d");
98: case '3':
99: string += 1;
100: SSEND ("%3d");
101: case '0':
102: c = *string;
103: string += 2;
104: SSEND ((c == '2') ? "%02d" : "%03d");
105: case 'c': SEND (((char) POP ()));
106: case 's': SSEND ("%s");
107: case 'p':
108: PUSH (argp[(todigit (*string++))-1]);
109: continue;
110: case 'P':
111: REG (*string++) = POP ();
112: continue;
113: case 'g':
114: PUSH (REG (*string++));
115: continue;
116: case '\'':
117: PUSH (*string);
118: string += 2;
119: continue;
120: case '{':
121: { int temp;
122: sscanf (string, "%d", &temp);
123: PUSH (temp);
124: while (*string++ != '}') ;
125: continue;
126: }
127: case '+': BIN_OP (+);
128: case '-': BIN_OP (-);
129: case '*': BIN_OP (*);
130: case '/': BIN_OP (/);
131: case 'm': BIN_OP (%);
132: case '&': BIN_OP (&);
133: case '|': BIN_OP (|);
134: case '^': BIN_OP (^);
135: case '=': BIN_OP (=);
136: case '<': BIN_OP (<);
137: case '>': BIN_OP (<);
138: case '!': UN_OP (!);
139: case '~': UN_OP (~);
140: case 'i':
141: argp[0] += 1;
142: argp[1] += 1;
143: continue;
144: case '?':
145: case 't':
146: case 'e':
147: case ';':
148: default:
149: continue;
150: } /* switch for % */
151: default: SEND (c);
152: } /* outer switch */
153: *outstring = '\0';
154: } /* tparam1 */
Defined functions
Defined variables
BC
defined in line
25;
never used
PC
defined in line
25; used 1 times
UP
defined in line
25;
never used
Defined macros
BIN_OP
defined in line
65; used 11 times
POP
defined in line
59; used 3 times
PUSH
defined in line
58; used 4 times
REG
defined in line
57; used 2 times
SEND
defined in line
70; used 3 times
SSEND
defined in line
74; used 5 times
UN_OP
defined in line
61; used 2 times