pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files - Added the PkgLint::Util::matc...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8f3699ed68a0
branches:  trunk
changeset: 507129:8f3699ed68a0
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Jan 26 23:05:49 2006 +0000

description:
- Added the PkgLint::Util::match function that matches a string against a
  regular expression and saves the values of the volatile @- and @+ arrays.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r ebf1df021546 -r 8f3699ed68a0 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Thu Jan 26 23:04:03 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Thu Jan 26 23:05:49 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.485 2006/01/25 00:23:48 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.486 2006/01/26 23:05:49 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -43,7 +43,7 @@
        use Exporter;
        use vars qw(@ISA @EXPORT_OK);
        @ISA = qw(Exporter);
-       @EXPORT_OK = qw(array_to_hash false print_table true);
+       @EXPORT_OK = qw(array_to_hash false match print_table true);
 }
 
 use constant false     => 0;
@@ -86,6 +86,22 @@
        return $result;
 }
 
+sub match($$) {
+       my ($s, $re) = @_;
+       my ($m);
+
+
+       if ($s !~ $re) {
+               return false;
+       }
+
+       $m = [];
+       foreach my $i (0 .. $#+) {
+               push(@{$m}, [$-[0], $+[0]]);
+       }
+       return $m;
+}
+
 #== End of PkgLint::Util ==================================================
 
 package PkgLint::Logging;



Home | Main Index | Thread Index | Old Index