FILE * in XS code for PerlIO world:
[p5sagit/p5-mst-13.2.git] / lib / Term / Cap.pm
index 6568895..6d31ab7 100644 (file)
@@ -1,7 +1,9 @@
 package Term::Cap;
 use Carp;
 
-# Last updated: Thu Dec 14 20:02:42 CST 1995 by sanders@bsdi.com
+our $VERSION = '1.00';
+
+# Last updated: Thu Nov 30 23:34:29 EST 2000 by schwern@pobox.com
 
 # TODO:
 # support Berkeley DB termcaps
@@ -104,8 +106,11 @@ as C<$self-E<gt>{TERMCAP}>.
 sub termcap_path { ## private
     my @termcap_path;
     # $TERMCAP, if it's a filespec
-    push(@termcap_path, $ENV{TERMCAP}) if ((exists $ENV{TERMCAP}) &&
-                                           ($ENV{TERMCAP} =~ /^\//));
+    push(@termcap_path, $ENV{TERMCAP})
+       if ((exists $ENV{TERMCAP}) &&
+           (($^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'dos')
+            ? $ENV{TERMCAP} =~ /^[a-z]:[\\\/]/is
+            : $ENV{TERMCAP} =~ /^\//s));
     if ((exists $ENV{TERMPATH}) && ($ENV{TERMPATH})) {
        # Add the users $TERMPATH
        push(@termcap_path, split(/(:|\s+)/, $ENV{TERMPATH}))
@@ -154,7 +159,7 @@ sub Tgetent { ## public -- static method
     my $foo = (exists $ENV{TERMCAP} ? $ENV{TERMCAP} : '');
 
     # $entry is the extracted termcap entry
-    if (($foo !~ m:^/:) && ($foo =~ m/(^|\|)${termpat}[:|]/)) {
+    if (($foo !~ m:^/:s) && ($foo =~ m/(^|\|)${termpat}[:|]/s)) {
        $entry = $foo;
     }
 
@@ -185,16 +190,20 @@ sub Tgetent { ## public -- static method
 
     # This is eval'ed inside the while loop for each file
     $search = q{
-       while ($_ = <TERMCAP>) {
+       while (<TERMCAP>) {
            next if /^\\t/ || /^#/;
            if ($_ =~ m/(^|\\|)${termpat}[:|]/o) {
                chomp;
                s/^[^:]*:// if $first++;
                $state = 0;
-               while ($_ =~ s/\\\\$//) { $_ .= <TERMCAP>; chomp; }
+               while ($_ =~ s/\\\\$//) {
+                   defined(my $x = <TERMCAP>) or last;
+                   $_ .= $x; chomp;
+               }
                last;
            }
        }
+       defined $entry or $entry = '';
        $entry .= $_;
     };