From e9f6866bf85f6f0817884ca2a42ddfb5d56841cb Mon Sep 17 00:00:00 2001 From: srittau Date: Thu, 17 Jan 2002 06:10:43 +0000 Subject: [PATCH] termcap patches from NetBSD package by Christos Zoulas --- etc/papd/printcap.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/etc/papd/printcap.c b/etc/papd/printcap.c index 633ff4eb..845e1b61 100644 --- a/etc/papd/printcap.c +++ b/etc/papd/printcap.c @@ -1,5 +1,5 @@ /* - * $Id: printcap.c,v 1.5 2001-07-31 19:50:14 srittau Exp $ + * $Id: printcap.c,v 1.6 2002-01-17 06:10:43 srittau Exp $ * * Copyright (c) 1990,1994 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -172,6 +172,7 @@ int tgetent( cap, bp, name) register int i = 0, cnt = 0; char ibuf[BUFSIZ]; int tf; + int skip; hopcount = 0; tbuf = bp; @@ -190,7 +191,7 @@ int tgetent( cap, bp, name) cp2 = getenv("TERM"); if (cp2==(char *) 0 || strcmp(name,cp2)==0) { strcpy(bp,cp); - return(tnchktc()); + return(tnchktc(cap)); } else { tf = open(cap, 0); } @@ -199,13 +200,14 @@ int tgetent( cap, bp, name) } if (tf==0) tf = open(cap, 0); -#else +#else /* V6 */ tf = open(cap, 0); -#endif +#endif /* V6 */ if (tf < 0) return (-1); for (;;) { cp = bp; + skip = 0; for (;;) { if (i == cnt) { cnt = read(tf, ibuf, BUFSIZ); @@ -217,12 +219,21 @@ int tgetent( cap, bp, name) } c = ibuf[i++]; if (c == '\n') { - if (cp > bp && cp[-1] == '\\'){ + if (!skip && cp > bp && cp[-1] == '\\') { cp--; continue; } + skip = 0; + if (cp == bp) + continue; + else + break; break; } + if (c == '#' && cp == bp) + skip++; + if (skip) + continue; if (cp >= bp+BUFSIZ) { write(2,"Termcap entry too long\n", 23); break; -- 2.39.2