annotate tparam.c @ 13230:ad1d4be6bb8d libc-951018 libc-951029 libc-951031 libc-951101 libc-951102 libc-951103 libc-951104 libc-951105 libc-951106 libc-951107 libc-951108 libc-951109 libc-951110 libc-951111 libc-951112 libc-951113 libc-951114 libc-951115 libc-951116 libc-951117 libc-951118 libc-951119 libc-951120 libc-951121 libc-951122 libc-951123 libc-951124 libc-951125 libc-951126 libc-951127 libc-951128 libc-951129 libc-951130

* config.guess: Recognize HP model 819 machines has having a PA 1.1 processor.
author Jeff Law <law@redhat.com>
date Mon, 16 Oct 1995 15:40:29 +0000
parents bd38619285f7
children 6e7bb4bd5010
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4687
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1 /* Merge parameters into a termcap entry string.
12678
8fc56d171ada (tparam): Remove arg array and the #ifdef.
David J. MacKenzie <djm@gnu.org>
parents: 4687
diff changeset
2 Copyright (C) 1985, 87, 93, 95 Free Software Foundation, Inc.
4687
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
3
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
7 any later version.
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
8
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
12 GNU General Public License for more details.
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
13
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
15 along with this program; see the file COPYING. If not, write to
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
17
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
18 /* Emacs config.h may rename various library functions such as malloc. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
19 #ifdef HAVE_CONFIG_H
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
20 #include <config.h>
12994
bd38619285f7 Don't assume that HAVE_CONFIG_H implies emacs.
David J. MacKenzie <djm@gnu.org>
parents: 12678
diff changeset
21 #endif
4687
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
22
12994
bd38619285f7 Don't assume that HAVE_CONFIG_H implies emacs.
David J. MacKenzie <djm@gnu.org>
parents: 12678
diff changeset
23 #ifndef emacs
4687
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
24 #if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
25 #define bcopy(s, d, n) memcpy ((d), (s), (n))
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
26 #endif
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
27
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
28 #ifdef STDC_HEADERS
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
29 #include <stdlib.h>
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
30 #include <string.h>
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
31 #else
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
32 char *malloc ();
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
33 char *realloc ();
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
34 #endif
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
35
12994
bd38619285f7 Don't assume that HAVE_CONFIG_H implies emacs.
David J. MacKenzie <djm@gnu.org>
parents: 12678
diff changeset
36 #endif /* not emacs */
4687
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
37
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
38 #ifndef NULL
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
39 #define NULL (char *) 0
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
40 #endif
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
41
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
42 #ifndef emacs
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
43 static void
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
44 memory_out ()
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
45 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
46 write (2, "virtual memory exhausted\n", 25);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
47 exit (1);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
48 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
49
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
50 static char *
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
51 xmalloc (size)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
52 unsigned size;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
53 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
54 register char *tem = malloc (size);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
55
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
56 if (!tem)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
57 memory_out ();
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
58 return tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
59 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
60
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
61 static char *
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
62 xrealloc (ptr, size)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
63 char *ptr;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
64 unsigned size;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
65 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
66 register char *tem = realloc (ptr, size);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
67
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
68 if (!tem)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
69 memory_out ();
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
70 return tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
71 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
72 #endif /* not emacs */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
73
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
74 /* Assuming STRING is the value of a termcap string entry
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
75 containing `%' constructs to expand parameters,
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
76 merge in parameter values and store result in block OUTSTRING points to.
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
77 LEN is the length of OUTSTRING. If more space is needed,
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
78 a block is allocated with `malloc'.
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
79
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
80 The value returned is the address of the resulting string.
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
81 This may be OUTSTRING or may be the address of a block got with `malloc'.
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
82 In the latter case, the caller must free the block.
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
83
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
84 The fourth and following args to tparam serve as the parameter values. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
85
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
86 static char *tparam1 ();
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
87
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
88 /* VARARGS 2 */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
89 char *
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
90 tparam (string, outstring, len, arg0, arg1, arg2, arg3)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
91 char *string;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
92 char *outstring;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
93 int len;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
94 int arg0, arg1, arg2, arg3;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
95 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
96 int arg[4];
12678
8fc56d171ada (tparam): Remove arg array and the #ifdef.
David J. MacKenzie <djm@gnu.org>
parents: 4687
diff changeset
97
4687
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
98 arg[0] = arg0;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
99 arg[1] = arg1;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
100 arg[2] = arg2;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
101 arg[3] = arg3;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
102 return tparam1 (string, outstring, len, NULL, NULL, arg);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
103 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
104
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
105 char *BC;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
106 char *UP;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
107
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
108 static char tgoto_buf[50];
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
109
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
110 char *
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
111 tgoto (cm, hpos, vpos)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
112 char *cm;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
113 int hpos, vpos;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
114 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
115 int args[2];
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
116 if (!cm)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
117 return NULL;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
118 args[0] = vpos;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
119 args[1] = hpos;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
120 return tparam1 (cm, tgoto_buf, 50, UP, BC, args);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
121 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
122
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
123 static char *
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
124 tparam1 (string, outstring, len, up, left, argp)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
125 char *string;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
126 char *outstring;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
127 int len;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
128 char *up, *left;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
129 register int *argp;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
130 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
131 register int c;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
132 register char *p = string;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
133 register char *op = outstring;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
134 char *outend;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
135 int outlen = 0;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
136
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
137 register int tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
138 int *old_argp = argp;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
139 int doleft = 0;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
140 int doup = 0;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
141
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
142 outend = outstring + len;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
143
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
144 while (1)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
145 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
146 /* If the buffer might be too short, make it bigger. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
147 if (op + 5 >= outend)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
148 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
149 register char *new;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
150 if (outlen == 0)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
151 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
152 outlen = len + 40;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
153 new = (char *) xmalloc (outlen);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
154 outend += 40;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
155 bcopy (outstring, new, op - outstring);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
156 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
157 else
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
158 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
159 outend += outlen;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
160 outlen *= 2;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
161 new = (char *) xrealloc (outstring, outlen);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
162 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
163 op += new - outstring;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
164 outend += new - outstring;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
165 outstring = new;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
166 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
167 c = *p++;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
168 if (!c)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
169 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
170 if (c == '%')
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
171 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
172 c = *p++;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
173 tem = *argp;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
174 switch (c)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
175 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
176 case 'd': /* %d means output in decimal. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
177 if (tem < 10)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
178 goto onedigit;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
179 if (tem < 100)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
180 goto twodigit;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
181 case '3': /* %3 means output in decimal, 3 digits. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
182 if (tem > 999)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
183 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
184 *op++ = tem / 1000 + '0';
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
185 tem %= 1000;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
186 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
187 *op++ = tem / 100 + '0';
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
188 case '2': /* %2 means output in decimal, 2 digits. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
189 twodigit:
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
190 tem %= 100;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
191 *op++ = tem / 10 + '0';
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
192 onedigit:
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
193 *op++ = tem % 10 + '0';
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
194 argp++;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
195 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
196
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
197 case 'C':
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
198 /* For c-100: print quotient of value by 96, if nonzero,
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
199 then do like %+. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
200 if (tem >= 96)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
201 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
202 *op++ = tem / 96;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
203 tem %= 96;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
204 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
205 case '+': /* %+x means add character code of char x. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
206 tem += *p++;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
207 case '.': /* %. means output as character. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
208 if (left)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
209 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
210 /* If want to forbid output of 0 and \n and \t,
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
211 and this is one of them, increment it. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
212 while (tem == 0 || tem == '\n' || tem == '\t')
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
213 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
214 tem++;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
215 if (argp == old_argp)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
216 doup++, outend -= strlen (up);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
217 else
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
218 doleft++, outend -= strlen (left);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
219 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
220 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
221 *op++ = tem ? tem : 0200;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
222 case 'f': /* %f means discard next arg. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
223 argp++;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
224 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
225
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
226 case 'b': /* %b means back up one arg (and re-use it). */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
227 argp--;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
228 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
229
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
230 case 'r': /* %r means interchange following two args. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
231 argp[0] = argp[1];
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
232 argp[1] = tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
233 old_argp++;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
234 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
235
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
236 case '>': /* %>xy means if arg is > char code of x, */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
237 if (argp[0] > *p++) /* then add char code of y to the arg, */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
238 argp[0] += *p; /* and in any case don't output. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
239 p++; /* Leave the arg to be output later. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
240 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
241
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
242 case 'a': /* %a means arithmetic. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
243 /* Next character says what operation.
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
244 Add or subtract either a constant or some other arg. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
245 /* First following character is + to add or - to subtract
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
246 or = to assign. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
247 /* Next following char is 'p' and an arg spec
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
248 (0100 plus position of that arg relative to this one)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
249 or 'c' and a constant stored in a character. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
250 tem = p[2] & 0177;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
251 if (p[1] == 'p')
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
252 tem = argp[tem - 0100];
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
253 if (p[0] == '-')
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
254 argp[0] -= tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
255 else if (p[0] == '+')
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
256 argp[0] += tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
257 else if (p[0] == '*')
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
258 argp[0] *= tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
259 else if (p[0] == '/')
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
260 argp[0] /= tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
261 else
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
262 argp[0] = tem;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
263
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
264 p += 3;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
265 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
266
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
267 case 'i': /* %i means add one to arg, */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
268 argp[0] ++; /* and leave it to be output later. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
269 argp[1] ++; /* Increment the following arg, too! */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
270 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
271
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
272 case '%': /* %% means output %; no arg. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
273 goto ordinary;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
274
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
275 case 'n': /* %n means xor each of next two args with 140. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
276 argp[0] ^= 0140;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
277 argp[1] ^= 0140;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
278 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
279
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
280 case 'm': /* %m means xor each of next two args with 177. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
281 argp[0] ^= 0177;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
282 argp[1] ^= 0177;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
283 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
284
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
285 case 'B': /* %B means express arg as BCD char code. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
286 argp[0] += 6 * (tem / 10);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
287 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
288
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
289 case 'D': /* %D means weird Delta Data transformation. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
290 argp[0] -= 2 * (tem % 16);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
291 break;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
292 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
293 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
294 else
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
295 /* Ordinary character in the argument string. */
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
296 ordinary:
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
297 *op++ = c;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
298 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
299 *op = 0;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
300 while (doup-- > 0)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
301 strcat (op, up);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
302 while (doleft-- > 0)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
303 strcat (op, left);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
304 return outstring;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
305 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
306
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
307 #ifdef DEBUG
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
308
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
309 main (argc, argv)
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
310 int argc;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
311 char **argv;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
312 {
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
313 char buf[50];
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
314 int args[3];
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
315 args[0] = atoi (argv[2]);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
316 args[1] = atoi (argv[3]);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
317 args[2] = atoi (argv[4]);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
318 tparam1 (argv[1], buf, "LEFT", "UP", args);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
319 printf ("%s\n", buf);
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
320 return 0;
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
321 }
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
322
f0abfb1b59fd entered into RCS
Roland McGrath <roland@gnu.org>
parents:
diff changeset
323 #endif /* DEBUG */