|
@@ -80,6 +80,7 @@ const
|
|
|
nMisplacedGlobalCompilerSwitch = 1029;
|
|
|
nLogMacroXSetToY = 1030;
|
|
|
nInvalidDispatchFieldName = 1031;
|
|
|
+ nErrWrongSwitchToggle = 1032;
|
|
|
|
|
|
// resourcestring patterns of messages
|
|
|
resourcestring
|
|
@@ -116,6 +117,7 @@ resourcestring
|
|
|
SMisplacedGlobalCompilerSwitch = 'Misplaced global compiler switch, ignored';
|
|
|
SLogMacroXSetToY = 'Macro %s set to %s';
|
|
|
SInvalidDispatchFieldName = 'Invalid Dispatch field name';
|
|
|
+ SErrWrongSwitchToggle = 'Wrong switch toggle, use ON/OFF or +/-';
|
|
|
|
|
|
type
|
|
|
TMessageType = (
|
|
@@ -2502,7 +2504,6 @@ function TFileResolver.FindIncludeFileName(const AName: string): String;
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
- i: Integer;
|
|
|
FN : string;
|
|
|
|
|
|
begin
|
|
@@ -3496,36 +3497,74 @@ begin
|
|
|
end;
|
|
|
|
|
|
procedure TPascalScanner.HandleModeSwitch(const Param: String);
|
|
|
-
|
|
|
+// $modeswitch param
|
|
|
+// name, name-, name+, name off, name on, name- comment, name on comment
|
|
|
Var
|
|
|
MS : TModeSwitch;
|
|
|
MSN,PM : String;
|
|
|
- P : Integer;
|
|
|
+ p : Integer;
|
|
|
+ Enable: Boolean;
|
|
|
|
|
|
begin
|
|
|
- MSN:=Uppercase(Param);
|
|
|
- P:=Pos(' ',MSN);
|
|
|
- if P<>0 then
|
|
|
- begin
|
|
|
- PM:=Trim(Copy(MSN,P+1,Length(MSN)-P));
|
|
|
- MSN:=Copy(MSN,1,P-1);
|
|
|
- end;
|
|
|
+ PM:=Param;
|
|
|
+ p:=1;
|
|
|
+ while (p<=length(PM)) and (PM[p] in ['a'..'z','A'..'Z','_','0'..'9']) do
|
|
|
+ inc(p);
|
|
|
+ MSN:=LeftStr(PM,p-1);
|
|
|
+ Delete(PM,1,p-1);
|
|
|
MS:=StrToModeSwitch(MSN);
|
|
|
if (MS=msNone) or not (MS in AllowedModeSwitches) then
|
|
|
begin
|
|
|
if po_CheckModeSwitches in Options then
|
|
|
- Error(nErrInvalidModeSwitch,SErrInvalidModeSwitch,[Param])
|
|
|
+ Error(nErrInvalidModeSwitch,SErrInvalidModeSwitch,[MSN])
|
|
|
else
|
|
|
- exit; // ignore
|
|
|
+ DoLog(mtWarning,nErrInvalidModeSwitch,SErrInvalidModeSwitch,[MSN]);
|
|
|
+ exit; // ignore
|
|
|
end;
|
|
|
- if (PM='-') or (PM='OFF') then
|
|
|
+ if PM='' then
|
|
|
+ Enable:=true
|
|
|
+ else
|
|
|
+ case PM[1] of
|
|
|
+ '+','-':
|
|
|
+ begin
|
|
|
+ Enable:=PM[1]='+';
|
|
|
+ p:=2;
|
|
|
+ if (p<=length(PM)) and not (PM[p] in [' ',#9]) then
|
|
|
+ Error(nErrWrongSwitchToggle,SErrWrongSwitchToggle,[]);
|
|
|
+ end;
|
|
|
+ ' ',#9:
|
|
|
+ begin
|
|
|
+ PM:=TrimLeft(PM);
|
|
|
+ if PM<>'' then
|
|
|
+ begin
|
|
|
+ p:=1;
|
|
|
+ while (p<=length(PM)) and (PM[p] in ['A'..'Z']) do inc(p);
|
|
|
+ if (p<=length(PM)) and not (PM[p] in [' ',#9]) then
|
|
|
+ Error(nErrWrongSwitchToggle,SErrWrongSwitchToggle,[]);
|
|
|
+ PM:=LeftStr(PM,p-1);
|
|
|
+ if PM='ON' then
|
|
|
+ Enable:=true
|
|
|
+ else if PM='OFF' then
|
|
|
+ Enable:=false
|
|
|
+ else
|
|
|
+ Error(nErrWrongSwitchToggle,SErrWrongSwitchToggle,[]);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ else
|
|
|
+ Error(nErrWrongSwitchToggle,SErrWrongSwitchToggle,[]);
|
|
|
+ end;
|
|
|
+
|
|
|
+ if MS in CurrentModeSwitches=Enable then
|
|
|
+ exit; // no change
|
|
|
+ if MS in ReadOnlyModeSwitches then
|
|
|
begin
|
|
|
- if MS in ReadOnlyModeSwitches then
|
|
|
- Error(nErrInvalidModeSwitch,SErrInvalidModeSwitch,[Param]);
|
|
|
- CurrentModeSwitches:=CurrentModeSwitches-[MS]
|
|
|
- end
|
|
|
+ DoLog(mtWarning,nErrInvalidModeSwitch,SErrInvalidModeSwitch,[MSN]);
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ if Enable then
|
|
|
+ CurrentModeSwitches:=CurrentModeSwitches+[MS]
|
|
|
else
|
|
|
- CurrentModeSwitches:=CurrentModeSwitches+[MS];
|
|
|
+ CurrentModeSwitches:=CurrentModeSwitches-[MS];
|
|
|
end;
|
|
|
|
|
|
procedure TPascalScanner.PushSkipMode;
|