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

[lintian] 04/13: spellintian.pm: Make spellintian a true dplint command



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 0bd452b8a86ad80906c644556b79bc7e4fb7d704
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Jun 19 22:55:04 2015 +0200

    spellintian.pm: Make spellintian a true dplint command
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 commands/spellintian.pm | 74 +++++++++++++++++++++++++++----------------------
 1 file changed, 41 insertions(+), 33 deletions(-)

diff --git a/commands/spellintian.pm b/commands/spellintian.pm
index 58f6370..8f653dc 100644
--- a/commands/spellintian.pm
+++ b/commands/spellintian.pm
@@ -44,29 +44,9 @@ EOF
     exit 0;
 }
 
-my $profile = Lintian::Profile->new;
-Lintian::Data->set_vendor($profile);
-
-my $picky = 0;
-{
-    local $SIG{__WARN__} = sub {
-        my ($message) = @_;
-        $message =~ s/\A([[:upper:]])/lc($1)/e;
-        $message =~ s/\n+\z//;
-        print {*STDERR} "spellintian: $message\n";
-        exit(1);
-    };
-    Getopt::Long::Configure('gnu_getopt');
-    Getopt::Long::GetOptions(
-        '--picky' => \$picky,
-        'h|help' => \&show_help,
-        'version' => \&show_version,
-    ) or exit(1);
-}
-
 sub spellcheck
 {
-    my ($path, $text) = @_;
+    my ($path, $picky, $text) = @_;
     my $prefix = $path ? "$path: " : q{};
     my $spelling_error_handler = sub {
         my ($mistake, $correction) = @_;
@@ -79,24 +59,48 @@ sub spellcheck
     return;
 }
 
-if (not @ARGV) {
-    my $text;
+
+sub main {
+    my $profile = Lintian::Profile->new;
+    Lintian::Data->set_vendor($profile);
+
+    my $picky = 0;
     {
-        local $RS = undef;
-        $text = <STDIN>;
+        local $SIG{__WARN__} = sub {
+            my ($message) = @_;
+            $message =~ s/\A([[:upper:]])/lc($1)/e;
+            $message =~ s/\n+\z//;
+            print {*STDERR} "spellintian: $message\n";
+            exit(1);
+        };
+        Getopt::Long::Configure('gnu_getopt');
+        Getopt::Long::GetOptions(
+            '--picky' => \$picky,
+            'h|help' => \&show_help,
+            'version' => \&show_version,
+        ) or exit(1);
     }
-    spellcheck(undef, $text);
-} else {
-    for my $path (@ARGV) {
+
+    if (not @ARGV) {
         my $text;
-        open(my $fh, '<', $path) or die $ERRNO;
         {
             local $RS = undef;
-            $text = <$fh>;
+            $text = <STDIN>;
+        }
+        spellcheck(undef, $picky, $text);
+    } else {
+        for my $path (@ARGV) {
+            my $text;
+            open(my $fh, '<', $path) or die $ERRNO;
+            {
+                local $RS = undef;
+                $text = <$fh>;
+            }
+            close($fh) or die $ERRNO;
+            spellcheck($path, $picky, $text);
         }
-        close($fh) or die $ERRNO;
-        spellcheck($path, $text);
     }
+    return;
 }
 
 END {
@@ -104,4 +108,8 @@ END {
     close(STDERR) or die $ERRNO;
 }
 
-# vim:ts=4 sts=4 sw=4 et
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: