diff options
Diffstat (limited to 'MDK')
-rw-r--r-- | MDK/Common.pm.pl | 2 | ||||
-rw-r--r-- | MDK/Common/System.pm | 21 |
2 files changed, 14 insertions, 9 deletions
diff --git a/MDK/Common.pm.pl b/MDK/Common.pm.pl index 62dcb51..019a7c9 100644 --- a/MDK/Common.pm.pl +++ b/MDK/Common.pm.pl @@ -74,7 +74,7 @@ use vars qw(@ISA @EXPORT $VERSION); #); # perl_checker: RE-EXPORT-ALL @EXPORT = map { @$_ } map { values %{'MDK::Common::' . $_ . 'EXPORT_TAGS'} } grep { /::$/ } keys %MDK::Common::; -$VERSION = "1.1.17"; +$VERSION = "1.1.18"; 1; EOF diff --git a/MDK/Common/System.pm b/MDK/Common/System.pm index 427a9e5..7a6d194 100644 --- a/MDK/Common/System.pm +++ b/MDK/Common/System.pm @@ -226,18 +226,23 @@ sub compat_arch { better_arch(arch(), $_[0]) } sub typeFromMagic { my $f = shift; - local *F; sysopen F, $f, 0 or return; + sysopen(my $F, $f, 0) or return; my $tmp; M: foreach (@_) { - my ($name, @l) = @$_; - while (@l) { - my ($offset, $signature) = splice(@l, 0, 2); - sysseek(F, $offset, 0) or next M; - sysread(F, $tmp, length $signature); - $tmp eq $signature or next M; + if (ref($_) eq 'CODE') { + my $name = $_->($F) or next M; + return $name; + } else { + my ($name, @l) = @$_; + while (@l) { + my ($offset, $signature) = splice(@l, 0, 2); + sysseek($F, $offset, 0) or next M; + sysread($F, $tmp, length $signature); + $tmp eq $signature or next M; + } + return $name; } - return $name; } undef; } |