This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add standard core test headers to the Class::ISA new tests
[perl5.git] / lib / termcap.pl
index d648526..f295a2d 100644 (file)
@@ -1,4 +1,13 @@
-;# $Header: termcap.pl,v 3.0.1.3 90/08/09 04:02:53 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:
 ;#     require 'ioctl.pl';
@@ -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 (<TERMCAP>) {
                next if /^#/;
                next if /^\t/;
-               if (/\\|$TERM[:\\|]/) {
+               if (/(^|\\|)${TERM}[:\\|]/) {
                    chop;
                    while (chop eq '\\\\') {
                        \$_ .= <TERMCAP>;
@@ -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;