Преглед изворни кода

Consistently use regex instead of regexp when possible

All changed instances are documentation or private code interfaces.
The only remaining variable instance with a regexp name is a publicly
exposed variable, which will eventually disappear once it has gone
through the deprecation process.
Guillem Jover пре 12 година
родитељ
комит
5ae4ce9c2d

+ 1 - 1
dselect/methods/Dselect/Ftp.pm

@@ -375,7 +375,7 @@ sub do_mdtm {
 	    # build a system time
 	    # build a system time
 	    $time = Time::Local::timegm(0, $minutes, $hours, $day, $month, $year);
 	    $time = Time::Local::timegm(0, $minutes, $hours, $day, $month, $year);
 	} else {
 	} else {
-	    die 'regexp match failed on LIST output';
+	    die 'regex match failed on LIST output';
 	}
 	}
     }
     }
 
 

+ 1 - 1
man/dpkg-buildpackage.1

@@ -215,7 +215,7 @@ Do not sign the \fB.changes\fP file.
 Force the signing of the resulting files (since dpkg 1.17.0),
 Force the signing of the resulting files (since dpkg 1.17.0),
 regardless of \fB\-us\fP or \fB\-uc\fP or other internal heuristics.
 regardless of \fB\-us\fP or \fB\-uc\fP or other internal heuristics.
 .TP
 .TP
-.BR \-i [\fIregexp\fP]
+.BR \-i [\fIregex\fP]
 .TQ
 .TQ
 .BR \-I [\fIpattern\fP]
 .BR \-I [\fIpattern\fP]
 .TQ
 .TQ

+ 7 - 7
man/dpkg-source.1

@@ -176,32 +176,32 @@ files. Supported values are:
 .IR 1 " to " 9 ", " best ", and " fast .
 .IR 1 " to " 9 ", " best ", and " fast .
 The default is \fI9\fP for gzip and bzip2, \fI6\fP for xz and lzma.
 The default is \fI9\fP for gzip and bzip2, \fI6\fP for xz and lzma.
 .TP
 .TP
-.BR \-i "[\fIregexp\fP], " \-\-diff\-ignore [=\fIregexp\fP]
+.BR \-i "[\fIregex\fP], " \-\-diff\-ignore [=\fIregex\fP]
 You may specify a perl regular expression to match files you want
 You may specify a perl regular expression to match files you want
 filtered out of the list of files for the diff. (This list is
 filtered out of the list of files for the diff. (This list is
 generated by a find command.) (If the source package is being built as a
 generated by a find command.) (If the source package is being built as a
 version 3 source package using a VCS, this can be used to ignore
 version 3 source package using a VCS, this can be used to ignore
 uncommited changes on specific files. Using \-i.* will ignore all of them.)
 uncommited changes on specific files. Using \-i.* will ignore all of them.)
-\fB\-i\fP by itself enables the option, with a default regexp that will
+\fB\-i\fP by itself enables the option, with a default regex that will
 filter out control files and directories of the most common revision
 filter out control files and directories of the most common revision
 control systems, backup and swap files and Libtool build output
 control systems, backup and swap files and Libtool build output
-directories. There can only be one active regexp, of multiple
+directories. There can only be one active regex, of multiple
 \fB\-i\fP options only the last one will take effect.
 \fB\-i\fP options only the last one will take effect.
 
 
 This is very helpful in cutting out extraneous files that get included
 This is very helpful in cutting out extraneous files that get included
 in the diff, e.g. if you maintain your source in a revision control
 in the diff, e.g. if you maintain your source in a revision control
 system and want to use a checkout to build a source package without
 system and want to use a checkout to build a source package without
 including the additional files and directories that it will usually
 including the additional files and directories that it will usually
-contain (e.g. CVS/, .cvsignore, .svn/). The default regexp is already
+contain (e.g. CVS/, .cvsignore, .svn/). The default regex is already
 very exhaustive, but if you need to replace it, please note that by
 very exhaustive, but if you need to replace it, please note that by
 default it can match any part of a path, so if you want to match the
 default it can match any part of a path, so if you want to match the
 begin of a filename or only full filenames, you will need to provide
 begin of a filename or only full filenames, you will need to provide
 the necessary anchors (e.g. '(^|/)', '($|/)') yourself.
 the necessary anchors (e.g. '(^|/)', '($|/)') yourself.
 .TP
 .TP
-.BR \-\-extend\-diff\-ignore =\fIregexp\fP
+.BR \-\-extend\-diff\-ignore =\fIregex\fP
 The perl regular expression specified will extend the default value
 The perl regular expression specified will extend the default value
 of \fB\-\-diff\-ignore\fP and its current value (if set). It does this
 of \fB\-\-diff\-ignore\fP and its current value (if set). It does this
-by concatenating "\fB|\fP\fIregexp\fP" to the existing value.
+by concatenating "\fB|\fP\fIregex\fP" to the existing value.
 This option is convenient to use in \fBdebian/source/options\fP to exclude
 This option is convenient to use in \fBdebian/source/options\fP to exclude
 some auto-generated files from the automatic patch generation.
 some auto-generated files from the automatic patch generation.
 .TP
 .TP
@@ -231,7 +231,7 @@ to each part of the path individually. The exact semantic of tar's
 http://www.gnu.org/software/tar/manual/tar.html#wildcards for a full
 http://www.gnu.org/software/tar/manual/tar.html#wildcards for a full
 documentation.
 documentation.
 
 
-The default regexp and patterns for both options can be seen
+The default regex and patterns for both options can be seen
 in the output of the \fB\-\-help\fP command.
 in the output of the \fB\-\-help\fP command.
 .SS Generic extract options
 .SS Generic extract options
 .TP
 .TP

+ 1 - 1
scripts/Dpkg/Index.pm

@@ -208,7 +208,7 @@ sub get_by_key {
 =item my @keys = $index->get_keys(%criteria)
 =item my @keys = $index->get_keys(%criteria)
 
 
 Returns the keys of items that matches all the criteria. The key of the
 Returns the keys of items that matches all the criteria. The key of the
-%criteria hash is a field name and the value is either a regexp that needs
+%criteria hash is a field name and the value is either a regex that needs
 to match the field value, or a reference to a function that must return
 to match the field value, or a reference to a function that must return
 true and that receives the field value as single parameter, or a scalar
 true and that receives the field value as single parameter, or a scalar
 that must be equal to the field value.
 that must be equal to the field value.

+ 9 - 6
scripts/Dpkg/Source/Package.pm

@@ -51,8 +51,7 @@ use Dpkg::Vendor qw(run_vendor_hook);
 use POSIX qw(:errno_h :sys_wait_h);
 use POSIX qw(:errno_h :sys_wait_h);
 use File::Basename;
 use File::Basename;
 
 
-# Public variables
-our $diff_ignore_default_regexp = '
+my $diff_ignore_default_regex = '
 # Ignore general backup files
 # Ignore general backup files
 (?:^|/).*~$|
 (?:^|/).*~$|
 # Ignore emacs recovery files
 # Ignore emacs recovery files
@@ -69,8 +68,12 @@ our $diff_ignore_default_regexp = '
 \.shelf|_MTN|\.be|\.bzr(?:\.backup|tags)?)(?:$|/.*$)
 \.shelf|_MTN|\.be|\.bzr(?:\.backup|tags)?)(?:$|/.*$)
 ';
 ';
 # Take out comments and newlines
 # Take out comments and newlines
-$diff_ignore_default_regexp =~ s/^#.*$//mg;
-$diff_ignore_default_regexp =~ s/\n//sg;
+$diff_ignore_default_regex =~ s/^#.*$//mg;
+$diff_ignore_default_regex =~ s/\n//sg;
+
+# Public variables
+our $diff_ignore_default_regexp = $diff_ignore_default_regex;
+
 no warnings 'qw'; ## no critic (TestingAndDebugging::ProhibitNoWarnings)
 no warnings 'qw'; ## no critic (TestingAndDebugging::ProhibitNoWarnings)
 our @tar_ignore_default_pattern = qw(
 our @tar_ignore_default_pattern = qw(
 *.a
 *.a
@@ -167,8 +170,8 @@ sub init_options {
     my ($self) = @_;
     my ($self) = @_;
     # Use full ignore list by default
     # Use full ignore list by default
     # note: this function is not called by V1 packages
     # note: this function is not called by V1 packages
-    $self->{options}{diff_ignore_regexp} ||= $diff_ignore_default_regexp;
-    $self->{options}{diff_ignore_regexp} .= '|(?:^|/)debian/source/local-.*$';
+    $self->{options}{diff_ignore_regex} ||= $diff_ignore_default_regex;
+    $self->{options}{diff_ignore_regex} .= '|(?:^|/)debian/source/local-.*$';
     if (defined $self->{options}{tar_ignore}) {
     if (defined $self->{options}{tar_ignore}) {
         $self->{options}{tar_ignore} = [ @tar_ignore_default_pattern ]
         $self->{options}{tar_ignore} = [ @tar_ignore_default_pattern ]
             unless @{$self->{options}{tar_ignore}};
             unless @{$self->{options}{tar_ignore}};

+ 5 - 5
scripts/Dpkg/Source/Package/V1.pm

@@ -44,10 +44,10 @@ sub init_options {
     my ($self) = @_;
     my ($self) = @_;
     # Don't call $self->SUPER::init_options() on purpose, V1.0 has no
     # Don't call $self->SUPER::init_options() on purpose, V1.0 has no
     # ignore by default
     # ignore by default
-    if ($self->{options}{diff_ignore_regexp}) {
-	$self->{options}{diff_ignore_regexp} .= '|(?:^|/)debian/source/local-.*$';
+    if ($self->{options}{diff_ignore_regex}) {
+	$self->{options}{diff_ignore_regex} .= '|(?:^|/)debian/source/local-.*$';
     } else {
     } else {
-	$self->{options}{diff_ignore_regexp} = '(?:^|/)debian/source/local-.*$';
+	$self->{options}{diff_ignore_regex} = '(?:^|/)debian/source/local-.*$';
     }
     }
     push @{$self->{options}{tar_ignore}}, 'debian/source/local-options',
     push @{$self->{options}{tar_ignore}}, 'debian/source/local-options',
          'debian/source/local-patch-header';
          'debian/source/local-patch-header';
@@ -176,7 +176,7 @@ sub do_build {
     my $sourcestyle = $self->{options}{sourcestyle};
     my $sourcestyle = $self->{options}{sourcestyle};
     my @argv = @{$self->{options}{ARGV}};
     my @argv = @{$self->{options}{ARGV}};
     my @tar_ignore = map { "--exclude=$_" } @{$self->{options}{tar_ignore}};
     my @tar_ignore = map { "--exclude=$_" } @{$self->{options}{tar_ignore}};
-    my $diff_ignore_regexp = $self->{options}{diff_ignore_regexp};
+    my $diff_ignore_regex = $self->{options}{diff_ignore_regex};
 
 
     if (scalar(@argv) > 1) {
     if (scalar(@argv) > 1) {
         usageerr(_g('-b takes at most a directory and an orig source ' .
         usageerr(_g('-b takes at most a directory and an orig source ' .
@@ -356,7 +356,7 @@ sub do_build {
         $diff->create();
         $diff->create();
         $diff->add_diff_directory($origdir, $dir,
         $diff->add_diff_directory($origdir, $dir,
                 basedirname => $basedirname,
                 basedirname => $basedirname,
-                diff_ignore_regexp => $diff_ignore_regexp,
+                diff_ignore_regex => $diff_ignore_regex,
                 options => []); # Force empty set of options to drop the
                 options => []); # Force empty set of options to drop the
                                 # default -p option
                                 # default -p option
         $diff->finish() || $ur++;
         $diff->finish() || $ur++;

+ 2 - 2
scripts/Dpkg/Source/Package/V2.pm

@@ -295,8 +295,8 @@ sub after_build {
 sub prepare_build {
 sub prepare_build {
     my ($self, $dir) = @_;
     my ($self, $dir) = @_;
     $self->{diff_options} = {
     $self->{diff_options} = {
-        diff_ignore_regexp => $self->{options}{diff_ignore_regexp} .
-                              '|(^|/)debian/patches/.dpkg-source-applied$',
+        diff_ignore_regex => $self->{options}{diff_ignore_regex} .
+                             '|(^|/)debian/patches/.dpkg-source-applied$',
         include_removal => $self->{options}{include_removal},
         include_removal => $self->{options}{include_removal},
         include_timestamp => $self->{options}{include_timestamp},
         include_timestamp => $self->{options}{include_timestamp},
         use_dev_null => 1,
         use_dev_null => 1,

+ 3 - 3
scripts/Dpkg/Source/Package/V3/Bzr.pm

@@ -91,7 +91,7 @@ sub do_build {
     my @argv = @{$self->{options}{ARGV}};
     my @argv = @{$self->{options}{ARGV}};
     # TODO: warn here?
     # TODO: warn here?
     #my @tar_ignore = map { "--exclude=$_" } @{$self->{options}{tar_ignore}};
     #my @tar_ignore = map { "--exclude=$_" } @{$self->{options}{tar_ignore}};
-    my $diff_ignore_regexp = $self->{options}{diff_ignore_regexp};
+    my $diff_ignore_regex = $self->{options}{diff_ignore_regex};
 
 
     $dir =~ s{/+$}{}; # Strip trailing /
     $dir =~ s{/+$}{}; # Strip trailing /
     my ($dirname, $updir) = fileparse($dir);
     my ($dirname, $updir) = fileparse($dir);
@@ -122,8 +122,8 @@ sub do_build {
     while (<$bzr_status_fh>) {
     while (<$bzr_status_fh>) {
         chomp;
         chomp;
         next unless s/^ +//;
         next unless s/^ +//;
-        if (! length $diff_ignore_regexp ||
-            ! m/$diff_ignore_regexp/o) {
+        if (! length $diff_ignore_regex ||
+            ! m/$diff_ignore_regex/o) {
             push @files, $_;
             push @files, $_;
         }
         }
     }
     }

+ 3 - 3
scripts/Dpkg/Source/Package/V3/Git.pm

@@ -94,7 +94,7 @@ sub can_build {
 
 
 sub do_build {
 sub do_build {
     my ($self, $dir) = @_;
     my ($self, $dir) = @_;
-    my $diff_ignore_regexp = $self->{options}{diff_ignore_regexp};
+    my $diff_ignore_regex = $self->{options}{diff_ignore_regex};
 
 
     $dir =~ s{/+$}{}; # Strip trailing /
     $dir =~ s{/+$}{}; # Strip trailing /
     my ($dirname, $updir) = fileparse($dir);
     my ($dirname, $updir) = fileparse($dir);
@@ -124,8 +124,8 @@ sub do_build {
     { local $/ = "\0";
     { local $/ = "\0";
       while (<$git_ls_files_fh>) {
       while (<$git_ls_files_fh>) {
           chomp;
           chomp;
-          if (! length $diff_ignore_regexp ||
-              ! m/$diff_ignore_regexp/o) {
+          if (! length $diff_ignore_regex ||
+              ! m/$diff_ignore_regex/o) {
               push @files, $_;
               push @files, $_;
           }
           }
       }
       }

+ 1 - 1
scripts/Dpkg/Source/Package/V3/Quilt.pm

@@ -170,7 +170,7 @@ sub prepare_build {
     my $func = sub {
     my $func = sub {
         return 1 if $_[0] =~ m{^debian/patches/series$} and -l $_[0];
         return 1 if $_[0] =~ m{^debian/patches/series$} and -l $_[0];
         return 1 if $_[0] =~ /^\.pc(\/|$)/;
         return 1 if $_[0] =~ /^\.pc(\/|$)/;
-        return 1 if $_[0] =~ /$self->{options}{diff_ignore_regexp}/;
+        return 1 if $_[0] =~ /$self->{options}{diff_ignore_regex}/;
         return 0;
         return 0;
     };
     };
     $self->{diff_options}{diff_ignore_func} = $func;
     $self->{diff_options}{diff_ignore_func} = $func;

+ 2 - 2
scripts/Dpkg/Source/Patch.pm

@@ -149,8 +149,8 @@ sub add_diff_directory {
     my $diff_ignore;
     my $diff_ignore;
     if ($opts{diff_ignore_func}) {
     if ($opts{diff_ignore_func}) {
         $diff_ignore = $opts{diff_ignore_func};
         $diff_ignore = $opts{diff_ignore_func};
-    } elsif ($opts{diff_ignore_regexp}) {
-        $diff_ignore = sub { return $_[0] =~ /$opts{diff_ignore_regexp}/o };
+    } elsif ($opts{diff_ignore_regex}) {
+        $diff_ignore = sub { return $_[0] =~ /$opts{diff_ignore_regex}/o };
     } else {
     } else {
         $diff_ignore = sub { return 0 };
         $diff_ignore = sub { return 0 };
     }
     }

+ 5 - 5
scripts/dpkg-source.pl

@@ -63,7 +63,7 @@ my %options = (
     comp_ext => compression_get_property(compression_get_default(), 'file_ext'),
     comp_ext => compression_get_property(compression_get_default(), 'file_ext'),
     # Ignore files
     # Ignore files
     tar_ignore => [],
     tar_ignore => [],
-    diff_ignore_regexp => '',
+    diff_ignore_regex => '',
     # Misc options
     # Misc options
     copy_orig_tarballs => 1,
     copy_orig_tarballs => 1,
     no_check => 0,
     no_check => 0,
@@ -167,11 +167,11 @@ while (@options) {
     } elsif (m/^-U([^\=:]+)$/) {
     } elsif (m/^-U([^\=:]+)$/) {
         $remove{$1} = 1;
         $remove{$1} = 1;
     } elsif (m/^-(?:i|-diff-ignore(?:$|=))(.*)$/) {
     } elsif (m/^-(?:i|-diff-ignore(?:$|=))(.*)$/) {
-        $options{diff_ignore_regexp} = $1 ? $1 : $Dpkg::Source::Package::diff_ignore_default_regexp;
+        $options{diff_ignore_regex} = $1 ? $1 : $Dpkg::Source::Package::diff_ignore_default_regexp;
     } elsif (m/^--extend-diff-ignore=(.+)$/) {
     } elsif (m/^--extend-diff-ignore=(.+)$/) {
 	$Dpkg::Source::Package::diff_ignore_default_regexp .= "|$1";
 	$Dpkg::Source::Package::diff_ignore_default_regexp .= "|$1";
-	if ($options{diff_ignore_regexp}) {
-	    $options{diff_ignore_regexp} .= "|$1";
+	if ($options{diff_ignore_regex}) {
+	    $options{diff_ignore_regex} .= "|$1";
 	}
 	}
     } elsif (m/^-(?:I|-tar-ignore=)(.+)$/) {
     } elsif (m/^-(?:I|-tar-ignore=)(.+)$/) {
         push @{$options{tar_ignore}}, $1;
         push @{$options{tar_ignore}}, $1;
@@ -495,7 +495,7 @@ sub usage {
   -D<field>=<value>        override or add a .dsc field and value.
   -D<field>=<value>        override or add a .dsc field and value.
   -U<field>                remove a field.
   -U<field>                remove a field.
   -q                       quiet mode.
   -q                       quiet mode.
-  -i[<regexp>]             filter out files to ignore diffs of
+  -i[<regex>]              filter out files to ignore diffs of
                              (defaults to: '%s').
                              (defaults to: '%s').
   -I[<pattern>]            filter out files when building tarballs
   -I[<pattern>]            filter out files when building tarballs
                              (defaults to: %s).
                              (defaults to: %s).

+ 3 - 3
scripts/t/550_Dpkg_Util.t

@@ -30,9 +30,9 @@ ok(any { 'bar' eq $_ } @array, 'array has item');
 ok(!any { 'notfound' eq $_ } @array, 'array does not have item');
 ok(!any { 'notfound' eq $_ } @array, 'array does not have item');
 ok(none { 'notfound' eq $_ } @array, 'array lacks item');
 ok(none { 'notfound' eq $_ } @array, 'array lacks item');
 
 
-ok(any { m/^quu/ } @array, 'array has item matching regexp');
-ok(none { m/^notfound/ } @array, 'array lacks item matching regexp');
+ok(any { m/^quu/ } @array, 'array has item matching regex');
+ok(none { m/^notfound/ } @array, 'array lacks item matching regex');
 
 
-ok(any { m/^quu/ } keys %hash, 'hash has item matching regexp');
+ok(any { m/^quu/ } keys %hash, 'hash has item matching regex');
 
 
 1;
 1;