summaryrefslogtreecommitdiff
path: root/debian/patches/add-a-new-directive-CFGDIR-to-configuration-file.patch
blob: 37fa0d886aebd0a4d0cd254b93efc4969e2260b9 (plain)
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
This patch adds a new directive, CFGDIR, to configuration file allowing user to
add a directory to a list where included configuration files are searched.

--- fpcbuild-2.6.2/fpcsrc/compiler/options.pas
+++ fpcbuild-2.6.2/fpcsrc/compiler/options.pas
@@ -40,6 +40,7 @@ Type
     OptCPUSetExplicitly: boolean;
     FileLevel : longint;
     QuickInfo : string;
+	ParaIncludeCfgPath,
     ParaIncludePath,
     ParaUnitPath,
     ParaObjectPath,
@@ -2046,24 +2047,31 @@
   line,
   level : longint;
   option_read : boolean;
+  oldfilemode : byte;
+  ConfigFile: TPathStr;
 begin
 { avoid infinite loop }
   Inc(FileLevel);
   Option_read:=false;
   If FileLevel>MaxLevel then
    Message(option_too_many_cfg_files);
+  if not ParaIncludeCfgPath.FindFile(fileName,true,ConfigFile) then
+    ConfigFile := ExpandFileName(filename);
 { Maybe It's Directory ?}   //Jaro Change:
-  if PathExists(filename,false) then
+  if PathExists(ConfigFile,false) then
     begin
        Message1(option_config_is_dir,filename);
        exit;
     end;
 { open file }
   Message1(option_using_file,filename);
-  assign(f,ExpandFileName(filename));
+  oldfilemode:=filemode;
+  filemode:=0;
+  assign(f,ConfigFile);
   {$I-}
    reset(f);
   {$I+}
+  filemode:=oldfilemode;
   if ioresult<>0 then
    begin
      Message1(option_unable_open_file,filename);
@@ -2147,6 +2155,7 @@
                   tmp:= GetName(opts);
                   if tmp <> '' then
                     def_system_macro(tmp);
+                  Option_read:=true;
                 end
               else
                if (s='UNDEF') then
@@ -2155,18 +2164,29 @@
                   tmp:= GetName(opts);
                   if tmp <> '' then
                     undef_system_macro(tmp);
+                  Option_read:=true;
                 end
               else
                if (s='WRITE') then
                 begin
                   Delete(opts,1,1);
                   WriteLn(opts);
+                  Option_read:=true;
                 end
               else
                if (s='INCLUDE') then
                 begin
                   Delete(opts,1,1);
                   Interpret_file(opts);
+                  Option_read:=true;
+                end
+              else
+               if (s='CFGDIR') then
+                begin
+                  Delete(opts,1,1);
+                  DefaultReplacements(opts);
+                  ParaIncludeCfgPath.AddPath(opts,false);
+                  Option_read:=true;
                 end;
             end;
          end
@@ -2514,6 +2534,7 @@
   OptCPUSetExplicitly:=false;
   FileLevel:=0;
   Quickinfo:='';
+  ParaIncludeCfgPath:=TSearchPathList.Create;
   ParaIncludePath:=TSearchPathList.Create;
   ParaObjectPath:=TSearchPathList.Create;
   ParaUnitPath:=TSearchPathList.Create;
@@ -2526,6 +2547,7 @@
 
 destructor TOption.destroy;
 begin
+  ParaIncludeCfgPath.Free;
   ParaIncludePath.Free;
   ParaObjectPath.Free;
   ParaUnitPath.Free;