Download this file

patch-rclaspell-dylib.diff    69 lines (64 with data), 2.0 kB

 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
diff --git aspell/rclaspell.cpp aspell/rclaspell.cpp-new
index 698832df..4fd8b6b8 100644
--- aspell/rclaspell.cpp
+++ aspell/rclaspell.cpp-new
@@ -71,12 +71,16 @@ static std::mutex o_aapi_mutex;
badnames += #NM + string(" "); \
}
-static const char *aspell_lib_suffixes[] = {
- ".so",
- ".so.15",
- ".so.16"
+static const vector<string> aspell_lib_suffixes {
+#if defined(__APPLE__)
+ ".15.dylib",
+ ".dylib",
+#else
+ ".so",
+ ".so.15",
+ ".so.16",
+#endif
};
-static const unsigned int nlibsuffs = sizeof(aspell_lib_suffixes) / sizeof(char *);
// Stuff that we don't wish to see in the .h (possible sysdeps, etc.)
class AspellData {
@@ -160,16 +164,39 @@ bool Aspell::init(string &reason)
return false;
}
+
+ // Don't know what with Apple and (DY)LD_LIBRARY_PATH. Does not work
+ // So we look in all ../lib in the PATH...
+#if defined(__APPLE__)
+ vector<string> path;
+ const char *pp = getenv("PATH");
+ if (pp) {
+ stringToTokens(pp, path, ":");
+ }
+#endif
+
reason = "Could not open shared library ";
string libbase("libaspell");
string lib;
- for (unsigned int i = 0; i < nlibsuffs; i++) {
- lib = libbase + aspell_lib_suffixes[i];
+ for (const auto& suff : aspell_lib_suffixes) {
+ lib = libbase + suff;
reason += string("[") + lib + "] ";
if ((m_data->m_handle = dlopen(lib.c_str(), RTLD_LAZY)) != 0) {
reason.erase();
goto found;
}
+#if defined(__APPLE__)
+ // Above was the normal lookup: let dlopen search the directories.
+ // Here is for Apple. Also look at all ../lib along the PATH
+ for (const auto& dir : path) {
+ string lib1 = path_canon(dir + "/../lib/" + lib);
+ if ((m_data->m_handle = dlopen(lib1.c_str(), RTLD_LAZY)) != 0) {
+ reason.erase();
+ lib=lib1;
+ goto found;
+ }
+ }
+#endif
}
found: