Change 13620 by jhi@alpha on 2001/12/11 13:56:17

        Subject: [PATCH lib/Term/Cap.pm lib/Term/Cap.t] Sync changes in CPAN version
        From: Jonathan Stowe <[EMAIL PROTECTED]>
        Date: Tue, 11 Dec 2001 07:28:45 +0000 (GMT) 
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

.... //depot/perl/lib/Term/Cap.pm#20 edit
.... //depot/perl/lib/Term/Cap.t#12 edit

Differences ...

==== //depot/perl/lib/Term/Cap.pm#20 (text) ====
Index: perl/lib/Term/Cap.pm
--- perl/lib/Term/Cap.pm.~1~    Tue Dec 11 07:00:05 2001
+++ perl/lib/Term/Cap.pm        Tue Dec 11 07:00:05 2001
@@ -3,10 +3,10 @@
 use Carp;
 use strict;
 
-use vars qw($VERSION);
+use vars qw($VERSION $VMS_TERMCAP);
 use vars qw($termpat $state $first $entry);
 
-$VERSION = '1.05';
+$VERSION = '1.06';
 
 # Version undef: Thu Dec 14 20:02:42 CST 1995 by [EMAIL PROTECTED]
 # Version 1.00:  Thu Nov 30 23:34:29 EST 2000 by [EMAIL PROTECTED]
@@ -23,7 +23,9 @@
 #       Fixed warnings in test
 # Version 1.05:  Mon Dec  3 15:33:49 GMT 2001
 #       Don't try to fall back on infocmp if it's not there. From chromatic.
-#
+# Version 1.06:  Thu Dec  6 18:43:22 GMT 2001
+#       Preload the default VMS termcap from Charles Lane
+#       Don't carp at setting OSPEED unless warnings are on.
 
 # TODO:
 # support Berkeley DB termcaps
@@ -68,7 +70,17 @@
 
 =cut
 
+# Preload the default VMS termcap.
+# If a different termcap is required then the text of one can be supplied
+# in $Term::Cap::VMS_TERMCAP before Tgetent is called.
+
+if ( $^O eq 'VMS') {
+       chomp (my @entry = <DATA>);
+       $VMS_TERMCAP = join '', @entry;
+}
+
 # Returns a list of termcap files to check.
+
 sub termcap_path { ## private
     my @termcap_path;
     # $TERMCAP, if it's a filespec
@@ -89,6 +101,7 @@
            '/usr/share/misc/termcap',
        );
     }
+
     # return the list of those termcaps that exist
     return grep(-f, @termcap_path);
 }
@@ -160,7 +173,9 @@
 
     # Compute PADDING factor from OSPEED (to be used by Tpad)
     if (! $self->{OSPEED}) {
-       carp "OSPEED was not set, defaulting to 9600";
+        if ( $^W ) {
+          carp "OSPEED was not set, defaulting to 9600";
+        }
        $self->{OSPEED} = 9600;
     }
     if ($self->{OSPEED} < 16) {
@@ -195,8 +210,7 @@
        local $ENV{TERM} = $term;
 
         if ( $^O eq 'VMS' ) {
-          chomp(my @entry = <DATA>);
-          $entry = join '', @entry;
+          $entry = $VMS_TERMCAP;
         }
         else {
            eval

==== //depot/perl/lib/Term/Cap.t#12 (text) ====
Index: perl/lib/Term/Cap.t
--- perl/lib/Term/Cap.t.~1~     Tue Dec 11 07:00:05 2001
+++ perl/lib/Term/Cap.t Tue Dec 11 07:00:05 2001
@@ -24,11 +24,11 @@
        ( $ENV{HOME} . '/.termcap', # we assume pretty UNIXy system anyway
          '/etc/termcap', 
          '/usr/share/misc/termcap' );
-unless( $files ) {
+unless( $files || $^O eq 'VMS') {
     plan skip_all => 'no termcap available to test';
 }
 else {
-    plan tests => 43;
+    plan tests => 44;
 }
 
 use_ok( 'Term::Cap' );
@@ -98,11 +98,16 @@
 # test the first few features by forcing Tgetent() to croak (line 156)
 undef $ENV{TERM};
 my $vals = {};
-eval { $t = Term::Cap->Tgetent($vals) };
+eval { local $^W = 1; $t = Term::Cap->Tgetent($vals) };
 like( $@, qr/TERM not set/, 'Tgetent() should croaks without TERM' );
 like( $warn, qr/OSPEED was not set/, 'Tgetent() should set default OSPEED' );
+
 is( $vals->{PADDING}, 10000/9600, 'Default OSPEED implies default PADDING' );
 
+$warn = 'xxxx';
+eval { local $^W = 0; $t = Term::Cap->Tgetent($vals) };
+is($warn,'xxxx',"Tgetent() doesn't carp() without warnings on");
+
 # check values for very slow speeds
 $vals->{OSPEED} = 1;
 $warn = '';
@@ -110,12 +115,17 @@
 is( $warn, '', 'Tgetent() should not work if OSPEED is provided' );
 is( $vals->{PADDING}, 200, 'Tgetent() should set slow PADDING when needed' );
 
-# now see if lines 177 or 180 will fail
-$ENV{TERM} = 'foo';
-$ENV{TERMPATH} = '!';
-$ENV{TERMCAP} = '';
-eval { $t = Term::Cap->Tgetent($vals) };
-isn't( $@, '', 'Tgetent() should catch bad termcap file' );
+
+SKIP: {
+        skip('Tgetent() bad termcap test, since using a fixed termcap',1)
+              if $^O eq 'VMS';
+        # now see if lines 177 or 180 will fail
+        $ENV{TERM} = 'foo';
+        $ENV{TERMPATH} = '!';
+        $ENV{TERMCAP} = '';
+        eval { $t = Term::Cap->Tgetent($vals) };
+        isn't( $@, '', 'Tgetent() should catch bad termcap file' );
+}
 
 SKIP: {
        skip( "Can't write 'tcout' file for tests", 9 ) unless $writable;
@@ -159,7 +169,7 @@
        'Tgoto() should handle %. and magic' );
 
 $t->{_test} = 'a%+';
-like( $t->Tgoto('test', '', 1), qr/a\x01/, 'Tgoto() shoudl handle %+' );
+like( $t->Tgoto('test', '', 1), qr/a\x01/, 'Tgoto() should handle %+' );
 $t->{_test} = 'a%+a';
 is( $t->Tgoto('test', '', 1), 'ab', 'Tgoto() should handle %+char' );
 $t->{_test} .= 'a' x 99;
End of Patch.

Reply via email to