From owner-freebsd-hackers Mon Sep 24 13:54:41 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 65D6937B410 for ; Mon, 24 Sep 2001 13:54:21 -0700 (PDT) Received: from hades.hell.gr (patr530-a188.otenet.gr [212.205.215.188]) by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id f8OKsHc08629 for ; Mon, 24 Sep 2001 23:54:17 +0300 (EEST) Received: (from charon@localhost) by hades.hell.gr (8.11.6/8.11.6) id f8OKgkD14589 for hackers@freebsd.org; Mon, 24 Sep 2001 23:42:46 +0300 (EEST) (envelope-from charon@labs.gr) Date: Mon, 24 Sep 2001 23:42:46 +0300 From: Giorgos Keramidas To: hackers@freebsd.org Subject: termcap sources Message-ID: <20010924234245.B14545@hades.hell.gr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="5vNYLRcllDrimb99" Content-Disposition: inline User-Agent: Mutt/1.3.22.1i X-GPG-Fingerprint: C1EB 0653 DB8B A557 3829 00F9 D60F 941A 3186 03B6 X-URL: http://labs.gr/~charon/ Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I saw a duplicate in one of the capabilities that wer submitted to -bugs earlier. This had me thinking. What happens when a duplicate capability exists in termcap? Are there any other duplicates in termcap.src? If yes, which? The first attachment is a perl script that strips all cruft from termcap.src (fed through stdin) and makes every terminal entry occupy a single line of text. This is necessary for the second attachment to work correctly. The second attachment is a perl script that splits capability names of each input line in an array, and performs the (boring for a human to do by reading through the termcap sources) duplicate check in all the elements of the array. The third attachment is the output of the command (termcap.src,v 1.109): % cat termcap.src | ./tstrip.pl | ./tdupcheck.pl As you can see there are quite a few terminals that have capabilities defined more than once! I don't have THAT many terminals to check, but I'm open to suggestions. Should we do something about this? If yes, what? -giorgos --5vNYLRcllDrimb99 Content-Type: application/x-perl Content-Disposition: attachment; filename="tstrip.pl" Content-Transfer-Encoding: quoted-printable #!/usr/bin/perl -w=0A=0A#=0A# $Id$=0A#=0A# Strip comments from termcap file= s. Also join all continuation lines (those=0A# ending with backslash) in o= ne long line of text. Use this to prepare input=0A# for the tdupcheck.pl p= rogram (the duplicate capability checker).=0A=0A$buf =3D "";=0A=0ALINE:=0Aw= hile (defined($line =3D )) {=0A chomp $line;=0A=0A # skip empt= y and comment lines=0A next LINE if ($line =3D~ m/^[\s]*$/ || $line =3D~= m/^[\s]*#/);=0A=0A # terminal continuation lines (ending in backslash)= =0A if ($line =3D~ m/^[\s]+.*\\$/) {=0A $line =3D~ s/^[\s]+//;=0A= $line =3D~ s/^://;=0A $line =3D~ s/\\$//;=0A $buf .= =3D $line;=0A next LINE;=0A }=0A=0A # terminal continuation li= nes (final of a terminal entry)=0A if ($line =3D~ m/^[\s]+/) {=0A = $line =3D~ s/^[\s]+//;=0A $line =3D~ s/^://;=0A $buf .=3D $l= ine;=0A next LINE;=0A }=0A=0A # terminal entry starting line= =0A # print collected terminal entry in $buf, and start all over=0A i= f (defined($buf)) {=0A print "$buf\n";=0A $line =3D~ s/\\$//;= =0A $buf =3D $line;=0A next LINE;=0A }=0A}=0A=0A# print an= y left-over contents of the output buffer=0Aif (defined($buf)) {=0A prin= t "$buf\n";=0A}=0A --5vNYLRcllDrimb99 Content-Type: application/x-perl Content-Disposition: attachment; filename="tdupcheck.pl" Content-Transfer-Encoding: quoted-printable #!/usr/bin/perl -w=0A=0A#=0A# $Id$=0A#=0A# Check for duplicate capabilities= in terminal entries fed to us through the=0A# standard input. Feed the te= rmcap source to tstrip.pl before giving it to=0A# this program, for example= :=0A#=0A# % cat /usr/src/share/termcap/termcap.src | ./tstrip.pl | ./tdup= check.pl=0A#=0A=0ALINE:=0Awhile (defined($line =3D )) {=0A chomp = $line;=0A=0A # protect "\:" from being used in split() as a separator.= =0A $line =3D~ s/\\:/\001/g;=0A @cap =3D split /:/,$line;=0A=0A # = cleanup all @cap members from capability values.=0A # we only care for t= heir names.=0A for ($c =3D 0; $c <=3D $#cap; $c++) {=0A $cap[$c] = =3D~ s/=3D.*//;=0A $cap[$c] =3D~ s/#.*//;=0A }=0A=0A # do the = (slow) check for duplicates=0A if ($#cap >=3D 0) {=0A $term =3D $= cap[0];=0A $term =3D~ s/\|.*$//;=0A shift @cap;=0A @du= ps =3D ();=0A for ($c =3D 0; $c <=3D $#cap; $c++) {=0A fo= r ($i =3D $c + 1; $i <=3D $#cap; $i++) {=0A if ($cap[$c] eq = $cap[$i]) {=0A push @dups, $cap[$c];=0A }= =0A }=0A }=0A if ($#dups >=3D 0) {=0A p= rintf "$term - " . join(":",@dups) . "\n";=0A }=0A }=0A}=0A --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dups.txt" q101 - cl 5410 - k4 AT386 - IC h1510 - do h1520 - do ibm3163 - ds:es:fs:hs abm80 - do d132 - ic tec400 - do f200 - ds:ts sol - ho it2 - do mdl110 - cd wsiris - cl:ho intext - le c100 - us:ue dtterm - op h29 - do z29a - mb:mr ztx - sr adm5 - do mime - do sexidy - le ttyWilliams - do tvi950 - do tvi955 - do abm85 - kd fos - bs --5vNYLRcllDrimb99-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message