]>
Commit | Line | Data |
---|---|---|
67dbd305 | 1 | diff -Nur util-linux-2.9r/text-utils/more.c util-linux-2.9r.pld/text-utils/more.c |
2 | --- util-linux-2.9r/text-utils/more.c Sat Mar 20 21:20:18 1999 | |
3 | +++ util-linux-2.9r.pld/text-utils/more.c Sun May 23 13:47:46 1999 | |
4 | @@ -138,7 +138,7 @@ | |
5 | char *shell; /* The name of the shell to use */ | |
6 | int shellp; /* A previous shell command exists */ | |
7 | char ch; | |
8 | -jmp_buf restore; | |
9 | +sigjmp_buf restore; | |
10 | char Line[LINSIZ]; /* Line buffer */ | |
11 | int Lpp = 24; /* lines per page */ | |
12 | char *Clear; /* clear screen */ | |
13 | @@ -151,7 +151,6 @@ | |
14 | char *cursorm; /* cursor movement */ | |
15 | char cursorhome[40]; /* contains cursor movement to home */ | |
16 | char *EodClr; /* clear rest of screen */ | |
17 | -char *tgetstr(); | |
18 | int Mcol = 80; /* number of columns */ | |
19 | int Wrap = 1; /* set if automargins */ | |
20 | int soglitch; /* terminal has standout mode glitch */ | |
21 | @@ -159,6 +158,9 @@ | |
22 | int pstate = 0; /* current UL state */ | |
23 | char *getenv(); | |
24 | static int magic(); | |
25 | +char termbuffer[2048]; | |
26 | +char tcbuffer[2048]; | |
27 | +char * strbuf = termbuffer; | |
28 | struct { | |
29 | long chrctr, line; | |
30 | } context, screen_start; | |
31 | @@ -297,7 +299,7 @@ | |
32 | if ((f = checkf (fnames[fnum], &clearit)) != NULL) { | |
33 | context.line = context.chrctr = 0; | |
34 | Currline = 0; | |
35 | - if (firstf) setjmp (restore); | |
36 | + if (firstf) sigsetjmp (restore, 1); | |
37 | if (firstf) { | |
38 | firstf = 0; | |
39 | if (srchopt) { | |
40 | @@ -309,7 +311,7 @@ | |
41 | skiplns (initline, f); | |
42 | } | |
43 | else if (fnum < nfiles && !no_tty) { | |
44 | - setjmp (restore); | |
45 | + sigsetjmp (restore, 1); | |
46 | left = command (fnames[fnum], f); | |
47 | } | |
48 | if (left != 0) { | |
49 | @@ -343,7 +345,7 @@ | |
50 | within = 0; | |
51 | } | |
52 | } | |
53 | - setjmp (restore); | |
54 | + sigsetjmp (restore, 1); | |
55 | fflush(stdout); | |
56 | fclose(f); | |
57 | screen_start.line = screen_start.chrctr = 0L; | |
58 | @@ -514,7 +516,7 @@ | |
59 | num_lines--; | |
60 | } | |
61 | if (pstate) { | |
62 | - putp (ULexit); | |
63 | + tputs (ULexit, 1, putchar); | |
64 | pstate = 0; | |
65 | } | |
66 | fflush(stdout); | |
67 | @@ -528,7 +530,7 @@ | |
68 | if (Pause && clreol) | |
69 | clreos (); | |
70 | Ungetc (c, f); | |
71 | - setjmp (restore); | |
72 | + sigsetjmp (restore, 1); | |
73 | Pause = 0; startup = 0; | |
74 | if ((num_lines = command (NULL, f)) == 0) | |
75 | return; | |
76 | @@ -557,7 +559,7 @@ | |
77 | putchar ('\n'); | |
78 | if (!startup) { | |
79 | signal(SIGQUIT, onquit); | |
80 | - longjmp (restore, 1); | |
81 | + siglongjmp (restore, 1); | |
82 | } | |
83 | else | |
84 | Pause++; | |
85 | @@ -744,7 +746,7 @@ | |
86 | if (!hard) { | |
87 | promptlen = 8; | |
88 | if (Senter && Sexit) { | |
89 | - putp (Senter); | |
90 | + tputs (Senter, 1, putchar); | |
91 | promptlen += (2 * soglitch); | |
92 | } | |
93 | if (clreol) | |
94 | @@ -760,7 +762,7 @@ | |
95 | promptlen += pr(_("[Press space to continue, 'q' to quit.]")); | |
96 | } | |
97 | if (Senter && Sexit) | |
98 | - putp (Sexit); | |
99 | + tputs (Sexit, 1, putchar); | |
100 | if (clreol) | |
101 | clreos (); | |
102 | fflush(stdout); | |
103 | @@ -807,7 +809,7 @@ | |
104 | if (!hardtabs || (column < promptlen && !hard)) { | |
105 | if (hardtabs && eraseln && !dumb) { | |
106 | column = 1 + (column | 7); | |
107 | - putp (eraseln); | |
108 | + tputs (eraseln, 1, putchar); | |
109 | promptlen = 0; | |
110 | } | |
111 | else { | |
112 | @@ -876,7 +878,7 @@ | |
113 | if (col == 0) | |
114 | putchar ('\r'); | |
115 | if (!dumb && eraseln) | |
116 | - putp (eraseln); | |
117 | + tputs (eraseln, 1, putchar); | |
118 | else | |
119 | for (col = promptlen - col; col > 0; col--) | |
120 | putchar (' '); | |
121 | @@ -900,12 +902,12 @@ | |
122 | */ | |
123 | void cleareol() | |
124 | { | |
125 | - putp(eraseln); | |
126 | + tputs(eraseln, 1, putchar); | |
127 | } | |
128 | ||
129 | void clreos() | |
130 | { | |
131 | - putp(EodClr); | |
132 | + tputs(EodClr, 1, putchar); | |
133 | } | |
134 | ||
135 | /* | |
136 | @@ -949,13 +951,13 @@ | |
137 | if (c == ' ' && state == 0 && ulglitch && wouldul(s, n-1)) | |
138 | state = 1; | |
139 | else | |
140 | - putp(state ? ULenter : ULexit); | |
141 | + tputs(state ? ULenter : ULexit, 1, putchar); | |
142 | } | |
143 | if (c != ' ' || pstate == 0 || state != 0 || ulglitch == 0) | |
144 | putchar(c); | |
145 | if (state && *chUL) { | |
146 | pr(chBS); | |
147 | - putp(chUL); | |
148 | + tputs(chUL, 1, putchar); | |
149 | } | |
150 | pstate = state; | |
151 | } | |
152 | @@ -968,7 +970,7 @@ | |
153 | doclear() | |
154 | { | |
155 | if (Clear && !hard) { | |
156 | - putp(Clear); | |
157 | + tputs(Clear, 1, putchar); | |
158 | ||
159 | /* Put out carriage return so that system doesn't | |
160 | ** get confused by escape sequences when expanding tabs | |
161 | @@ -984,7 +986,7 @@ | |
162 | void | |
163 | home() | |
164 | { | |
165 | - putp(Home); | |
166 | + tputs(Home, 1, putchar); | |
167 | } | |
168 | ||
169 | static int lastcmd, lastarg, lastp; | |
170 | @@ -1200,9 +1202,9 @@ | |
171 | if (dum_opt) { | |
172 | kill_line (); | |
173 | if (Senter && Sexit) { | |
174 | - putp (Senter); | |
175 | + tputs (Senter, 1, putchar); | |
176 | promptlen = pr (_("[Press 'h' for instructions.]")) + (2 * soglitch); | |
177 | - putp (Sexit); | |
178 | + tputs (Sexit, 1, putchar); | |
179 | } | |
180 | else | |
181 | promptlen = pr (_("[Press 'h' for instructions.]")); | |
182 | @@ -1569,7 +1571,7 @@ | |
183 | if ((term = getenv("TERM")) == 0) { | |
184 | dumb++; ul_opt = 0; | |
185 | } | |
186 | - setupterm(term, 1, &ret); | |
187 | + ret = tgetent(tcbuffer, getenv("TERM")); | |
188 | if (ret <= 0) { | |
189 | dumb++; ul_opt = 0; | |
190 | } | |
191 | @@ -1577,35 +1579,35 @@ | |
192 | #ifdef TIOCGWINSZ | |
193 | if (ioctl(fileno(stdout), TIOCGWINSZ, &win) < 0) { | |
194 | #endif | |
195 | - Lpp = tigetnum("lines"); | |
196 | - Mcol = tigetnum("cols"); | |
197 | + Lpp = tgetnum("li"); | |
198 | + Mcol = tgetnum("co"); | |
199 | #ifdef TIOCGWINSZ | |
200 | } else { | |
201 | if ((Lpp = win.ws_row) == 0) | |
202 | - Lpp = tigetnum("lines"); | |
203 | + Lpp = tgetnum("li"); | |
204 | if ((Mcol = win.ws_col) == 0) | |
205 | - Mcol = tigetnum("cols"); | |
206 | + Mcol = tgetnum("co"); | |
207 | } | |
208 | #endif | |
209 | - if ((Lpp <= 0) || tigetflag("hc")) { | |
210 | + if ((Lpp <= 0) || tgetflag("hc")) { | |
211 | hard++; /* Hard copy terminal */ | |
212 | Lpp = 24; | |
213 | } | |
214 | ||
215 | - if (tigetflag("xenl")) | |
216 | + if (tgetflag("xn")) | |
217 | eatnl++; /* Eat newline at last column + 1; dec, concept */ | |
218 | if (Mcol <= 0) | |
219 | Mcol = 80; | |
220 | ||
221 | if (tailequ (fnames[0], "page")) | |
222 | noscroll++; | |
223 | - Wrap = tigetflag("am"); | |
224 | - bad_so = tigetflag ("xhp"); | |
225 | - eraseln = tigetstr("el"); | |
226 | - Clear = tigetstr("clear"); | |
227 | - Senter = tigetstr("smso"); | |
228 | - Sexit = tigetstr("rmso"); | |
229 | - if ((soglitch = tigetnum("xmc")) < 0) | |
230 | + Wrap = tgetflag("am"); | |
231 | + bad_so = tgetflag ("xs"); | |
232 | + eraseln = tgetstr("ce", &strbuf); | |
233 | + Clear = tgetstr("cl", &strbuf); | |
234 | + Senter = tgetstr("co", &strbuf); | |
235 | + Sexit = tgetstr("se", &strbuf); | |
236 | + if ((soglitch = tgetnum("sg")) < 0) | |
237 | soglitch = 0; | |
238 | ||
239 | /* | |
240 | @@ -1616,12 +1618,12 @@ | |
241 | * isn't available, settle for standout sequence. | |
242 | */ | |
243 | ||
244 | - if (tigetflag("ul") || tigetflag("os")) | |
245 | + if (tgetflag("ul") || tgetflag("os")) | |
246 | ul_opt = 0; | |
247 | - if ((chUL = tigetstr("uc")) == NULL ) | |
248 | + if ((chUL = tgetstr("uc", &strbuf)) == NULL ) | |
249 | chUL = ""; | |
250 | - if (((ULenter = tigetstr("smul")) == NULL || | |
251 | - (ULexit = tigetstr("rmul")) == NULL) && !*chUL) { | |
252 | + if (((ULenter = tgetstr("us", &strbuf)) == NULL || | |
253 | + (ULexit = tgetstr("ue", &strbuf)) == NULL) && !*chUL) { | |
254 | if ((ULenter = Senter) == NULL || (ULexit = Sexit) == NULL) { | |
255 | ULenter = ""; | |
256 | ULexit = ""; | |
257 | @@ -1631,20 +1633,20 @@ | |
258 | ulglitch = 0; | |
259 | } | |
260 | ||
261 | - if ((padstr = tigetstr("pad")) != NULL) | |
262 | + if ((padstr = tgetstr("pc", &strbuf)) != NULL) | |
263 | PC = *padstr; | |
264 | - Home = tigetstr("home"); | |
265 | + Home = tgetstr("ho", &strbuf); | |
266 | if (Home == 0 || *Home == '\0') | |
267 | { | |
268 | - if ((cursorm = tigetstr("cup")) != NULL) { | |
269 | - const char *t = (const char *)tparm(cursorm, 0, 0); | |
270 | + if ((cursorm = tgetstr("cm", &strbuf)) != NULL) { | |
271 | + const char *t = (const char *)tgoto(cursorm, 0, 0); | |
272 | strncpy(cursorhome, t, sizeof(cursorhome)); | |
273 | cursorhome[sizeof(cursorhome)-1] = 0; | |
274 | Home = cursorhome; | |
275 | } | |
276 | } | |
277 | - EodClr = tigetstr("ed"); | |
278 | - if ((chBS = tigetstr("cub1")) == NULL) | |
279 | + EodClr = tgetstr("cd", &strbuf); | |
280 | + if ((chBS = tgetstr("le", &strbuf)) == NULL) | |
281 | chBS = "\b"; | |
282 | ||
283 | } | |
284 | @@ -1716,7 +1718,7 @@ | |
285 | } | |
286 | else { | |
287 | if (!eraseln) promptlen = maxlen; | |
288 | - longjmp (restore, 1); | |
289 | + siglongjmp (restore, 1); | |
290 | } | |
291 | } | |
292 | else if ((ch == otty.c_cc[VKILL]) && !slash) { | |
293 | @@ -1857,15 +1859,15 @@ | |
294 | kill_line (); | |
295 | promptlen += strlen (mess); | |
296 | if (Senter && Sexit) { | |
297 | - putp (Senter); | |
298 | + tputs (Senter, 1, putchar); | |
299 | pr(mess); | |
300 | - putp (Sexit); | |
301 | + tputs (Sexit, 1, putchar); | |
302 | } | |
303 | else | |
304 | pr (mess); | |
305 | fflush(stdout); | |
306 | errors++; | |
307 | - longjmp (restore, 1); | |
308 | + siglongjmp (restore, 1); | |
309 | } | |
310 | ||
311 | ||
312 | @@ -1937,5 +1939,5 @@ | |
313 | signal (SIGTSTP, onsusp); | |
314 | set_tty (); | |
315 | if (inwait) | |
316 | - longjmp (restore, 1); | |
317 | + siglongjmp (restore, 1); | |
318 | } |