/usr/lib/lazarus/0.9.30.4/ide/compoptsmodes.pas is in lazarus-src-0.9.30.4 0.9.30.4-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | { /***************************************************************************
compoptsmodes.pas - Lazarus IDE unit
---------------------------------------
Conditional compiler options and build modes.
***************************************************************************/
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
This unit contains a class to create diffs between compiler options.
}
unit CompOptsModes;
{$mode objfpc}{$H+}
{$i ide.inc}
interface
uses
Classes, SysUtils, LCLProc, ExprEval,
IDEProcs, ProjectIntf;
type
{ TCompilerDiffTool
A tool to collect the difference between two option sets }
TCompilerDiffTool = class
private
FDiff: TStrings;
FDiffer: boolean;
FPath: string;
procedure SetDiff(const AValue: TStrings);
procedure SetDiffer(const AValue: boolean);
procedure SetPath(const AValue: string);
public
constructor Create(DiffList: TStrings);
procedure AddDiffItem(const PropertyName, Value: string);
procedure AddDiffItemUndefined(const PropertyName: string);
function AddDiff(const PropertyName: string; const Old, New: string): boolean;
function AddDiff(const PropertyName: string; const Old, New: integer): boolean;
function AddDiff(const PropertyName: string; const Old, New: boolean): boolean;
function AddStringsDiff(const PropertyName: string; const OldList, NewList: TStrings): boolean;
function AddPathsDiff(const PropertyName: string; const Old, New: string): boolean;
function AddSetDiff(const PropertyName: string; const Old, New: integer;
const EnumNames: PString): boolean;
property Diff: TStrings read FDiff write SetDiff;
property Path: string read FPath write SetPath;
property Differ: boolean read FDiffer write SetDiffer;
end;
implementation
{ TCompilerDiffTool }
procedure TCompilerDiffTool.SetDiff(const AValue: TStrings);
begin
if Self=nil then exit;
if FDiff=AValue then exit;
FDiff:=AValue;
end;
procedure TCompilerDiffTool.SetDiffer(const AValue: boolean);
begin
if Self=nil then exit;
if FDiffer=AValue then exit;
FDiffer:=AValue;
end;
procedure TCompilerDiffTool.SetPath(const AValue: string);
begin
if Self=nil then exit;
if FPath=AValue then exit;
FPath:=AValue;
// ! config path, not file path. Always /, not PathDelim
if (FPath<>'') and (Path[length(Path)]<>'/') then FPath:=FPath+'/';
end;
constructor TCompilerDiffTool.Create(DiffList: TStrings);
begin
FDiff:=DiffList;
if Diff<>nil then
Diff.Clear;
end;
procedure TCompilerDiffTool.AddDiffItem(const PropertyName, Value: string);
begin
if Self=nil then exit;
Differ:=true;
if Diff<>nil then
Diff.Add(Path+PropertyName+'='+Value);
end;
procedure TCompilerDiffTool.AddDiffItemUndefined(const PropertyName: string);
begin
if Self=nil then exit;
Differ:=true;
if Diff<>nil then
Diff.Add(Path+PropertyName+' undefined');
end;
function TCompilerDiffTool.AddDiff(const PropertyName: string; const Old,
New: string): boolean;
begin
//if Self<>nil then debugln(['TCompilerDiffTool.AddDiff ',PropertyName,'=',Old,',',New]);
if Old=New then exit(false);
Result:=true;
if Self=nil then exit;
AddDiffItem(PropertyName,New);
end;
function TCompilerDiffTool.AddDiff(const PropertyName: string; const Old,
New: integer): boolean;
begin
if Old=New then exit(false);
Result:=true;
if Self=nil then exit;
AddDiffItem(PropertyName,IntToStr(New));
end;
function TCompilerDiffTool.AddDiff(const PropertyName: string; const Old,
New: boolean): boolean;
begin
if Old=New then exit(false);
Result:=true;
if Self=nil then exit;
AddDiffItem(PropertyName,dbgs(New));
end;
function TCompilerDiffTool.AddStringsDiff(const PropertyName: string;
const OldList, NewList: TStrings): boolean;
var
i: Integer;
OldCnt: Integer;
NewCnt: Integer;
begin
OldCnt:=0;
if OldList<>nil then
OldCnt:=OldList.Count;
NewCnt:=0;
if NewList<>nil then
NewCnt:=NewList.Count;
Result:=AddDiff(PropertyName+'/Count',OldCnt,NewCnt);
if Result and (Self=nil) then exit;
for i:=0 to OldCnt-1 do begin
if (i>=NewCnt) then begin
Result:=true;
if Self=nil then exit;
AddDiffItem(PropertyName+'/Item'+IntToStr(i),'deleted='+OldList[i]);
end
else if (OldList[i]<>NewList[i]) then begin
Result:=true;
if Self=nil then exit;
AddDiffItem(PropertyName+'/Item'+IntToStr(i),NewList[i]);
end;
end;
end;
function TCompilerDiffTool.AddPathsDiff(const PropertyName: string; const Old,
New: string): boolean;
begin
if Old=New then exit(false);
Result:=true;
if Self=nil then exit;
AddDiff(PropertyName,Old,New);
end;
function TCompilerDiffTool.AddSetDiff(const PropertyName: string; const Old,
New: integer; const EnumNames: PString): boolean;
var
i: Integer;
Mask: LongInt;
s: String;
begin
if Old=New then exit(false);
Result:=true;
if Self=nil then exit;
Mask := 1;
s:='';
for i := 0 to 31 do begin
if (New and Mask) <> (Old and Mask) then begin
if s<>'' then s:=s+',';
if (New and Mask) <> 0 then
s:=s+'+'
else
s:=s+'-';
s:=s+EnumNames[i];
end;
Mask := Mask shl 1;
end;
AddDiffItem(PropertyName,s);
end;
end.
|