110 lines
3.6 KiB
Diff
110 lines
3.6 KiB
Diff
Fix for pstoedit search for plugins.
|
|
|
|
By default, pstoedit "make install" installs to PSTOEDITLIBDIR, so if
|
|
nobody moves them to another location, then it is sufficient to search in
|
|
PSTOEDITLIBDIR.
|
|
|
|
|
|
But the way how pstoedit searches for plugins is broken:
|
|
|
|
If pstoedit.reg does not exist or does not contain common/plugindir, then
|
|
it tries $exepath/../lib/pstoedit, always sets pluginsloaded, and never
|
|
tries PSTOEDITLIBDIR.
|
|
|
|
If pstoedit.reg contains common/plugindir, then it tries that path,
|
|
always sets pluginsloaded, and never tries PSTOEDITLIBDIR.
|
|
|
|
=> The default installation directory is never tried, if it is not equal
|
|
to one of above.
|
|
|
|
|
|
The implementation has just another problem:
|
|
|
|
If pstoedit.reg contains common/plugindir, and the directory defined
|
|
there is equal to $pkglibdir, but the string is not literally
|
|
"{expansion_of_bindir}/../lib/pstoedit", then plugins are loaded twice.
|
|
So the check as it is makes only a little sense, because nobody would
|
|
create ~/.pstoedit.reg containing:
|
|
|
|
common/plugindir=/usr/bin/../lib/pstoedit
|
|
|
|
|
|
The new implementation does things differently:
|
|
|
|
If common/plugindir is defined, it checks only that directory.
|
|
|
|
It swaps the check order: First checks whether PSTOEDITLIBDIR exists. If
|
|
it exists, it skips blind attempts to find plugins.
|
|
|
|
As PSTOEDITLIBDIR is always defined by makefile, the blind fallback will
|
|
be attempted only in obscure environments.
|
|
|
|
|
|
Index: pstoedit-3.70/src/pstoedit.cpp
|
|
===================================================================
|
|
--- pstoedit-3.70.orig/src/pstoedit.cpp
|
|
+++ pstoedit-3.70/src/pstoedit.cpp
|
|
@@ -30,6 +30,7 @@
|
|
#include I_string_h
|
|
|
|
#include <assert.h>
|
|
+#include <sys/stat.h>
|
|
|
|
#include "pstoeditoptions.h"
|
|
|
|
@@ -261,33 +262,33 @@ static void loadpstoeditplugins(const ch
|
|
loadPlugInDrivers(plugindir.c_str(), errstream, verbose); // load the driver plugins
|
|
pluginsloaded = true;
|
|
}
|
|
- // also look in the directory where the pstoedit .exe/dll was found
|
|
- char szExePath[1000];
|
|
- szExePath[0] = '\0';
|
|
- const unsigned long r = P_GetPathToMyself(progname, szExePath, sizeof(szExePath));
|
|
- if (verbose) errstream << "pstoedit : path to myself:" << progname << " " << r << " " << szExePath<< endl;
|
|
- char *p = 0;
|
|
- if (r && (p = strrchr(szExePath, directoryDelimiter)) != 0) {
|
|
- *p = '\0';
|
|
- if (!strequal(szExePath, plugindir.c_str())) {
|
|
- loadPlugInDrivers(szExePath, errstream,verbose);
|
|
- pluginsloaded = true;
|
|
- }
|
|
- }
|
|
- // now try also $exepath/../lib/pstoedit
|
|
- strcat_s(szExePath,1000,"/../lib/pstoedit");
|
|
- if (!strequal(szExePath, plugindir.c_str())) {
|
|
- loadPlugInDrivers(szExePath, errstream,verbose);
|
|
- pluginsloaded = true;
|
|
- }
|
|
-
|
|
#ifdef PSTOEDITLIBDIR
|
|
- if (!pluginsloaded) {
|
|
+ struct stat s;
|
|
+ if (!pluginsloaded &&
|
|
+ !stat(PSTOEDITLIBDIR, &s) &&
|
|
+ S_ISDIR(s.st_mode)) {
|
|
// also try to load drivers from the PSTOEDITLIBDIR
|
|
loadPlugInDrivers(PSTOEDITLIBDIR, errstream,verbose);
|
|
pluginsloaded = true;
|
|
}
|
|
#endif
|
|
+ // If the above failed, also look in the directory where the pstoedit .exe/dll was found
|
|
+ if (!pluginsloaded) {
|
|
+ char szExePath[1000];
|
|
+ szExePath[0] = '\0';
|
|
+ const unsigned long r = P_GetPathToMyself(progname, szExePath, sizeof(szExePath));
|
|
+ if (verbose) errstream << "pstoedit : path to myself:" << progname << " " << r << " " << szExePath<< endl;
|
|
+ char *p = 0;
|
|
+ if (r && (p = strrchr(szExePath, directoryDelimiter)) != 0) {
|
|
+ *p = '\0';
|
|
+ loadPlugInDrivers(szExePath, errstream,verbose);
|
|
+ }
|
|
+ // now try also $exepath/../lib/pstoedit
|
|
+ strcat_s(szExePath,1000,"/../lib/pstoedit");
|
|
+ if (!strequal(szExePath, plugindir.c_str())) {
|
|
+ loadPlugInDrivers(szExePath, errstream,verbose);
|
|
+ }
|
|
+ }
|
|
|
|
// delete[]plugindir;
|
|
}
|