Subject: Re: bin/7198: recent xterm termcap entry flakes out screen
To: ITOH Yasufumi <yasufu-i@is.aist-nara.ac.jp>
From: David Brownlee <abs@anim.dreamworks.com>
List: netbsd-bugs
Date: 03/21/1999 13:31:45
On Sat, 20 Mar 1999, ITOH Yasufumi wrote:
> abs@anim.dreamworks.com writes:
>
> > Another approach might be to modify NetBSD's tgetent() to
> > effectively s/:[ \t\n]+:/:/ when the entry is greater than
> > 1024 bytes long. More work, but more generally useful :)
>
> Sounds good. Go ahead. :)
>
> It is also nice of screen not to break statically linked binaries,
> so I put my patch in pkgsrc.
>
Makes sense :)
OK - the I could add the code in tgetent(), or in cgetset() which
it calls to 'push' the contents of the TERMCAP variable onto the
start of the stack of places in which to look for term entries.
If I do the latter I end up with something like:
(cvs.netbsd.org is down, so 'hand' diff :)
This makes cgetset() strip the fields in pretty much the same fashion
as the cgetcap() and friends, which should be pretty much TRT.
I've tested it out on a selection of data, and in the screen case it
saves around 60bytes.
Does anyone have any objections if I commit this (when cvs comes back)
int
cgetset(ent)
const char *ent;
{
+ const char *source, *check;
+ char *dest;
if (ent == NULL) {
if (toprec)
free(toprec);
toprec = NULL;
topreclen = 0;
return (0);
}
topreclen = strlen(ent);
if ((toprec = malloc (topreclen + 1)) == NULL) {
errno = ENOMEM;
return (-1);
}
gottoprec = 0;
- strcpy(toprec,ent); # XXXX strcpy is OK here
+ source=ent;
+ dest=toprec;
+ while (*source) /* Strip whitespace */
+ *dest++ = *source++; /* Do not check first field */
+ while (*source == ':') {
+ check=source+1;
+ while (*check && isspace(*check) ||
+ (*check=='\\' && isspace(check[1])))
+ ++check;
+ if( *check == ':' )
+ source=check;
+ else
+ break;
+
+ }
+ }
+ *dest=0;
return (0);
}
David/absolute
-=- "I know its not the right thing, and I know its not the good thing" -=-