Browse Source

Fix val(str, enum).

Rika Ichinose 1 year ago
parent
commit
be11d22c17
1 changed files with 2 additions and 4 deletions
  1. 2 4
      rtl/inc/sstrings.inc

+ 2 - 4
rtl/inc/sstrings.inc

@@ -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;