Update to 5.44.1.15 from upstream CVS, Fix unbuffer to return exit code of

ubuffered program, Fix Tk initialization
This commit is contained in:
vcrhonek 2010-03-10 09:25:00 +00:00
parent f659af23bb
commit 4789c74752
15 changed files with 341 additions and 479 deletions

View File

@ -1,2 +1 @@
config.sub
expect-5.43.0.tar.bz2
expect-5.44.1.15.tar.bz2

View File

@ -1,12 +1,12 @@
diff -up expect-5.43/example/mkpasswd.random expect-5.43/example/mkpasswd
--- expect-5.43/example/mkpasswd.random 2004-12-07 00:38:21.000000000 +0100
+++ expect-5.43/example/mkpasswd 2008-09-25 12:27:19.000000000 +0200
diff -up expect-5.44.1.15/example/mkpasswd.orig expect-5.44.1.15/example/mkpasswd
--- expect-5.44.1.15/example/mkpasswd.orig 2010-03-08 16:01:05.518378075 +0100
+++ expect-5.44.1.15/example/mkpasswd 2010-03-08 16:01:27.408388162 +0100
@@ -92,7 +92,14 @@ proc insert {pvar char} {
}
proc rand {m} {
- expr {int($m*rand())}
+ set device /dev/urandom ;# /dev/random can block
+ set device /dev/urandom ;# /dev/random can block
+ set fileId [open $device r]
+ binary scan [read $fileId 4] i1 number
+ set clipped [expr $number % $m]

View File

@ -1,12 +0,0 @@
diff -up expect-5.43/configure.in.lib-spec expect-5.43/configure.in
--- expect-5.43/configure.in.lib-spec 2005-02-08 02:45:06.000000000 +0100
+++ expect-5.43/configure.in 2008-09-25 12:23:26.000000000 +0200
@@ -1141,7 +1141,7 @@ if test $ac_cv_sys_long_file_names = no;
fi
EXP_BUILD_LIB_SPEC="-L`pwd` -lexpect${EXP_LIB_VERSION}${DBGX}"
-EXP_LIB_SPEC="-L\${INSTALL_ROOT}\${exec_prefix}/lib -lexpect${EXP_LIB_VERSION}${DBGX}"
+EXP_LIB_SPEC="-L\${libdir}/../.. -lexpect${EXP_LIB_VERSION}${DBGX}"
EXP_UNSHARED_LIB_FILE=libexpect${EXP_LIB_VERSION}${DBGX}.a
# The TCL_SHARED_LIB_SUFFIX macro below relies on the DBGX macro,

View File

@ -1,212 +0,0 @@
diff -up expect-5.43/exp_chan.c.spawn expect-5.43/exp_chan.c
--- expect-5.43/exp_chan.c.spawn 2005-02-08 03:01:20.000000000 +0100
+++ expect-5.43/exp_chan.c 2008-09-25 12:22:14.000000000 +0200
@@ -622,6 +622,7 @@ expCreateChannel(interp,fdin,fdout,pid)
esPtr->buffer = Tcl_NewStringObj("",0);
Tcl_IncrRefCount(esPtr->buffer);
esPtr->umsize = exp_default_match_max;
+ esPtr->umsize_changed = exp_default_match_max_changed;
/* this will reallocate object with an appropriate sized buffer */
expAdjust(esPtr);
diff -up expect-5.43/exp_command.h.spawn expect-5.43/exp_command.h
--- expect-5.43/exp_command.h.spawn 2004-07-30 17:35:28.000000000 +0200
+++ expect-5.43/exp_command.h 2008-09-25 12:22:14.000000000 +0200
@@ -30,6 +30,7 @@ would appreciate credit if this program
EXTERN char * exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *));
EXTERN int exp_default_match_max;
+EXTERN int exp_default_match_max_changed;
EXTERN int exp_default_parity;
EXTERN int exp_default_rm_nulls;
EXTERN int exp_default_close_on_eof;
@@ -103,6 +104,7 @@ typedef struct ExpState {
int msize; /* # of bytes that buffer can hold (max) */
int umsize; /* # of bytes (min) that is guaranteed to match */
/* this comes from match_max command */
+ int umsize_changed; /* is umsize changed by user? */
int printed; /* # of bytes written to stdout (if logging on) */
/* but not actually returned via a match yet */
int echoed; /* additional # of bytes (beyond "printed" above) */
diff -up expect-5.43/expect.c.spawn expect-5.43/expect.c
--- expect-5.43/expect.c.spawn 2004-07-07 01:26:02.000000000 +0200
+++ expect-5.43/expect.c 2008-09-25 12:22:14.000000000 +0200
@@ -41,8 +41,17 @@ would appreciate credit if this program
#include "tcldbg.h"
#endif
+/* The initial length is 2000. We increment it by 2000. The maximum
+ is 8MB (0x800000). */
+#define EXP_MATCH_MAX 2000
+#define EXP_MATCH_INC 2000
+#define EXP_MATCH_STEP_LIMIT 0x700000
+#define EXP_MATCH_LIMIT 0x800000
+#define EXP_MATCH_LIMIT_QUOTE "0x800000"
+
/* initial length of strings that we can guarantee patterns can match */
-int exp_default_match_max = 2000;
+int exp_default_match_max = EXP_MATCH_MAX;
+int exp_default_match_max_changed = 0;
#define INIT_EXPECT_TIMEOUT_LIT "10" /* seconds */
#define INIT_EXPECT_TIMEOUT 10 /* seconds */
int exp_default_parity = TRUE;
@@ -1619,6 +1628,76 @@ expNullStrip(obj,offsetBytes)
return newsize;
}
+/* returns # of bytes until we see a newline at the end or EOF. */
+/*ARGSUSED*/
+static int
+expReadNewLine(interp,esPtr,save_flags) /* INTL */
+Tcl_Interp *interp;
+ExpState *esPtr;
+int save_flags;
+{
+ int size;
+ int exp_size;
+ int full_size;
+ int count;
+ char *str;
+
+ count = 0;
+ for (;;) {
+ exp_size = expSizeGet(esPtr);
+
+ /* When we reach the limit, we will only read one char at a
+ time. */
+ if (esPtr->umsize >= EXP_MATCH_STEP_LIMIT)
+ size = TCL_UTF_MAX;
+ else
+ size = exp_size;
+
+ if (exp_size + TCL_UTF_MAX >= esPtr->msize) {
+ if (esPtr->umsize >= EXP_MATCH_LIMIT) {
+ expDiagLogU("WARNING: interact buffer is full. probably your program\r\n");
+ expDiagLogU("is not interactive or has a very long output line. The\r\n");
+ expDiagLogU("current limit is " EXP_MATCH_LIMIT_QUOTE ".\r\n");
+ expDiagLogU("Dumping first half of buffer in order to continue\r\n");
+ expDiagLogU("Recommend you enlarge the buffer.\r\n");
+ exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
+ return count;
+ }
+ else {
+ esPtr->umsize += EXP_MATCH_INC;
+ expAdjust(esPtr);
+ }
+ }
+
+ full_size = esPtr->msize - (size / TCL_UTF_MAX);
+ size = Tcl_ReadChars(esPtr->channel,
+ esPtr->buffer,
+ full_size,
+ 1 /* append */);
+ if (size > 0) {
+ count += size;
+ /* We try again if there are more to read and we haven't
+ seen a newline at the end. */
+ if (size == full_size) {
+ str = Tcl_GetStringFromObj(esPtr->buffer, &size);
+ if (str[size - 1] != '\n')
+ continue;
+ }
+ }
+ else {
+ /* It is even trickier. We got an error from read. We have
+ to recover from it. Let's make sure the size of
+ buffer is correct. It can be corrupted. */
+ str = Tcl_GetString(esPtr->buffer);
+ Tcl_SetObjLength(esPtr->buffer, strlen(str));
+ }
+
+ break;
+ }
+
+ return count;
+}
+
/* returns # of bytes read or (non-positive) error of form EXP_XXX */
/* returns 0 for end of file */
/* If timeout is non-zero, set an alarm before doing the read, else assume */
@@ -1633,6 +1712,8 @@ int save_flags;
{
int cc = EXP_TIMEOUT;
int size = expSizeGet(esPtr);
+ int full_size;
+ int count;
if (size + TCL_UTF_MAX >= esPtr->msize)
exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect");
@@ -1649,11 +1730,43 @@ int save_flags;
}
#endif
-
+ /* FIXME: If we ask less than what is available in the tcl buffer
+ when tcl has seen EOF, we will throw away the remaining data
+ since the next read will get EOF. Since expect is line-oriented,
+ we exand our buffer to get EOF or the next newline at the end of
+ the input buffer. I don't know if it is the right fix. H.J. */
+ count = 0;
+ full_size = esPtr->msize - (size / TCL_UTF_MAX);
cc = Tcl_ReadChars(esPtr->channel,
- esPtr->buffer,
- esPtr->msize - (size / TCL_UTF_MAX),
- 1 /* append */);
+ esPtr->buffer,
+ full_size,
+ 1 /* append */);
+ if (cc > 0) {
+ count += cc;
+ /* It gets very tricky. There are more to read. We will expand
+ our buffer and get EOF or a newline at the end unless the
+ buffer length has been changed. */
+ if (cc == full_size) {
+ char *str;
+ str = Tcl_GetStringFromObj(esPtr->buffer, &size);
+ if (str[size - 1] != '\n') {
+ if (esPtr->umsize_changed) {
+ char buf[20]; /* big enough for 64bit int in hex. */
+ snprintf(buf,sizeof(buf),"0x%x", esPtr->umsize);
+ expDiagLogU("WARNING: interact buffer is not large enough to hold\r\n");
+ expDiagLogU("all output. probably your program is not interactive or\r\n");
+ expDiagLogU("has a very long output line. The current limit is ");
+ expDiagLogU(buf);
+ expDiagLogU(".\r\n");
+ }
+ else {
+ cc = expReadNewLine(interp,esPtr,save_flags);
+ if (cc > 0)
+ count += cc;
+ }
+ }
+ }
+ }
i_read_errno = errno;
#ifdef SIMPLE_EVENT
@@ -1674,7 +1787,7 @@ int save_flags;
}
}
#endif
- return cc;
+ return count > 0 ? count : cc;
}
/*
@@ -2751,8 +2864,14 @@ char **argv;
return(TCL_ERROR);
}
- if (Default) exp_default_match_max = size;
- else esPtr->umsize = size;
+ if (Default) {
+ exp_default_match_max = size;
+ exp_default_match_max_changed = 1;
+ }
+ else {
+ esPtr->umsize = size;
+ esPtr->umsize_changed = 1;
+ }
return(TCL_OK);
}

View File

@ -1,74 +0,0 @@
diff -up expect-5.43/expect_cf.h.in.h-comments expect-5.43/expect_cf.h.in
--- expect-5.43/expect_cf.h.in.h-comments 2004-05-07 19:48:02.000000000 +0200
+++ expect-5.43/expect_cf.h.in 2008-09-25 12:22:37.000000000 +0200
@@ -4,7 +4,8 @@
#ifndef __EXPECT_CF_H__
#define __EXPECT_CF_H__
-#undef NO_STDLIB_H /* Tcl requires this name */
+/* Tcl requires this name */
+#undef NO_STDLIB_H
#undef NO_UNION_WAIT
#undef HAVE_STDARG_H
#undef HAVE_VARARGS_H
@@ -12,12 +13,18 @@
#undef HAVE_SYSCONF_H
#undef HAVE_SYS_FCNTL_H
#undef HAVE_SYS_WAIT_H
-#undef HAVE_SYS_BSDTYPES_H /* nice ISC special */
-#undef HAVE_SYS_SELECT_H /* nice ISC special */
-#undef HAVE_SYS_TIME_H /* nice ISC special */
-#undef HAVE_SYS_PTEM_H /* SCO needs this for window size */
-#undef HAVE_STRREDIR_H /* Solaris needs this for console redir */
-#undef HAVE_STRPTY_H /* old-style Dynix ptys need this */
+/* nice ISC special */
+#undef HAVE_SYS_BSDTYPES_H
+/* nice ISC special */
+#undef HAVE_SYS_SELECT_H
+/* nice ISC special */
+#undef HAVE_SYS_TIME_H
+/* SCO needs this for window size */
+#undef HAVE_SYS_PTEM_H
+/* Solaris needs this for console redir */
+#undef HAVE_STRREDIR_H
+/* old-style Dynix ptys need this */
+#undef HAVE_STRPTY_H
#undef HAVE_UNISTD_H
#undef HAVE_SYSMACROS_H
#undef HAVE_INTTYPES_H
@@ -26,8 +33,10 @@
#undef pid_t
#undef RETSIGTYPE
-#undef TIME_WITH_SYS_TIME /* ok to include both time.h and sys/time.h */
-#undef SETPGRP_VOID /* if setpgrp takes 0 args */
+/* ok to include both time.h and sys/time.h */
+#undef TIME_WITH_SYS_TIME
+/* if setpgrp takes 0 args */
+#undef SETPGRP_VOID
/*
* This section is for compile macros needed by
@@ -42,7 +51,8 @@
#undef SIMPLE_EVENT
#undef HAVE_STRFTIME
#undef HAVE_MEMMOVE
-#undef HAVE_TIMEZONE /* timezone() a la Pyramid */
+/* timezone() a la Pyramid */
+#undef HAVE_TIMEZONE
#undef HAVE_SIGLONGJMP
#undef HAVE_STRCHR
diff -up expect-5.43/tcldbgcf.h.in.h-comments expect-5.43/tcldbgcf.h.in
--- expect-5.43/tcldbgcf.h.in.h-comments 2002-02-12 03:00:56.000000000 +0100
+++ expect-5.43/tcldbgcf.h.in 2008-09-25 12:22:37.000000000 +0200
@@ -7,7 +7,8 @@
#ifndef __NIST_DBG_CF_H__
#define __NIST_DBG_CF_H__
-#undef NO_STDLIB_H /* Tcl requires this name */
+/* Tcl requires this name */
+#undef NO_STDLIB_H
/*
* Check for functions

View File

@ -1,12 +1,12 @@
diff -up expect-5.43/exp_log.c.log_file expect-5.43/exp_log.c
--- expect-5.43/exp_log.c.log_file 2004-08-18 22:54:35.000000000 +0200
+++ expect-5.43/exp_log.c 2008-09-25 12:24:42.000000000 +0200
@@ -471,7 +471,7 @@ expLogChannelOpen(interp,filename,append
Tcl_DStringAppend(&tsdPtr->logFilename,filename,-1);
diff -up expect-5.44.1.15/exp_log.c.orig expect-5.44.1.15/exp_log.c
--- expect-5.44.1.15/exp_log.c.orig 2010-03-08 15:45:20.581378309 +0100
+++ expect-5.44.1.15/exp_log.c 2010-03-08 15:45:38.838398279 +0100
@@ -374,7 +374,7 @@ expDiagChannelOpen(interp,filename)
Tcl_DStringAppend(&tsdPtr->diagFilename,filename,-1);
}
- tsdPtr->logChannel = Tcl_OpenFileChannel(interp,newfilename,mode,0777);
+ tsdPtr->logChannel = Tcl_OpenFileChannel(interp,newfilename,mode,0666);
if (!tsdPtr->logChannel) {
Tcl_DStringFree(&tsdPtr->logFilename);
- tsdPtr->diagChannel = Tcl_OpenFileChannel(interp,newfilename,"a",0777);
+ tsdPtr->diagChannel = Tcl_OpenFileChannel(interp,newfilename,"a",0666);
if (!tsdPtr->diagChannel) {
Tcl_DStringFree(&tsdPtr->diagFilename);
return TCL_ERROR;

View File

@ -1,12 +0,0 @@
diff -up expect-5.43/Makefile.in.pkgIndex-x expect-5.43/Makefile.in
--- expect-5.43/Makefile.in.pkgIndex-x 2008-09-25 12:26:26.000000000 +0200
+++ expect-5.43/Makefile.in 2008-09-25 12:26:26.000000000 +0200
@@ -368,7 +368,7 @@ install_shared_lib: $(EXP_LIB_FILES)
else true; fi
if [ -s $(EXP_SHARED_LIB_FILE) ] ; then \
$(INSTALL_PROGRAM) $(EXP_SHARED_LIB_FILE) $(tcl_libdir)/$(EXP_SHARED_LIB_FILE) ; \
- $(INSTALL_PROGRAM) pkgIndex $(libdir)/pkgIndex.tcl ; \
+ $(INSTALL_DATA) pkgIndex $(libdir)/pkgIndex.tcl ; \
else true; fi
expect_installed: exp_main_exp.o $(EXP_LIB_FILE) install_shared_lib

View File

@ -1,34 +1,46 @@
diff -up expect-5.43/configure.in.pkgpath expect-5.43/configure.in
--- expect-5.43/configure.in.pkgpath 2008-09-25 12:28:28.000000000 +0200
+++ expect-5.43/configure.in 2008-09-25 12:28:28.000000000 +0200
@@ -1260,6 +1260,7 @@ AC_SUBST(SETUID)
AC_SUBST(UNSHARED_RANLIB)
diff -up expect-5.44.1.15/configure.in.pkgpath expect-5.44.1.15/configure.in
--- expect-5.44.1.15/configure.in.pkgpath 2009-11-03 20:27:58.000000000 +0100
+++ expect-5.44.1.15/configure.in 2010-03-09 14:46:47.997377875 +0100
@@ -1198,6 +1198,7 @@ AC_SUBST(EXP_SHLIB_LD_LIBS)
AC_SUBST(SETUID)
AC_SUBST(SETPGRP_VOID)
AC_SUBST(DEFAULT_STTY_ARGS)
AC_SUBST(STTY_BIN)
+AC_SUBST(TCL_VERSION)
AC_OUTPUT([Makefile \
pkgIndex],
chmod +x ${srcdir}/install-sh ${srcdir}/mkinstalldirs)
diff -up expect-5.43/Makefile.in.pkgpath expect-5.43/Makefile.in
--- expect-5.43/Makefile.in.pkgpath 2008-09-25 12:28:28.000000000 +0200
+++ expect-5.43/Makefile.in 2008-09-25 12:28:28.000000000 +0200
@@ -173,8 +173,8 @@ STTY = -DDFLT_STTY="\"@DEFAULT_STTY_ARGS
bindir = $(INSTALL_ROOT)@bindir@
bindir_arch_indep = $(INSTALL_ROOT)$(prefix)/bin
tcl_libdir = $(INSTALL_ROOT)@libdir@
-libdir = $(INSTALL_ROOT)@libdir@/expect$(VERSION)
-libdir_arch_indep = $(INSTALL_ROOT)$(prefix)/lib/expect$(VERSION)
+libdir = $(INSTALL_ROOT)@libdir@/tcl@TCL_VERSION@/expect$(VERSION)
+libdir_arch_indep = $(INSTALL_ROOT)@datadir@/tcl@TCL_VERSION@/expect$(VERSION)
mandir = $(INSTALL_ROOT)@mandir@
man1dir = $(mandir)/man1
diff -up expect-5.43/pkgIndex.in.pkgpath expect-5.43/pkgIndex.in
--- expect-5.43/pkgIndex.in.pkgpath 2002-02-12 03:00:56.000000000 +0100
+++ expect-5.43/pkgIndex.in 2008-09-25 12:28:28.000000000 +0200
@@ -7,4 +7,4 @@
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.
#--------------------------------------------------------------------
#--------------------------------------------------------------------
diff -up expect-5.44.1.15/Makefile.in.pkgpath expect-5.44.1.15/Makefile.in
--- expect-5.44.1.15/Makefile.in.pkgpath 2008-10-03 19:05:14.000000000 +0200
+++ expect-5.44.1.15/Makefile.in 2010-03-09 14:47:20.101376873 +0100
@@ -121,8 +121,8 @@ includedir = @includedir@
DESTDIR =
PKG_DIR = $(PACKAGE_NAME)$(PACKAGE_VERSION)
-pkgdatadir = $(datadir)/$(PKG_DIR)
-pkglibdir = $(libdir)/$(PKG_DIR)
+pkgdatadir = $(datadir)/tcl@TCL_VERSION@/$(PKG_DIR)
+pkglibdir = $(libdir)/tcl@TCL_VERSION@/$(PKG_DIR)
pkgincludedir = $(includedir)/$(PKG_DIR)
top_builddir = .
@@ -267,7 +267,7 @@ install-doc: doc
else true; fi ; \
done
-test: binaries libraries
+test: binaries libraries pkgIndex.tcl-test
$(TCLSH) `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS)
shell: binaries libraries
@@ -331,6 +331,11 @@ pkgIndex.tcl:
pkgIndex.tcl-hand:
(echo 'package ifneeded Expect $(PACKAGE_VERSION) \
+ [list load [file join $$dir .. .. $(PKG_LIB_FILE)]]'\
+ ) > pkgIndex.tcl
+
+pkgIndex.tcl-test:
+ (echo 'package ifneeded Expect $(PACKAGE_VERSION) \
[list load [file join $$dir $(PKG_LIB_FILE)]]'\
) > pkgIndex.tcl
-package ifneeded Expect @EXP_VERSION_FULL@ [list load [file join $dir .. @EXP_SHARED_LIB_FILE@]]
+package ifneeded Expect @EXP_VERSION_FULL@ [list load [file join $dir .. .. @EXP_SHARED_LIB_FILE@]]

View File

@ -1,42 +0,0 @@
diff -up expect-5.43/exp_command.c_old expect-5.43/exp_command.c
--- expect-5.43/exp_command.c_old 2009-02-10 16:23:48.000000000 +0100
+++ expect-5.43/exp_command.c 2009-02-10 16:31:38.000000000 +0100
@@ -2311,12 +2311,11 @@ Tcl_Obj *CONST objv[]; /* Argument objec
/* Historical note: we used "close" long before there was a */
/* Tcl builtin by the same name. */
- Tcl_CmdInfo info;
+ Tcl_CmdInfo* close_info;
Tcl_ResetResult(interp);
- if (0 == Tcl_GetCommandInfo(interp,"close",&info)) {
- info.clientData = 0;
- }
- return(Tcl_CloseObjCmd(info.clientData,interp,objc_orig,objv_orig));
+
+ close_info = (Tcl_CmdInfo*) Tcl_GetAssocData (interp, EXP_CMDINFO_CLOSE, NULL);
+ return(close_info->objProc(close_info->objClientData,interp,objc,objv));
}
if (chanName) {
@@ -2961,7 +2960,10 @@ Tcl_Obj *CONST objv[];
/* if successful (i.e., TCL_RETURN is returned) */
/* modify the result, so that we will handle it specially */
- int result = Tcl_ReturnObjCmd(clientData,interp,objc,objv);
+ Tcl_CmdInfo* return_info = (Tcl_CmdInfo*)
+ Tcl_GetAssocData (interp, EXP_CMDINFO_RETURN, NULL);
+
+ int result = return_info->objProc(return_info->objClientData,interp,objc,objv);
if (result == TCL_RETURN)
result = EXP_TCL_RETURN;
return result;
diff -up expect-5.43/exp_command.h_old expect-5.43/exp_command.h
--- expect-5.43/exp_command.h_old 2009-02-10 17:33:19.000000000 +0100
+++ expect-5.43/exp_command.h 2009-02-10 17:33:46.000000000 +0100
@@ -326,3 +326,6 @@ EXTERN ExpState * expDevttyGet _ANSI_ARG
/* generic functions that really should be provided by Tcl */
EXTERN int expSizeGet _ANSI_ARGS_((ExpState *));
EXTERN int expSizeZero _ANSI_ARGS_((ExpState *));
+
+#define EXP_CMDINFO_CLOSE "expect/cmdinfo/close"
+#define EXP_CMDINFO_RETURN "expect/cmdinfo/return"

View File

@ -1,22 +0,0 @@
diff -up expect-5.43/Dbg.c.tcl8.5 expect-5.43/Dbg.c
--- expect-5.43/Dbg.c.tcl8.5 2002-03-23 05:11:54.000000000 +0100
+++ expect-5.43/Dbg.c 2008-09-25 12:25:40.000000000 +0200
@@ -10,6 +10,7 @@ would appreciate credit if this program
#include <stdio.h>
+#include "expect_cf.h"
#include "tcldbgcf.h"
#if 0
/* tclInt.h drags in stdlib. By claiming no-stdlib, force it to drag in */
diff -up expect-5.43/exp_inter.c.tcl8.5 expect-5.43/exp_inter.c
--- expect-5.43/exp_inter.c.tcl8.5 2004-08-18 04:03:00.000000000 +0200
+++ expect-5.43/exp_inter.c 2008-09-25 12:25:40.000000000 +0200
@@ -36,6 +36,7 @@ would appreciate credit if this program
#include <ctype.h>
#include "tcl.h"
+#include "tclInt.h"
#include "string.h"
#include "exp_tty_in.h"

View File

@ -0,0 +1,232 @@
Author: Sergei Golovan <sgolovan@debian.org>
Description: Fixes Tk intialization by calling Tk_Init instead of
using copy&pasted Tk_Init from older Tk.
--- expect-5.44.1.14.orig/exp_main_tk.c
+++ expect-5.44.1.14/exp_main_tk.c
@@ -162,13 +162,7 @@
* the "argv" variable in Tk_Init.
*/
-static int synchronize;
-static CONST char *name;
-static char *display;
-static char *geometry;
-static char *colormap;
-static char *visual;
-static int rest = 0;
+static int rest;
/* for Expect */
int my_rc = 1;
@@ -181,21 +175,6 @@
int print_version = 0;
static Tk_ArgvInfo argTable[] = {
- {"-colormap", TK_ARGV_STRING, (char *) NULL, (char *) &colormap,
- "Colormap for main window"},
- {"-display", TK_ARGV_STRING, (char *) NULL, (char *) &display,
- "Display to use"},
- {"-geometry", TK_ARGV_STRING, (char *) NULL, (char *) &geometry,
- "Initial geometry for window"},
- {"-name", TK_ARGV_STRING, (char *) NULL, (char *) &name,
- "Name to use for application"},
- {"-sync", TK_ARGV_CONSTANT, (char *) 1, (char *) &synchronize,
- "Use synchronous mode for display server"},
- {"-visual", TK_ARGV_STRING, (char *) NULL, (char *) &visual,
- "Visual for main window"},
- {"--", TK_ARGV_REST, (char *) 1, (char *) &rest,
- "Pass all remaining arguments through to script"},
-/* for Expect */
{"-command", TK_ARGV_GENFUNC, (char *) optcmd_eval, (char *)0,
"Command(s) to execute immediately"},
{"-diag", TK_ARGV_CONSTANT, (char *) optcmd_diagToStderr, (char *)0,
@@ -210,6 +189,8 @@
{"-Debug", TK_ARGV_GENFUNC, (char *) optcmd_debug, (char *)0,
"Enable debugger"},
#endif
+ {"--", TK_ARGV_REST, (char *) 1, (char *) &rest,
+ "Pass all remaining arguments through to script"},
{(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
(char *) NULL}
};
@@ -243,11 +224,11 @@
Tcl_Interp *interp; /* Interpreter to initialize. */
{
CONST char *p;
- char* alist, *cstr;
- int argc, code;
- char **argv, *args[20];
- Tcl_DString class;
+ char *alist, *pp;
+ int argc, length, i, j;
+ char **argv, **newargv;
char buffer[30];
+ size_t len;
/*
* If there is an "argv" variable, get its value, extract out
@@ -255,8 +236,7 @@
* the arguments that we used.
*/
- synchronize = 0;
- name = display = geometry = colormap = visual = NULL;
+ rest = -1;
p = Tcl_GetVar2(interp, "argv", (char *) NULL, TCL_GLOBAL_ONLY);
argv = NULL;
if (p != NULL) {
@@ -285,115 +265,57 @@
}
}
- alist = Tcl_Merge(argc, argv);
- Tcl_SetVar2(interp, "argv", (char *) NULL, alist, TCL_GLOBAL_ONLY);
- sprintf(buffer, "%d", argc);
- Tcl_SetVar2(interp, "argc", (char *) NULL, buffer, TCL_GLOBAL_ONLY);
- ckfree(alist);
- }
-
- /*
- * Figure out the application's name and class.
- */
+ if (rest >= 0) {
+ /* Resore '--' in arguments list
+ */
- if (name == NULL) {
- name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
- if ((name == NULL) || (*name == 0)) {
- name = "tk";
- } else {
- p = (char *)strrchr(name, '/'); /* added cast - DEL */
- if (p != NULL) {
- name = p+1;
+ length = 0;
+ for (i = 0; i < argc; i++) {
+ length += strlen(argv[i]) + 1;
}
- }
- }
- Tcl_DStringInit(&class);
- Tcl_DStringAppend(&class, name, -1);
- cstr = Tcl_DStringValue(&class);
- if (islower(*cstr)) {
- *cstr = toupper((unsigned char) *cstr);
- }
- /*
- * Create an argument list for creating the top-level window,
- * using the information parsed from argv, if any.
- */
+ newargv = (char **) ckalloc((unsigned) ((argc+2)*sizeof(char *)) + length + 3);
- args[0] = "toplevel";
- args[1] = ".";
- args[2] = "-class";
- args[3] = Tcl_DStringValue(&class);
- argc = 4;
- if (display != NULL) {
- args[argc] = "-screen";
- args[argc+1] = display;
- argc += 2;
-
- /*
- * If this is the first application for this process, save
- * the display name in the DISPLAY environment variable so
- * that it will be available to subprocesses created by us.
- */
+ pp = ((char *) newargv) + (argc+2)*sizeof(char *);
+ j = 0;
+ for (i = 0; i < argc; i++) {
+ if (i == rest) {
+ memcpy(pp, "--", 3);
+ newargv[j++] = pp;
+ pp += 3;
+ }
+
+ len = strlen(argv[i]) + 1;
+ memcpy(pp, argv[i], len);
+ newargv[j++] = pp;
+ pp += len;
+ }
+ newargv[j] = NULL;
- if (numMainWindows == 0) {
- Tcl_SetVar2(interp, "env", "DISPLAY", display, TCL_GLOBAL_ONLY);
+ alist = Tcl_Merge(argc+1, newargv);
+ } else {
+ newargv = NULL;
+ alist = Tcl_Merge(argc, argv);
}
- }
- if (colormap != NULL) {
- args[argc] = "-colormap";
- args[argc+1] = colormap;
- argc += 2;
- }
- if (visual != NULL) {
- args[argc] = "-visual";
- args[argc+1] = visual;
- argc += 2;
- }
- args[argc] = NULL;
- code = TkCreateFrame((ClientData) NULL, interp, argc, args, 1, name);
- Tcl_DStringFree(&class);
- if (code != TCL_OK) {
- goto done;
- }
- Tcl_ResetResult(interp);
-#ifndef MAC_OSX_TK
- if (synchronize) {
- XSynchronize(Tk_Display(Tk_MainWindow(interp)), True);
- }
-#endif
- /*
- * Set the geometry of the main window, if requested. Put the
- * requested geometry into the "geometry" variable.
- */
-
- if (geometry != NULL) {
- Tcl_SetVar(interp, "geometry", geometry, TCL_GLOBAL_ONLY);
- code = Tcl_VarEval(interp, "wm geometry . ", geometry, (char *) NULL);
- if (code != TCL_OK) {
- goto done;
- }
- }
- if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 1) == NULL) {
- code = TCL_ERROR;
- goto done;
- }
- code = Tcl_PkgProvide(interp, "Tk", TK_VERSION);
- if (code != TCL_OK) {
- goto done;
+ Tcl_SetVar2(interp, "argv", (char *) NULL, alist, TCL_GLOBAL_ONLY);
+ sprintf(buffer, "%d", argc);
+ Tcl_SetVar2(interp, "argc", (char *) NULL, buffer, TCL_GLOBAL_ONLY);
+ ckfree(alist);
}
- /*
- * Invoke platform-specific initialization.
- */
-
- code = TkpInit(interp, 0);
+ if (Tk_Init(interp) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
- done:
if (argv != NULL) {
ckfree((char *) argv);
}
- return code;
+ if (newargv != NULL) {
+ ckfree((char *) newargv);
+ }
+
+ return TCL_OK;
}
/*ARGSUSED*/

View File

@ -0,0 +1,9 @@
diff -up expect-5.44.1.15/example/unbuffer.orig expect-5.44.1.15/example/unbuffer
--- expect-5.44.1.15/example/unbuffer.orig 2010-03-08 16:24:38.260378258 +0100
+++ expect-5.44.1.15/example/unbuffer 2010-03-08 16:24:57.525387178 +0100
@@ -19,4 +19,5 @@ if {[string compare [lindex $argv 0] "-p
set timeout -1
eval [list spawn -noecho] $argv
expect
+ exit [lindex [eval wait] 3]
}

View File

@ -1,31 +1,31 @@
%{!?tcl_version: %define tcl_version %(echo 'puts $tcl_version' | tclsh)}
%{!?tcl_sitearch: %define tcl_sitearch %{_libdir}/tcl%{tcl_version}}
%define majorver 5.43
%define majorver 5.44
Summary: A program-script interaction and testing utility
Name: expect
Version: %{majorver}.0
Release: 19%{?dist}
Version: %{majorver}.1.15
Release: 1%{?dist}
License: Public Domain
Group: Development/Languages
# URL: probably more useful is http://sourceforge.net/projects/expect/
URL: http://expect.nist.gov/
Source: http://expect.nist.gov/src/%{name}-%{version}.tar.bz2
Source1: config.sub
# Source: upstream doesn't release tarballs, CVS snapshot packed
Source: %{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Buildrequires: tcl-devel tk-devel autoconf automake libXft-devel
Patch0: expect-5.38.0-spawn-43310.patch
Patch1: expect-5.43.0-h-comments.patch
Patch2: expect-5.38.0-lib-spec.patch
Patch3: expect-5.39.0-libdir.patch
Patch4: expect-5.43.0-log_file.patch
Patch5: expect-5.43.0-tcl8.5.patch
Patch6: expect-5.43.0-pkgIndex-x.patch
Patch7: expect-5.43.0-tcl8.5.6.patch
Buildrequires: tcl-devel tk-devel autoconf automake libXft-devel chrpath
# Patch0: fixes change log file permissions
Patch0: expect-5.43.0-log_file.patch
# Patch1: fixes install location, change pkgIndex
Patch1: expect-5.43.0-pkgpath.patch
# Patch2: fixes bz456738, expectk is unsupported by upstream actually,
# but the patch is under discussion (patch by Sergei Golovan)
Patch2: expect-5.44.1.15-tk-init.patch
# examples patches
# Patch100: changes random function
Patch100: expect-5.32.2-random.patch
Patch101: unbuffer-child-flush-143963.patch
# Fix install location for tcl 8.5
Patch200: expect-5.43.0-pkgpath.patch
# Patch101: bz547686, no response from upstream
Patch101: expect-5.44.1.15-unbuffer-exit-code.patch
%description
Expect is a tcl application for automating and testing
@ -62,27 +62,20 @@ control another program and interact with it.
This package contains expectk and some scripts that use it.
%prep
%setup -q -n expect-%{majorver}
%patch0 -p1 -b .spawn
%patch1 -p1 -b .h-comments
%patch2 -p1 -b .lib-spec
%patch3 -p1 -b .libdir
%patch4 -p1 -b .log_file
%patch5 -p1 -b .tcl8.5
%patch6 -p1 -b .pkgIndex-x
#%patch7 -p1 -b .tcl8.5.6
%setup -q -n expect-%{version}
%patch0 -p1 -b .log_file
%patch1 -p1 -b .pkgpath
%patch2 -p1 -b .tk-init
# examples fixes
%patch100 -p1 -b .random
%patch101 -p1 -b .unbuffer
%patch200 -p1 -b .pkgpath
# *-lib-spec.patch and *-tcl8.5.patch and -pkgpath.patch touch configure.in
%patch101 -p1 -b .unbuffer-exit-code
# -pkgpath.patch touch configure.in
aclocal
autoconf
( cd testsuite
autoconf -I.. )
%build
cp -fp %SOURCE1 .;
%configure --with-tcl=%{_libdir} --with-tk=%{_libdir} --enable-shared \
--with-tclinclude=%{_includedir}/tcl-private
make %{?_smp_mflags}
@ -92,7 +85,10 @@ make test
%install
rm -rf "$RPM_BUILD_ROOT"
make install INSTALL_ROOT="$RPM_BUILD_ROOT"
make install DESTDIR="$RPM_BUILD_ROOT"
# move
mv "$RPM_BUILD_ROOT"%{tcl_sitearch}/expect%{version}/libexpect%{version}.so "$RPM_BUILD_ROOT"%{_libdir}
# for linking with -lexpect
ln -s libexpect%{majorver}.so "$RPM_BUILD_ROOT"%{_libdir}/libexpect.so
@ -102,6 +98,9 @@ rm -f "$RPM_BUILD_ROOT"%{_bindir}/{cryptdir,decryptdir}
rm -f "$RPM_BUILD_ROOT"%{_mandir}/man1/{cryptdir,decryptdir}.1*
rm -f "$RPM_BUILD_ROOT"%{_bindir}/autopasswd
# remove rpath
chrpath --delete $RPM_BUILD_ROOT%{_libdir}/libexpect%{version}.so
%clean
rm -rf "$RPM_BUILD_ROOT"
@ -124,9 +123,9 @@ rm -rf "$RPM_BUILD_ROOT"
%{_bindir}/unbuffer
%{_bindir}/weather
%{_bindir}/xkibitz
%dir %{tcl_sitearch}/expect%{majorver}
%{tcl_sitearch}/expect%{majorver}/pkgIndex.tcl
%{_libdir}/libexpect%{majorver}.so
%dir %{tcl_sitearch}/expect%{version}
%{tcl_sitearch}/expect%{version}/pkgIndex.tcl
%{_libdir}/libexpect%{version}.so
%{_mandir}/man1/autoexpect.1.gz
%{_mandir}/man1/dislocate.1.gz
%{_mandir}/man1/expect.1.gz
@ -139,8 +138,6 @@ rm -rf "$RPM_BUILD_ROOT"
%files devel
%defattr(-,root,root,-)
%exclude %{tcl_sitearch}/expect%{majorver}/libexpect%{majorver}.a
%exclude %{_libdir}/libexpect%{majorver}.a
%{_libdir}/libexpect.so
%{_mandir}/man3/libexpect.3*
%{_includedir}/*
@ -157,6 +154,16 @@ rm -rf "$RPM_BUILD_ROOT"
%{_mandir}/man1/tknewsbiff.1*
%changelog
* Wed Mar 10 2010 Vitezslav Crhonek <vcrhonek@redhat.com> - 5.44.1.15-1
- Update to 5.44.1.15 from upstream CVS
Resolves: #528654, Resolves: #501820
- Remove config.sub (no longer needed), remove unused patches (few are
upstream now, few are pointless with new version), comment patches
- Fix unbuffer to return exit code of ubuffered program
Resolves: #547686
- Fix Tk initialization
Resolves: #456738
* Mon Aug 10 2009 Ville Skyttä <ville.skytta@iki.fi> - 5.43.0-19
- Use bzipped upstream tarball.

View File

@ -1,2 +1,2 @@
7b4ffbcfcbe779a6b8e1f2931f0aeff7 expect-5.44.1.15.tar.bz2
d2ef2acafb72e8f3f3029d30e2a8e228 config.sub
e6aaab98967f6410099b40f2b3ddebb4 expect-5.43.0.tar.bz2

View File

@ -1,23 +0,0 @@
diff -up expect-5.43/example/unbuffer.unbuffer expect-5.43/example/unbuffer
--- expect-5.43/example/unbuffer.unbuffer 2004-01-25 02:37:49.000000000 +0100
+++ expect-5.43/example/unbuffer 2008-09-25 12:27:48.000000000 +0200
@@ -6,10 +6,17 @@ if {[string compare [lindex $argv 0] "-p
# pipeline
set stty_init "-echo"
eval spawn -noecho [lrange $argv 1 end]
- interact
+ close_on_eof -i $user_spawn_id 0
+ interact {
+ eof {
+ # flush remaining output from child
+ expect -timeout 1 -re .+
+ return
+ }
+ }
} else {
set stty_init "-opost"
- eval spawn -noecho $argv
set timeout -1
+ eval spawn -noecho $argv
expect
}