summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shambarger <devel@shambarger.net>2019-11-05 16:59:41 +0000
committerAmadeusz Sławiński <amade@asmblr.net>2019-12-28 13:45:24 +0100
commit241553f21ce38eae821ea4c1e12241365563d444 (patch)
tree0b905e2bbf9c910d81644fdc736f2acfc1930121
parentc4a059f1170eaf1ffb4ce18804944d744a73f6e8 (diff)
downloadscreen-241553f21ce38eae821ea4c1e12241365563d444.tar.gz
Create TERMCAP entries limited to 1023 bytes by default.
TERMCAP_BUF defaults to 1023 to create TERMCAP entries that work on most systems. To save space, TERMCAP is unwrapped, and vt220 extra keys are skipped (unless TERMCAP_BUF > 1023); navigation keys are still included. Entries larger than TERMCAP_BUF are now truncated, and no longer Panic screen. Termcap entries are still wrapped when saved to a file. Signed-off-by: Scott Shambarger <devel@shambarger.net>
-rw-r--r--src/extern.h1
-rw-r--r--src/fileio.c5
-rw-r--r--src/os.h2
-rw-r--r--src/term.c1
-rw-r--r--src/termcap.c56
5 files changed, 46 insertions, 19 deletions
diff --git a/src/extern.h b/src/extern.h
index aa8b975..d4e57df 100644
--- a/src/extern.h
+++ b/src/extern.h
@@ -235,6 +235,7 @@ extern int StuffKey __P((int));
/* termcap.c */
extern int InitTermcap __P((int, int));
extern char *MakeTermcap __P((int));
+extern void DumpTermcap __P((int, FILE *));
extern char *gettermcapstring __P((char *));
#ifdef MAPKEYS
extern int remap __P((int, int));
diff --git a/src/fileio.c b/src/fileio.c
index fb97a5e..3d9da04 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -480,10 +480,7 @@ void WriteFile(struct acluser *user, char *fn, int dump) {
break;
case DUMP_TERMCAP:
- if ((p = index(MakeTermcap(fore->w_aflag), '=')) != NULL) {
- fputs(++p, f);
- putc('\n', f);
- }
+ DumpTermcap(fore->w_aflag, f);
break;
#ifdef COPY_PASTE
diff --git a/src/os.h b/src/os.h
index 3cbefae..2a1c2ca 100644
--- a/src/os.h
+++ b/src/os.h
@@ -507,7 +507,7 @@ typedef struct fd_set { int fds_bits[1]; } fd_set;
*/
#ifndef TERMCAP_BUFSIZE
-# define TERMCAP_BUFSIZE 2048
+# define TERMCAP_BUFSIZE 1023
#endif
#ifndef MAXPATHLEN
diff --git a/src/term.c b/src/term.c
index da672c4..c7a13c9 100644
--- a/src/term.c
+++ b/src/term.c
@@ -197,6 +197,7 @@ struct term term[T_N] =
{ "F1", T_STR }, KMAPDEF("\033[23~")
{ "F2", T_STR }, KMAPDEF("\033[24~")
/* extra keys for vt220 (David.Leonard@it.uq.edu.au) */
+/* define T_FEXTRA */
{ "F3", T_STR },
{ "F4", T_STR },
{ "F5", T_STR },
diff --git a/src/termcap.c b/src/termcap.c
index d0ce5d2..26cba62 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -75,11 +75,10 @@ char screenterm[MAXTERMLEN + 1]; /* new $TERM, usually "screen" */
char *extra_incap, *extra_outcap;
-static const char TermcapConst[] = "\\\n\
-\t:DO=\\E[%dB:LE=\\E[%dD:RI=\\E[%dC:UP=\\E[%dA:bs:bt=\\E[Z:\\\n\
-\t:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:cm=\\E[%i%d;%dH:ct=\\E[3g:\\\n\
-\t:do=^J:nd=\\E[C:pt:rc=\\E8:rs=\\Ec:sc=\\E7:st=\\EH:up=\\EM:\\\n\
-\t:le=^H:bl=^G:cr=^M:it#8:ho=\\E[H:nw=\\EE:ta=^I:is=\\E)0:";
+static const char TermcapConst[] = "DO=\\E[%dB:LE=\\E[%dD:RI=\\E[%dC:\
+UP=\\E[%dA:bs:bt=\\E[Z:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:cm=\\E[%i%d;%dH:\
+ct=\\E[3g:do=^J:nd=\\E[C:pt:rc=\\E8:rs=\\Ec:sc=\\E7:st=\\EH:up=\\EM:\
+le=^H:bl=^G:cr=^M:it#8:ho=\\E[H:nw=\\EE:ta=^I:is=\\E)0:";
char *
gettermcapstring(s)
@@ -827,21 +826,13 @@ AddCap(s)
char *s;
{
register int n;
-
- if (tcLineLen + (n = strlen(s)) > 55 && Termcaplen < TERMCAP_BUFSIZE - 4 - 1)
- {
- strcpy(Termcap + Termcaplen, "\\\n\t:");
- Termcaplen += 4;
- tcLineLen = 0;
- }
+ n=strlen(s);
if (Termcaplen + n < TERMCAP_BUFSIZE - 1)
{
strcpy(Termcap + Termcaplen, s);
Termcaplen += n;
tcLineLen += n;
}
- else
- Panic(0, "TERMCAP overflow - sorry.");
}
/*
@@ -1077,6 +1068,12 @@ int aflag;
{
if (i >= T_KEYPAD) /* don't put keypad codes in TERMCAP */
continue; /* - makes it too big */
+#if (TERMCAP_BUF < 1024)
+ if (i >= T_FEXTRA && i < T_BACKTAB) /* also skip extra vt220 keys */
+ continue;
+ if (i > T_BACKTAB && i < T_NAVIGATE) /* more vt220 keys */
+ continue;
+#endif
if (i >= T_CURSOR && i < T_OCAPS)
{
act = &umtab[i - (T_CURSOR - T_OCAPS + T_CAPS)];
@@ -1131,6 +1128,37 @@ int aflag;
return Termcap;
}
+#define TERMCAP_MAX_WIDTH 63
+void
+DumpTermcap(aflag, f)
+int aflag;
+FILE *f;
+{
+ register const char *p, *pe;
+ int n, col=0;
+
+ if ((p = index(MakeTermcap(aflag), '=')) == NULL)
+ return;
+ p++;
+ debug1("DumpTermcap: '%s'\n", p);
+ /* write termcap entry with wrapping */
+ while((pe = index(p, ':')))
+ {
+ n = pe - p + 1;
+ if((col > 8) && ((col + n) > TERMCAP_MAX_WIDTH))
+ {
+ fwrite("\\\n\t:", 1, 4, f);
+ col = 8;
+ }
+ fwrite(p, 1, n, f);
+ col += n;
+ p = ++pe;
+ }
+ if(*p)
+ fwrite(p, 1, strlen(p), f);
+ fputc('\n', f);
+}
+
static void
MakeString(cap, buf, buflen, s)
char *cap, *buf;