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

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