* Fixed upper limit in tbits.findnextbit, Mantis #25398.

git-svn-id: trunk@26754 -
This commit is contained in:
sergei 2014-02-11 16:39:45 +00:00
parent 0f7e1af3bb
commit 6c66b8ffe3
3 changed files with 28 additions and 3 deletions

1
.gitattributes vendored
View File

@ -13807,6 +13807,7 @@ tests/webtbs/tw25332a.pp svneol=native#text/plain
tests/webtbs/tw25349.pp svneol=native#text/plain
tests/webtbs/tw2536.pp svneol=native#text/plain
tests/webtbs/tw25361.pp svneol=native#text/plain
tests/webtbs/tw25398.pp svneol=native#text/plain
tests/webtbs/tw2540.pp svneol=native#text/plain
tests/webtbs/tw25494.pp svneol=native#text/plain
tests/webtbs/tw25551.pp svneol=native#text/plain

View File

@ -319,16 +319,14 @@ end;
function TBits.FindNextBit : longint;
var
loop : longint;
maxVal : longint;
begin
result := -1; { will occur only if no other bits set to }
{ current findState }
if findIndex > -1 then { must have called FindFirstBit first }
begin { or set the start index }
maxVal := (FSize * 32) - 1;
for loop := findIndex + 1 to maxVal do
for loop := findIndex + 1 to FBSize-1 do
begin
if get(loop) = findState then
begin

26
tests/webtbs/tw25398.pp Normal file
View File

@ -0,0 +1,26 @@
{$mode objfpc}{$h+}
uses classes;
var
b: tbits;
i: integer;
begin
b:= TBits.Create;
b.Size:= 128;
b.SetOn(0);
b.SetOn(13);
b.SetOn(118);
i:= b.FindFirstBit(True);
if i<>0 then
halt(1);
i:= b.FindNextBit;
if i<>13 then
halt(2);
i:= b.FindNextBit;
if i<>118 then
halt(3);
i:= b.FindNextBit;
if i<>-1 then
halt(4);
end.