summarylogtreecommitdiffstats
path: root/0004-reloc.mingw.patch
blob: 706f2b0223f2c127cb3ab5e75a56528b63c0d47a (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
--- aspell-0.60.7-20110707/common/info.cpp.orig	2004-11-10 06:18:45.000000000 +0000
+++ aspell-0.60.7-20110707/common/info.cpp	2014-03-20 14:46:13.395537900 +0000
@@ -39,6 +39,19 @@
 
 #include "gettext.h"
 
+#ifdef ENABLE_W32_PREFIX
+extern "C" {
+static HINSTANCE dll_hinstance;
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+  if (fdwReason == DLL_PROCESS_ATTACH)
+    dll_hinstance = hinstDLL;
+  return TRUE;
+}
+}
+#endif
+
 namespace acommon {
 
   class Dir {
@@ -778,4 +789,60 @@
     return data;
   }

+#ifdef ENABLE_W32_PREFIX
+
+const char *
+get_w32_prefix ()
+{
+  
+  static char *wprefix = NULL;
+  
+/*
+      Entry * next;
+      String key;
+      String value;
+      String file;
+*/
+  if (wprefix == NULL)
+  {
+    DWORD bsize = MAX_PATH;
+    DWORD l = bsize;
+    char *bslash, *slash;
+    char *buf = (char *) malloc (bsize);
+    while (l == bsize)
+    {
+      l = GetModuleFileNameA (dll_hinstance, buf, bsize);
+      if (l == 0)
+      {
+        DebugBreak ();
+        abort ();
+      }
+      if (l == bsize)
+      {
+        buf = (char *) realloc ((void *) buf, bsize * 2);
+        bsize *= 2;
+        l = bsize;
+      }
+    }
+    bslash = strrchr (buf, '\\');
+    slash = strrchr (buf, '/');
+    if (bslash > slash)
+      slash = bslash;
+    slash[0] = '\0';
+    l = strlen (buf);
+    if (l > 3 && strcmp (&buf[l - 3], "bin") == 0)
+    {
+      bslash = strrchr (buf, '\\');
+      slash = strrchr (buf, '/');
+      if (bslash > slash)
+        slash = bslash;
+      slash[0] = '\0';
+    }
+    wprefix = buf;
+
+  }
+  return wprefix;
+}
+#endif
+
 }
--- aspell-0.60.7-20110707/common/info.hpp.orig	2004-05-30 10:49:17.000000000 +0000
+++ aspell-0.60.7-20110707/common/info.hpp	2014-03-20 14:45:24.476325900 +0000
@@ -140,8 +140,7 @@
   };
 
 
-
-
+  const char * get_w32_prefix ();
 }
 
 #endif /* ASPELL_INFO__HPP */
--- aspell-0.60.7-20110707/common/config.cpp.orig	2014-03-20 13:52:58.851882300 +0000
+++ aspell-0.60.7-20110707/common/config.cpp	2014-03-20 14:17:49.116621900 +0000
@@ -310,6 +310,14 @@
     const Entry * res = 0;
     const Entry * cur = first_;
 
+#ifdef ENABLE_W32_PREFIX
+    if (key == "prefix")
+    {
+      Entry *e = new Config::Entry();
+      e->value = get_w32_prefix ();
+      return e;
+    }
+#endif
     while (cur) {
       if (cur->key == key && cur->action != NoOp)  res = cur;
       cur = cur->next;
--- aspell-0.60.7-20110707/common/config.cpp.orig	2014-03-20 15:11:29.935614000 +0000
+++ aspell-0.60.7-20110707/common/config.cpp	2014-03-20 15:22:47.619168900 +0000
@@ -22,6 +22,8 @@
 # include <langinfo.h>
 #endif
 
+#include "info.hpp"
+#include <windows.h>
 #include "cache.hpp"
 #include "asc_ctype.hpp"
 #include "config.hpp"