This file is indexed.

/usr/lib/lazarus/0.9.30.4/ideintf/macrointf.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
{ Copyright (C) 2004

 *****************************************************************************
 *                                                                           *
 *  See the file COPYING.modifiedLGPL.txt, included in this distribution,    *
 *  for details about the copyright.                                         *
 *                                                                           *
 *  This program 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.                     *
 *                                                                           *
 *****************************************************************************

  Abstract:
    Interface to the IDE macros.
}
unit MacroIntf;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil;

type
  { TIDEMacros - macros for paths and compiler settings }

  TIDEMacros = class
  protected
    FBaseTimeStamp: integer;
    FGraphTimeStamp: integer;
  public
    property BaseTimeStamp: integer read FBaseTimeStamp;
    property GraphTimeStamp: integer read FGraphTimeStamp;
    procedure IncreaseBaseStamp;
    procedure IncreaseGraphStamp;
    function StrHasMacros(const s: string): boolean; virtual;
    function SubstituteMacros(var s: string): boolean; virtual;
    function IsMacro(const Name: string): boolean; virtual;
    // file utility functions
    function CreateAbsoluteSearchPath(var SearchPath: string;
                                      const BaseDirectory: string): boolean;
  end;
  
var
  // the global IDE values
  IDEMacros: TIDEMacros = nil; // set by the IDE

procedure RenameIDEMacroInString(var s: string; const OldName, NewName: string);

implementation

const
  MaxStamp = $7fffffff;
  MinStamp = -$7fffffff;
  InvalidStamp = MinStamp-1;

procedure RenameIDEMacroInString(var s: string; const OldName, NewName: string);
var
  p: Integer;
  Macro1: String;
  Macro2: String;

  procedure Replace(const OldValue, NewValue: string);
  begin
    s:=copy(s,1,p-1)+NewValue+copy(s,p+length(OldValue),length(s));
    inc(p,length(NewValue));
  end;

begin
  Macro1:='$('+OldName+')';
  Macro2:='$'+OldName+'(';
  p:=1;
  while (p<length(s)) do
  begin
    if (s[p]<>'$') then
      inc(p)  // skip normal character
    else if (s[p+1]='$') then
      inc(p,2) // skip $$
    else begin
      // macro at p found
      if SysUtils.CompareText(Macro1,copy(s,p,length(Macro1)))=0 then
        Replace(Macro1,'$('+NewName+')')
      else if SysUtils.CompareText(Macro2,copy(s,p,length(Macro1)))=0 then
        Replace(Macro2,'$'+NewName+'(')
      else
        inc(p);
    end;
  end;
end;

{ TIDEMacros }

procedure TIDEMacros.IncreaseBaseStamp;
begin
  if FBaseTimeStamp<MaxStamp then
    inc(FBaseTimeStamp)
  else
    FBaseTimeStamp:=MinStamp;
end;

procedure TIDEMacros.IncreaseGraphStamp;
begin
  if FGraphTimeStamp<MaxStamp then
    inc(FGraphTimeStamp)
  else
    FGraphTimeStamp:=MinStamp;
end;

function TIDEMacros.StrHasMacros(const s: string): boolean;
begin
  Result:=false;
end;

function TIDEMacros.SubstituteMacros(var s: string): boolean;
begin
  Result:=true;
end;

function TIDEMacros.IsMacro(const Name: string): boolean;
begin
  if Name='' then ;
  Result:=true;
end;

function TIDEMacros.CreateAbsoluteSearchPath(var SearchPath: string;
  const BaseDirectory: string): boolean;
var
  BaseDir: String;
begin
  if SearchPath='' then exit(true);
  BaseDir:=BaseDirectory;
  if not SubstituteMacros(BaseDir) then exit(false);
  Result:=SubstituteMacros(SearchPath);
  SearchPath:=FileUtil.CreateAbsoluteSearchPath(SearchPath,BaseDir);
end;

end.