Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

locally implement File::FnMatch::fnmatch the way we use it

  • Loading branch information...
commit df45049ceac9e040b68e8aa0af60f8af9a82efaa 1 parent 03018e0
@cuzelac cuzelac authored
Showing with 22 additions and 3 deletions.
  1. +22 −3 source/lib/Seco/Multipkg.pm
View
25 source/lib/Seco/Multipkg.pm
@@ -123,8 +123,6 @@ use IPC::Open3;
use FileHandle;
use Fcntl ':mode';
-use File::FnMatch ':fnmatch';
-
use constant MULTIPKG_VERSION => '__MULTIPKG_BUILD_VERSION__';
use base qw/Seco::Class/;
@@ -687,10 +685,31 @@ sub _find_match_attributes {
my $rules = shift;
# return the last shell pattern match
- my @found = ( grep { fnmatch( $_->{name}, $name, FNM_PATHNAME ) } (@$rules) );
+ my @found = ( grep { _fnmatch( $_->{name}, $name ) } (@$rules) );
return pop(@found);
}
+# pure-perl implementation of File::FnMatch::fnmatch with 'FNM_PATHNAME' argument
+sub _fnmatch {
+ my $pat = shift;
+ my $str = shift;
+
+ #dots are literal dots
+ $pat =~ s{\.}{\\\.}g;
+
+ #internal slashes must be escaped
+ $pat =~ s{/}{\\/}g;
+
+ #asterisks are everything but slash
+ $pat =~ s{\*}{[^\/]*}g;
+
+ #anchor it
+ $pat =~ s{^}{\^};
+ $pat =~ s{$}{\$};
+
+ return $str =~ m/$pat/;
+}
+
sub _find_parent_attributes {
my $name = shift;
my $rules = shift;
Please sign in to comment.
Something went wrong with that request. Please try again.