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