getch2: Load the "ce", "ks" and "ke" caps into a static buffer

Fixes reports of printing of garbage (or anything else) other than clearing
the status line to the end of line: the buffer returned by termcap_get
could get moved, and if that happened then these 3 caps pointed to garbage.
This commit is contained in:
Diogo Franco (Kovensky)
2013-07-26 16:03:56 -03:00
parent 630edc0637
commit fac2d9097e
+6 -3
View File
@@ -270,7 +270,10 @@ int load_termcap(char *termtype){
#endif
ensure_cap(&termcap_buf, 2048);
erase_to_end_of_line = termcap_get("ce");
static char term_buf[64];
char *buf_ptr = &term_buf[0];
erase_to_end_of_line = tgetstr("ce", &buf_ptr);
screen_width = tgetnum("co");
screen_height = tgetnum("li");
@@ -279,8 +282,8 @@ int load_termcap(char *termtype){
if (screen_height < 1 || screen_height > 255)
screen_height = 24;
term_smkx = termcap_get("ks");
term_rmkx = termcap_get("ke");
term_smkx = tgetstr("ks", &buf_ptr);
term_rmkx = tgetstr("ke", &buf_ptr);
cap_key_pair keys[] = {
{"kP", MP_KEY_PGUP}, {"kN", MP_KEY_PGDWN}, {"kh", MP_KEY_HOME}, {"kH", MP_KEY_END},