From 145afba3acc8c324b54fde8942f287d28a403ab1 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Wed, 20 Sep 2023 14:56:17 +0200 Subject: 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 --- Perl/Webwml/TransIgnore.pm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'Perl') 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 +## Copyright (C) 2023 Thomas Lange ## ## 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 +Copyright (C) 2023 Thomas Lange 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 -- cgit v1.2.3