From 3c4633a3a1ace272566618c9e002489d3c03b569 Mon Sep 17 00:00:00 2001 From: knu Date: Fri, 30 Nov 2012 04:01:07 +0000 Subject: 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 --- lib/abbrev.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 lib/abbrev.rb (limited to 'lib') diff --git a/lib/abbrev.rb b/lib/abbrev.rb old mode 100644 new mode 100755 index 443ab6d8f1..d4f8196f49 --- 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| -- cgit v1.2.3