Ticket #5570: expect-5.45.4-tcl9-DRAFT.patch

File expect-5.45.4-tcl9-DRAFT.patch, 42.2 KB (added by Xi Ruoyao, 8 weeks ago)
  • Dbg.c

    diff --git a/Dbg.c b/Dbg.c
    index c7689e5..993cb1b 100644
    a b char *argv[];  
    362362        static char buf_basic[DEFAULT_WIDTH+1]; /* basic buffer */
    363363        static char *buf = buf_basic;
    364364        int space;              /* space remaining in buf */
    365         int len;
     365        Tcl_Size len;
    366366        char *bufp;
    367367        int proc;               /* if current command is "proc" */
    368368        int arg_index;
    char *argv[];  
    398398#if TCL_MAJOR_VERSION >= 8
    399399                                              -1,
    400400#endif
    401                                 &elementPtr,&nextPtr,(int *)0,(int *)0);
     401                                &elementPtr,&nextPtr,NULL,NULL);
    402402                        if (*elementPtr == '\0') wrap = TRUE;
    403403                        else if (*nextPtr == '\0') wrap = FALSE;
    404404                        else wrap = TRUE;
    Tcl_Obj *objv[];  
    443443{
    444444    char **argv;
    445445    int argc;
    446     int len;
     446    Tcl_Size len;
    447447    argv = (char **)ckalloc(objc+1 * sizeof(char *));
    448448    for (argc=0 ; argc<objc ; argc++) {
    449449        argv[argc] = Tcl_GetStringFromObj(objv[argc],&len);
  • exp_chan.c

    diff --git a/exp_chan.c b/exp_chan.c
    index 944200a..377253a 100644
    a b  
    4040extern int              expSetBlockModeProc _ANSI_ARGS_((int fd, int mode));
    4141static int              ExpBlockModeProc _ANSI_ARGS_((ClientData instanceData,
    4242                            int mode));
    43 static int              ExpCloseProc _ANSI_ARGS_((ClientData instanceData,
    44                             Tcl_Interp *interp));
     43static int              ExpClose2Proc _ANSI_ARGS_((ClientData instanceData,
     44                            Tcl_Interp *interp, int flags));
    4545static int              ExpInputProc _ANSI_ARGS_((ClientData instanceData,
    4646                            char *buf, int toRead, int *errorCode));
    4747static int              ExpOutputProc _ANSI_ARGS_((
    48                             ClientData instanceData, char *buf, int toWrite,
     48                            ClientData instanceData, const char *buf, int toWrite,
    4949                            int *errorCode));
    5050static void             ExpWatchProc _ANSI_ARGS_((ClientData instanceData,
    5151                            int mask));
    void exp_background_channelhandler _ANSI_ARGS_((ClientData,  
    5959 */
    6060
    6161Tcl_ChannelType expChannelType = {
    62     "exp",                              /* Type name. */
    63     TCL_CHANNEL_VERSION_2,
    64     ExpCloseProc,                       /* Close proc. */
    65     ExpInputProc,                       /* Input proc. */
    66     ExpOutputProc,                      /* Output proc. */
    67     NULL,                               /* Seek proc. */
    68     NULL,                               /* Set option proc. */
    69     NULL,                               /* Get option proc. */
    70     ExpWatchProc,                       /* Initialize notifier. */
    71     ExpGetHandleProc,                   /* Get OS handles out of channel. */
    72     NULL,                               /* Close2 proc */
    73     ExpBlockModeProc,                   /* Set blocking/nonblocking mode.*/
     62    .typeName = "exp",
     63    .version = TCL_CHANNEL_VERSION_5,
     64    .inputProc = ExpInputProc,
     65    .outputProc = ExpOutputProc,
     66    .watchProc = ExpWatchProc,
     67    .getHandleProc = ExpGetHandleProc,
     68    .close2Proc = ExpClose2Proc,
     69    .blockModeProc = ExpBlockModeProc,
    7470};
    7571
    7672typedef struct ThreadSpecificData {
    ExpInputProc(instanceData, buf, toRead, errorCodePtr)  
    261257static int
    262258ExpOutputProc(instanceData, buf, toWrite, errorCodePtr)
    263259    ClientData instanceData;            /* Exp state. */
    264     char *buf;                          /* The data buffer. */
     260    const char *buf;                            /* The data buffer. */
    265261    int toWrite;                        /* How many bytes to write? */
    266262    int *errorCodePtr;                  /* Where to store error code. */
    267263{
    ExpOutputProc(instanceData, buf, toWrite, errorCodePtr)  
    312308
    313309/*ARGSUSED*/
    314310static int
    315 ExpCloseProc(instanceData, interp)
    316     ClientData instanceData;    /* Exp state. */
    317     Tcl_Interp *interp;         /* For error reporting - unused. */
     311ExpClose2Proc(
     312    ClientData instanceData,    /* Exp state. */
     313    Tcl_Interp *interp,         /* For error reporting - unused. */
     314    int flags)
    318315{
     316    if (flags & (TCL_CLOSE_READ | TCL_CLOSE_WRITE))
     317        return EINVAL;
     318
    319319    ExpState *esPtr = (ExpState *) instanceData;
    320320    ExpState **nextPtrPtr;
    321321    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    expSizeZero(esPtr)  
    502502int
    503503expWriteChars(esPtr,buffer,lenBytes)
    504504     ExpState *esPtr;
    505      char *buffer;
     505     const char *buffer;
    506506     int lenBytes;
    507507{
    508508  int rc;
  • exp_command.c

    diff --git a/exp_command.c b/exp_command.c
    index b554b18..680ba15 100644
    a b expStateCurrent(  
    191191{
    192192    static char *user_spawn_id = "exp0";
    193193
    194     char *name = exp_get_var(interp,SPAWN_ID_VARNAME);
     194    const char *name = exp_get_var(interp,SPAWN_ID_VARNAME);
    195195    if (!name) name = user_spawn_id;
    196196
    197197    return expStateFromChannelName(interp,name,opened,adjust,any,SPAWN_ID_VARNAME);
    expStateCheck(  
    203203    ExpState *esPtr,
    204204    int open,
    205205    int adjust,
    206     char *msg)
     206    const char *msg)
    207207{
    208208    if (open && !esPtr->open) {
    209209        exp_error(interp,"%s: spawn id %s not open",msg,esPtr->name);
    expStateCheck(  
    216216ExpState *
    217217expStateFromChannelName(
    218218    Tcl_Interp *interp,
    219     char *name,
     219    const char *name,
    220220    int open,
    221221    int adjust,
    222222    int any,
    223     char *msg)
     223    const char *msg)
    224224{
    225225    ExpState *esPtr;
    226226    Tcl_Channel channel;
    exp_trap_on(int master)  
    284284}
    285285
    286286int
    287 exp_trap_off(char *name)
     287exp_trap_off(const char *name)
    288288{
    289289#ifdef HAVE_PTYTRAP
    290290    ExpState *esPtr;
    exp_close(  
    357357             */
    358358
    359359            ThreadSpecificData* tsdPtr = TCL_TSD_INIT(&dataKey);
    360             char*               cName  = Tcl_GetChannelName(esPtr->chan_orig->channel_orig);
     360            const char*         cName  = Tcl_GetChannelName(esPtr->chan_orig->channel_orig);
    361361            Tcl_HashEntry*      entry  = Tcl_FindHashEntry(&tsdPtr->origins,cName);
    362362            ExpOrigin*          orig   = (ExpOrigin*) Tcl_GetHashValue(entry);
    363363
    static int  
    575575Exp_SpawnObjCmd(
    576576    ClientData clientData,
    577577    Tcl_Interp *interp,
    578     int objc,
     578    Tcl_Size objc,
    579579    Tcl_Obj *CONST objv[])              /* Argument objects. */
    580580{
    581581    ExpState *esPtr = 0;
    static int  
    13701370Exp_ExpPidObjCmd(
    13711371    ClientData clientData,
    13721372    Tcl_Interp *interp,
    1373     int objc,
     1373    Tcl_Size objc,
    13741374    Tcl_Obj *CONST objv[])              /* Argument objects. */
    13751375{
    13761376    char *chanName = 0;
    static int  
    14201420Exp_GetpidDeprecatedObjCmd(
    14211421    ClientData clientData,
    14221422    Tcl_Interp *interp,
    1423     int objc,
     1423    Tcl_Size objc,
    14241424    Tcl_Obj *CONST objv[])              /* Argument objects. */
    14251425{
    14261426    expDiagLog("getpid is deprecated, use pid\r\n");
    static int  
    14331433Exp_SleepObjCmd(
    14341434    ClientData clientData,
    14351435    Tcl_Interp *interp,
    1436     int objc,
     1436    Tcl_Size objc,
    14371437    Tcl_Obj *CONST objv[])              /* Argument objects. */
    14381438{
    14391439    double s;
    static int  
    14911491slow_write(
    14921492    Tcl_Interp *interp,
    14931493    ExpState *esPtr,
    1494     char *buffer,
     1494    const char *buffer,
    14951495    int rembytes,
    14961496    struct slow_arg *arg)
    14971497{
    slow_write(  
    14991499
    15001500    while (rembytes > 0) {
    15011501        int i, bytelen, charlen;
    1502         char *p;
     1502        const char *p;
    15031503
    15041504        p = buffer;
    15051505        charlen = (arg->size<rembytes?arg->size:rembytes);
    static int  
    15991599human_write(
    16001600    Tcl_Interp *interp,
    16011601    ExpState *esPtr,
    1602     char *buffer,
     1602    const char *buffer,
    16031603    struct human_arg *arg)
    16041604{
    1605     char *sp;
     1605    const char *sp;
    16061606    int size;
    16071607    float t;
    16081608    float alpha;
    exp_i_parse_states(  
    18371837{
    18381838    struct ExpState *esPtr;
    18391839    char *p = i->value;
    1840     int argc;
    1841     char **argv;
     1840    Tcl_Size argc;
     1841    const char **argv;
    18421842    int j;
    18431843
    18441844    if (Tcl_SplitList(NULL, p, &argc, &argv) != TCL_OK) goto error;
    exp_i_update(  
    18641864    Tcl_Interp *interp,
    18651865    struct exp_i *i)
    18661866{
    1867     char *p;    /* string representation of list of spawn ids */
     1867    const char *p;      /* string representation of list of spawn ids */
    18681868
    18691869    if (i->direct == EXP_INDIRECT) {
    18701870        p = Tcl_GetVar(interp,i->variable,TCL_GLOBAL_ONLY);
    static int  
    19161916Exp_SendLogObjCmd(
    19171917    ClientData clientData,
    19181918    Tcl_Interp *interp,
    1919     int objc,
     1919    Tcl_Size objc,
    19201920    Tcl_Obj *CONST objv[])              /* Argument objects. */
    19211921{
    19221922    static char* options[] = { "--", NULL };
    static int  
    19601960Exp_SendObjCmd(
    19611961    ClientData clientData,
    19621962    Tcl_Interp *interp,
    1963     int objc,
     1963    Tcl_Size objc,
    19641964    Tcl_Obj *CONST objv[])
    19651965{
    19661966    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    Exp_SendObjCmd(  
    19761976#define SEND_STYLE_BREAK        0x20
    19771977    int send_style = SEND_STYLE_PLAIN;
    19781978    int want_cooked = TRUE;
    1979     char *string;               /* string to send */
    1980     int len = -1;               /* length of string to send */
     1979    const char *string;         /* string to send */
     1980    Tcl_Size len = -1;          /* length of string to send */
    19811981    int zeros;          /* count of how many ascii zeros to send */
    19821982
    19831983    char *chanName = 0;
    static int  
    21582158Exp_LogFileObjCmd(
    21592159    ClientData clientData,
    21602160    Tcl_Interp *interp,
    2161     int objc,
     2161    Tcl_Size objc,
    21622162    Tcl_Obj *CONST objv[])              /* Argument objects. */
    21632163{
    21642164    static char resultbuf[1000];
    static int  
    22912291Exp_LogUserObjCmd(
    22922292    ClientData clientData,
    22932293    Tcl_Interp *interp,
    2294     int objc,
     2294    Tcl_Size objc,
    22952295    Tcl_Obj *CONST objv[])              /* Argument objects. */
    22962296{
    22972297    int old_loguser = expLogUserGet();
    static int  
    23232323Exp_DebugObjCmd(
    23242324    ClientData clientData,
    23252325    Tcl_Interp *interp,
    2326     int objc,
     2326    Tcl_Size objc,
    23272327    Tcl_Obj *CONST objv[])              /* Argument objects. */
    23282328{
    23292329    int now = FALSE;    /* soon if FALSE, now if TRUE */
    static int  
    23932393Exp_ExpInternalObjCmd(
    23942394    ClientData clientData,
    23952395    Tcl_Interp *interp,
    2396     int objc,
     2396    Tcl_Size objc,
    23972397    Tcl_Obj *CONST objv[])              /* Argument objects. */
    23982398{
    23992399    int newChannel = FALSE;
    static int  
    24732473Exp_ExitObjCmd(
    24742474    ClientData clientData,
    24752475    Tcl_Interp *interp,
    2476     int objc,
     2476    Tcl_Size objc,
    24772477    Tcl_Obj *CONST objv[])              /* Argument objects. */
    24782478{
    24792479    int value = 0;
    Exp_ExitObjCmd(  
    24862486            objc--;
    24872487            objv++;
    24882488            if (objc) {
    2489                 int len;
     2489                Tcl_Size len;
    24902490                char* act = Tcl_GetStringFromObj (objv[0], &len);
    24912491
    24922492                if (exp_onexit_action)
    static int  
    25292529Exp_ConfigureObjCmd(
    25302530    ClientData clientData,
    25312531    Tcl_Interp *interp,
    2532     int objc,
     2532    Tcl_Size objc,
    25332533    Tcl_Obj *CONST objv[])      /* Argument objects. */
    25342534{
    25352535    /* Magic configuration stuff. */
    static int  
    25702570Exp_CloseObjCmd(
    25712571    ClientData clientData,
    25722572    Tcl_Interp *interp,
    2573     int objc,
     2573    Tcl_Size objc,
    25742574    Tcl_Obj *CONST objv[])      /* Argument objects. */
    25752575{
    25762576    int onexec_flag = FALSE;    /* true if -onexec seen */
    static int  
    27082708Exp_StraceObjCmd(
    27092709    ClientData clientData,
    27102710    Tcl_Interp *interp,
    2711     int objc,
     2711    Tcl_Size objc,
    27122712    Tcl_Obj *CONST objv[])              /* Argument objects. */
    27132713{
    27142714    static int trace_level = 0;
    static int  
    28622862Exp_WaitObjCmd(
    28632863    ClientData clientData,
    28642864    Tcl_Interp *interp,
    2865     int objc,
     2865    Tcl_Size objc,
    28662866    Tcl_Obj *CONST objv[])              /* Argument objects. */
    28672867{
    28682868    char *chanName = 0;
    static int  
    30753075Exp_ForkObjCmd(
    30763076    ClientData clientData,
    30773077    Tcl_Interp *interp,
    3078     int objc,
     3078    Tcl_Size objc,
    30793079    Tcl_Obj *CONST objv[])              /* Argument objects. */
    30803080{
    30813081    int rc;
    static int  
    31093109Exp_DisconnectObjCmd(
    31103110    ClientData clientData,
    31113111    Tcl_Interp *interp,
    3112     int objc,
     3112    Tcl_Size objc,
    31133113    Tcl_Obj *CONST objv[])              /* Argument objects. */
    31143114{
    31153115    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    static int  
    32193219Exp_OverlayObjCmd(
    32203220    ClientData clientData,
    32213221    Tcl_Interp *interp,
    3222     int objc,
     3222    Tcl_Size objc,
    32233223    Tcl_Obj *CONST objv[])              /* Argument objects. */
    32243224{
    32253225    int newfd, oldfd;
    int  
    33103310Exp_InterpreterObjCmd(
    33113311    ClientData clientData,
    33123312    Tcl_Interp *interp,
    3313     int objc,
     3313    Tcl_Size objc,
    33143314    Tcl_Obj *CONST objv[])              /* Argument objects. */
    33153315{
    33163316    Tcl_Obj *eofObj = 0;
    int  
    33583358Exp_ExpContinueObjCmd(
    33593359    ClientData clientData,
    33603360    Tcl_Interp *interp,
    3361     int objc,
     3361    Tcl_Size objc,
    33623362    Tcl_Obj *CONST objv[])              /* Argument objects. */
    33633363{
    33643364    if (objc == 1) {
    int  
    33783378Exp_InterReturnObjCmd(
    33793379    ClientData clientData,
    33803380    Tcl_Interp *interp,
    3381     int objc,
     3381    Tcl_Size objc,
    33823382    Tcl_Obj *CONST objv[])
    33833383{
    33843384    /* let Tcl's return command worry about args */
    int  
    33993399Exp_OpenObjCmd(
    34003400    ClientData clientData,
    34013401    Tcl_Interp *interp,
    3402     int objc,
     3402    Tcl_Size objc,
    34033403    Tcl_Obj *CONST objv[])              /* Argument objects. */
    34043404{
    34053405    ExpState *esPtr;
    exp_create_commands(interp,c)  
    35173517                !(Tcl_FindHashEntry(&globalNsPtr->cmdTable,c->name) ||
    35183518                        Tcl_FindHashEntry(&currNsPtr->cmdTable,c->name))) {
    35193519            if (c->objproc)
    3520                 Tcl_CreateObjCommand(interp,c->name,
     3520                Tcl_CreateObjCommand2(interp,c->name,
    35213521                        c->objproc,c->data,exp_deleteObjProc);
    35223522            else
    35233523                Tcl_CreateCommand(interp,c->name,c->proc,
    exp_create_commands(interp,c)  
    35293529                && !(c->flags & EXP_NOPREFIX)) {
    35303530            sprintf(cmdnamebuf,"exp_%s",c->name);
    35313531            if (c->objproc)
    3532                 Tcl_CreateObjCommand(interp,cmdnamebuf,c->objproc,c->data,
     3532                Tcl_CreateObjCommand2(interp,cmdnamebuf,c->objproc,c->data,
    35333533                        exp_deleteObjProc);
    35343534            else
    35353535                Tcl_CreateCommand(interp,cmdnamebuf,c->proc,
  • exp_command.h

    diff --git a/exp_command.h b/exp_command.h
    index d30d911..e46d73c 100644
    a b would appreciate credit if this program or parts of it are used.  
    2424#endif
    2525
    2626#include <tclPort.h>
     27#include "expect.h"
    2728
    2829#define EXP_CHANNELNAMELEN (16 + TCL_INTEGER_SPACE)
    2930
    30 EXTERN char *           exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *));
     31EXTERN const char *             exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *));
    3132
    3233EXTERN int exp_default_match_max;
    3334EXTERN int exp_default_parity;
    extern Tcl_ChannelType expChannelType;  
    210211#define EXP_INDIRECT    2
    211212
    212213EXTERN void             expAdjust _ANSI_ARGS_((ExpState *));
    213 EXTERN int              expWriteChars _ANSI_ARGS_((ExpState *,char *,int));
     214EXTERN int              expWriteChars _ANSI_ARGS_((ExpState *,const char *,int));
    214215EXTERN int              expWriteCharsUni _ANSI_ARGS_((ExpState *,Tcl_UniChar *,int));
    215216EXTERN void             exp_buffer_shuffle _ANSI_ARGS_((Tcl_Interp *,ExpState *,int,char *,char *));
    216217EXTERN int              exp_close _ANSI_ARGS_((Tcl_Interp *,ExpState *));
    EXTERN void exp_close_all _ANSI_ARGS_((Tcl_Interp *));  
    218219EXTERN void             exp_ecmd_remove_fd_direct_and_indirect
    219220                                _ANSI_ARGS_((Tcl_Interp *,int));
    220221EXTERN void             exp_trap_on _ANSI_ARGS_((int));
    221 EXTERN int              exp_trap_off _ANSI_ARGS_((char *));
     222EXTERN int              exp_trap_off _ANSI_ARGS_((const char *));
    222223
    223224EXTERN void             exp_strftime(char *format, const struct tm *timeptr,Tcl_DString *dstring);
    224225
    EXTERN int exp_i_update _ANSI_ARGS_((Tcl_Interp *,  
    308309
    309310struct exp_cmd_data {
    310311        char            *name;
    311         Tcl_ObjCmdProc  *objproc;
     312        Tcl_ObjCmdProc2 *objproc;
    312313        Tcl_CmdProc     *proc;
    313314        ClientData      data;
    314315        int             flags;
    EXTERN void exp_init_trap_cmds _ANSI_ARGS_((Tcl_Interp *));  
    323324EXTERN void             exp_init_interact_cmds _ANSI_ARGS_((Tcl_Interp *));
    324325EXTERN void             exp_init_tty_cmds();
    325326
    326 EXTERN ExpState *       expStateCheck _ANSI_ARGS_((Tcl_Interp *,ExpState *,int,int,char *));
     327EXTERN ExpState *       expStateCheck _ANSI_ARGS_((Tcl_Interp *,ExpState *,int,int,const char *));
    327328EXTERN ExpState *       expStateCurrent _ANSI_ARGS_((Tcl_Interp *,int,int,int));
    328 EXTERN ExpState *       expStateFromChannelName _ANSI_ARGS_((Tcl_Interp *,char *,int,int,int,char *));
     329EXTERN ExpState *       expStateFromChannelName _ANSI_ARGS_((Tcl_Interp *,const char *,int,int,int,const char *));
    329330EXTERN void             expStateFree _ANSI_ARGS_((ExpState *));
    330331
    331332EXTERN ExpState *       expCreateChannel _ANSI_ARGS_((Tcl_Interp *,int,int,int));
  • exp_int.h

    diff --git a/exp_int.h b/exp_int.h
    index a7cd496..a5f3427 100644
    a b would appreciate credit if this program or parts of it are used.  
    2020#endif
    2121
    2222#include <errno.h>
     23#include "expect.h"
    2324
    2425void    exp_console_set     _ANSI_ARGS_((void));
    2526void    expDiagLogPtrSet    _ANSI_ARGS_((void (*)_ANSI_ARGS_((char *))));
    void expDiagLogPtr _ANSI_ARGS_((char *));  
    2728void    expDiagLogPtrX      _ANSI_ARGS_((char *,int));
    2829void    expDiagLogPtrStr    _ANSI_ARGS_((char *,char *));
    2930void    expDiagLogPtrStrStr _ANSI_ARGS_((char *,char *,char *));
    30 void    expErrnoMsgSet      _ANSI_ARGS_((char * (*) _ANSI_ARGS_((int))));
    31 char * expErrnoMsg    _ANSI_ARGS_((int));
     31void    expErrnoMsgSet      _ANSI_ARGS_((const char * (*) _ANSI_ARGS_((int))));
     32const char * expErrnoMsg    _ANSI_ARGS_((int));
    3233
    3334#ifdef NO_STDLIB_H
    3435#  include "../compat/stdlib.h"
  • exp_inter.c

    diff --git a/exp_inter.c b/exp_inter.c
    index 8802032..eba6be1 100644
    a b static char *  
    696696inter_updateproc(
    697697    ClientData clientData,
    698698    Tcl_Interp *interp, /* Interpreter containing variable. */
    699     char *name1,        /* Name of variable. */
    700     char *name2,        /* Second part of variable name. */
     699    const char *name1,  /* Name of variable. */
     700    const char *name2,  /* Second part of variable name. */
    701701    int flags)          /* Information about what happened. */
    702702{
    703703        exp_configure_count++;
    int  
    714714Exp_InteractObjCmd(
    715715    ClientData clientData,
    716716    Tcl_Interp *interp,
    717     int objc,
     717    Tcl_Size objc,
    718718    Tcl_Obj *CONST initial_objv[])              /* Argument objects. */
    719719{
    720720    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
  • exp_log.c

    diff --git a/exp_log.c b/exp_log.c
    index a0767ff..150d1af 100644
    a b expWriteBytesAndLogIfTtyU(esPtr,buf,lenChars)  
    110110
    111111void
    112112expLogDiagU(buf)
    113 char *buf;
     113const char *buf;
    114114{
    115115    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    116116
    expStdoutLog TCL_VARARGS_DEF(int,arg1)  
    191191/* use this function for logging the parent/child conversation */
    192192void
    193193expStdoutLogU(buf,force_stdout)
    194 char *buf;
     194const char *buf;
    195195int force_stdout;       /* override value of logUser */
    196196{
    197197    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    expErrorLog TCL_VARARGS_DEF(char *,arg1)  
    240240/*ARGSUSED*/
    241241void
    242242expErrorLogU(buf)
    243 char *buf;
     243const char *buf;
    244244{
    245245    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    246246
    expDiagWriteObj(obj)  
    401401/* write 8-bit bytes */
    402402void
    403403expDiagWriteBytes(str,len)
    404 char *str;
     404const char *str;
    405405int len;
    406406{
    407407    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    int len;  
    414414/* write UTF chars */
    415415void
    416416expDiagWriteChars(str,len)
    417 char *str;
     417const char *str;
    418418int len;
    419419{
    420420    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    expLogUserSet(logUser)  
    633633/* in diagnostic mode, "expect -d" */
    634634static char *
    635635expPrintifyReal(s)
    636 char *s;
     636const char *s;
    637637{
    638638        static int destlen = 0;
    639639        static char *dest = 0;
    expPrintifyObj(obj)  
    726726
    727727char *
    728728expPrintify(s) /* INTL */
    729 char *s;
     729const char *s;
    730730{
    731731    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    732732
  • exp_log.h

    diff --git a/exp_log.h b/exp_log.h
    index ca78386..2b9d4ee 100644
    a b  
    11/* exp_log.h */
    22
     3#include "expect.h"
     4
    35extern void             expErrorLog _ANSI_ARGS_(TCL_VARARGS(char *,fmt));
    4 extern void             expErrorLogU _ANSI_ARGS_((char *));
     6extern void             expErrorLogU _ANSI_ARGS_((const char *));
    57
    68extern void             expStdoutLog _ANSI_ARGS_(TCL_VARARGS(int,force_stdout));
    7 extern void             expStdoutLogU _ANSI_ARGS_((char *buf, int force_stdout));
     9extern void             expStdoutLogU _ANSI_ARGS_((const char *buf, int force_stdout));
    810
    911EXTERN void             expDiagInit _ANSI_ARGS_((void));
    1012EXTERN int              expDiagChannelOpen _ANSI_ARGS_((Tcl_Interp *,char *));
    EXTERN void expDiagChannelClose _ANSI_ARGS_((Tcl_Interp *));  
    1315EXTERN char *           expDiagFilename _ANSI_ARGS_((void));
    1416EXTERN int              expDiagToStderrGet _ANSI_ARGS_((void));
    1517EXTERN void             expDiagToStderrSet _ANSI_ARGS_((int));
    16 EXTERN void             expDiagWriteBytes _ANSI_ARGS_((char *,int));
    17 EXTERN void             expDiagWriteChars _ANSI_ARGS_((char *,int));
     18EXTERN void             expDiagWriteBytes _ANSI_ARGS_((const char *,int));
     19EXTERN void             expDiagWriteChars _ANSI_ARGS_((const char *,int));
    1820EXTERN void             expDiagWriteObj _ANSI_ARGS_((Tcl_Obj *));
    1921EXTERN void             expDiagLog _ANSI_ARGS_(TCL_VARARGS(char *,fmt));
    2022EXTERN void             expDiagLogU _ANSI_ARGS_((char *));
    2123
    22 EXTERN char *           expPrintify _ANSI_ARGS_((char *));
     24EXTERN char *           expPrintify _ANSI_ARGS_((const char *));
    2325EXTERN char *           expPrintifyUni _ANSI_ARGS_((Tcl_UniChar *,int));
    2426EXTERN char *           expPrintifyObj _ANSI_ARGS_((Tcl_Obj *));
    2527EXTERN void             expPrintf _ANSI_ARGS_(TCL_VARARGS(char *,fmt));
    EXTERN void expLogAllSet _ANSI_ARGS_((int));  
    3840EXTERN int              expLogAllGet _ANSI_ARGS_((void));
    3941EXTERN void             expLogToStdoutSet _ANSI_ARGS_((int));
    4042EXTERN int              expLogToStdoutGet _ANSI_ARGS_((void));
    41 EXTERN void             expLogDiagU _ANSI_ARGS_((char *));
     43EXTERN void             expLogDiagU _ANSI_ARGS_((const char *));
    4244EXTERN int              expWriteBytesAndLogIfTtyU _ANSI_ARGS_((ExpState *,Tcl_UniChar *,int));
    4345
    4446EXTERN int              expLogUserGet _ANSI_ARGS_((void));
  • exp_main_sub.c

    diff --git a/exp_main_sub.c b/exp_main_sub.c
    index 499c0ae..2b195a7 100644
    a b handle_eval_error(interp,check_for_nostack)  
    227227Tcl_Interp *interp;
    228228int check_for_nostack;
    229229{
    230         char *msg;
     230        const char *msg;
    231231
    232232        /* if errorInfo has something, print it */
    233233    /* else use what's in the interp result */
    int check_for_nostack;  
    253253        /* no \n at end, since ccmd will already have one. */
    254254        /* Actually, this is not true if command is last in */
    255255        /* file and has no newline after it, oh well */
    256         expErrorLogU(exp_cook(msg,(int *)0));
     256        expErrorLogU(exp_cook(msg,NULL));
    257257        expErrorLogU("\r\n");
    258258}
    259259
    Tcl_Obj *eofObj;  
    394394            case TCL_OK:
    395395                str = Tcl_GetStringResult(interp);
    396396                if (*str != 0) {
    397                     expStdoutLogU(exp_cook(str,(int *)0),1);
     397                    expStdoutLogU(exp_cook(str,NULL),1);
    398398                    expStdoutLogU("\r\n",1);
    399399                }
    400400                continue;
    Tcl_Interp *interp;  
    543543      return TCL_ERROR;
    544544    }
    545545#else
    546     if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
     546    if (Tcl_InitStubs(interp, "9.0", 0) == NULL) {
    547547      return TCL_ERROR;
    548548    }
    549549#endif
    char **argv;  
    713713                        exp_cmdlinecmds = TRUE;
    714714                        rc = Tcl_Eval(interp,optarg);
    715715                        if (rc != TCL_OK) {
    716                             expErrorLogU(exp_cook(Tcl_GetVar(interp,"errorInfo",TCL_GLOBAL_ONLY),(int *)0));
     716                            expErrorLogU(exp_cook(Tcl_GetVar(interp,"errorInfo",TCL_GLOBAL_ONLY),NULL));
    717717                            expErrorLogU("\r\n");
    718718                        }
    719719                        break;
    char **argv;  
    861861                expDiagLog("set argv0 \"%s\"\r\n",exp_argv0);
    862862        }
    863863
    864         args = Tcl_Merge(argc-optind,argv+optind);
     864        /* TODO: Is the cast safe? */
     865        args = Tcl_Merge(argc-optind,(const char **)(argv+optind));
    865866        expDiagLogU("set argv \"");
    866867        expDiagLogU(args);
    867868        expDiagLogU("\"\r\n");
  • exp_pty.c

    diff --git a/exp_pty.c b/exp_pty.c
    index 0970211..626d7a8 100644
    a b expDiagLogPtrStrStr(fmt,str1,str2)  
    351351  (*expDiagLogPtrVal)(buf);
    352352}
    353353
    354 static char *           (*expErrnoMsgVal) _ANSI_ARGS_((int));
     354static const char *             (*expErrnoMsgVal) _ANSI_ARGS_((int));
    355355
    356 char *
     356const char *
    357357expErrnoMsg(errorNo)
    358358int errorNo;
    359359{
    int errorNo;  
    362362
    363363void
    364364expErrnoMsgSet(fn)
    365      char * (*fn) _ANSI_ARGS_((int));
     365     const char * (*fn) _ANSI_ARGS_((int));
    366366{
    367367  expErrnoMsgVal = fn;
    368368}
  • exp_trap.c

    diff --git a/exp_trap.c b/exp_trap.c
    index 390e0e3..fe3d727 100644
    a b int code;  
    147147                Tcl_AsyncMark(async_handler);
    148148        } else {
    149149                got_sig = -1;
    150                 for (i=1;i<NSIG;i++) {
     150                for (int i=1;i<NSIG;i++) {
    151151                        if (traps[i].mark) {
    152152                                got_sig = i;
    153153                                Tcl_AsyncMark(async_handler);
    int objc;  
    304304Tcl_Obj *CONST objv[];
    305305{
    306306        char *action = 0;
    307         int n;          /* number of signals in list */
     307        Tcl_Size n;             /* number of signals in list */
    308308        Tcl_Obj **list; /* list of signals */
    309309        char *arg;
    310310        int len;        /* length of action */
    311         int i;
    312311        int show_name = FALSE;  /* if user asked for current sig by name */
    313312        int show_number = FALSE;/* if user asked for current sig by number */
    314313        int show_max = FALSE;   /* if user asked for NSIG-1 */
    Tcl_Obj *CONST objv[];  
    382381          return TCL_ERROR;
    383382        }
    384383
    385         for (i=0;i<n;i++) {
     384        for (Tcl_Size i=0;i<n;i++) {
    386385          char *s;
    387386          int sig;
    388387
    int oldcode;  
    509508
    510509                if (eip) {
    511510                  /* odd that Tcl doesn't have a call that does all this at once */
    512                   int len;
     511                  Tcl_Size len;
    513512                  char *s = Tcl_GetStringFromObj(eip,&len);
    514513                  Tcl_AddObjErrorInfo(interp,s,len);
    515514                  Tcl_DecrRefCount(eip);
  • exp_tty.c

    diff --git a/exp_tty.c b/exp_tty.c
    index 3f22c90..1bb83e7 100644
    a b exp_tty_break(  
    277277/* to write send_user strings without always putting in \r. */
    278278/* If len == 0, use strlen to compute it */
    279279/* NB: if terminal is not in raw mode, nothing is done. */
    280 char *
     280const char *
    281281exp_cook(
    282     char *s,
    283     int *len)   /* current and new length of s */
     282    const char *s,
     283    Tcl_Size *len)      /* current and new length of s */
    284284{
    285285        static int destlen = 0;
    286286        static char *dest = 0;
    static int /* returns TCL_whatever */  
    316316exec_stty(
    317317    Tcl_Interp *interp,
    318318    int argc,
    319     char **argv,
     319    const char **argv,
    320320    int devtty)         /* if true, redirect to /dev/tty */
    321321{
    322322        int i;
    Exp_SttyCmd(  
    370370    ClientData clientData,
    371371    Tcl_Interp *interp,
    372372    int argc,
    373     char **argv)
     373    const char **argv)
    374374{
    375375        /* redirection symbol is not counted as a stty arg in terms */
    376376        /* of recognition. */
    Exp_SttyCmd(  
    382382        int cooked = FALSE;
    383383        int was_raw, was_echo;
    384384
    385         char **redirect;        /* location of "<" */
    386         char *infile = 0;
     385        const char **redirect;  /* location of "<" */
     386        const char *infile = 0;
    387387        int fd;                 /* (slave) fd of infile */
    388388        int master = -1;        /* master fd of infile */
    389         char **argv0 = argv;
     389        const char **argv0 = argv;
    390390
    391391        for (argv=argv0+1;*argv;argv++) {
    392392                if (argv[0][0] == '<') {
    Exp_SttyCmd(  
    507507                /* a different tty */
    508508
    509509                /* temporarily zap redirect */
    510                 char *redirect_save = *redirect;
     510                const char *redirect_save = *redirect;
    511511                *redirect = 0;
    512512
    513513                for (argv=argv0+1;*argv;argv++) {
    Exp_SystemCmd(  
    569569    ClientData clientData,
    570570    Tcl_Interp *interp,
    571571    int argc,
    572     char **argv)
     572    const char **argv)
    573573{
    574574        int result = TCL_OK;
    575575        RETSIGTYPE (*old)();    /* save old sigalarm handler */
  • exp_win.c

    diff --git a/exp_win.c b/exp_win.c
    index 97adbee..497f10d 100644
    a b typedef struct {  
    7878static exp_winsize winsize = {0, 0};
    7979static exp_winsize win2size = {0, 0};
    8080
    81 int exp_window_size_set(fd)
     81void exp_window_size_set(fd)
    8282int fd;
    8383{
    8484#ifdef TIOCSWINSZ
    int fd;  
    8989#endif
    9090}
    9191
    92 int exp_window_size_get(fd)
     92void exp_window_size_get(fd)
    9393int fd;
    9494{
    9595#ifdef TIOCGWINSZ
    int fd;  
    106106
    107107void
    108108exp_win_rows_set(rows)
    109 char *rows;
     109const char *rows;
    110110{
    111111        winsize.rows = atoi(rows);
    112112        exp_window_size_set(exp_dev_tty);
    exp_win_rows_get()  
    123123
    124124void
    125125exp_win_columns_set(columns)
    126 char *columns;
     126const char *columns;
    127127{
    128128        winsize.columns = atoi(columns);
    129129        exp_window_size_set(exp_dev_tty);
    exp_win_columns_get()  
    142142 * separate copy of everything above - used for handling user stty requests
    143143 */
    144144
    145 int exp_win2_size_set(fd)
     145void exp_win2_size_set(fd)
    146146int fd;
    147147{
    148148#ifdef TIOCSWINSZ
    int fd;  
    153153#endif
    154154}
    155155
    156 int exp_win2_size_get(fd)
     156void exp_win2_size_get(fd)
    157157int fd;
    158158{
    159159#ifdef TIOCGWINSZ
    int fd;  
    167167void
    168168exp_win2_rows_set(fd,rows)
    169169int fd;
    170 char *rows;
     170const char *rows;
    171171{
    172172        exp_win2_size_get(fd);
    173173        win2size.rows = atoi(rows);
    int fd;  
    191191void
    192192exp_win2_columns_set(fd,columns)
    193193int fd;
    194 char *columns;
     194const char *columns;
    195195{
    196196        exp_win2_size_get(fd);
    197197        win2size.columns = atoi(columns);
  • exp_win.h

    diff --git a/exp_win.h b/exp_win.h
    index 8e77aea..0fcdb68 100644
    a b This file is in the public domain. However, the author and NIST  
    66would appreciate credit if you use this file or parts of it.
    77*/
    88
    9 #include <tcl.h> /* For _ANSI_ARGS_ */
     9#include "expect.h" /* For _ANSI_ARGS_ */
    1010
    11 int exp_window_size_set();
    12 int exp_window_size_get();
     11void exp_window_size_set();
     12void exp_window_size_get();
    1313
    14 void  exp_win_rows_set    _ANSI_ARGS_ ((char* rows));
     14void  exp_win_rows_set    _ANSI_ARGS_ ((const char* rows));
    1515char* exp_win_rows_get    _ANSI_ARGS_ ((void));
    16 void  exp_win_columns_set _ANSI_ARGS_ ((char* columns));
     16void  exp_win_columns_set _ANSI_ARGS_ ((const char* columns));
    1717char* exp_win_columns_get _ANSI_ARGS_ ((void));
    1818
    19 void  exp_win2_rows_set    _ANSI_ARGS_ ((int fd, char* rows));
     19void  exp_win2_rows_set    _ANSI_ARGS_ ((int fd, const char* rows));
    2020char* exp_win2_rows_get    _ANSI_ARGS_ ((int fd));
    21 void  exp_win2_columns_set _ANSI_ARGS_ ((int fd, char* columns));
     21void  exp_win2_columns_set _ANSI_ARGS_ ((int fd, const char* columns));
    2222char* exp_win2_columns_get _ANSI_ARGS_ ((int fd));
  • expect.c

    diff --git a/expect.c b/expect.c
    index 86b4abf..eae52a7 100644
    a b static char *exp_indirect_update1( /* 1-part Tcl variable names */  
    163163static char *exp_indirect_update2( /* 2-part Tcl variable names */
    164164    ClientData clientData,
    165165    Tcl_Interp *interp, /* Interpreter containing variable. */
    166     char *name1,        /* Name of variable. */
    167     char *name2,        /* Second part of variable name. */
     166    const char *name1,  /* Name of variable. */
     167    const char *name2,  /* Second part of variable name. */
    168168    int flags);         /* Information about what happened. */
    169169
    170170#ifdef SIMPLE_EVENT
    exp_eval_with_one_arg(  
    285285    CONST char *p;
    286286    CONST char *next;
    287287    int rc;
    288     int bytesLeft, numWords;
     288    Tcl_Size bytesLeft;
     289    int numWords;
    289290    Tcl_Parse parse;
    290291
    291292    /*
    exp_eval_with_one_arg(  
    325326                 numWords--, tokenPtr += (tokenPtr->numComponents + 1)) {
    326327                /* FUTURE: Save token information, do substitution later */
    327328
    328                 Tcl_Obj* w = Tcl_EvalTokens(interp, tokenPtr+1,
     329                rc = Tcl_EvalTokensStandard(interp, tokenPtr+1,
    329330                        tokenPtr->numComponents);
     331                Tcl_Obj* w = (rc == TCL_OK ? Tcl_GetObjResult(interp) : NULL);
    330332                /* w has refCount 1 here, if not NULL */
    331333                if (w == NULL) {
    332334                    Tcl_DecrRefCount (res);
    exp_eval_with_one_arg(  
    335337
    336338                }
    337339                Tcl_ListObjAppendElement (interp, res, w);
    338                 Tcl_DecrRefCount (w); /* Local reference goes away */
     340                Tcl_ResetResult (interp); /* Local reference goes away */
    339341            }
    340342        }
    341343
    parse_expect_args(  
    490492                {
    491493                    Tcl_Obj* g;
    492494                    Tcl_UniChar* str;
    493                     int strlen;
     495                    Tcl_Size strlen;
    494496
    495497                    str = Tcl_GetUnicodeFromObj (objv[i], &strlen);
    496498                    g = exp_retoglob (str, strlen);
    eval_case_string(  
    852854        expDiagLog("\"? ");
    853855
    854856        if (e->gate) {
    855             int plen;
     857            Tcl_Size plen;
    856858            Tcl_UniChar* pat = Tcl_GetUnicodeFromObj(e->gate,&plen);
    857859
    858860            expDiagLog("Gate \"");
    eval_case_string(  
    915917        expDiagLogU(expPrintify(Tcl_GetString(e->pat)));
    916918        expDiagLog("\"? ");
    917919        if (str) {
    918             int plen;
     920            Tcl_Size plen;
    919921            Tcl_UniChar* pat = Tcl_GetUnicodeFromObj(e->pat,&plen);
    920922
    921923            match = Exp_StringCaseMatch(str,numchars, pat, plen,
    eval_case_string(  
    932934        }
    933935        expDiagLogU(no);
    934936    } else if (e->use == PAT_EXACT) {
    935         int patLength;
     937        Tcl_Size patLength;
    936938        char *pat = Tcl_GetStringFromObj(e->pat, &patLength);
    937939        Tcl_UniChar *p;
    938940
    int  
    13841386Exp_ExpectGlobalObjCmd(
    13851387    ClientData clientData,
    13861388    Tcl_Interp *interp,
    1387     int objc,
     1389    Tcl_Size objc,
    13881390    Tcl_Obj *CONST objv[])              /* Argument objects. */
    13891391{
    13901392    int result = TCL_OK;
    which looks in the global space if they are not in the local space.  
    20422044This allows the user to localize them if desired, and also to
    20432045avoid having to put "global" in procedure definitions.
    20442046*/
    2045 char *
     2047const char *
    20462048exp_get_var(
    20472049    Tcl_Interp *interp,
    20482050    char *var)
    20492051{
    2050     char *val;
     2052    const char *val;
    20512053
    20522054    if (NULL != (val = Tcl_GetVar(interp,var,0 /* local */)))
    20532055        return(val);
    static char *  
    21212123exp_indirect_update2(
    21222124    ClientData clientData,
    21232125    Tcl_Interp *interp, /* Interpreter containing variable. */
    2124     char *name1,        /* Name of variable. */
    2125     char *name2,        /* Second part of variable name. */
     2126    const char *name1,  /* Name of variable. */
     2127    const char *name2,  /* Second part of variable name. */
    21262128    int flags)          /* Information about what happened. */
    21272129{
    21282130        char *msg;
    int  
    25252527Exp_ExpectObjCmd(
    25262528    ClientData clientData,
    25272529    Tcl_Interp *interp,
    2528     int objc,
     2530    Tcl_Size objc,
    25292531    Tcl_Obj *CONST objv[])              /* Argument objects. */
    25302532{
    25312533    int cc;                     /* number of chars returned in a single read */
    static int  
    27822784Exp_TimestampObjCmd(
    27832785    ClientData clientData,
    27842786    Tcl_Interp *interp,
    2785     int objc,
     2787    Tcl_Size objc,
    27862788    Tcl_Obj *CONST objv[])              /* Argument objects. */
    27872789{
    27882790        char *format = 0;
    int  
    29622964Exp_MatchMaxObjCmd(
    29632965    ClientData clientData,
    29642966    Tcl_Interp *interp,
    2965     int objc,
     2967    Tcl_Size objc,
    29662968    Tcl_Obj *CONST objv[])              /* Argument objects. */
    29672969{
    29682970    int size = -1;
    int  
    30083010Exp_RemoveNullsObjCmd(
    30093011    ClientData clientData,
    30103012    Tcl_Interp *interp,
    3011     int objc,
     3013    Tcl_Size objc,
    30123014    Tcl_Obj *CONST objv[])              /* Argument objects. */
    30133015{
    30143016    int value = -1;
    int  
    30523054Exp_ParityObjCmd(
    30533055    ClientData clientData,
    30543056    Tcl_Interp *interp,
    3055     int objc,
     3057    Tcl_Size objc,
    30563058    Tcl_Obj *CONST objv[])              /* Argument objects. */
    30573059{
    30583060    int parity;
    int  
    30913093Exp_CloseOnEofObjCmd(
    30923094    ClientData clientData,
    30933095    Tcl_Interp *interp,
    3094     int objc,
     3096    Tcl_Size objc,
    30953097    Tcl_Obj *CONST objv[])              /* Argument objects. */
    30963098{
    30973099    int close_on_eof;
  • expect.h

    diff --git a/expect.h b/expect.h
    index e5e29e3..16e28af 100644
    a b would appreciate credit if this program or parts of it are used.  
    1212#define _EXPECT_H
    1313
    1414#include <stdio.h>
     15#include <stdarg.h>
    1516#include <setjmp.h>
    16 
    17 /*
    18  * tcl.h --
    19  *
    20  *      This header file describes the externally-visible facilities
    21  *      of the Tcl interpreter.
    22  *
    23  * Copyright (c) 1987-1994 The Regents of the University of California.
    24  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
    25  * Copyright (c) 1993-1996 Lucent Technologies.
    26  * Copyright (c) 1998-1999 Scriptics Corporation.
    27  *
    28  * See the file "license.terms" for information on usage and redistribution
    29  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    30  *
    31  * RCS: @(#) $Id: expect.h,v 5.32 2010/07/01 00:53:49 eee Exp $
    32  */
    33 
    34 #ifndef _TCL
    35 #define _TCL
    36 
    37 #ifndef __WIN32__
    38 #   if defined(_WIN32) || defined(WIN32)
    39 #       define __WIN32__
    40 #   endif
    41 #endif
    42 
    43 #ifdef __WIN32__
    44 #   ifndef STRICT
    45 #       define STRICT
    46 #   endif
    47 #   ifndef USE_PROTOTYPE
    48 #       define USE_PROTOTYPE 1
    49 #   endif
    50 #   ifndef HAS_STDARG
    51 #       define HAS_STDARG 1
    52 #   endif
    53 #   ifndef USE_PROTOTYPE
    54 #       define USE_PROTOTYPE 1
    55 #   endif
    56 
    57 /*
    58  * Under Windows we need to call Tcl_Alloc in all cases to avoid competing
    59  * C run-time library issues.
    60  */
    61 
    62 #   ifndef USE_TCLALLOC
    63 #       define USE_TCLALLOC 1
    64 #   endif
    65 #endif /* __WIN32__ */
    66 
    67 /*
    68  * The following definitions set up the proper options for Macintosh
    69  * compilers.  We use this method because there is no autoconf equivalent.
    70  */
    71 
    72 #ifdef MAC_TCL
    73 #   ifndef HAS_STDARG
    74 #       define HAS_STDARG 1
    75 #   endif
    76 #   ifndef USE_TCLALLOC
    77 #       define USE_TCLALLOC 1
    78 #   endif
    79 #   ifndef NO_STRERROR
    80 #       define NO_STRERROR 1
    81 #   endif
    82 #endif
    83 
    84 /*
    85  * Utility macros: STRINGIFY takes an argument and wraps it in "" (double
    86  * quotation marks), JOIN joins two arguments.
    87  */
    88 
    89 #define VERBATIM(x) x
    90 #ifdef _MSC_VER
    91 # define STRINGIFY(x) STRINGIFY1(x)
    92 # define STRINGIFY1(x) #x
    93 # define JOIN(a,b) JOIN1(a,b)
    94 # define JOIN1(a,b) a##b
    95 #else
    96 # ifdef RESOURCE_INCLUDED
    97 #  define STRINGIFY(x) STRINGIFY1(x)
    98 #  define STRINGIFY1(x) #x
    99 #  define JOIN(a,b) JOIN1(a,b)
    100 #  define JOIN1(a,b) a##b
    101 # else
    102 #  ifdef __STDC__
    103 #   define STRINGIFY(x) #x
    104 #   define JOIN(a,b) a##b
    105 #  else
    106 #   define STRINGIFY(x) "x"
    107 #   define JOIN(a,b) VERBATIM(a)VERBATIM(b)
    108 #  endif
    109 # endif
    110 #endif
    111 
    112 /*
    113  * A special definition used to allow this header file to be included
    114  * in resource files so that they can get obtain version information from
    115  * this file.  Resource compilers don't like all the C stuff, like typedefs
    116  * and procedure declarations, that occur below.
    117  */
    118 
    119 #ifndef RESOURCE_INCLUDED
    120 
    121 #ifndef BUFSIZ
    122 #include <stdio.h>
    123 #endif
    124 
    125 /*
    126  * Definitions that allow Tcl functions with variable numbers of
    127  * arguments to be used with either varargs.h or stdarg.h.  TCL_VARARGS
    128  * is used in procedure prototypes.  TCL_VARARGS_DEF is used to declare
    129  * the arguments in a function definiton: it takes the type and name of
    130  * the first argument and supplies the appropriate argument declaration
    131  * string for use in the function definition.  TCL_VARARGS_START
    132  * initializes the va_list data structure and returns the first argument.
    133  */
    134 
    135 #if defined(__STDC__) || defined(HAS_STDARG)
    136 #   include <stdarg.h>
    137 
    138 #   define TCL_VARARGS(type, name) (type name, ...)
    139 #   define TCL_VARARGS_DEF(type, name) (type name, ...)
    140 #   define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
    141 #else
    142 #   include <varargs.h>
    143 
    144 #   ifdef __cplusplus
    145 #       define TCL_VARARGS(type, name) (type name, ...)
    146 #       define TCL_VARARGS_DEF(type, name) (type va_alist, ...)
    147 #   else
    148 #       define TCL_VARARGS(type, name) ()
    149 #       define TCL_VARARGS_DEF(type, name) (va_alist)
    150 #   endif
    151 #   define TCL_VARARGS_START(type, name, list) \
    152         (va_start(list), va_arg(list, type))
    153 #endif
    154 
    155 /*
    156  * Macros used to declare a function to be exported by a DLL.
    157  * Used by Windows, maps to no-op declarations on non-Windows systems.
    158  * The default build on windows is for a DLL, which causes the DLLIMPORT
    159  * and DLLEXPORT macros to be nonempty. To build a static library, the
    160  * macro STATIC_BUILD should be defined.
    161  */
    162 
    163 #ifdef STATIC_BUILD
    164 # define DLLIMPORT
    165 # define DLLEXPORT
    166 #else
    167 # if defined(__WIN32__) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__declspec)))
    168 #   define DLLIMPORT __declspec(dllimport)
    169 #   define DLLEXPORT __declspec(dllexport)
    170 # else
    171 #  define DLLIMPORT
    172 #  define DLLEXPORT
    173 # endif
    174 #endif
    175 
    176 /*
    177  * These macros are used to control whether functions are being declared for
    178  * import or export.  If a function is being declared while it is being built
    179  * to be included in a shared library, then it should have the DLLEXPORT
    180  * storage class.  If is being declared for use by a module that is going to
    181  * link against the shared library, then it should have the DLLIMPORT storage
    182  * class.  If the symbol is beind declared for a static build or for use from a
    183  * stub library, then the storage class should be empty.
    184  *
    185  * The convention is that a macro called BUILD_xxxx, where xxxx is the
    186  * name of a library we are building, is set on the compile line for sources
    187  * that are to be placed in the library.  When this macro is set, the
    188  * storage class will be set to DLLEXPORT.  At the end of the header file, the
    189  * storage class will be reset to DLLIMPORt.
    190  */
    191 
    192 #undef TCL_STORAGE_CLASS
    193 #ifdef BUILD_tcl
    194 # define TCL_STORAGE_CLASS DLLEXPORT
    195 #else
    196 # ifdef USE_TCL_STUBS
    197 #  define TCL_STORAGE_CLASS
    198 # else
    199 #  define TCL_STORAGE_CLASS DLLIMPORT
    200 # endif
    201 #endif
    202 
    203 /*
    204  * Definitions that allow this header file to be used either with or
    205  * without ANSI C features like function prototypes.  */
     17#include <tcl.h>
    20618
    20719#undef _ANSI_ARGS_
    20820#undef CONST
    209 
    210 #if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE)
    211 #   define _USING_PROTOTYPES_ 1
    212 #   define _ANSI_ARGS_(x)       x
    213 #   define CONST const
    214 #else
    215 #   define _ANSI_ARGS_(x)       ()
    216 #   define CONST
    217 #endif
    218 
    219 #ifdef __cplusplus
    220 #   define EXTERN extern "C" TCL_STORAGE_CLASS
    221 #else
    222 #   define EXTERN extern TCL_STORAGE_CLASS
    223 #endif
    224 
    225 /*
    226  * Macro to use instead of "void" for arguments that must have
    227  * type "void *" in ANSI C;  maps them to type "char *" in
    228  * non-ANSI systems.
    229  */
    230 #ifndef __WIN32__
    231 #ifndef VOID
    232 #   ifdef __STDC__
    233 #       define VOID void
    234 #   else
    235 #       define VOID char
    236 #   endif
    237 #endif
    238 #else /* __WIN32__ */
    239 /*
    240  * The following code is copied from winnt.h
    241  */
    242 #ifndef VOID
    243 #define VOID void
    244 typedef char CHAR;
    245 typedef short SHORT;
    246 typedef long LONG;
    247 #endif
    248 #endif /* __WIN32__ */
    249 
    250 /*
    251  * Miscellaneous declarations.
    252  */
    253 
    254 #ifndef NULL
    255 #define NULL 0
    256 #endif
    257 
    258 typedef struct Tcl_RegExp_ *Tcl_RegExp;
    259 
    260 /*
    261  * These function have been renamed. The old names are deprecated, but we
    262  * define these macros for backwards compatibilty.
    263  */
    264 
    265 #define Tcl_Ckalloc Tcl_Alloc
    266 #define Tcl_Ckfree Tcl_Free
    267 #define Tcl_Ckrealloc Tcl_Realloc
    268 #define Tcl_Return Tcl_SetResult
    269 #define Tcl_TildeSubst Tcl_TranslateFileName
    270 
    271 #endif /* RESOURCE_INCLUDED */
    272 
    273 #undef TCL_STORAGE_CLASS
    274 #define TCL_STORAGE_CLASS DLLIMPORT
    275 
    276 #endif /* _TCL */
    277 
    278 /*
    279  * end of tcl.h definitions
    280  */
    281 
     21#undef CONST84
     22#undef TCL_VARARGS
     23#undef TCL_VARARGS_DEF
     24#undef TCL_VARARGS_START
     25
     26#define _ANSI_ARGS_(x)  x
     27#define CONST const
     28#define CONST84 const
     29#define TCL_VARARGS(type, name) (type name, ...)
     30#define TCL_VARARGS_DEF(type, name) (type name, ...)
     31#define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
    28232
    28333/*
    28434 * regexp definitions - from tcl8.0/tclRegexp.h
  • expect_tcl.h

    diff --git a/expect_tcl.h b/expect_tcl.h
    index 0fa5a99..59a5cd3 100644
    a b would appreciate credit if this program or parts of it are used.  
    1313#define _EXPECT_TCL_H
    1414
    1515#include <stdio.h>
    16 #include "expect_comm.h"
     16#include "expect.h"
    1717
    1818/*
    1919 * This is a convenience macro used to initialize a thread local storage ptr.
    EXTERN int exp_interpret_cmdfile _ANSI_ARGS_((Tcl_Interp *,FILE *));  
    4444EXTERN int      exp_interpret_cmdfilename _ANSI_ARGS_((Tcl_Interp *,char *));
    4545EXTERN void     exp_interpret_rcfiles _ANSI_ARGS_((Tcl_Interp *,int my_rc,int sys_rc));
    4646
    47 EXTERN char *   exp_cook _ANSI_ARGS_((char *s,int *len));
     47EXTERN const char *     exp_cook _ANSI_ARGS_((const char *s,Tcl_Size *len));
    4848
    4949EXTERN void     expCloseOnExec _ANSI_ARGS_((int));
    5050
  • retoglob.c

    diff --git a/retoglob.c b/retoglob.c
    index 521d0ae..e426fe2 100644
    a b exp_retoglob (  
    100100#define CHOPC(c) {while (*str != (c) && strlen) CHOP(1) ;}
    101101#define EMIT(c)  {lastsz = 1; *nexto++ = (c);}
    102102#define EMITX(c) {lastsz++;   *nexto++ = (c);}
    103 #define MATCH(lit) ((strlen >= (sizeof (lit)/sizeof (Tcl_UniChar))) && (0 == Tcl_UniCharNcmp (str,(lit),sizeof(lit)/sizeof (Tcl_UniChar))))
     103#define MATCH(lit) ((strlen >= (sizeof (lit)/sizeof (Tcl_UniChar))) && (0 == memcmp (str,(lit),sizeof(lit))))
    104104#define MATCHC(c) (strlen && (*str == (c)))
    105105#define PUSHPAREN {*nextp++ = nexto;}
    106106#define UNEMIT {nexto -= lastsz; lastsz = -1;}
  • tcldbg.h

    diff --git a/tcldbg.h b/tcldbg.h
    index 8f9cb9a..88ff5d1 100644
    a b would appreciate credit if this program or parts of it are used.  
    1212#ifndef _NIST_DBG
    1313#define _NIST_DBG
    1414
    15 #include "tcl.h"
     15#include "expect.h"
    1616
    1717typedef int (Dbg_InterProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData data));
    1818typedef int (Dbg_IgnoreFuncsProc) _ANSI_ARGS_((