check integer ordinal range on only Ruby 1.8 (#13644)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11706 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2013-04-05 05:51:58 +00:00
parent ed0a8413a2
commit 0d02931759
1 changed files with 8 additions and 4 deletions

View File

@ -199,15 +199,19 @@ module Redmine
while starting < max && line_left[starting] == line_right[starting] while starting < max && line_left[starting] == line_right[starting]
starting += 1 starting += 1
end end
while line_left[starting].ord.between?(128, 191) && starting > 0 unless "".respond_to?(:force_encoding)
starting -= 1 while line_left[starting].ord.between?(128, 191) && starting > 0
starting -= 1
end
end end
ending = -1 ending = -1
while ending >= -(max - starting) && line_left[ending] == line_right[ending] while ending >= -(max - starting) && line_left[ending] == line_right[ending]
ending -= 1 ending -= 1
end end
while line_left[ending].ord.between?(128, 191) && ending > -1 unless "".respond_to?(:force_encoding)
ending -= 1 while line_left[ending].ord.between?(128, 191) && ending > -1
ending -= 1
end
end end
unless starting == 0 && ending == -1 unless starting == 0 && ending == -1
[starting, ending] [starting, ending]