pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc lintpkgsrc: fix conversion of glob...
details: https://anonhg.NetBSD.org/pkgsrc/rev/5e07e9c41c81
branches: trunk
changeset: 382957:5e07e9c41c81
user: rillig <rillig%pkgsrc.org@localhost>
date: Tue Aug 09 18:14:22 2022 +0000
description:
lintpkgsrc: fix conversion of glob pattern to regular expression
It is used for evaluating expression modifiers of the form
':S,from,to,'.
Bump version.
diffstat:
pkgtools/lintpkgsrc/Makefile | 5 ++---
pkgtools/lintpkgsrc/files/lintpkgsrc.pl | 9 ++++++---
pkgtools/lintpkgsrc/files/t/glob.t | 22 ++++++++--------------
3 files changed, 16 insertions(+), 20 deletions(-)
diffs (115 lines):
diff -r c0a14e05f854 -r 5e07e9c41c81 pkgtools/lintpkgsrc/Makefile
--- a/pkgtools/lintpkgsrc/Makefile Tue Aug 09 18:12:04 2022 +0000
+++ b/pkgtools/lintpkgsrc/Makefile Tue Aug 09 18:14:22 2022 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.46 2022/08/04 21:55:57 rillig Exp $
+# $NetBSD: Makefile,v 1.47 2022/08/09 18:14:22 rillig Exp $
-PKGNAME= lintpkgsrc-4.99
+PKGNAME= lintpkgsrc-2022.08.09
CATEGORIES= pkgtools
MAINTAINER= pkgsrc-users%NetBSD.org@localhost
@@ -10,7 +10,6 @@
DEPENDS+= digest>=20010101:../../pkgtools/digest
TEST_DEPENDS+= p5-File-Slurp>=0:../../devel/p5-File-Slurp
TEST_DEPENDS+= p5-IO-Null>=0:../../devel/p5-IO-Null
-CONFLICTS+= pkglint<4.82
USE_TOOLS+= perl:run
diff -r c0a14e05f854 -r 5e07e9c41c81 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Tue Aug 09 18:12:04 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Tue Aug 09 18:14:22 2022 +0000
@@ -1,6 +1,6 @@
#!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.56 2022/08/04 21:55:58 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.57 2022/08/09 18:14:22 rillig Exp $
# Written by David Brownlee <abs%netbsd.org@localhost>.
#
@@ -874,6 +874,9 @@
@pkgdirs;
}
+# Convert the glob pattern to a regular expression.
+# Return '' if the regular expression equals the glob expression.
+# Return undef on error.
sub glob2regex($) {
my ($glob) = @_;
my (@chars, $in_alt);
@@ -886,8 +889,8 @@
} elsif ($_ eq '?') {
$regex .= '.';
} elsif ($_ eq '+') {
- $regex .= '.';
- } elsif ($_ eq '\\+') {
+ $regex .= '\\+';
+ } elsif ($_ eq '\\') {
$regex .= $_ . shift @chars;
} elsif ($_ eq '.' || $_ eq '|') {
$regex .= quotemeta;
diff -r c0a14e05f854 -r 5e07e9c41c81 pkgtools/lintpkgsrc/files/t/glob.t
--- a/pkgtools/lintpkgsrc/files/t/glob.t Tue Aug 09 18:12:04 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/t/glob.t Tue Aug 09 18:14:22 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: glob.t,v 1.4 2022/08/09 17:53:47 rillig Exp $
+# $NetBSD: glob.t,v 1.5 2022/08/09 18:14:22 rillig Exp $
use strict;
use warnings;
@@ -14,24 +14,19 @@
ok(glob2regex('?'), '^.$');
- # The '' means that the regular expression equals the glob.
ok(glob2regex('[a-z]'), '');
- # The '' means that the regular expression equals the glob.
ok(glob2regex('[a-z0-9]'), '');
- # The '' means that the regular expression equals the glob.
ok(glob2regex('[a-z0-9_]'), '');
# Outside of braces, the ',' is a regular character.
- # The '' means that the regular expression equals the glob.
ok(glob2regex('a,b'), '');
# FIXME: Inside brackets, the '*' is a literal '*'.
ok(glob2regex('[*]'), '^[.*]$');
- # FIXME: After a backslash, the '*' must be preserved.
- ok(glob2regex('\*'), '^\.*$');
+ ok(glob2regex('\*'), '');
ok(glob2regex('*.[ch]'), '^.*\.[ch]$');
@@ -42,21 +37,20 @@
# There is an unbalanced '}' at the very end.
ok(glob2regex('{{thi,fou}r,fif}teen}'), undef);
- # XXX: Why is '+' turned into '.'?
- ok(glob2regex('a+b|c'), '^a.b\|c$');
+ ok(glob2regex('a+b|c'), '^a\+b\|c$');
- # XXX: Typo in the code, the case '\\+' is unreachable.
- # Escaping the backslash works nevertheless.
ok(glob2regex('a\[b*'), '^a\[b.*$');
- ok(glob2regex('a\+b'), '^a\.b$');
+ ok(glob2regex('a\+b'), '');
- # FIXME: Must be '^a\?b$' instead.
- ok(glob2regex('a\?b'), '^a\.b$');
+ ok(glob2regex('a\?b'), '');
# XXX: Depending on the exact implementation, the '\n' may be
# interpreted as a newline, a literal 'n' or a literal '\' 'n'.
ok(glob2regex('a\n*'), '^a\n.*$');
+
+ # https://gnats.netbsd.org/12996
+ ok(glob2regex('libsigc++'), '^libsigc\+\+$');
}
test_glob2regex();
Home |
Main Index |
Thread Index |
Old Index