summaryrefslogtreecommitdiff
path: root/debian/patches/dyson-execpathstr.patch
blob: 843f1cbb8cf339abf23c46d21ea88318ab93b014 (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
Description: ParamStr(0) should return abs path as on linux
Bug-Dyson: http://osdyson.org/issues/178
Index: fpc/fpcsrc/rtl/solaris/system.pp
===================================================================
--- fpc.orig/fpcsrc/rtl/solaris/system.pp	2014-07-05 08:42:27.480906242 +0400
+++ fpc/fpcsrc/rtl/solaris/system.pp	2014-07-07 21:39:54.477572186 +0400
@@ -106,11 +106,11 @@
  begin
    { stricly conforming POSIX applications  }
    { have the executing filename as argv[0] }
-//   if l=0 then
-//     begin
-//       paramstr := execpathstr;
-//     end
-//   else
+   if l=0 then
+     begin
+       paramstr := execpathstr;
+     end
+   else
      if (l < argc) then
        paramstr:=strpas(argv[l])
      else
@@ -184,6 +184,16 @@
   FpSigAction(SIGILL,@oldsigill,nil);
 end;
 
+procedure SysInitExecPath;
+var
+  i    : longint;
+begin
+  execpathstr[0]:=#0;
+  i:=Fpreadlink('/proc/self/path/a.out',@execpathstr[1],high(execpathstr));
+  if (i>0) and (execpathstr[1]='/') then
+     execpathstr[0]:=char(i);
+end;
+
 
 procedure SetupCmdLine;
 var
@@ -283,6 +293,7 @@
 { Reset IO Error }
   InOutRes:=0;
 { Arguments }
+  SysInitExecPath;
   SetupCmdLine;
   InitSystemThreads;
   initvariantmanager;