diff options
| author | Thien-Thi Nguyen | 2003-12-25 12:13:59 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2003-12-25 12:13:59 +0000 |
| commit | 56ffd194371f38239589eb0f818682a0b2e0dbac (patch) | |
| tree | 9a000920dc6e619614a09b12c2a9f44073914dc9 /src | |
| parent | 8290faa335bcb23063c9ee355ccfa1b6def202c6 (diff) | |
| download | emacs-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')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/termcap.c | 46 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4adadd84db1..f3b9d0f81ea 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2003-12-25 Thien-Thi Nguyen <ttn@gnu.org> | ||
| 2 | |||
| 3 | * termcap.c (tgetst1): Scan for "%pN"; if all | ||
| 4 | N are continuous in [1,9], remove all "%pN". | ||
| 5 | |||
| 1 | 2003-12-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | 6 | 2003-12-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> |
| 2 | 7 | ||
| 3 | * gtkutil.c (xg_frame_set_char_size): Call x_wm_set_size_hint. | 8 | * gtkutil.c (xg_frame_set_char_size): Call x_wm_set_size_hint. |
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) |