From 456a0061f0812a8dce332b65621603535063cac3 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Fri, 1 Nov 2013 13:06:02 +0000 Subject: [PATCH] Fix output when client is built against termcap. The pointer passed to tgetstr() must not be reset each time around the loop. Also some other minor cleanups in term_init(). git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@428 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 2 ++ source/term.c | 27 ++++++++------------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Changelog b/Changelog index afe62be..4449c39 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2c01] +* Fix output when built against termcap. (caf) + * Fix STATUS_NOTIFY so that it appears in the right window. (caf) * Improve robustness of status formats handling. (caf) diff --git a/source/term.c b/source/term.c index eaf8dee..47a532e 100644 --- a/source/term.c +++ b/source/term.c @@ -797,9 +797,6 @@ PROCESS_INFORMATION pi = { 0 }; #endif /* STERM_C */ #endif /* NOT IN WTERM_C */ - - - /* * term_init: does all terminal initialization... reads termcap info, sets * the terminal to CBREAK, no ECHO mode. Chooses the best of the terminal @@ -812,9 +809,9 @@ int termfeatures = 0; int term_init (char *term) { #ifndef WTERM_C - int i; - int desired; - + int i; + int desired; + char *termcap2_ptr = termcap2; #if !defined(__EMX__) && !defined(WINNT) && !defined(GUI) memset(current_term, 0, sizeof(struct term_struct)); @@ -852,28 +849,20 @@ int term_init (char *term) for (i = 0; i < numcaps; i++) { - int ival; - char *cval; - if (tcaps[i].type == CAP_TYPE_INT) { - ival = Tgetnum(tcaps[i]); - *(int *)tcaps[i].ptr = ival; + *(int *)tcaps[i].ptr = Tgetnum(tcaps[i]); } else if (tcaps[i].type == CAP_TYPE_BOOL) { - ival = Tgetflag(tcaps[i]); - *(int *)tcaps[i].ptr = ival; + *(int *)tcaps[i].ptr = Tgetflag(tcaps[i]); } else { - char *tmp = termcap2; - - cval = Tgetstr(tcaps[i], tmp); + char *cval = Tgetstr(tcaps[i], termcap2_ptr); if (cval == (char *) -1) - *(char **)tcaps[i].ptr = NULL; - else - *(char **)tcaps[i].ptr = cval; + cval = NULL; + *(char **)tcaps[i].ptr = cval; } }