From 0f68039566ac464bc1d4ff8f5b574153a1f6e9e9 Mon Sep 17 00:00:00 2001 From: Alexey Tourbin Date: Wed, 25 Apr 2007 22:12:22 +0400 Subject: [PATCH] fixed Fcntl::S_IFMT() breakage introduced by change 30674 (blead 26701) Message-ID: <20070425141222.GA24828@solemn.turbinal> p4raw-id: //depot/perl@31080 --- MANIFEST | 1 + ext/Fcntl/Fcntl.pm | 24 +++++++++++++----------- ext/Fcntl/t/mode.t | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 ext/Fcntl/t/mode.t diff --git a/MANIFEST b/MANIFEST index 0dc43b8..4bb181b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -649,6 +649,7 @@ ext/Fcntl/Fcntl.pm Fcntl extension Perl module ext/Fcntl/Fcntl.xs Fcntl extension external subroutines ext/Fcntl/Makefile.PL Fcntl extension makefile writer ext/Fcntl/t/fcntl.t See if Fcntl works +ext/Fcntl/t/mode.t See if S_ISREG() and S_ISDIR() work ext/Fcntl/t/syslfs.t See if large files work for sysio ext/File/Glob/bsd_glob.c File::Glob extension run time code ext/File/Glob/bsd_glob.h File::Glob extension header file diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm index 067c061..83edeb6 100644 --- a/ext/Fcntl/Fcntl.pm +++ b/ext/Fcntl/Fcntl.pm @@ -55,13 +55,14 @@ See L about the S_I* constants. =cut +use strict; our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $AUTOLOAD); require Exporter; use XSLoader (); @ISA = qw(Exporter); BEGIN { - $VERSION = "1.05"; + $VERSION = "1.06"; } # Items to export into callers namespace by default @@ -214,18 +215,18 @@ BEGIN { XSLoader::load 'Fcntl', $VERSION; } -sub S_IFMT { @_ ? ( $_[0] & _S_IFMT ) : _S_IFMT } +sub S_IFMT { @_ ? ( $_[0] & _S_IFMT() ) : _S_IFMT() } sub S_IMODE { $_[0] & 07777 } -sub S_ISREG { ( $_[0] & _S_IFMT ) == S_IFREG } -sub S_ISDIR { ( $_[0] & _S_IFMT ) == S_IFDIR } -sub S_ISLNK { ( $_[0] & _S_IFMT ) == S_IFLNK } -sub S_ISSOCK { ( $_[0] & _S_IFMT ) == S_IFSOCK } -sub S_ISBLK { ( $_[0] & _S_IFMT ) == S_IFBLK } -sub S_ISCHR { ( $_[0] & _S_IFMT ) == S_IFCHR } -sub S_ISFIFO { ( $_[0] & _S_IFMT ) == S_IFIFO } -sub S_ISWHT { ( $_[0] & _S_IFMT ) == S_IFWHT } -sub S_ISENFMT { ( $_[0] & _S_IFMT ) == S_IFENFMT } +sub S_ISREG { ( $_[0] & _S_IFMT() ) == S_IFREG() } +sub S_ISDIR { ( $_[0] & _S_IFMT() ) == S_IFDIR() } +sub S_ISLNK { ( $_[0] & _S_IFMT() ) == S_IFLNK() } +sub S_ISSOCK { ( $_[0] & _S_IFMT() ) == S_IFSOCK() } +sub S_ISBLK { ( $_[0] & _S_IFMT() ) == S_IFBLK() } +sub S_ISCHR { ( $_[0] & _S_IFMT() ) == S_IFCHR() } +sub S_ISFIFO { ( $_[0] & _S_IFMT() ) == S_IFIFO() } +sub S_ISWHT { ( $_[0] & _S_IFMT() ) == S_IFWHT() } +sub S_ISENFMT { ( $_[0] & _S_IFMT() ) == S_IFENFMT() } sub AUTOLOAD { (my $constname = $AUTOLOAD) =~ s/.*:://; @@ -235,6 +236,7 @@ sub AUTOLOAD { my (undef,$file,$line) = caller; die "$error at $file line $line.\n"; } + no strict 'refs'; *$AUTOLOAD = sub { $val }; goto &$AUTOLOAD; } diff --git a/ext/Fcntl/t/mode.t b/ext/Fcntl/t/mode.t new file mode 100644 index 0000000..57135f6 --- /dev/null +++ b/ext/Fcntl/t/mode.t @@ -0,0 +1,17 @@ +#!./perl -w + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; + require './test.pl'; +} + +plan tests => 2; + +use File::Temp; +use Fcntl qw(:mode); + +my $tmpfile = File::Temp->new; +my $mode = (stat "$tmpfile")[2]; +ok( S_ISREG($mode), " S_ISREG tmpfile"); +ok(!S_ISDIR($mode), "!S_ISDIR tmpfile"); -- 2.7.4