aboutsummaryrefslogtreecommitdiffstats
path: root/src/termcap.c
diff options
context:
space:
mode:
authorKenichi Handa2004-04-16 12:51:06 +0000
committerKenichi Handa2004-04-16 12:51:06 +0000
commit6b61353c0a0320ee15bb6488149735381fed62ec (patch)
treee69adba60e504a5a37beb556ad70084de88a7aab /src/termcap.c
parentdc6a28319312fe81f7a1015e363174022313f0bd (diff)
downloademacs-6b61353c0a0320ee15bb6488149735381fed62ec.tar.gz
emacs-6b61353c0a0320ee15bb6488149735381fed62ec.zip
Sync to HEAD
Diffstat (limited to 'src/termcap.c')
-rw-r--r--src/termcap.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/termcap.c b/src/termcap.c
index fa8d0ced0aa..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)
@@ -828,3 +874,6 @@ tprint (cap)
828} 874}
829 875
830#endif /* TEST */ 876#endif /* TEST */
877
878/* arch-tag: c2e8d427-2271-4fac-95fe-411857238b80
879 (do not change this comment) */