diff options
author | Thomas Lange <lange@debian.org> | 2023-09-20 14:56:17 +0200 |
---|---|---|
committer | Thomas Lange <lange@debian.org> | 2023-09-20 14:56:17 +0200 |
commit | 145afba3acc8c324b54fde8942f287d28a403ab1 (patch) | |
tree | fe083aa7e57139a8cc283a4238d35f5c92b81092 | |
parent | f3ef3a31e34e624dca1d7b1836b5a89358d22608 (diff) |
add support for Perl regex in the global .transignore file
You can use all types of Perl regex
local .transignore files in subdirectories are no needed any more
-rw-r--r-- | Perl/Webwml/TransIgnore.pm | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Perl/Webwml/TransIgnore.pm b/Perl/Webwml/TransIgnore.pm index a06f987ff87..55d3812633b 100644 --- a/Perl/Webwml/TransIgnore.pm +++ b/Perl/Webwml/TransIgnore.pm @@ -1,6 +1,7 @@ #!/usr/bin/perl ## Copyright (C) 2001 Denis Barbier <barbier@debian.org> +## Copyright (C) 2023 Thomas Lange <lange@debian.org> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -70,12 +71,16 @@ sub new # Read global .transignore file $self->_read($root); + my @regex; # remove the root path from the front of the files for (0 .. $#{$self->{LOCAL}}) { - ${$self->{LOCAL}}[$_] =~ s{^$root/}{}; + ${$self->{LOCAL}}[$_] =~ s{^$root/}{}; + push @regex, qr/${$self->{LOCAL}}[$_]/; } - $self->{GLOBAL} = $self->{LOCAL}; + + # global patterns are regex + $self->{GLOBAL} = \@regex; # reinitialize $self->{LOCAL} $self->{LOCAL} = []; @@ -138,7 +143,7 @@ sub local =item global -Return the list of files defined +Return the list of regex defined my @ignore = $ti->global(); @@ -184,18 +189,20 @@ sub is_global my $self = shift; my $entry = shift; - foreach my $file ( @{$self->{GLOBAL}} ) + foreach my $regex ( @{$self->{GLOBAL}} ) { - return 1 if $file eq $entry; + return 1 if $entry =~ m/$regex/; } return 0; } + =back =head1 AUTHOR Copyright (C) 2001 Denis Barbier <barbier@debian.org> +Copyright (C) 2023 Thomas Lange <lange@debian.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by |