StrToBool does not respect custom BoolStrs
Original Reporter info from Mantis: luizamerico
-
Reporter name: Luiz Americo
Original Reporter info from Mantis: luizamerico
- Reporter name: Luiz Americo
Description:
The following program raises an EConvertError, but under Delphi 7 runs fine. In the other side after changing BoolStr to a custom value like 'sim' and calling StrToBool('True') will raise an EConvertError.
Using Free Pascal Compiler version 2.5.1 [2010/06/16] for i386
program bugStrToBool;
{$mode objfpc}{$H+}
uses
Classes, SysUtils;
var
B: Boolean;
S: String;
begin
WriteLn('BoolToStr(False, True): ' + BoolToStr(False, True));
WriteLn('BoolToStr(True, True): ' + BoolToStr(True, True));
SetLength(TrueBoolStrs, 1);
SetLength(FalseBoolStrs, 1);
TrueBoolStrs[0] := 'Sim';
FalseBoolStrs[0] := 'Não';
WriteLn('BoolStrs = Não;Sim');
WriteLn('BoolToStr(False, True): ' + BoolToStr(False, True));
WriteLn('BoolToStr(True, True): ' + BoolToStr(True, True));
S := BoolToStr(False, True);
B := StrToBool(S);
WriteLn('StrToBool(' + S +') = ' + BoolToStr(B, True));
S := BoolToStr(True, True);
B := StrToBool(S);
WriteLn('StrToBool(' + S +') = ' + BoolToStr(B, True));
//B := StrToBool('True'); //Under Delphi this raises an exception
end.
Mantis conversion info:
- Mantis ID: 16848
- Fixed in version: 2.6.0
- Fixed in revision: 15764 (#89be8d45)