Re: Fastcode StrToInt32 B&V 0.5.0



Using GlobalStr := #0; will not show the problem, because all 3 Val
functions are designed to work with both PChars and AnsiStrings. The #0 is
recognised as a string terminator and the error code is set correctly.

--
regards,
John

The Fastcode Project:
http://www.fastcodeproject.org/


"Aleksandr" <alsha at mail333 dot com> wrote in message
news:452b40b8$1@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi, John

I think GlobalStr := '123';
must be replaced with GlobalStr := #0;

--
regards,
Aleksandr

The Fastcode Project:
http://www.fastcodeproject.org/

"John O'Harrow" <john@xxxxxxxxxxxxxxxxxxxx> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:45293eb7$1@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Dennis,

Why did you disable Validate 25?

This is the first time we have found an RTL function that does not work
with non-nil zero length strings.

In fact it is the Val function (_ValLong function in system.pas) that
fails, as demonstrated by the following function.

This provides good justification for us to drop support of non-nil zero
length strings in all Fastcode functions.

var
GlobalStr: AnsiString;

procedure TForm1.Button1Click(Sender: TObject);
var
Value, Code: Integer;
begin
GlobalStr := '123';
PInteger(Integer(GlobalStr)-4)^ := 0; //Force Length to 0
Val(GlobalStr, Value, Code);
if Value <> 0 then
ShowMessage('Value should be 0');
end;

--
regards,
John

The Fastcode Project:
http://www.fastcodeproject.org/






.


Loading