[SCM] Debian package checker branch, master, updated. 2.3.0-35-g49d4354
The following commit has been merged in the master branch:
commit af6bc4ad62a1bddf862999071cae87ab1c4d599d
Author: Raphael Geissert <atomo64@gmail.com>
Date: Wed Dec 30 17:35:38 2009 -0600
Refactor multi-word spelling checking code to avoid duplication
Now all of the multi-word spelling corrections are stored in a hash.
diff --git a/lib/Spelling.pm b/lib/Spelling.pm
index 0f12ac5..260df94 100644
--- a/lib/Spelling.pm
+++ b/lib/Spelling.pm
@@ -514,6 +514,13 @@ our %CORRECTIONS = qw(
# The format above doesn't allow spaces.
$CORRECTIONS{'alot'} = 'a lot';
+our %MULTIWORD_CORRECTIONS = (
+ qr'(?i)an other' => 'another',
+ qr'(?i)debian/gnu linux' => 'Debian GNU/Linux',
+ qr'(?i)these package' => 'this package',
+ qr'(?i)this packages' => 'these packages',
+ );
+
# Picky corrections, applied before lowercasing the word. These are only
# applied to things known to be entirely English text, such as package
# descriptions, and should not be applied to files that may contain
@@ -632,25 +639,17 @@ sub spelling_check {
}
# Special case for correcting multi-word strings.
- if ($text =~ m,(debian/gnu\s+linux),i) {
- $counter++;
- _tag($tag, $filename, $1, "Debian GNU/Linux")
- if defined $tag;
- }
- if ($text =~ m,\b(an other)\b,i) {
- $counter++;
- _tag($tag, $filename, $1, "another")
- if defined $tag;
- }
- if ($text =~ m,\b(this packages)\b,i) {
- $counter++;
- _tag($tag, $filename, $1, "these packages")
- if defined $tag;
- }
- if ($text =~ m,\b(these package)\b,i) {
- $counter++;
- _tag($tag, $filename, $1, "this package")
- if defined $tag;
+ for my $regex (keys %MULTIWORD_CORRECTIONS) {
+ if ($text =~ m,\b($regex)\b,) {
+ my $word = $1;
+ my $correction = $MULTIWORD_CORRECTIONS{$regex};
+ if ($word =~ /^[A-Z]/) {
+ $correction = ucfirst $correction;
+ }
+ $counter++;
+ _tag($tag, $filename, $word, $correction)
+ if defined $tag;
+ }
}
return $counter;
diff --git a/t/tests/spelling-multiword/tags b/t/tests/spelling-multiword/tags
index 7961876..a954125 100644
--- a/t/tests/spelling-multiword/tags
+++ b/t/tests/spelling-multiword/tags
@@ -1,3 +1,3 @@
-W: spelling-multiword: spelling-error-in-description An other another
+W: spelling-multiword: spelling-error-in-description An other Another
W: spelling-multiword: spelling-error-in-description Debian/GNU Linux Debian GNU/Linux
-W: spelling-multiword: spelling-error-in-description This packages these packages
+W: spelling-multiword: spelling-error-in-description This packages These packages
--
Debian package checker
Reply to: