[SCM] Debian package checker branch, master, updated. 2.5.11-197-g69e0ac5
The following commit has been merged in the master branch:
commit 69e0ac591bbc9d4a380de37d9ea013bf404cf97e
Author: Niels Thykier <niels@thykier.net>
Date: Fri Mar 29 19:04:47 2013 +0100
*: Replace ad-hoc regexes with {,l,r}strip
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/checks/control-file b/checks/control-file
index 3081d98..cd00a6f 100644
--- a/checks/control-file
+++ b/checks/control-file
@@ -27,7 +27,8 @@ use List::Util qw(first);
use Lintian::Data ();
use Lintian::Relation ();
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail file_is_encoded_in_non_utf8 read_dpkg_control);
+use Lintian::Util qw(fail file_is_encoded_in_non_utf8 read_dpkg_control
+ rstrip strip);
# The list of libc packages, used for checking for a hard-coded dependency
# rather than using ${shlibs:Depends}.
@@ -272,8 +273,7 @@ for my $i (0 .. $#descriptions) {
# version.
sub check_dev_depends {
my ($info, $package, $depends, @packages) = @_;
- $depends =~ s/^\s+//;
- $depends =~ s/\s+$//;
+ strip ($depends);
for my $target (@packages) {
next unless ($target =~ /^lib[\w.+-]+\d/
and $target !~ /-(?:dev|docs?|common)$/);
@@ -343,7 +343,7 @@ sub check_relation {
)/x) {
my ($prev, $next) = ($1, $2);
for ($prev, $next) {
- s/\s+$//;
+ rstrip;
}
tag 'missing-separator-between-items', 'in', $pkg,
"$field field between '$prev' and '$next'";
diff --git a/checks/debhelper b/checks/debhelper
index 9cd47da..ea54703 100644
--- a/checks/debhelper
+++ b/checks/debhelper
@@ -25,7 +25,7 @@ use warnings;
use Lintian::Data;
use Lintian::Relation;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail slurp_entire_file strip);
+use Lintian::Util qw(fail slurp_entire_file strip strip);
# If compat is less than or equal to this, then a missing version
# for this level is only a pedantic issue.
@@ -240,10 +240,8 @@ my $compatnan = 0;
if (-f "$droot/compat") {
my $compat_file = slurp_entire_file("$droot/compat");
($compat) = split(/\n/, $compat_file);
- $compat =~ s/^\s+$//;
- if ($compat) {
- $compat =~ s/^\s+//;
- $compat =~ s/\s+$//;
+ strip ($compat);
+ if ($compat ne '') {
if ($compat !~ m/^\d+$/) {
tag 'debhelper-compat-not-a-number', $compat;
$compat =~ s/[^\d]//g;
diff --git a/checks/menus b/checks/menus
index 6e4c6ef..0006d50 100644
--- a/checks/menus
+++ b/checks/menus
@@ -27,7 +27,7 @@ use warnings;
use Lintian::Check qw(check_spelling check_spelling_picky $known_shells_regex);
use Lintian::Data;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail file_is_encoded_in_non_utf8);
+use Lintian::Util qw(fail file_is_encoded_in_non_utf8 strip);
# Supported documentation formats for doc-base files.
our %known_doc_base_formats = map { $_ => 1 }
@@ -371,8 +371,7 @@ sub check_doc_base_field {
# Format field.
} elsif ($field eq 'format') {
my $format = join (' ', @$vals);
- $format =~ s/^\s+//o;
- $format =~ s/\s+$//o;
+ strip ($format);
$format = lc $format;
tag 'doc-base-file-unknown-format', "$dbfile:$line", $format
unless $known_doc_base_formats{$format};
diff --git a/checks/patch-systems b/checks/patch-systems
index 0b740fc..01f462a 100644
--- a/checks/patch-systems
+++ b/checks/patch-systems
@@ -24,7 +24,7 @@ use strict;
use warnings;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail);
+use Lintian::Util qw(fail strip);
use Cwd qw(realpath);
sub run {
@@ -124,7 +124,7 @@ sub run {
my @patches;
my @badopts;
while(<IN>) {
- chomp; s/^\s+//; s/\s+$//; # Strip leading/trailing spaces
+ strip; # Strip leading/trailing spaces
s/(^|\s+)#.*$//; # Strip comment
next unless $_;
if (/^(\S+)\s+(\S.*)$/) {
diff --git a/checks/scripts b/checks/scripts
index 1559a45..da8d5fb 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -30,7 +30,7 @@ use Lintian::Check qw($known_shells_regex);
use Lintian::Data;
use Lintian::Relation;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail);
+use Lintian::Util qw(fail strip);
# This is a map of all known interpreters. The key is the interpreter
# name (the binary invoked on the #! line). The value is an anonymous
@@ -859,8 +859,7 @@ while (<SCRIPTS>) {
$divert =~ s,^/,,;
# remove any remaining leading or trailing whitespace.
- $divert =~ s/^\s+//;
- $divert =~ s/\s+$//;
+ strip ($divert);
$divert = quotemeta($divert);
diff --git a/collection/scripts b/collection/scripts
index 2136991..859b752 100755
--- a/collection/scripts
+++ b/collection/scripts
@@ -26,7 +26,7 @@ use warnings;
use lib "$ENV{'LINTIAN_ROOT'}/lib/";
use Lintian::Collect;
-use Lintian::Util qw(fail);
+use Lintian::Util qw(fail lstrip);
sub collect {
my ($pkg, $type, $dir) = @_;
@@ -50,7 +50,7 @@ foreach my $file ($info->sorted_index) {
next if ($scriptpath =~ m/^\#!/); # skip lincity data files
# #!#!#!
my $copy_path = $scriptpath;
- $scriptpath =~ s/^\s+//; # remove leading whitespace
+ lstrip ($scriptpath); # remove leading whitespace
$scriptpath =~ s/^\#.*//; # remove comments
if ($scriptpath eq '') {
print SCRIPTS "$copy_path $file\n";
diff --git a/lib/Lintian/Collect/Changes.pm b/lib/Lintian/Collect/Changes.pm
index deb1544..c006cd1 100644
--- a/lib/Lintian/Collect/Changes.pm
+++ b/lib/Lintian/Collect/Changes.pm
@@ -22,6 +22,8 @@ use strict;
use warnings;
use base 'Lintian::Collect';
+use Lintian::Util qw(strip);
+
=head1 NAME
Lintian::Collect::Changes - Lintian interface to .changes file data collection
@@ -130,8 +132,7 @@ sub files {
my $file_list = $self->field('files') || '';
local $_;
for (split /\n/, $file_list) {
- chomp;
- s/^\s+//o;
+ strip;
next if $_ eq '';
my ($md5sum,$size,$section,$priority,$file) = split(/\s+/o, $_);
@@ -149,8 +150,7 @@ sub files {
foreach my $alg (qw(sha1 sha256)) {
my $list = $self->field("checksums-$alg") || '';
for (split /\n/, $list) {
- chomp;
- s/^\s+//o;
+ strip;
next if $_ eq '';
my ($checksum, $size, $file) = split(/\s+/o, $_);
diff --git a/lib/Lintian/Tag/TextUtil.pm b/lib/Lintian/Tag/TextUtil.pm
index 2fc6db7..c3d3886 100644
--- a/lib/Lintian/Tag/TextUtil.pm
+++ b/lib/Lintian/Tag/TextUtil.pm
@@ -30,7 +30,7 @@ our @EXPORT = qw(split_paragraphs wrap_paragraphs dtml_to_html dtml_to_text);
# requires wrap() function
use Text::Wrap;
-use Lintian::Util qw(fail);
+use Lintian::Util qw(fail strip);
# html_wrap -- word-wrap a paragaph. The wrap() function from Text::Wrap
# is not suitable, because it chops words that are longer than the line
@@ -85,9 +85,8 @@ sub split_paragraphs {
if (($t =~ s/^([ \t][^\n]*)\n?//o) or ($t =~ s/^()\n//o)) {
#FLUSH;
if ($l) {
- $l =~ s/\s+/ /go;
- $l =~ s/^\s+//o;
- $l =~ s/\s+$//o;
+ strip ($l);
+ $l =~ s/\s++/ /go;
push(@o,$l);
undef $l;
}
@@ -105,9 +104,8 @@ sub split_paragraphs {
}
#FLUSH;
if ($l) {
- $l =~ s/\s+/ /go;
- $l =~ s/^\s+//o;
- $l =~ s/\s+$//o;
+ strip ($l);
+ $l =~ s/\s++/ /go;
push(@o,$l);
undef $l;
}
diff --git a/lib/Lintian/Tags.pm b/lib/Lintian/Tags.pm
index 5c85786..f4ca28d 100644
--- a/lib/Lintian/Tags.pm
+++ b/lib/Lintian/Tags.pm
@@ -27,7 +27,7 @@ use Exporter qw(import);
use Lintian::Architecture qw(:all);
use Lintian::Output;
use Lintian::Tag::Override;
-use Lintian::Util qw(fail $PKGNAME_REGEX);
+use Lintian::Util qw(fail $PKGNAME_REGEX strip);
BEGIN {
our @EXPORT = qw(tag);
@@ -505,8 +505,7 @@ sub file_overrides {
local $_;
OVERRIDE:
while (<$file>) {
- s/^\s+//;
- s/\s+$//;
+ strip;
if ($_ eq '') {
# Throw away comments, as they are not attached to a tag
# also throw away the option of "carrying over" the last
diff --git a/t/runtests b/t/runtests
index 0854811..2f98ba3 100755
--- a/t/runtests
+++ b/t/runtests
@@ -58,7 +58,7 @@ BEGIN {
use lib "$ENV{'LINTIAN_ROOT'}/lib";
-use Lintian::Util qw(delete_dir fail read_dpkg_control slurp_entire_file);
+use Lintian::Util qw(delete_dir fail read_dpkg_control rstrip slurp_entire_file);
# --- Global configuration
@@ -981,7 +981,7 @@ sub _msg_qh {
my @output;
for my $tid (keys %thrs) {
my $p = $thrs{$tid}[-1];
- $p =~ s/\s+$//;
+ rstrip ($p);
push @output, $p;
}
--
Debian package checker
Reply to: