<short summary of the patch>
authorCamm Maguire <camm@debian.org>
Thu, 11 Aug 2022 17:16:42 +0000 (18:16 +0100)
committerCamm Maguire <camm@debian.org>
Thu, 11 Aug 2022 17:16:42 +0000 (18:16 +0100)
TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.

gcl (2.6.12-78) unstable; urgency=medium

  * rebuild against latest compilers and tools
  * Version_2_6_13pre69

Gbp-Pq: Name Version_2_6_13pre70

h/linux.h
o/main.c

index 474f7f31424399174825ca567896a377f5684b9c..3c94d8dc3bc61de62797b062a768d0bad6328d77 100644 (file)
--- a/h/linux.h
+++ b/h/linux.h
@@ -132,17 +132,10 @@ do { int c = 0; \
 
 #include <limits.h>
 #include <sys/stat.h>
-#define GET_FULL_PATH_SELF(a_) do {            \
-    static char q[PATH_MAX];                   \
-    const char *s="/proc/self/exe";            \
-    struct stat ss;                            \
-    if (stat(s,&ss))                           \
-      (a_)=argv[0];                            \
-    else {                                     \
-      if (!realpath(s,q))                      \
-       error("realpath error");                \
-      (a_)=q;                                  \
-    }                                          \
+#define GET_FULL_PATH_SELF(a_) do {                            \
+    static char q[PATH_MAX];                                   \
+    massert(which("/proc/self/exe",q) || which(argv[0],q));    \
+    (a_)=q;                                                    \
   } while(0)
 
 
index de77f74141c66e178e1d1b6d409775242f9c6281..e9dda78759e731ba6d76d517defed0a92ec4db63 100755 (executable)
--- a/o/main.c
+++ b/o/main.c
@@ -460,18 +460,49 @@ DEFUN_NEW("EQUAL-TAIL-RECURSION-CHECK",object,fSequal_tail_recursion_check,SI,1,
   RETURN1((object)(w-u));
 }
 
+static int
+mbin(const char *s,char *o) {
+
+  struct stat ss;
+
+  if (!stat(s,&ss) && (ss.st_mode&S_IFMT)==S_IFREG && !access(s,R_OK|X_OK)) {
+    massert(realpath(s,o));
+    return 1;
+  }
+
+  return 0;
+
+}
+
+static int
+which(const char *n,char *o) {
+
+  char *s;
+
+  if (strchr(n,'/'))
+    return mbin(n,o);
+
+  massert(snprintf(FN1,sizeof(FN1),"%s",getenv("PATH"))>1);
+  for (s=NULL;(s=strtok(s ? NULL : FN1,":"));) {
+
+    massert(snprintf(FN2,sizeof(FN2),"%s/%s",s,n));
+    if (mbin(FN2,o))
+      return 1;
+
+  }
+
+  return 0;
+
+}
+
+
 
 int
 main(int argc, char **argv, char **envp) {
 
-#ifdef GET_FULL_PATH_SELF
   GET_FULL_PATH_SELF(kcl_self);
-#else
-  kcl_self = argv[0];
-#endif
-
   *argv=kcl_self;
-  
+
 #ifdef CAN_UNRANDOMIZE_SBRK
 #include <stdio.h>
 #include <stdlib.h>