* Make use of copy() without count when rest of string is needed

This commit is contained in:
Michaël Van Canneyt 2023-06-19 11:23:04 +02:00 committed by FPK
parent 535107a700
commit 1930aaa340

View File

@ -886,7 +886,7 @@ begin
end end
else if Copy(More,1,1) = 'x' then else if Copy(More,1,1) = 'x' then
begin begin
Assign(xmloutput,Copy(More,2,length(More)-1)); Assign(xmloutput,Copy(More,2));
Rewrite(xmloutput); Rewrite(xmloutput);
WriteLn(xmloutput,'<?xml version="1.0" encoding="utf-8"?>'); WriteLn(xmloutput,'<?xml version="1.0" encoding="utf-8"?>');
WriteLn(xmloutput,'<fpcoutput>'); WriteLn(xmloutput,'<fpcoutput>');
@ -2336,7 +2336,7 @@ begin
external assembler, it is ignored if internal assembler is used. } external assembler, it is ignored if internal assembler is used. }
'o' : 'o' :
begin begin
asmextraopt:=copy(more,j+1,length(more)-j); asmextraopt:=copy(more,j+1);
break; break;
end; end;
'p' : 'p' :
@ -2428,7 +2428,7 @@ begin
include(init_settings.localswitches,cs_ieee_errors); include(init_settings.localswitches,cs_ieee_errors);
'a' : 'a' :
begin begin
s:=upper(copy(more,j+1,length(more)-j)); s:=upper(copy(more,j+1));
if not(SetAbiType(s,target_info.abi)) then if not(SetAbiType(s,target_info.abi)) then
IllegalPara(opt); IllegalPara(opt);
ABISetExplicitly:=true; ABISetExplicitly:=true;
@ -2446,7 +2446,7 @@ begin
'c' : 'c' :
begin begin
if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),init_settings.defproccall) then if not SetAktProcCall(upper(copy(more,j+1)),init_settings.defproccall) then
IllegalPara(opt); IllegalPara(opt);
break; break;
end; end;
@ -2466,7 +2466,7 @@ begin
include(init_settings.localswitches,cs_check_fpu_exceptions); include(init_settings.localswitches,cs_check_fpu_exceptions);
'f' : 'f' :
begin begin
s:=upper(copy(more,j+1,length(more)-j)); s:=upper(copy(more,j+1));
if not(SetFpuType(s,init_settings.fputype)) then if not(SetFpuType(s,init_settings.fputype)) then
IllegalPara(opt); IllegalPara(opt);
FPUSetExplicitly:=True; FPUSetExplicitly:=True;
@ -2474,7 +2474,7 @@ begin
end; end;
'F' : 'F' :
begin begin
if not SetMinFPConstPrec(copy(more,j+1,length(more)-j),init_settings.minfpconstprec) then if not SetMinFPConstPrec(copy(more,j+1),init_settings.minfpconstprec) then
IllegalPara(opt); IllegalPara(opt);
break; break;
end; end;
@ -2493,7 +2493,7 @@ begin
end; end;
'h' : 'h' :
begin begin
l:=pos(',',copy(more,j+1,length(more)-j)); l:=pos(',',copy(more,j+1));
if l=0 then if l=0 then
l:=length(more)-j+1; l:=length(more)-j+1;
val(copy(more,j+1,l-1),heapsize,code); val(copy(more,j+1,l-1),heapsize,code);
@ -2507,7 +2507,7 @@ begin
IllegalPara(opt) IllegalPara(opt)
else if l<=length(more)-j then else if l<=length(more)-j then
begin begin
val(copy(more,j+l+1,length(more)),maxheapsize,code); val(copy(more,j+l+1),maxheapsize,code);
if code<>0 then if code<>0 then
IllegalPara(opt) IllegalPara(opt)
else if (maxheapsize<heapsize) then else if (maxheapsize<heapsize) then
@ -2526,11 +2526,11 @@ begin
{$ifdef arm} {$ifdef arm}
'I' : 'I' :
begin begin
if (upper(copy(more,j+1,length(more)-j))='THUMB') and if (upper(copy(more,j+1)='THUMB') and
{ does selected CPU really understand thumb? } { does selected CPU really understand thumb? }
(init_settings.cputype in cpu_has_thumb) then (init_settings.cputype in cpu_has_thumb) then
init_settings.instructionset:=is_thumb init_settings.instructionset:=is_thumb
else if upper(copy(more,j+1,length(more)-j))='ARM' then else if upper(copy(more,j+1))='ARM' then
init_settings.instructionset:=is_arm init_settings.instructionset:=is_arm
else else
IllegalPara(opt); IllegalPara(opt);
@ -2582,7 +2582,7 @@ begin
end; end;
'v': 'v':
begin begin
init_settings.llvmversion:=llvmversion2enum(copy(More,l+1,length(More))); init_settings.llvmversion:=llvmversion2enum(copy(More,l+1));
if init_settings.llvmversion=llvmver_invalid then if init_settings.llvmversion=llvmver_invalid then
begin begin
IllegalPara(opt); IllegalPara(opt);
@ -2620,7 +2620,7 @@ begin
include(init_settings.localswitches,cs_check_ordinal_size); include(init_settings.localswitches,cs_check_ordinal_size);
'p' : 'p' :
begin begin
s:=upper(copy(more,j+1,length(more)-j)); s:=upper(copy(more,j+1));
{$ifdef cpucapabilities} {$ifdef cpucapabilities}
{ find first occurrence of + or - } { find first occurrence of + or - }
deletepos:=PosCharset(['+','-'],s); deletepos:=PosCharset(['+','-'],s);
@ -2739,7 +2739,7 @@ begin
end; end;
's' : 's' :
begin begin
val(copy(more,j+1,length(more)-j),stacksize,code); val(copy(more,j+1),stacksize,code);
if (code<>0) if (code<>0)
{$ifdef cpu16bitaddr} {$ifdef cpu16bitaddr}
or (stacksize>=65521) or (stacksize>=65521)
@ -2767,7 +2767,7 @@ begin
include(init_settings.moduleswitches,cs_create_smart); include(init_settings.moduleswitches,cs_create_smart);
'T' : 'T' :
begin begin
if not UpdateTargetSwitchStr(copy(more,j+1,length(more)),init_settings.targetswitches,true) then if not UpdateTargetSwitchStr(copy(more,j+1),init_settings.targetswitches,true) then
IllegalPara(opt); IllegalPara(opt);
break; break;
end; end;
@ -2781,7 +2781,7 @@ begin
IllegalPara(opt); IllegalPara(opt);
'V': 'V':
begin begin
s:=upper(copy(more,j+1,length(more)-j)); s:=upper(copy(more,j+1));
if s='GLOBAL-DYNAMIC' then if s='GLOBAL-DYNAMIC' then
init_settings.tlsmodel:=tlsm_global_dynamic init_settings.tlsmodel:=tlsm_global_dynamic
else if s='LOCAL-EXEC' then else if s='LOCAL-EXEC' then
@ -2822,9 +2822,9 @@ begin
if l>0 then if l>0 then
begin begin
if cs_support_macro in init_settings.moduleswitches then if cs_support_macro in init_settings.moduleswitches then
set_system_macro(hs,Copy(more,l+2,255)) set_system_macro(hs,Copy(more,l+2))
else else
set_system_compvar(hs,Copy(more,l+2,255)); set_system_compvar(hs,Copy(more,l+2));
end end
else else
def_system_macro(hs); def_system_macro(hs);
@ -2844,23 +2844,23 @@ begin
'd' : 'd' :
begin begin
include(init_settings.globalswitches,cs_link_deffile); include(init_settings.globalswitches,cs_link_deffile);
description:=Copy(more,j+1,255); description:=Copy(more,j+1);
break; break;
end; end;
'D' : 'D' :
begin begin
datestr:=Copy(more,j+1,255); datestr:=Copy(more,j+1);
break; break;
end; end;
'T' : 'T' :
begin begin
timestr:=Copy(more,j+1,255); timestr:=Copy(more,j+1);
break; break;
end; end;
'v' : 'v' :
begin begin
include(init_settings.globalswitches,cs_link_deffile); include(init_settings.globalswitches,cs_link_deffile);
dllversion:=Copy(more,j+1,255); dllversion:=Copy(more,j+1);
l:=pos('.',dllversion); l:=pos('.',dllversion);
dllminor:=0; dllminor:=0;
error:=0; error:=0;
@ -3165,7 +3165,7 @@ begin
end; end;
'o' : 'o' :
begin begin
if not UpdateDebugStr(copy(more,j+1,length(more)),init_settings.debugswitches) then if not UpdateDebugStr(copy(more,j+1),init_settings.debugswitches) then
IllegalPara(opt); IllegalPara(opt);
break; break;
end; end;
@ -3361,7 +3361,7 @@ begin
include(init_settings.optimizerswitches,cs_opt_size); include(init_settings.optimizerswitches,cs_opt_size);
'p' : 'p' :
begin begin
if not Setoptimizecputype(copy(more,j+1,length(more)),init_settings.optimizecputype) then if not Setoptimizecputype(copy(more,j+1),init_settings.optimizecputype) then
begin begin
OptCPUSetExplicitly:=true; OptCPUSetExplicitly:=true;
{ Give warning for old i386 switches } { Give warning for old i386 switches }
@ -3375,7 +3375,7 @@ begin
end; end;
'o' : 'o' :
begin begin
if not UpdateOptimizerStr(copy(more,j+1,length(more)),init_settings.optimizerswitches) then if not UpdateOptimizerStr(copy(more,j+1),init_settings.optimizerswitches) then
IllegalPara(opt); IllegalPara(opt);
break; break;
end; end;
@ -3395,13 +3395,13 @@ begin
Message2(option_obsolete_switch_use_new,'-Ou','-Oouncertain'); Message2(option_obsolete_switch_use_new,'-Ou','-Oouncertain');
'w' : 'w' :
begin begin
if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.dowpoptimizerswitches) then if not UpdateWpoStr(copy(more,j+1),init_settings.dowpoptimizerswitches) then
IllegalPara(opt); IllegalPara(opt);
break; break;
end; end;
'W' : 'W' :
begin begin
if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.genwpoptimizerswitches) then if not UpdateWpoStr(copy(more,j+1),init_settings.genwpoptimizerswitches) then
IllegalPara(opt); IllegalPara(opt);
break; break;
end; end;
@ -3536,7 +3536,7 @@ begin
SetCompileMode('DELPHI',true); SetCompileMode('DELPHI',true);
'e' : 'e' :
begin begin
SetErrorFlags(copy(more,j+1,length(more))); SetErrorFlags(copy(more,j+1));
break; break;
end; end;
'f' : 'f' :
@ -3553,7 +3553,7 @@ begin
end end
else else
begin begin
if (HandleFeature(upper(copy(more,j,length(more)-j+1)))) then if (HandleFeature(upper(copy(more,j)))) then
j:=length(more) j:=length(more)
else else
IllegalPara(opt); IllegalPara(opt);
@ -3710,7 +3710,7 @@ begin
{$ifdef UNITALIASES} {$ifdef UNITALIASES}
'a' : 'a' :
begin begin
AddUnitAlias(Copy(More,j+1,255)); AddUnitAlias(Copy(More,j+1));
break; break;
end; end;
{$endif UNITALIASES} {$endif UNITALIASES}
@ -3805,7 +3805,7 @@ begin
non relocatable DLL at a specific base address PM } non relocatable DLL at a specific base address PM }
if (length(More)>j) then if (length(More)>j) then
begin begin
val('$'+Copy(More,j+1,255),imagebase,code); val('$'+Copy(More,j+1),imagebase,code);
if code<>0 then if code<>0 then
IllegalPara(opt); IllegalPara(opt);
ImageBaseSetExplicity:=true; ImageBaseSetExplicity:=true;
@ -3859,7 +3859,7 @@ begin
begin begin
if (length(More)>j) then if (length(More)>j) then
begin begin
val(Copy(More,j+1,255),ataritos_exe_flags,code); val(Copy(More,j+1),ataritos_exe_flags,code);
if code<>0 then if code<>0 then
IllegalPara(opt); IllegalPara(opt);
end end
@ -3925,7 +3925,7 @@ begin
{$if defined(i8086)} {$if defined(i8086)}
if (target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) then if (target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) then
begin begin
case Upper(Copy(More,j+1,255)) of case Upper(Copy(More,j+1)) of
'TINY': init_settings.x86memorymodel:=mm_tiny; 'TINY': init_settings.x86memorymodel:=mm_tiny;
'SMALL': init_settings.x86memorymodel:=mm_small; 'SMALL': init_settings.x86memorymodel:=mm_small;
'MEDIUM': init_settings.x86memorymodel:=mm_medium; 'MEDIUM': init_settings.x86memorymodel:=mm_medium;
@ -3944,7 +3944,7 @@ begin
'M': 'M':
begin begin
if (target_info.system in (systems_darwin-[system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim,system_aarch64_iphonesim])) and if (target_info.system in (systems_darwin-[system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim,system_aarch64_iphonesim])) and
ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',copy(More,2,255),false) then ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',copy(More,2),false) then
begin begin
break; break;
end end
@ -3968,7 +3968,7 @@ begin
if ((target_info.system in systems_embedded) or (target_info.system in systems_freertos)) and if ((target_info.system in systems_embedded) or (target_info.system in systems_freertos)) and
ControllerSupport then ControllerSupport then
begin begin
s:=upper(copy(more,j+1,length(more)-j)); s:=upper(copy(more,j+1));
if not(SetControllerType(s,init_settings.controllertype)) then if not(SetControllerType(s,init_settings.controllertype)) then
IllegalPara(opt) IllegalPara(opt)
else else
@ -3988,13 +3988,13 @@ begin
'P': 'P':
begin begin
if (target_info.system in [system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim,system_aarch64_iphonesim]) and if (target_info.system in [system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim,system_aarch64_iphonesim]) and
ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',copy(More,2,255),true) then ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',copy(More,2),true) then
begin begin
break; break;
end end
{$ifdef XTENSA} {$ifdef XTENSA}
else if (target_info.system in [system_xtensa_freertos]) and else if (target_info.system in [system_xtensa_freertos]) and
ParseVersionStr(idf_version,'IDF_VERSION',copy(More,2,255)) then ParseVersionStr(idf_version,'IDF_VERSION',copy(More,2)) then
begin begin
break; break;
end end
@ -4014,7 +4014,7 @@ begin
begin begin
if (target_info.system in [system_m68k_sinclairql]) then if (target_info.system in [system_m68k_sinclairql]) then
begin begin
sinclairql_metadata_format:=Upper(Copy(More,j+1,255)); sinclairql_metadata_format:=Upper(Copy(More,j+1));
case sinclairql_metadata_format of case sinclairql_metadata_format of
'QHDR', 'XTCC': ; { allowed formats } 'QHDR', 'XTCC': ; { allowed formats }
else else
@ -4042,7 +4042,7 @@ begin
{$if defined(i8086)} {$if defined(i8086)}
if (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then if (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
begin begin
case Upper(Copy(More,j+1,255)) of case Upper(Copy(More,j+1)) of
'EXE': SetAppType(app_cui); 'EXE': SetAppType(app_cui);
'COM': SetAppType(app_com); 'COM': SetAppType(app_com);
else else
@ -4055,7 +4055,7 @@ begin
{$if defined(m68k)} {$if defined(m68k)}
if (target_info.system in [system_m68k_atari]) then if (target_info.system in [system_m68k_atari]) then
begin begin
case Upper(Copy(More,j+1,255)) of case Upper(Copy(More,j+1)) of
'TOS': ataritos_exe_format := 'ataritos'; 'TOS': ataritos_exe_format := 'ataritos';
'MINT': ataritos_exe_format := 'aoutmint'; 'MINT': ataritos_exe_format := 'aoutmint';
else else
@ -4177,7 +4177,7 @@ begin
case more[j+1] of case more[j+1] of
'S': 'S':
begin begin
llvmutilssuffix:=copy(more,j+2,length(more)); llvmutilssuffix:=copy(more,j+2);
j:=length(more); j:=length(more);
end end
else else
@ -4198,7 +4198,7 @@ begin
begin begin
if (target_info.system in suppported_targets_x_smallr) then if (target_info.system in suppported_targets_x_smallr) then
begin begin
rlinkpath:=Copy(more,2,length(More)-1); rlinkpath:=Copy(more,2);
DefaultReplacements(rlinkpath); DefaultReplacements(rlinkpath);
end end
else else
@ -4207,7 +4207,7 @@ begin
end; end;
'R' : 'R' :
begin begin
sysrootpath:=copy(more,2,length(more)-1); sysrootpath:=copy(more,2);
defaultreplacements(sysrootpath); defaultreplacements(sysrootpath);
more:=''; more:='';
end; end;
@ -4251,12 +4251,12 @@ begin
end; end;
'M' : 'M' :
begin begin
mainaliasname:=Copy(more,2,length(More)-1); mainaliasname:=Copy(more,2);
More:=''; More:='';
end; end;
'P' : 'P' :
begin begin
utilsprefix:=Copy(more,2,length(More)-1); utilsprefix:=Copy(more,2);
DefaultReplacements(utilsprefix); DefaultReplacements(utilsprefix);
More:=''; More:='';
end; end;
@ -4268,12 +4268,12 @@ begin
begin begin
case more[j+1] of case more[j+1] of
'A' : begin 'A' : begin
s:=Copy(more,3,length(More)-2); s:=Copy(more,3);
if not LinkLibraryAliases.AddDep(s) Then if not LinkLibraryAliases.AddDep(s) Then
IllegalPara(opt); IllegalPara(opt);
end; end;
'O' : begin 'O' : begin
s:=Copy(more,3,length(More)-2); s:=Copy(more,3);
if not LinkLibraryOrder.AddWeight(s) Then if not LinkLibraryOrder.AddWeight(s) Then
IllegalPara(opt); IllegalPara(opt);
end; end;