385aba
Description: <short summary="" of="" the="" patch="">
385aba
 TODO: Put a short summary on the line above and replace this paragraph
385aba
 with a longer explanation of this change. Complete the meta-information
385aba
 with other relevant fields (see below for details). To make it easier, the
385aba
 information below has been extracted from the changelog. Adjust it or drop
385aba
 it.
385aba
 .
385aba
 gcl (2.6.12-78) unstable; urgency=medium
385aba
 .
385aba
   * rebuild against latest compilers and tools
385aba
   * Version_2_6_13pre69
385aba
Author: Camm Maguire <camm@debian.org>
385aba
385aba
---
385aba
The information above should follow the Patch Tagging Guidelines, please
385aba
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
385aba
are templates for supplementary fields that you might want to add:
385aba
385aba
Origin: <vendor|upstream|other>, <url of="" original="" patch="">
385aba
Bug: <url in="" upstream="" bugtracker="">
385aba
Bug-Debian: https://bugs.debian.org/<bugnumber>
385aba
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
385aba
Forwarded: <no|not-needed|url proving="" that="" it="" has="" been="" forwarded="">
385aba
Reviewed-By: <name and="" email="" of="" someone="" who="" approved="" the="" patch="">
385aba
Last-Update: 2018-10-29
385aba
385aba
--- gcl-2.6.12.orig/h/linux.h
385aba
+++ gcl-2.6.12/h/linux.h
385aba
@@ -132,17 +132,10 @@ do { int c = 0; \
385aba
 
385aba
 #include <limits.h>
385aba
 #include <sys stat.h="">
385aba
-#define GET_FULL_PATH_SELF(a_) do {		\
385aba
-    static char q[PATH_MAX];			\
385aba
-    const char *s="/proc/self/exe";		\
385aba
-    struct stat ss;				\
385aba
-    if (stat(s,&ss))				\
385aba
-      (a_)=argv[0];				\
385aba
-    else {					\
385aba
-      if (!realpath(s,q))			\
385aba
-	error("realpath error");		\
385aba
-      (a_)=q;					\
385aba
-    }						\
385aba
+#define GET_FULL_PATH_SELF(a_) do {				\
385aba
+    static char q[PATH_MAX];					\
385aba
+    massert(which("/proc/self/exe",q) || which(argv[0],q));	\
385aba
+    (a_)=q;							\
385aba
   } while(0)
385aba
 
385aba
 
385aba
--- gcl-2.6.12.orig/o/main.c
385aba
+++ gcl-2.6.12/o/main.c
385aba
@@ -460,18 +460,49 @@ DEFUN_NEW("EQUAL-TAIL-RECURSION-CHECK",o
385aba
   RETURN1((object)(w-u));
385aba
 }
385aba
 
385aba
+static int
385aba
+mbin(const char *s,char *o) {
385aba
+
385aba
+  struct stat ss;
385aba
+
385aba
+  if (!stat(s,&ss) && (ss.st_mode&S_IFMT)==S_IFREG && !access(s,R_OK|X_OK)) {
385aba
+    massert(realpath(s,o));
385aba
+    return 1;
385aba
+  }
385aba
+
385aba
+  return 0;
385aba
+
385aba
+}
385aba
+
385aba
+static int
385aba
+which(const char *n,char *o) {
385aba
+
385aba
+  char *s;
385aba
+
385aba
+  if (strchr(n,'/'))
385aba
+    return mbin(n,o);
385aba
+
385aba
+  massert(snprintf(FN1,sizeof(FN1),"%s",getenv("PATH"))>1);
385aba
+  for (s=NULL;(s=strtok(s ? NULL : FN1,":"));) {
385aba
+
385aba
+    massert(snprintf(FN2,sizeof(FN2),"%s/%s",s,n));
385aba
+    if (mbin(FN2,o))
385aba
+      return 1;
385aba
+
385aba
+  }
385aba
+
385aba
+  return 0;
385aba
+
385aba
+}
385aba
+
385aba
+
385aba
 
385aba
 int
385aba
 main(int argc, char **argv, char **envp) {
385aba
 
385aba
-#ifdef GET_FULL_PATH_SELF
385aba
   GET_FULL_PATH_SELF(kcl_self);
385aba
-#else
385aba
-  kcl_self = argv[0];
385aba
-#endif
385aba
-
385aba
   *argv=kcl_self;
385aba
-  
385aba
+
385aba
 #ifdef CAN_UNRANDOMIZE_SBRK
385aba
 #include <stdio.h>
385aba
 #include <stdlib.h>