Blame SOURCES/expect-5.45-segfault-with-stubs.patch

261060
diff -up expect5.45/exp_clib.c.orig expect5.45/exp_clib.c
261060
--- expect5.45/exp_clib.c.orig	2010-09-01 00:20:27.000000000 +0200
261060
+++ expect5.45/exp_clib.c	2015-05-19 12:01:22.413349423 +0200
261060
@@ -84,6 +84,8 @@ would appreciate credit if this program
261060
 #ifndef _STDLIB
261060
 #define _STDLIB
261060
 
261060
+#include <tcl.h>
261060
+
261060
 extern void		abort _ANSI_ARGS_((void));
261060
 extern double		atof _ANSI_ARGS_((CONST char *string));
261060
 extern int		atoi _ANSI_ARGS_((CONST char *string));
261060
@@ -114,7 +116,6 @@ extern unsigned long	strtoul _ANSI_ARGS_
261060
 #include <stdlib.h>		/* for malloc */
261060
 #endif
261060
 
261060
-#include <tcl.h>
261060
 #include "expect.h"
261060
 #define TclRegError exp_TclRegError
261060
 
261060
@@ -1465,6 +1466,467 @@ TclGetRegError()
261060
  */
261060
 
261060
 /*
261060
+ * following stolen from tcl8.0.4/generic/tclPosixStr.c
261060
+ */
261060
+
261060
+/*
261060
+ *----------------------------------------------------------------------
261060
+ *
261060
+ * Tcl_ErrnoMsg --
261060
+ *
261060
+ *     Return a human-readable message corresponding to a given
261060
+ *     errno value.
261060
+ *
261060
+ * Results:
261060
+ *     The return value is the standard POSIX error message for
261060
+ *     errno.  This procedure is used instead of strerror because
261060
+ *     strerror returns slightly different values on different
261060
+ *     machines (e.g. different capitalizations), which cause
261060
+ *     problems for things such as regression tests.  This procedure
261060
+ *     provides messages for most standard errors, then it calls
261060
+ *     strerror for things it doesn't understand.
261060
+ *
261060
+ * Side effects:
261060
+ *     None.
261060
+ *
261060
+ *----------------------------------------------------------------------
261060
+ */
261060
+
261060
+static
261060
+char *
261060
+Tcl_ErrnoMsg(err)
261060
+    int err;                   /* Error number (such as in errno variable). */
261060
+{
261060
+    switch (err) {
261060
+#ifdef E2BIG
261060
+       case E2BIG: return "argument list too long";
261060
+#endif
261060
+#ifdef EACCES
261060
+       case EACCES: return "permission denied";
261060
+#endif
261060
+#ifdef EADDRINUSE
261060
+       case EADDRINUSE: return "address already in use";
261060
+#endif
261060
+#ifdef EADDRNOTAVAIL
261060
+       case EADDRNOTAVAIL: return "can't assign requested address";
261060
+#endif
261060
+#ifdef EADV
261060
+       case EADV: return "advertise error";
261060
+#endif
261060
+#ifdef EAFNOSUPPORT
261060
+       case EAFNOSUPPORT: return "address family not supported by protocol family";
261060
+#endif
261060
+#ifdef EAGAIN
261060
+       case EAGAIN: return "resource temporarily unavailable";
261060
+#endif
261060
+#ifdef EALIGN
261060
+       case EALIGN: return "EALIGN";
261060
+#endif
261060
+#if defined(EALREADY) && (!defined(EBUSY) || (EALREADY != EBUSY ))
261060
+       case EALREADY: return "operation already in progress";
261060
+#endif
261060
+#ifdef EBADE
261060
+       case EBADE: return "bad exchange descriptor";
261060
+#endif
261060
+#ifdef EBADF
261060
+       case EBADF: return "bad file number";
261060
+#endif
261060
+#ifdef EBADFD
261060
+       case EBADFD: return "file descriptor in bad state";
261060
+#endif
261060
+#ifdef EBADMSG
261060
+       case EBADMSG: return "not a data message";
261060
+#endif
261060
+#ifdef EBADR
261060
+       case EBADR: return "bad request descriptor";
261060
+#endif
261060
+#ifdef EBADRPC
261060
+       case EBADRPC: return "RPC structure is bad";
261060
+#endif
261060
+#ifdef EBADRQC
261060
+       case EBADRQC: return "bad request code";
261060
+#endif
261060
+#ifdef EBADSLT
261060
+       case EBADSLT: return "invalid slot";
261060
+#endif
261060
+#ifdef EBFONT
261060
+       case EBFONT: return "bad font file format";
261060
+#endif
261060
+#ifdef EBUSY
261060
+       case EBUSY: return "file busy";
261060
+#endif
261060
+#ifdef ECHILD
261060
+       case ECHILD: return "no children";
261060
+#endif
261060
+#ifdef ECHRNG
261060
+       case ECHRNG: return "channel number out of range";
261060
+#endif
261060
+#ifdef ECOMM
261060
+       case ECOMM: return "communication error on send";
261060
+#endif
261060
+#ifdef ECONNABORTED
261060
+       case ECONNABORTED: return "software caused connection abort";
261060
+#endif
261060
+#ifdef ECONNREFUSED
261060
+       case ECONNREFUSED: return "connection refused";
261060
+#endif
261060
+#ifdef ECONNRESET
261060
+       case ECONNRESET: return "connection reset by peer";
261060
+#endif
261060
+#if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
261060
+       case EDEADLK: return "resource deadlock avoided";
261060
+#endif
261060
+#if defined(EDEADLOCK) && (!defined(EDEADLK) || (EDEADLOCK != EDEADLK))
261060
+       case EDEADLOCK: return "resource deadlock avoided";
261060
+#endif
261060
+#ifdef EDESTADDRREQ
261060
+       case EDESTADDRREQ: return "destination address required";
261060
+#endif
261060
+#ifdef EDIRTY
261060
+       case EDIRTY: return "mounting a dirty fs w/o force";
261060
+#endif
261060
+#ifdef EDOM
261060
+       case EDOM: return "math argument out of range";
261060
+#endif
261060
+#ifdef EDOTDOT
261060
+       case EDOTDOT: return "cross mount point";
261060
+#endif
261060
+#ifdef EDQUOT
261060
+       case EDQUOT: return "disk quota exceeded";
261060
+#endif
261060
+#ifdef EDUPPKG
261060
+       case EDUPPKG: return "duplicate package name";
261060
+#endif
261060
+#ifdef EEXIST
261060
+       case EEXIST: return "file already exists";
261060
+#endif
261060
+#ifdef EFAULT
261060
+       case EFAULT: return "bad address in system call argument";
261060
+#endif
261060
+#ifdef EFBIG
261060
+       case EFBIG: return "file too large";
261060
+#endif
261060
+#ifdef EHOSTDOWN
261060
+       case EHOSTDOWN: return "host is down";
261060
+#endif
261060
+#ifdef EHOSTUNREACH
261060
+       case EHOSTUNREACH: return "host is unreachable";
261060
+#endif
261060
+#if defined(EIDRM) && (!defined(EINPROGRESS) || (EIDRM != EINPROGRESS))
261060
+       case EIDRM: return "identifier removed";
261060
+#endif
261060
+#ifdef EINIT
261060
+       case EINIT: return "initialization error";
261060
+#endif
261060
+#ifdef EINPROGRESS
261060
+       case EINPROGRESS: return "operation now in progress";
261060
+#endif
261060
+#ifdef EINTR
261060
+       case EINTR: return "interrupted system call";
261060
+#endif
261060
+#ifdef EINVAL
261060
+       case EINVAL: return "invalid argument";
261060
+#endif
261060
+#ifdef EIO
261060
+       case EIO: return "I/O error";
261060
+#endif
261060
+#ifdef EISCONN
261060
+       case EISCONN: return "socket is already connected";
261060
+#endif
261060
+#ifdef EISDIR
261060
+       case EISDIR: return "illegal operation on a directory";
261060
+#endif
261060
+#ifdef EISNAME
261060
+       case EISNAM: return "is a name file";
261060
+#endif
261060
+#ifdef ELBIN
261060
+       case ELBIN: return "ELBIN";
261060
+#endif
261060
+#ifdef EL2HLT
261060
+       case EL2HLT: return "level 2 halted";
261060
+#endif
261060
+#ifdef EL2NSYNC
261060
+       case EL2NSYNC: return "level 2 not synchronized";
261060
+#endif
261060
+#ifdef EL3HLT
261060
+       case EL3HLT: return "level 3 halted";
261060
+#endif
261060
+#ifdef EL3RST
261060
+       case EL3RST: return "level 3 reset";
261060
+#endif
261060
+#ifdef ELIBACC
261060
+       case ELIBACC: return "can not access a needed shared library";
261060
+#endif
261060
+#ifdef ELIBBAD
261060
+       case ELIBBAD: return "accessing a corrupted shared library";
261060
+#endif
261060
+#ifdef ELIBEXEC
261060
+       case ELIBEXEC: return "can not exec a shared library directly";
261060
+#endif
261060
+#ifdef ELIBMAX
261060
+       case ELIBMAX: return
261060
+               "attempting to link in more shared libraries than system limit";
261060
+#endif
261060
+#ifdef ELIBSCN
261060
+       case ELIBSCN: return ".lib section in a.out corrupted";
261060
+#endif
261060
+#ifdef ELNRNG
261060
+       case ELNRNG: return "link number out of range";
261060
+#endif
261060
+#if defined(ELOOP) && (!defined(ENOENT) || (ELOOP != ENOENT))
261060
+       case ELOOP: return "too many levels of symbolic links";
261060
+#endif
261060
+#ifdef EMFILE
261060
+       case EMFILE: return "too many open files";
261060
+#endif
261060
+#ifdef EMLINK
261060
+       case EMLINK: return "too many links";
261060
+#endif
261060
+#ifdef EMSGSIZE
261060
+       case EMSGSIZE: return "message too long";
261060
+#endif
261060
+#ifdef EMULTIHOP
261060
+       case EMULTIHOP: return "multihop attempted";
261060
+#endif
261060
+#ifdef ENAMETOOLONG
261060
+       case ENAMETOOLONG: return "file name too long";
261060
+#endif
261060
+#ifdef ENAVAIL
261060
+       case ENAVAIL: return "not available";
261060
+#endif
261060
+#ifdef ENET
261060
+       case ENET: return "ENET";
261060
+#endif
261060
+#ifdef ENETDOWN
261060
+       case ENETDOWN: return "network is down";
261060
+#endif
261060
+#ifdef ENETRESET
261060
+       case ENETRESET: return "network dropped connection on reset";
261060
+#endif
261060
+#ifdef ENETUNREACH
261060
+       case ENETUNREACH: return "network is unreachable";
261060
+#endif
261060
+#ifdef ENFILE
261060
+       case ENFILE: return "file table overflow";
261060
+#endif
261060
+#ifdef ENOANO
261060
+       case ENOANO: return "anode table overflow";
261060
+#endif
261060
+#if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
261060
+       case ENOBUFS: return "no buffer space available";
261060
+#endif
261060
+#ifdef ENOCSI
261060
+       case ENOCSI: return "no CSI structure available";
261060
+#endif
261060
+#if defined(ENODATA) && (!defined(ECONNREFUSED) || (ENODATA != ECONNREFUSED))
261060
+       case ENODATA: return "no data available";
261060
+#endif
261060
+#ifdef ENODEV
261060
+       case ENODEV: return "no such device";
261060
+#endif
261060
+#ifdef ENOENT
261060
+       case ENOENT: return "no such file or directory";
261060
+#endif
261060
+#ifdef ENOEXEC
261060
+       case ENOEXEC: return "exec format error";
261060
+#endif
261060
+#ifdef ENOLCK
261060
+       case ENOLCK: return "no locks available";
261060
+#endif
261060
+#ifdef ENOLINK
261060
+       case ENOLINK: return "link has be severed";
261060
+#endif
261060
+#ifdef ENOMEM
261060
+       case ENOMEM: return "not enough memory";
261060
+#endif
261060
+#ifdef ENOMSG
261060
+       case ENOMSG: return "no message of desired type";
261060
+#endif
261060
+#ifdef ENONET
261060
+       case ENONET: return "machine is not on the network";
261060
+#endif
261060
+#ifdef ENOPKG
261060
+       case ENOPKG: return "package not installed";
261060
+#endif
261060
+#ifdef ENOPROTOOPT
261060
+       case ENOPROTOOPT: return "bad proocol option";
261060
+#endif
261060
+#ifdef ENOSPC
261060
+       case ENOSPC: return "no space left on device";
261060
+#endif
261060
+#if defined(ENOSR) && (!defined(ENAMETOOLONG) || (ENAMETOOLONG != ENOSR))
261060
+       case ENOSR: return "out of stream resources";
261060
+#endif
261060
+#if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR))
261060
+       case ENOSTR: return "not a stream device";
261060
+#endif
261060
+#ifdef ENOSYM
261060
+       case ENOSYM: return "unresolved symbol name";
261060
+#endif
261060
+#ifdef ENOSYS
261060
+       case ENOSYS: return "function not implemented";
261060
+#endif
261060
+#ifdef ENOTBLK
261060
+       case ENOTBLK: return "block device required";
261060
+#endif
261060
+#ifdef ENOTCONN
261060
+       case ENOTCONN: return "socket is not connected";
261060
+#endif
261060
+#ifdef ENOTDIR
261060
+       case ENOTDIR: return "not a directory";
261060
+#endif
261060
+#if defined(ENOTEMPTY) && (!defined(EEXIST) || (ENOTEMPTY != EEXIST))
261060
+       case ENOTEMPTY: return "directory not empty";
261060
+#endif
261060
+#ifdef ENOTNAM
261060
+       case ENOTNAM: return "not a name file";
261060
+#endif
261060
+#ifdef ENOTSOCK
261060
+       case ENOTSOCK: return "socket operation on non-socket";
261060
+#endif
261060
+#ifdef ENOTSUP
261060
+       case ENOTSUP: return "operation not supported";
261060
+#endif
261060
+#ifdef ENOTTY
261060
+       case ENOTTY: return "inappropriate device for ioctl";
261060
+#endif
261060
+#ifdef ENOTUNIQ
261060
+       case ENOTUNIQ: return "name not unique on network";
261060
+#endif
261060
+#ifdef ENXIO
261060
+       case ENXIO: return "no such device or address";
261060
+#endif
261060
+#if defined(EOPNOTSUPP) &&  (!defined(ENOTSUP) || (ENOTSUP != EOPNOTSUPP))
261060
+       case EOPNOTSUPP: return "operation not supported on socket";
261060
+#endif
261060
+#ifdef EPERM
261060
+       case EPERM: return "not owner";
261060
+#endif
261060
+#if defined(EPFNOSUPPORT) && (!defined(ENOLCK) || (ENOLCK != EPFNOSUPPORT))
261060
+       case EPFNOSUPPORT: return "protocol family not supported";
261060
+#endif
261060
+#ifdef EPIPE
261060
+       case EPIPE: return "broken pipe";
261060
+#endif
261060
+#ifdef EPROCLIM
261060
+       case EPROCLIM: return "too many processes";
261060
+#endif
261060
+#ifdef EPROCUNAVAIL
261060
+       case EPROCUNAVAIL: return "bad procedure for program";
261060
+#endif
261060
+#ifdef EPROGMISMATCH
261060
+       case EPROGMISMATCH: return "program version wrong";
261060
+#endif
261060
+#ifdef EPROGUNAVAIL
261060
+       case EPROGUNAVAIL: return "RPC program not available";
261060
+#endif
261060
+#ifdef EPROTO
261060
+       case EPROTO: return "protocol error";
261060
+#endif
261060
+#ifdef EPROTONOSUPPORT
261060
+       case EPROTONOSUPPORT: return "protocol not suppored";
261060
+#endif
261060
+#ifdef EPROTOTYPE
261060
+       case EPROTOTYPE: return "protocol wrong type for socket";
261060
+#endif
261060
+#ifdef ERANGE
261060
+       case ERANGE: return "math result unrepresentable";
261060
+#endif
261060
+#if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
261060
+       case EREFUSED: return "EREFUSED";
261060
+#endif
261060
+#ifdef EREMCHG
261060
+       case EREMCHG: return "remote address changed";
261060
+#endif
261060
+#ifdef EREMDEV
261060
+       case EREMDEV: return "remote device";
261060
+#endif
261060
+#ifdef EREMOTE
261060
+       case EREMOTE: return "pathname hit remote file system";
261060
+#endif
261060
+#ifdef EREMOTEIO
261060
+       case EREMOTEIO: return "remote i/o error";
261060
+#endif
261060
+#ifdef EREMOTERELEASE
261060
+       case EREMOTERELEASE: return "EREMOTERELEASE";
261060
+#endif
261060
+#ifdef EROFS
261060
+       case EROFS: return "read-only file system";
261060
+#endif
261060
+#ifdef ERPCMISMATCH
261060
+       case ERPCMISMATCH: return "RPC version is wrong";
261060
+#endif
261060
+#ifdef ERREMOTE
261060
+       case ERREMOTE: return "object is remote";
261060
+#endif
261060
+#ifdef ESHUTDOWN
261060
+       case ESHUTDOWN: return "can't send afer socket shutdown";
261060
+#endif
261060
+#ifdef ESOCKTNOSUPPORT
261060
+       case ESOCKTNOSUPPORT: return "socket type not supported";
261060
+#endif
261060
+#ifdef ESPIPE
261060
+       case ESPIPE: return "invalid seek";
261060
+#endif
261060
+#ifdef ESRCH
261060
+       case ESRCH: return "no such process";
261060
+#endif
261060
+#ifdef ESRMNT
261060
+       case ESRMNT: return "srmount error";
261060
+#endif
261060
+#ifdef ESTALE
261060
+       case ESTALE: return "stale remote file handle";
261060
+#endif
261060
+#ifdef ESUCCESS
261060
+       case ESUCCESS: return "Error 0";
261060
+#endif
261060
+#if defined(ETIME) && (!defined(ELOOP) || (ETIME != ELOOP))
261060
+       case ETIME: return "timer expired";
261060
+#endif
261060
+#if defined(ETIMEDOUT) && (!defined(ENOSTR) || (ETIMEDOUT != ENOSTR))
261060
+       case ETIMEDOUT: return "connection timed out";
261060
+#endif
261060
+#ifdef ETOOMANYREFS
261060
+       case ETOOMANYREFS: return "too many references: can't splice";
261060
+#endif
261060
+#ifdef ETXTBSY
261060
+       case ETXTBSY: return "text file or pseudo-device busy";
261060
+#endif
261060
+#ifdef EUCLEAN
261060
+       case EUCLEAN: return "structure needs cleaning";
261060
+#endif
261060
+#ifdef EUNATCH
261060
+       case EUNATCH: return "protocol driver not attached";
261060
+#endif
261060
+#ifdef EUSERS
261060
+       case EUSERS: return "too many users";
261060
+#endif
261060
+#ifdef EVERSION
261060
+       case EVERSION: return "version mismatch";
261060
+#endif
261060
+#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
261060
+       case EWOULDBLOCK: return "operation would block";
261060
+#endif
261060
+#ifdef EXDEV
261060
+       case EXDEV: return "cross-domain link";
261060
+#endif
261060
+#ifdef EXFULL
261060
+       case EXFULL: return "message tables full";
261060
+#endif
261060
+       default:
261060
+#ifdef NO_STRERROR
261060
+           return "unknown POSIX error";
261060
+#else
261060
+           return strerror(errno);
261060
+#endif
261060
+    }
261060
+}
261060
+
261060
+/*
261060
+ * end of excerpt from tcl8.0.X/generic/tclPosixStr.c
261060
+ */
261060
+
261060
+/*
261060
  * stolen from exp_log.c - this function is called from the Expect library
261060
  * but the one that the library supplies calls Tcl functions.  So we supply
261060
  * our own.
261060
diff -up expect5.45/expect.h.orig expect5.45/expect.h
261060
--- expect5.45/expect.h.orig	2010-09-01 00:20:27.000000000 +0200
261060
+++ expect5.45/expect.h	2015-05-19 12:00:58.674248152 +0200
261060
@@ -258,6 +258,46 @@ typedef long LONG;
261060
 typedef struct Tcl_RegExp_ *Tcl_RegExp;
261060
 
261060
 /*
261060
+ * The following declarations either map ckalloc and ckfree to
261060
+ * malloc and free, or they map them to procedures with all sorts
261060
+ * of debugging hooks defined in tclCkalloc.c.
261060
+ */
261060
+
261060
+#ifdef TCL_MEM_DEBUG
261060
+
261060
+#  define Tcl_Alloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
261060
+#  define Tcl_Free(x)  Tcl_DbCkfree(x, __FILE__, __LINE__)
261060
+#  define Tcl_Realloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
261060
+#  define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
261060
+#  define ckfree(x)  Tcl_DbCkfree(x, __FILE__, __LINE__)
261060
+#  define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
261060
+
261060
+#else
261060
+
261060
+/*
261060
+ * If USE_TCLALLOC is true, then we need to call Tcl_Alloc instead of
261060
+ * the native malloc/free.  The only time USE_TCLALLOC should not be
261060
+ * true is when compiling the Tcl/Tk libraries on Unix systems.  In this
261060
+ * case we can safely call the native malloc/free directly as a performance
261060
+ * optimization.
261060
+ */
261060
+
261060
+#  if USE_TCLALLOC
261060
+#     define ckalloc(x) Tcl_Alloc(x)
261060
+#     define ckfree(x) Tcl_Free(x)
261060
+#     define ckrealloc(x,y) Tcl_Realloc(x,y)
261060
+#  else
261060
+#     define ckalloc(x) malloc(x)
261060
+#     define ckfree(x)  free(x)
261060
+#     define ckrealloc(x,y) realloc(x,y)
261060
+#  endif
261060
+#  define Tcl_DumpActiveMemory(x)
261060
+#  define Tcl_ValidateAllMemory(x,y)
261060
+
261060
+#endif /* !TCL_MEM_DEBUG */
261060
+
261060
+
261060
+/*
261060
  * These function have been renamed. The old names are deprecated, but we
261060
  * define these macros for backwards compatibilty.
261060
  */
261060
@@ -268,6 +308,14 @@ typedef struct Tcl_RegExp_ *Tcl_RegExp;
261060
 #define Tcl_Return Tcl_SetResult
261060
 #define Tcl_TildeSubst Tcl_TranslateFileName
261060
 
261060
+/*
261060
+ * In later releases, Tcl_Panic will be the correct name to use.  For now
261060
+ * we leave it as panic to avoid breaking existing binaries.
261060
+ */
261060
+
261060
+#define Tcl_Panic panic
261060
+#define Tcl_PanicVA panicVA
261060
+
261060
 #endif /* RESOURCE_INCLUDED */
261060
 
261060
 #undef TCL_STORAGE_CLASS