Fix val(str, enum).

This commit is contained in:
Rika Ichinose 2024-07-20 01:33:45 +03:00 committed by Michael Van Canneyt
parent 9059ac067c
commit be11d22c17

View File

@ -1638,7 +1638,6 @@ type Psorted_array=^Tsorted_array;
var l,r,l2,r2,m,sp,isp:SizeInt; var l,r,l2,r2,m,sp,isp:SizeInt;
c:char; c:char;
cs:Pstring;
begin begin
{Val for numbers accepts spaces at the start, so lets do the same {Val for numbers accepts spaces at the start, so lets do the same
@ -1662,16 +1661,15 @@ begin
break; break;
inc(isp); inc(isp);
c:=UpCase(s[sp]); c:=UpCase(s[sp]);
cs:=Psorted_array(Pstring_to_ord(str2ordindex)^.data)[l].s;
{ Among all strings beginning with, say, ab, the ab itself will be the first. { Among all strings beginning with, say, ab, the ab itself will be the first.
So after this check, “isp length(any string in the range) is guaranteed. } So after this check, “isp length(any string in the range) is guaranteed. }
if isp>length(cs^) then if isp>length(Psorted_array(Pstring_to_ord(str2ordindex)^.data)[l].s^) then
begin begin
inc(l); inc(l);
if l=r then if l=r then
break; break;
end; end;
if UpCase(cs^[isp])=c then { Shortcut: L may be already correct (enums often have common prefixes). } if UpCase(Psorted_array(Pstring_to_ord(str2ordindex)^.data)[l].s^[isp])=c then { Shortcut: L may be already correct (enums often have common prefixes). }
begin begin
if l+1=r then { Shortcut: the only string left (enums often have different suffixes). } if l+1=r then { Shortcut: the only string left (enums often have different suffixes). }
continue; continue;