aboutsummaryrefslogtreecommitdiffstats
path: root/src/termcap.c
diff options
context:
space:
mode:
authorThien-Thi Nguyen2003-12-25 12:13:59 +0000
committerThien-Thi Nguyen2003-12-25 12:13:59 +0000
commit56ffd194371f38239589eb0f818682a0b2e0dbac (patch)
tree9a000920dc6e619614a09b12c2a9f44073914dc9 /src/termcap.c
parent8290faa335bcb23063c9ee355ccfa1b6def202c6 (diff)
downloademacs-56ffd194371f38239589eb0f818682a0b2e0dbac.tar.gz
emacs-56ffd194371f38239589eb0f818682a0b2e0dbac.zip
(tgetst1): Scan for "%pN"; if all
N are continuous in [1,9], remove all "%pN".
Diffstat (limited to 'src/termcap.c')
-rw-r--r--src/termcap.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/termcap.c b/src/termcap.c
index b1e0a87936e..a1c068e0964 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -284,6 +284,52 @@ tgetst1 (ptr, area)
284 } 284 }
285 *r++ = c; 285 *r++ = c;
286 } 286 }
287
288 /* Sometimes entries have "%pN" which means use parameter N in the
289 next %-substitution. If all such N are continuous in the range
290 [1,9] we can remove each "%pN" because they are redundant, thus
291 reducing bandwidth requirements. True, Emacs is well beyond the
292 days of 150baud teletypes, but some of its users aren't much so.
293
294 This pass could probably be integrated into the one above but
295 abbreviation expansion makes that effort a little more hairy than
296 its worth; this is cleaner. */
297 {
298 register int last_p_param = 0;
299 int remove_p_params = 1;
300 struct { char *beg; int len; } cut[11];
301
302 for (cut[0].beg = p = ret; p < r - 3; p++)
303 {
304 if (!remove_p_params)
305 break;
306 if (*p == '%' && *(p + 1) == 'p')
307 {
308 if (*(p + 2) - '0' == 1 + last_p_param)
309 {
310 cut[last_p_param].len = p - cut[last_p_param].beg;
311 last_p_param++;
312 p += 3;
313 cut[last_p_param].beg = p;
314 }
315 else /* not continuous: bail */
316 remove_p_params = 0;
317 if (last_p_param > 10) /* too many: bail */
318 remove_p_params = 0;
319 }
320 }
321 if (remove_p_params && last_p_param)
322 {
323 register int i;
324 char *wp;
325
326 cut[last_p_param].len = r - cut[last_p_param].beg;
327 for (i = 0, wp = ret; i <= last_p_param; wp += cut[i++].len)
328 bcopy (cut[i].beg, wp, cut[i].len);
329 r = wp;
330 }
331 }
332
287 *r = '\0'; 333 *r = '\0';
288 /* Update *AREA. */ 334 /* Update *AREA. */
289 if (area) 335 if (area)