Date: Mon, 24 Sep 2001 23:42:46 +0300 From: Giorgos Keramidas <charon@labs.gr> To: hackers@freebsd.org Subject: termcap sources Message-ID: <20010924234245.B14545@hades.hell.gr>
next in thread | raw e-mail | index | archive | help
--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 <STDIN>)) {=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 <STDIN>)) {=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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010924234245.B14545>