X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Ftermcap.pl;h=f295a2d476b53b9b360abe329f4c5448d04a2434;hb=c595d0543e6b5fbcaf00be87ff6162c56aa65a75;hp=a92b71456c73e44960ed493e793186e0c7c98156;hpb=9f68db38bddc39fbd37e57bf1751eaf7aac28e57;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/termcap.pl b/lib/termcap.pl index a92b714..f295a2d 100644 --- a/lib/termcap.pl +++ b/lib/termcap.pl @@ -1,10 +1,19 @@ -;# $Header: termcap.pl,v 3.0.1.1 90/02/28 17:46:44 lwall Locked $ +;# $RCSfile: termcap.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:24:16 $ +# +# This library is no longer being maintained, and is included for backward +# compatibility with Perl 4 programs which may require it. +# +# In particular, this should not be used as an example of modern Perl +# programming techniques. +# +# Suggested alternative: Term::Cap +# ;# ;# Usage: -;# do 'ioctl.pl'; +;# require 'ioctl.pl'; ;# ioctl(TTY,$TIOCGETP,$foo); ;# ($ispeed,$ospeed) = unpack('cc',$foo); -;# do 'termcap.pl' || die "Can't get termcap.pl"; +;# require 'termcap.pl'; ;# &Tgetent('vt100'); # sets $TC{'cm'}, etc. ;# &Tputs(&Tgoto($TC{'cm'},$col,$row), 0, 'FILEHANDLE'); ;# &Tputs($TC{'dl'},$affcnt,'FILEHANDLE'); @@ -13,15 +22,16 @@ sub Tgetent { local($TERM) = @_; local($TERMCAP,$_,$entry,$loop,$field); - warn "Tgetent: no ospeed set" unless $ospeed; - foreach $key (keys(TC)) { + # warn "Tgetent: no ospeed set" unless $ospeed; + foreach $key (keys %TC) { delete $TC{$key}; } $TERM = $ENV{'TERM'} unless $TERM; + $TERM =~ s/(\W)/\\$1/g; $TERMCAP = $ENV{'TERMCAP'}; $TERMCAP = '/etc/termcap' unless $TERMCAP; if ($TERMCAP !~ m:^/:) { - if (index($TERMCAP,"|$TERM|") < $[) { + if ($TERMCAP !~ /(^|\|)$TERM[:\|]/) { $TERMCAP = '/etc/termcap'; } } @@ -33,7 +43,7 @@ sub Tgetent { while () { next if /^#/; next if /^\t/; - if (/\\|$TERM[:\\|]/) { + if (/(^|\\|)${TERM}[:\\|]/) { chop; while (chop eq '\\\\') { \$_ .= ; @@ -62,6 +72,9 @@ sub Tgetent { $entry = $1; $_ = $2; s/\\E/\033/g; + s/\\(200)/pack('c',0)/eg; # NUL character + s/\\(0\d\d)/pack('c',oct($1))/eg; # octal + s/\\(0x[0-9A-Fa-f][0-9A-Fa-f])/pack('c',hex($1))/eg; # hex s/\\(\d\d\d)/pack('c',$1 & 0177)/eg; s/\\n/\n/g; s/\\r/\r/g; @@ -70,7 +83,7 @@ sub Tgetent { s/\\f/\f/g; s/\\\^/\377/g; s/\^\?/\177/g; - s/\^(.)/pack('c',$1 & 31)/eg; + s/\^(.)/pack('c',ord($1) & 31)/eg; s/\\(.)/$1/g; s/\377/^/g; $TC{$entry} = $_ if $TC{$entry} eq '';