summaryrefslogtreecommitdiff
path: root/ed.screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'ed.screen.c')
-rw-r--r--ed.screen.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/ed.screen.c b/ed.screen.c
index 8bcbdacacdd6..2ef572c5206f 100644
--- a/ed.screen.c
+++ b/ed.screen.c
@@ -1,4 +1,4 @@
-/* $Header: /p/tcsh/cvsroot/tcsh/ed.screen.c,v 3.78 2011/02/27 00:14:38 christos Exp $ */
+/* $Header: /p/tcsh/cvsroot/tcsh/ed.screen.c,v 3.82 2016/11/24 15:04:14 christos Exp $ */
/*
* ed.screen.c: Editor/termcap-curses interface
*/
@@ -32,7 +32,7 @@
*/
#include "sh.h"
-RCSID("$tcsh: ed.screen.c,v 3.78 2011/02/27 00:14:38 christos Exp $")
+RCSID("$tcsh: ed.screen.c,v 3.82 2016/11/24 15:04:14 christos Exp $")
#include "ed.h"
#include "tc.h"
@@ -994,14 +994,14 @@ SetAttributes(Char atr)
int highlighting = 0;
void
-StartHighlight()
+StartHighlight(void)
{
(void) tputs(Str(T_mr), 1, PUTPURE);
highlighting = 1;
}
void
-StopHighlight()
+StopHighlight(void)
{
(void) tputs(Str(T_me), 1, PUTPURE);
highlighting = 0;
@@ -1437,7 +1437,8 @@ GetTermCaps(void)
if (i <= 0) {
if (i == -1) {
#if (SYSVREL == 0) || defined(IRIS3D)
- xprintf(CGETS(7, 20, "%s: Cannot open /etc/termcap.\n"), progname);
+ xprintf(CGETS(7, 20,
+ "%s: The terminal database could not be opened.\n"), progname);
}
else if (i == 0) {
#endif /* SYSVREL */
@@ -1563,13 +1564,13 @@ GetSize(int *lins, int *cols)
#endif /* SIG_WINDOW */
#ifdef KNOWsize
-static void
+static int
UpdateVal(const Char *tag, int value, Char *termcap, Char *backup)
{
Char *ptr, *p;
if ((ptr = Strstr(termcap, tag)) == NULL) {
(void)Strcpy(backup, termcap);
- return;
+ return 0;
} else {
size_t len = (ptr - termcap) + Strlen(tag);
(void)Strncpy(backup, termcap, len);
@@ -1580,6 +1581,7 @@ UpdateVal(const Char *tag, int value, Char *termcap, Char *backup)
ptr = Strchr(ptr, ':');
if (ptr)
(void) Strcat(backup, ptr);
+ return 1;
}
}
#endif
@@ -1625,21 +1627,23 @@ ChangeSize(int lins, int cols)
if ((tptr = getenv("TERMCAP")) != NULL) {
/* Leave 64 characters slop in case we enlarge the termcap string */
Char termcap[TC_BUFSIZE+64], backup[TC_BUFSIZE+64], *ptr;
- Char buf[4];
+ int changed;
ptr = str2short(tptr);
(void) Strncpy(termcap, ptr, TC_BUFSIZE);
termcap[TC_BUFSIZE-1] = '\0';
- UpdateVal(STRco, Val(T_co), termcap, backup);
- UpdateVal(STRli, Val(T_li), termcap, backup);
+ changed = UpdateVal(STRco, Val(T_co), termcap, backup);
+ changed |= UpdateVal(STRli, Val(T_li), termcap, backup);
- /*
- * Chop the termcap string at TC_BUFSIZE-1 characters to avoid
- * core-dumps in the termcap routines
- */
- termcap[TC_BUFSIZE - 1] = '\0';
- tsetenv(STRTERMCAP, termcap);
+ if (changed) {
+ /*
+ * Chop the termcap string at TC_BUFSIZE-1 characters to avoid
+ * core-dumps in the termcap routines
+ */
+ termcap[TC_BUFSIZE - 1] = '\0';
+ tsetenv(STRTERMCAP, termcap);
+ }
}
}
#endif /* KNOWsize */