I study a little the Delphi source code, and this look a little ugly for me (in system.pas, procedure ValLong) :
while True do
begin
case S[I] of
'0'..'9': Dig := Ord(S[I]) - Ord('0');
else
Break;
end;
if (Result < 0) or (Result > (High(Integer) div 10)) then
Break;
Result := Result*10 + Dig;
Inc(I);
Empty := False;
end;
As you can see the only way to get out of the loop is to read outside the boundary of S (a string). Do I miss something and this is an correct practice ?