[lintian] 02/13: Import spellintian as-is
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 2b9e714d20695cbc00e4f63bbf03df97d999db3b
Author: Jakub Wilk <jwilk@jwilk.net>
Date: Fri Jun 19 22:39:47 2015 +0200
Import spellintian as-is
This will be adapted in the comming commits.
Signed-off-by: Niels Thykier <niels@thykier.net>
---
commands/spellintian.pm | 116 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+)
diff --git a/commands/spellintian.pm b/commands/spellintian.pm
new file mode 100644
index 0000000..8448e88
--- /dev/null
+++ b/commands/spellintian.pm
@@ -0,0 +1,116 @@
+#!/usr/bin/perl
+
+# Copyright © 2014 Jakub Wilk <jwilk@jwilk.net>
+
+# This program is free software. It is distributed under the terms of
+# the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, you can find it on the World Wide
+# Web at <https://www.gnu.org/copyleft/gpl.html>, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+use strict;
+use warnings;
+
+use English qw(-no_match_vars);
+use Getopt::Long ();
+
+use Lintian::Profile ();
+use Lintian::Data ();
+use Lintian::Check ();
+
+use Monkey::Patch ();
+
+our $VERSION = '0.0';
+
+sub show_version
+{
+ print "spellintian $VERSION\n";
+ exit 0;
+}
+
+sub show_help
+{
+ print <<'EOF' ;
+Usage: spellintian [--picky] [FILE...]
+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);
+}
+
+my $monkey = Monkey::Patch::patch_package 'Lintian::Check' => '_tag' => sub {
+ my ($orig, $path, undef, $mistake, $correction) = @_;
+ my $prefix = ref($path) ? '' : "$path: ";
+ print "$prefix$mistake -> $correction\n";
+};
+
+sub spellcheck
+{
+ my ($path, $text) = @_;
+ # Normalize whitespace as a work-around for
+ # <https://bugs.debian.org/763456>:
+ $text =~ s/\s+/ /g;
+ if (not defined $path) {
+ $path = \undef;
+ }
+ Lintian::Check::check_spelling($path, $text);
+ if ($picky) {
+ Lintian::Check::check_spelling_picky($path, $text);
+ }
+ return;
+}
+
+if (not @ARGV) {
+ my $text;
+ {
+ local $RS = undef;
+ $text = <STDIN>;
+ }
+ spellcheck(undef, $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, $text);
+ }
+}
+
+END {
+ close(STDOUT) or die $ERRNO;
+ close(STDERR) or die $ERRNO;
+}
+
+# vim:ts=4 sts=4 sw=4 et
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: