mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:49:09 +02:00
Fix val(str, enum).
This commit is contained in:
parent
9059ac067c
commit
be11d22c17
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user