diff --git a/lang/expect/Makefile b/lang/expect/Makefile index e147d535ce31..d4b186a80ddd 100644 --- a/lang/expect/Makefile +++ b/lang/expect/Makefile @@ -1,31 +1,31 @@ # Created by: pst PORTNAME= expect PORTVERSION= 5.45.4 -PORTREVISION= 2 +PORTREVISION= 3 PORTEPOCH= 1 CATEGORIES= lang tcl tk MASTER_SITES= SF/${PORTNAME}/Expect/${PORTVERSION} DISTNAME= ${PORTNAME}${PORTVERSION} MAINTAINER= tcltk@FreeBSD.org COMMENT= Sophisticated scripter based on Tcl/Tk LICENSE= PD LICENSE_FILE= ${WRKSRC}/license.terms USES= tcl:tea autoreconf USE_LDCONFIG= ${LOCALBASE}/lib/${DISTNAME} WRKSRC= ${WRKDIR}/${DISTNAME} PLIST_SUB+= PORTVERSION=${PORTVERSION} SUB_FILES+= pkg-message SUB_LIST+= MANPREFIX=${MANPREFIX} TEST_TARGET= test post-install: ${LN} -sf ${DISTNAME}/lib${DISTNAME}.so \ ${STAGEDIR}${PREFIX}/lib/lib${PORTNAME}.so.1 ${LN} -sf lib${PORTNAME}.so.1 ${STAGEDIR}${PREFIX}/lib/lib${PORTNAME}.so .include diff --git a/lang/expect/files/patch-modernize b/lang/expect/files/patch-modernize new file mode 100644 index 000000000000..15a33269c77a --- /dev/null +++ b/lang/expect/files/patch-modernize @@ -0,0 +1,1039 @@ +Index: Dbg.c +================================================================== +--- Dbg.c ++++ Dbg.c +@@ -171,16 +171,16 @@ + Tcl_SetVar2Ex(interp, Dbg_VarName, name, Tcl_GetRange(objPtr, + info.matches[i].start, info.matches[i].end-1), 0); + } + } + +-/* return 1 to break, 0 to continue */ ++/* return 1 to break, 0 to continue ++ * cmd: command about to be executed ++ * bp: breakpoint to test ++ */ + static int +-breakpoint_test(interp,cmd,bp) +-Tcl_Interp *interp; +-char *cmd; /* command about to be executed */ +-struct breakpoint *bp; /* breakpoint to test */ ++breakpoint_test(Tcl_Interp *interp,const char *cmd,struct breakpoint *bp) + { + if (bp->re) { + int found = 0; + Tcl_Obj *cmdObj; + Tcl_RegExp re = Tcl_GetRegExpFromObj(NULL, bp->pat, +@@ -237,11 +237,11 @@ + * if global frame indicated). */ + enum debug_cmd dir; /* look up or down the stack */ + { + Interp *iPtr = (Interp *) interp; + int level, result; +- CallFrame *framePtr; /* frame currently being searched */ ++ CallFrame *framePtr = NULL; /* frame currently being searched */ + + CallFrame *curFramePtr = iPtr->varFramePtr; + + /* + * Parse string to figure out which level number to go to. +@@ -299,11 +299,10 @@ + } + } + *framePtrPtr = framePtr; + return result; + } +- + + static char *printify(s) + char *s; + { + static int destlen = 0; +@@ -656,10 +655,12 @@ + case ret: + /* same comment as in "case next" */ + if (goalFramePtr != iPtr->varFramePtr) goto finish; + goto start_interact; + /* DANGER: unhandled cases! none, up, down, where */ ++ default: ++ break; /* Silence compiler warning */ + } + + start_interact: + if (print_command_first_time) { + print(interp,"%s: %s\n", +@@ -714,10 +715,12 @@ + goalFramePtr = goalFramePtr->callerVarPtr; + goto finish; + case where: + PrintStack(interp,iPtr->varFramePtr,viewFramePtr,objc,objv,level_text); + break; ++ default: ++ break; /* Silence compiler warning */ + } + + /* restore view and restart interactor */ + iPtr->varFramePtr = viewFramePtr; + goto start_interact; + +Index: configure.in +================================================================== +--- configure.in ++++ configure.in +@@ -217,10 +217,12 @@ + # This needn't be done in the 2nd and 3rd tests. + AC_DEFINE(HAVE_OPENPTY) + LIBS="$LIBS -lutil" + ]) + fi ++ ++AC_CHECK_HEADER(libutil.h,AC_DEFINE(HAVE_LIBUTIL_H)) + + ###################################################################### + # End of library/func checking + ###################################################################### + + +Index: exp_chan.c +================================================================== +--- exp_chan.c ++++ exp_chan.c +@@ -23,20 +23,20 @@ + # include + #endif + + #include + +-#include "tclInt.h" /* Internal definitions for Tcl. */ +- +-#include "tcl.h" ++#include /* Internal definitions for Tcl. */ ++#include + + #include "string.h" + + #include "exp_rename.h" + #include "exp_prog.h" + #include "exp_command.h" + #include "exp_log.h" ++#include "exp_event.h" + #include "tcldbg.h" /* Dbg_StdinMode */ + + extern int expSetBlockModeProc _ANSI_ARGS_((int fd, int mode)); + static int ExpBlockModeProc _ANSI_ARGS_((ClientData instanceData, + int mode)); +@@ -55,21 +55,18 @@ + /* + * This structure describes the channel type structure for Expect-based IO: + */ + + Tcl_ChannelType expChannelType = { +- "exp", /* Type name. */ +- ExpBlockModeProc, /* Set blocking/nonblocking mode.*/ +- ExpCloseProc, /* Close proc. */ +- ExpInputProc, /* Input proc. */ +- ExpOutputProc, /* Output proc. */ +- NULL, /* Seek proc. */ +- NULL, /* Set option proc. */ +- NULL, /* Get option proc. */ +- ExpWatchProc, /* Initialize notifier. */ +- ExpGetHandleProc, /* Get OS handles out of channel. */ +- NULL, /* Close2 proc */ ++ .typeName = "exp", /* Type name. */ ++ .version = TCL_CHANNEL_VERSION_2, ++ .blockModeProc = ExpBlockModeProc, /* Set blocking/nonblocking mode.*/ ++ .closeProc = ExpCloseProc, /* Close proc. */ ++ .inputProc = ExpInputProc, /* Input proc. */ ++ .outputProc = ExpOutputProc, /* Output proc. */ ++ .watchProc = ExpWatchProc, /* Initialize notifier. */ ++ .getHandleProc = ExpGetHandleProc /* Get OS handles out of channel. */ + }; + + typedef struct ThreadSpecificData { + /* + * List of all exp channels currently open. This is per thread and is +@@ -434,14 +431,14 @@ + ClientData *handlePtr; /* Where to store the handle. */ + { + ExpState *esPtr = (ExpState *) instanceData; + + if (direction & TCL_WRITABLE) { +- *handlePtr = (ClientData) esPtr->fdin; ++ *handlePtr = (ClientData)(intptr_t)esPtr->fdin; + } + if (direction & TCL_READABLE) { +- *handlePtr = (ClientData) esPtr->fdin; ++ *handlePtr = (ClientData)(intptr_t)esPtr->fdin; + } else { + return TCL_ERROR; + } + return TCL_OK; + } + +Index: exp_clib.c +================================================================== +--- exp_clib.c ++++ exp_clib.c +@@ -47,10 +47,14 @@ + #include + # ifdef SRIOCSREDIR + # undef TIOCCONS + # endif + #endif ++ ++#ifdef HAVE_UNISTD_H ++#include ++#endif + + #include + /*#include - deprecated - ANSI C moves them into string.h */ + #include "string.h" + +@@ -114,10 +118,11 @@ + #include /* for malloc */ + #endif + + #include + #include "expect.h" ++#include "exp_command.h" + #define TclRegError exp_TclRegError + + /* + * regexp code - from tcl8.0.4/generic/regexp.c + */ +@@ -1805,10 +1810,17 @@ + fp->match_end = fp->buffer; + return fp; + + } + ++/* ultrix (at least 4.1-2) fails to obtain controlling tty if setsid */ ++/* is called. setpgrp works though. */ ++#if defined(POSIX) && !defined(ultrix) || defined(__convex__) ++#define DO_SETSID ++#endif ++ ++#if !defined(DO_SETSID) && (!defined(SYSV3) || defined(CRAY)) /* { */ + static + void + exp_setpgrp() + { + #ifdef MIPS_BSD +@@ -1821,10 +1833,11 @@ + (void) setpgrp(); + #else + (void) setpgrp(0,0); + #endif + } ++#endif /* } */ + + /* returns fd of master side of pty */ + int + exp_spawnv(file,argv) + char *file; +@@ -1831,11 +1844,13 @@ + char *argv[]; /* some compiler complains about **argv? */ + { + int cc; + int errorfd; /* place to stash fileno(stderr) in child */ + /* while we're setting up new stderr */ ++#if defined(TIOCNOTTY) && !defined(SYSV3) && !defined(DO_SETSID) + int ttyfd; ++#endif + int sync_fds[2]; + int sync2_fds[2]; + int status_pipe[2]; + int child_errno; + char sync_byte; +@@ -2006,19 +2021,10 @@ + + #ifdef CRAY + (void) close(exp_pty[0]); + #endif + +-/* ultrix (at least 4.1-2) fails to obtain controlling tty if setsid */ +-/* is called. setpgrp works though. */ +-#if defined(POSIX) && !defined(ultrix) +-#define DO_SETSID +-#endif +-#ifdef __convex__ +-#define DO_SETSID +-#endif +- + #ifdef DO_SETSID + setsid(); + #else + #ifdef SYSV3 + #ifndef CRAY +@@ -2037,11 +2043,16 @@ + + #endif /* SYSV3 */ + #endif /* DO_SETSID */ + + /* save error fd while we're setting up new one */ ++#ifdef F_DUPFD_CLOEXEC ++ errorfd = fcntl(2,F_DUPFD_CLOEXEC,3); ++#else + errorfd = fcntl(2,F_DUPFD,3); ++ fcntl(errorfd, F_SETFD, FD_CLOEXEC); ++#endif /* F_DUPFD_CLOXEC */ + /* and here is the macro to restore it */ + #define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);} + + if (exp_autoallocpty) { + +@@ -2442,11 +2453,11 @@ + + struct f *f; + int return_val; + int sys_error = 0; + #define return_normally(x) {return_val = x; goto cleanup;} +-#define return_errno(x) {sys_error = x; goto cleanup;} ++#define return_errno(x) {sys_error = x; return_val = -1; goto cleanup;} + + f = fdfp2f(fd,fp); + if (!f) return_errno(ENOMEM); + + exp_buffer = f->buffer; +@@ -2851,11 +2862,13 @@ + } + + int + exp_disconnect() + { ++#if defined(TIOCNOTTY) && !defined(SYSV3) && !defined(POSIX) + int ttyfd; ++#endif + + #ifndef EALREADY + #define EALREADY 37 + #endif + + +Index: exp_command.c +================================================================== +--- exp_command.c ++++ exp_command.c +@@ -530,10 +530,17 @@ + if (-1 == ioctl(fd,TIOCSPGRP,&pgrp)) perror("TIOCSPGRP"); + if (-1 == tcsetpgrp(fd,pgrp)) perror("tcsetpgrp"); + } + #endif + ++/* ultrix (at least 4.1-2) fails to obtain controlling tty if setsid */ ++/* is called. setpgrp works though. */ ++#if defined(POSIX) && !defined(ultrix) || defined(__convex__) ++#define DO_SETSID ++#endif ++ ++#if !defined(DO_SETSID) && (!defined(SYSV3) || defined(CRAY)) /* { */ + static + void + expSetpgrp() + { + #ifdef MIPS_BSD +@@ -546,11 +553,11 @@ + (void) setpgrp(); + #else + (void) setpgrp(0,0); + #endif + } +- ++#endif /* } */ + + /*ARGSUSED*/ + static void + set_slave_name( + ExpState *esPtr, +@@ -579,13 +586,11 @@ + Tcl_Obj *CONST objv[]) /* Argument objects. */ + { + ExpState *esPtr = 0; + int slave; + int pid; +-#ifdef TIOCNOTTY +- /* tell Saber to ignore non-use of ttyfd */ +- /*SUPPRESS 591*/ ++#if defined(TIOCNOTTY) && !defined(SYSV3) && !defined(DO_SETSID) + int ttyfd; + #endif /* TIOCNOTTY */ + int errorfd; /* place to stash fileno(stderr) in child */ + /* while we're setting up new stderr */ + int master, k; +@@ -901,17 +906,21 @@ + } + if (mode & TCL_READABLE) { + if (TCL_ERROR == Tcl_GetChannelHandle(channel, TCL_READABLE, &rfdc)) { + return TCL_ERROR; + } +- rfd = (int)(long) rfdc; ++ rfd = (int)(intptr_t) rfdc; ++ } else { ++ rfd = -1; + } + if (mode & TCL_WRITABLE) { + if (TCL_ERROR == Tcl_GetChannelHandle(channel, TCL_WRITABLE, &wfdc)) { + return TCL_ERROR; + } +- wfd = (int)(long) wfdc; ++ wfd = (int)(intptr_t) wfdc; ++ } else { ++ wfd = -1; + } + master = ((mode & TCL_READABLE)?rfd:wfd); + + /* make a new copy of file descriptor */ + if (-1 == (write_master = master = dup(master))) { +@@ -1124,19 +1133,10 @@ + + #ifdef CRAY + (void) close(master); + #endif + +-/* ultrix (at least 4.1-2) fails to obtain controlling tty if setsid */ +-/* is called. setpgrp works though. */ +-#if defined(POSIX) && !defined(ultrix) +-#define DO_SETSID +-#endif +-#ifdef __convex__ +-#define DO_SETSID +-#endif +- + #ifdef DO_SETSID + setsid(); + #else + #ifdef SYSV3 + #ifndef CRAY +@@ -1159,11 +1159,16 @@ + + /* save stderr elsewhere to avoid BSD4.4 bogosity that warns */ + /* if stty finds dev(stderr) != dev(stdout) */ + + /* save error fd while we're setting up new one */ ++#ifdef F_DUPFD_CLOEXEC ++ errorfd = fcntl(2,F_DUPFD_CLOEXEC,3); ++#else + errorfd = fcntl(2,F_DUPFD,3); ++ fcntl(errorfd, F_SETFD, FD_CLOEXEC); ++#endif /* F_DUPFD_CLOXEC */ + /* and here is the macro to restore it */ + #define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);} + + close(0); + close(1); +@@ -1974,11 +1979,11 @@ + #define SEND_STYLE_SLOW 0x04 + #define SEND_STYLE_ZERO 0x10 + #define SEND_STYLE_BREAK 0x20 + int send_style = SEND_STYLE_PLAIN; + int want_cooked = TRUE; +- char *string; /* string to send */ ++ char *string = NULL; /* string to send */ + int len = -1; /* length of string to send */ + int zeros; /* count of how many ascii zeros to send */ + + char *chanName = 0; + struct exp_state_list *state_list; +@@ -2533,11 +2538,11 @@ + Tcl_Obj *CONST objv[]) /* Argument objects. */ + { + /* Magic configuration stuff. */ + int i, opt, val; + +- static CONST84 char* options [] = { ++ static const char* options [] = { + "-strictwrite", NULL + }; + enum options { + EXP_STRICTWRITE + }; +@@ -3112,13 +3117,11 @@ + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ + { + ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + +-#ifdef TIOCNOTTY +- /* tell CenterLine to ignore non-use of ttyfd */ +- /*SUPPRESS 591*/ ++#if defined(TIOCNOTTY) && !defined(SYSV3) && !defined(DO_SETSID) + int ttyfd; + #endif /* TIOCNOTTY */ + + if (objc > 1) { + exp_error(interp,"usage: disconnect"); + +Index: exp_event.c +================================================================== +--- exp_event.c ++++ exp_event.c +@@ -22,10 +22,11 @@ + + #include "tcl.h" + #include "exp_prog.h" + #include "exp_command.h" /* for ExpState defs */ + #include "exp_event.h" ++#include "exp_log.h" + + typedef struct ThreadSpecificData { + int rr; /* round robin ptr */ + } ThreadSpecificData; + +@@ -118,10 +119,13 @@ + exp_arm_background_channelhandler_force(esPtr); + break; + case disarm_req_while_blocked: + exp_disarm_background_channelhandler_force(esPtr); + break; ++ default: ++ expDiagLog("Unexpected value %d of bg-handler in %s", ++ esPtr->bg_status, __func__); + } + } + + /* this can only be called at the beginning of the bg handler in which */ + /* case we know the status must be "armed" */ + +Index: exp_inter.c +================================================================== +--- exp_inter.c ++++ exp_inter.c +@@ -402,12 +402,12 @@ + ExpState *esPtr, + int skipBytes, + int matchBytes) + { + int seenBytes; /* either printed or echoed */ +- int echoBytes; +- int offsetBytes; ++ int echoBytes = 0; ++ int offsetBytes = 0; + + /* write is unlikely to fail, since we just read from same descriptor */ + seenBytes = esPtr->printed + esPtr->echoed; + if (skipBytes >= seenBytes) { + echoBytes = matchBytes; +@@ -704,13 +704,10 @@ + return 0; + } + + #define finish(x) { status = x; goto done; } + +-static char return_cmd[] = "return"; +-static char interpreter_cmd[] = "interpreter"; +- + /*ARGSUSED*/ + int + Exp_InteractObjCmd( + ClientData clientData, + Tcl_Interp *interp, +@@ -1342,19 +1339,19 @@ + for (;;) { + int te; /* result of Tcl_Eval */ + int rc; /* return code from ready. This is further refined by matcher. */ + int cc; /* # of chars from read() */ + struct action *action = 0; +- time_t previous_time; ++ time_t previous_time = 0; + time_t current_time; +- int matchLen; /* # of chars matched */ ++ int matchLen = 0; /* # of chars matched */ + int skip; /* # of chars not involved in match */ + int print; /* # of chars to print */ + int oldprinted; /* old version of u->printed */ + int change; /* if action requires cooked mode */ + int attempt_match = TRUE; +- struct input *soonest_input; ++ struct input *soonest_input = NULL; + int timeout; /* current as opposed to default_timeout */ + Tcl_Time temp_time; + + /* calculate how long to wait */ + /* by finding shortest remaining timeout */ + +Index: exp_log.c +================================================================== +--- exp_log.c ++++ exp_log.c +@@ -88,10 +88,12 @@ + int wc; + ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + + if (esPtr->valid) + wc = expWriteCharsUni(esPtr,buf,lenChars); ++ else ++ wc = -1; + + if (tsdPtr->logChannel && ((esPtr->fdout == 1) || expDevttyIs(esPtr))) { + Tcl_DString ds; + Tcl_DStringInit (&ds); + Tcl_UniCharToUtfDString (buf,lenChars,&ds); + +Index: exp_pty.c +================================================================== +--- exp_pty.c ++++ exp_pty.c +@@ -133,11 +133,13 @@ + alarm(0); + return(cc); + } + + static RETSIGTYPE (*oldAlarmHandler)(); ++#ifndef O_NOCTTY + static RETSIGTYPE (*oldHupHandler)(); ++#endif + static time_t current_time; /* time when testing began */ + + /* if TRUE, begin testing, else end testing */ + /* returns -1 for failure, 0 for success */ + int + +Index: exp_trap.c +================================================================== +--- exp_trap.c ++++ exp_trap.c +@@ -295,15 +295,14 @@ + return -1; + } + + /*ARGSUSED*/ + int +-Exp_TrapObjCmd(clientData, interp, objc, objv) +-ClientData clientData; +-Tcl_Interp *interp; +-int objc; +-Tcl_Obj *CONST objv[]; ++Exp_TrapObjCmd(ClientData clientData, ++ Tcl_Interp *interp, ++ int objc, ++ Tcl_Obj *CONST objv[]) + { + char *action = 0; + int n; /* number of signals in list */ + Tcl_Obj **list; /* list of signals */ + char *arg; +@@ -317,11 +316,13 @@ + Tcl_Interp *new_interp = interp;/* interp in which to evaluate */ + /* action when signal occurs */ + + objc--; objv++; + +- while (objc) { ++ if (objc <= 0) goto usage_error; ++ ++ do { + arg = Tcl_GetString(*objv); + + if (streq(arg,"-code")) { + objc--; objv++; + new_code = TRUE; +@@ -336,11 +337,11 @@ + show_number = TRUE; + } else if (streq(arg,"-max")) { + objc--; objv++; + show_max = TRUE; + } else break; +- } ++ } while(objc); + + if (show_name || show_number || show_max) { + if (objc > 0) goto usage_error; + if (show_max) { + Tcl_SetObjResult(interp,Tcl_NewIntObj(NSIG-1)); + +Index: exp_tty.c +================================================================== +--- exp_tty.c ++++ exp_tty.c +@@ -583,22 +583,24 @@ + char buf[MAX_ARGLIST]; + char *bufp = buf; + int total_len = 0, arg_len; + + int stty_args_recognized = TRUE; +- int cmd_is_stty = FALSE; ++ int cmd_is_stty; + int cooked = FALSE; +- int was_raw, was_echo; ++ const char *was_raw = "-raw", *was_echo = "-echo"; + + if (argc == 1) return TCL_OK; + +- if (streq(argv[1],"stty")) { ++ cmd_is_stty = streq(argv[1],"stty"); ++ if (cmd_is_stty) { + expDiagLogU("system stty is deprecated, use stty\r\n"); + +- cmd_is_stty = TRUE; +- was_raw = exp_israw(); +- was_echo = exp_isecho(); ++ if (exp_israw()) ++ was_raw++; ++ if (exp_isecho()) ++ was_echo++; + } + + if (argc > 2 && cmd_is_stty) { + exp_ioctled_devtty = TRUE; + +@@ -633,15 +635,11 @@ + } + exp_error(interp,"system stty: ioctl(user): %s\r\n",Tcl_PosixError(interp)); + return(TCL_ERROR); + } + if (cmd_is_stty) { +- char buf [11]; +- sprintf(buf,"%sraw %secho", +- (was_raw?"":"-"), +- (was_echo?"":"-")); +- Tcl_SetResult (interp, buf, TCL_VOLATILE); ++ Tcl_AppendResult (interp, was_raw, " ", was_echo, NULL); + } + return(TCL_OK); + } + } + +@@ -697,15 +695,11 @@ + tty_cooked = tty_current; + } + } + + if (cmd_is_stty) { +- char buf [11]; +- sprintf(buf,"%sraw %secho", +- (was_raw?"":"-"), +- (was_echo?"":"-")); +- Tcl_SetResult (interp, buf, TCL_VOLATILE); ++ Tcl_AppendResult (interp, was_raw, " ", was_echo, NULL); + } + + /* following macros stolen from Tcl's tclUnix.h file */ + /* we can't include the whole thing because it depends on other macros */ + /* that come out of Tcl's Makefile, sigh */ + +Index: exp_tty.h +================================================================== +--- exp_tty.h ++++ exp_tty.h +@@ -17,13 +17,14 @@ + + void exp_tty_raw(int set); + void exp_tty_echo(int set); + void exp_tty_break(Tcl_Interp *interp, int fd); + int exp_tty_raw_noecho(Tcl_Interp *interp, exp_tty *tty_old, int *was_raw, int *was_echo); ++int exp_tty_cooked_echo(Tcl_Interp *interp, exp_tty *tty_old, int *was_raw, int *was_echo); + int exp_israw(void); + int exp_isecho(void); + + void exp_tty_set(Tcl_Interp *interp, exp_tty *tty, int raw, int echo); + int exp_tty_set_simple(exp_tty *tty); + int exp_tty_get_simple(exp_tty *tty); + + #endif /* __EXP_TTY_H__ */ + +Index: exp_win.c +================================================================== +--- exp_win.c ++++ exp_win.c +@@ -76,24 +76,24 @@ + #endif + + static exp_winsize winsize = {0, 0}; + static exp_winsize win2size = {0, 0}; + +-int exp_window_size_set(fd) +-int fd; ++int exp_window_size_set(int fd) + { ++ return + #ifdef TIOCSWINSZ + ioctl(fd,TIOCSWINSZ,&winsize); + #endif + #if defined(TIOCSSIZE) && !defined(TIOCSWINSZ) + ioctl(fd,TIOCSSIZE,&winsize); + #endif + } + +-int exp_window_size_get(fd) +-int fd; ++int exp_window_size_get(int fd) + { ++ return + #ifdef TIOCGWINSZ + ioctl(fd,TIOCGWINSZ,&winsize); + #endif + #if defined(TIOCGSIZE) && !defined(TIOCGWINSZ) + ioctl(fd,TIOCGSIZE,&winsize); +@@ -103,12 +103,11 @@ + winsize.columns = 0; + #endif + } + + void +-exp_win_rows_set(rows) +-char *rows; ++exp_win_rows_set(const char *rows) + { + winsize.rows = atoi(rows); + exp_window_size_set(exp_dev_tty); + } + +@@ -120,12 +119,11 @@ + sprintf(rows,"%d",winsize.rows); + return rows; + } + + void +-exp_win_columns_set(columns) +-char *columns; ++exp_win_columns_set(const char *columns) + { + winsize.columns = atoi(columns); + exp_window_size_set(exp_dev_tty); + } + +@@ -140,23 +138,23 @@ + + /* + * separate copy of everything above - used for handling user stty requests + */ + +-int exp_win2_size_set(fd) +-int fd; ++static void ++exp_win2_size_set(int fd) + { + #ifdef TIOCSWINSZ + ioctl(fd,TIOCSWINSZ,&win2size); + #endif + #if defined(TIOCSSIZE) && !defined(TIOCSWINSZ) + ioctl(fd,TIOCSSIZE,&win2size); + #endif + } + +-int exp_win2_size_get(fd) +-int fd; ++static void ++exp_win2_size_get(int fd) + { + #ifdef TIOCGWINSZ + ioctl(fd,TIOCGWINSZ,&win2size); + #endif + #if defined(TIOCGSIZE) && !defined(TIOCGWINSZ) +@@ -163,22 +161,19 @@ + ioctl(fd,TIOCGSIZE,&win2size); + #endif + } + + void +-exp_win2_rows_set(fd,rows) +-int fd; +-char *rows; ++exp_win2_rows_set(int fd,const char *rows) + { + exp_win2_size_get(fd); + win2size.rows = atoi(rows); + exp_win2_size_set(fd); + } + + char* +-exp_win2_rows_get(fd) +-int fd; ++exp_win2_rows_get(int fd) + { + static char rows [20]; + exp_win2_size_get(fd); + sprintf(rows,"%d",win2size.rows); + #if !defined(EXP_WIN) +@@ -187,22 +182,19 @@ + #endif + return rows; + } + + void +-exp_win2_columns_set(fd,columns) +-int fd; +-char *columns; ++exp_win2_columns_set(int fd,const char *columns) + { + exp_win2_size_get(fd); + win2size.columns = atoi(columns); + exp_win2_size_set(fd); + } + + char* +-exp_win2_columns_get(fd) +-int fd; ++exp_win2_columns_get(int fd) + { + static char columns [20]; + exp_win2_size_get(fd); + sprintf(columns,"%d",win2size.columns); + return columns; + +Index: exp_win.h +================================================================== +--- exp_win.h ++++ exp_win.h +@@ -9,14 +9,14 @@ + #include /* For _ANSI_ARGS_ */ + + int exp_window_size_set(); + int exp_window_size_get(); + +-void exp_win_rows_set _ANSI_ARGS_ ((char* rows)); ++void exp_win_rows_set _ANSI_ARGS_ ((const char* rows)); + char* exp_win_rows_get _ANSI_ARGS_ ((void)); +-void exp_win_columns_set _ANSI_ARGS_ ((char* columns)); ++void exp_win_columns_set _ANSI_ARGS_ ((const char* columns)); + char* exp_win_columns_get _ANSI_ARGS_ ((void)); + +-void exp_win2_rows_set _ANSI_ARGS_ ((int fd, char* rows)); ++void exp_win2_rows_set _ANSI_ARGS_ ((int fd, const char* rows)); + char* exp_win2_rows_get _ANSI_ARGS_ ((int fd)); +-void exp_win2_columns_set _ANSI_ARGS_ ((int fd, char* columns)); ++void exp_win2_columns_set _ANSI_ARGS_ ((int fd, const char* columns)); + char* exp_win2_columns_get _ANSI_ARGS_ ((int fd)); + +Index: expect.c +================================================================== +--- expect.c ++++ expect.c +@@ -2535,28 +2535,28 @@ + int i; /* misc temporary */ + struct exp_cmd_descriptor eg; + struct exp_state_list *state_list; /* list of ExpStates to watch */ + struct exp_state_list *slPtr; /* temp for interating over state_list */ + ExpState **esPtrs; +- int mcount; /* number of esPtrs to watch */ ++ int mcount = 0; /* number of esPtrs to watch */ + + struct eval_out eo; /* final case of interest */ + + int result; /* Tcl result */ + + time_t start_time_total; /* time at beginning of this procedure */ + time_t start_time = 0; /* time when restart label hit */ + time_t current_time = 0; /* current time (when we last looked)*/ +- time_t end_time; /* future time at which to give up */ ++ time_t end_time = 0; /* future time at which to give up */ + + ExpState *last_esPtr; /* for differentiating when multiple f's */ + /* to print out better debugging messages */ + int last_case; /* as above but for case */ + int first_time = 1; /* if not "restarted" */ + + int key; /* identify this expect command instance */ +- int configure_count; /* monitor exp_configure_count */ ++ int configure_count = 0; /* monitor exp_configure_count */ + + int timeout; /* seconds */ + int remtime; /* remaining time in timeout */ + int reset_timer; /* should timer be reset after continue? */ + Tcl_Time temp_time; +@@ -2945,16 +2945,18 @@ + if (!chan) { + esPtr = expStateCurrent(interp,0,0,0); + } else { + esPtr = expStateFromChannelName(interp,chan,0,0,0,(char*)cmd); + } +- if (!esPtr) return(TCL_ERROR); ++ if (!esPtr) ++ return(TCL_ERROR); ++ ++ *esOut = esPtr; + } + + *at = i; + *Default = def; +- *esOut = esPtr; + return TCL_OK; + } + + + /*ARGSUSED*/ + +Index: pty_termios.c +================================================================== +--- pty_termios.c ++++ pty_termios.c +@@ -61,10 +61,18 @@ + #ifdef HAVE_INTTYPES_H + # include + #endif + #include + #include ++#if defined(HAVE_OPENPTY) ++#include ++#if defined(HAVE_LIBUTIL_H) ++#include ++#else ++#include ++#endif ++#endif + + #ifdef NO_STDLIB_H + #include "../compat/stdlib.h" + #else + #include +@@ -100,10 +108,11 @@ + #include "exp_win.h" + + #include "exp_tty_in.h" + #include "exp_rename.h" + #include "exp_pty.h" ++#include "exp_int.h" + + void expDiagLog(); + void expDiagLogPtr(); + + #include +@@ -370,15 +379,18 @@ + #endif + + int + exp_getptymaster() + { ++#if !defined(HAVE_CONVEX_GETPTY) && !defined(HAVE_PTYM) && !defined(HAVE_SCO_CLIST_PTYS) && defined(TEST_PTY) + char *hex, *bank; +- struct stat stat_buf; ++#endif + int master = -1; + int slave = -1; ++#ifdef HAVE_SCO_CLIST_PTYS + int num; ++#endif + + exp_pty_error = 0; + + #define TEST_PTY 1 + +@@ -427,10 +439,11 @@ + #if defined(HAVE_PTC) && !defined(HAVE__GETPTY) /* old SGI, version 3 */ + #undef TEST_PTY + master = open("/dev/ptc", O_RDWR); + if (master >= 0) { + int ptynum; ++ struct stat stat_buf; + + if (fstat(master, &stat_buf) < 0) { + close(master); + return(-1); + } +@@ -633,12 +646,14 @@ + exp_getptyslave( + int ttycopy, + int ttyinit, + CONST char *stty_args) + { +- int slave, slave2; ++ int slave; ++#if defined(HAVE_PTMX_BSD) + char buf[10240]; ++#endif + + if (0 > (slave = open(slave_name, O_RDWR))) { + static char buf[500]; + exp_pty_error = buf; + sprintf(exp_pty_error,"open(%s,rw) = %d (%s)",slave_name,slave,expErrnoMsg(errno)); +