]> arthur.barton.de Git - netatalk.git/commitdiff
termcap patches from NetBSD package by Christos Zoulas
authorsrittau <srittau>
Thu, 17 Jan 2002 06:10:43 +0000 (06:10 +0000)
committersrittau <srittau>
Thu, 17 Jan 2002 06:10:43 +0000 (06:10 +0000)
etc/papd/printcap.c

index 633ff4ebf6a1067a70f5602255458cf2c868bcc0..845e1b618a67262d2b4a40c3dcaf49f399be72aa 100644 (file)
@@ -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;