summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-util/gambas/files/non-symlink-0.71.patch')
-rw-r--r--dev-util/gambas/files/non-symlink-0.71.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/dev-util/gambas/files/non-symlink-0.71.patch b/dev-util/gambas/files/non-symlink-0.71.patch
new file mode 100644
index 000000000000..4030c3d4a621
--- /dev/null
+++ b/dev-util/gambas/files/non-symlink-0.71.patch
@@ -0,0 +1,68 @@
+--- src/comp/gbi.c.org 2003-10-27 21:51:41.000000000 +0100
++++ src/comp/gbi.c 2003-11-17 23:41:29.000000000 +0100
+@@ -54,6 +54,34 @@
+ #include "str.h"
+ #include "gambas.h"
+
++/* needed to install in a different location than /usr */
++char *which(const char *app)
++{
++ char *path = NULL;
++ char *p = NULL;
++ char *rValue = NULL;
++
++ path = getenv("PATH");
++ if (!path) {
++ path = "/usr/bin/";
++ }
++ p = strtok(strdup(path), ":");
++ while (p) {
++ rValue = (char *)calloc(sizeof(char), strlen(p)+strlen(app)+2);
++ strcat(rValue, p);
++ rValue[strlen(p)] = '/';
++ strcat(rValue, app);
++ rValue[strlen(p)+1+strlen(app)] = '\0';
++ if (access(rValue, X_OK) == 0) {
++ return rValue;
++ }
++ p = strtok(NULL, ":");
++ free(rValue);
++ rValue = NULL;
++ }
++ return NULL;
++}
++
+
+ PRIVATE char _lib_path[MAX_PATH + 1];
+ PRIVATE FILE *out;
+@@ -102,10 +129,10 @@
+
+ /* chemin d'installation de Gambas */
+
+- path = FILE_readlink("/usr/bin/gbx");
++ path = which("gbx");
+
+ if (path == NULL)
+- error("Cannot read symbolic link /usr/bin/gbx");
++ error("Cannot find gbx");
+
+ strcpy(_lib_path, FILE_cat(FILE_get_dir(FILE_get_dir(path)), "lib", NULL));
+
+@@ -422,7 +450,7 @@
+ if (strcmp(name, "gb") == 0)
+ {
+ sprintf(path, LIB_PATTERN, _lib_path, name);
+- dlib = dlopen("/usr/bin/gbx", RTLD_NOW);
++ dlib = dlopen(which("gbx"), RTLD_NOW);
+ if (!dlib)
+ error2("Cannot open component:", dlerror());
+
+@@ -472,7 +500,7 @@
+ sprintf(buf, "LD_PRELOAD=%s", lib);
+ putenv(buf);
+ putenv("GAMBAS_PRELOAD=1");
+- execv("/usr/bin/gbi", argv);
++ execvp("gbi", argv);
+ #endif
+ }
+