aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-30 04:01:07 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-30 04:01:07 +0000
commit3c4633a3a1ace272566618c9e002489d3c03b569 (patch)
treea479525122ae1534b60b25992d5c373d47bdfd71
parent4078d42b72339cd80a88a1d2aa163b5499e2f5f7 (diff)
downloadruby-3c4633a3a1ace272566618c9e002489d3c03b569.tar.gz
Stop using a regexp that causes a false warning.
* lib/abbrev.rb (Abbrev#abbrev): Stop using a regexp that causes a false warning. [Bug #7471] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog3
-rwxr-xr-x[-rw-r--r--]lib/abbrev.rb8
2 files changed, 7 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f01903f21..abf2142972 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@ Fri Nov 30 12:47:59 2012 Akinori MUSHA <knu@iDaemons.org>
should only match the beginning of each word, not the beginning
of every line in it.
+ * lib/abbrev.rb (Abbrev#abbrev): Stop using a regexp that causes a
+ false warning. [Bug #7471]
+
Fri Nov 30 12:30:55 2012 Akinori MUSHA <knu@iDaemons.org>
* test/test_abbrev.rb: Add tests for lib/abbrev.rb.
diff --git a/lib/abbrev.rb b/lib/abbrev.rb
index 443ab6d8f1..d4f8196f49 100644..100755
--- a/lib/abbrev.rb
+++ b/lib/abbrev.rb
@@ -73,9 +73,9 @@ module Abbrev
end
words.each do |word|
- next if (abbrev = word).empty?
- while (len = abbrev.rindex(/[\w\W]\z/)) > 0
- abbrev = word[0,len]
+ next if word.empty?
+ word.size.downto(1) { |len|
+ abbrev = word[0...len]
next if pattern && pattern !~ abbrev
@@ -87,7 +87,7 @@ module Abbrev
else
break
end
- end
+ }
end
words.each do |word|