bug-dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-dejagnu] [Fwd: [PATCH] Small fixes for expect to allow compilation


From: Andrew Cagney
Subject: [Bug-dejagnu] [Fwd: [PATCH] Small fixes for expect to allow compilation with native IRIX6 tools]
Date: Fri, 27 Sep 2002 13:48:39 -0400
User-agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020824

--- Begin Message --- Subject: [PATCH] Small fixes for expect to allow compilation with native IRIX6 tools Date: Tue, 26 Mar 2002 00:26:58 +0100 User-agent: Mutt/1.3.27i
Hello All,

this patch does some code cleanup and adds some missing ifdef's in
places where the native IRIX6 tools are complaining about.


Thiemo


        /expect/ChangeLog
        * exp_clib.c: Fix bad comment nesting. Code cleanup.
        * exp_command.c: Likewise. Ifdef out code of some old TCL support.
        Cast some type conversions explicitly.


diff -BurpN source-orig/expect/exp_clib.c source/expect/exp_clib.c
--- source-orig/expect/exp_clib.c       Sat Sep  8 08:26:30 2001
+++ source/expect/exp_clib.c    Thu Feb 21 07:03:27 2002
@@ -126,7 +126,7 @@ static struct f {
 
        char *buffer;           /* buffer of matchable chars */
        char *buffer_end;       /* one beyond end of matchable chars */
-       /*char *match;          /* start of matched string */
+       /*char *match;*/                /* start of matched string */
        char *match_end;        /* one beyond end of matched string */
        int msize;              /* size of allocate space */
                                /* actual size is one larger for null */
@@ -191,7 +191,6 @@ char *argv[];       /* some compiler complains
        int cc;
        int errorfd;    /* place to stash fileno(stderr) in child */
                        /* while we're setting up new stderr */
-       int ttyfd;
        int sync_fds[2];
        int sync2_fds[2];
        char sync_byte;
@@ -344,10 +343,14 @@ when trapping, see below in child half o
 /*     setpgrp(0,getpid());*/  /* make a new pgrp leader */
 
 #ifdef TIOCNOTTY
-       ttyfd = open("/dev/tty", O_RDWR);
-       if (ttyfd >= 0) {
-               (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
-               (void) close(ttyfd);
+       {
+               int ttyfd;
+
+               ttyfd = open("/dev/tty", O_RDWR);
+               if (ttyfd >= 0) {
+                       (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
+                       (void) close(ttyfd);
+               }
        }
 #endif /* TIOCNOTTY */
 
@@ -506,7 +509,7 @@ when trapping, see below in child half o
        /* wait for master to let us go on */
        /* debuglog("child: waiting for go ahead from parent\r\n"); */
 
-/*     close(master);  /* force master-side close so we can read */
+/*     close(master);*/        /* force master-side close so we can read */
        cc = read(sync2_fds[0],&sync_byte,1);
        if (cc == -1) {
                restore_error_fd
@@ -773,7 +776,7 @@ struct exp_case *ecases;
        for (ec=ecases;ec->type != exp_end;ec++) {
                if ((ec->type == exp_regexp) && !ec->re) {
                        TclRegError((char *)0);
-                       if (!(ec->re = TclRegComp(ec->pattern))) {
+                       if (!(ec->re = (Expect_regexp 
*)TclRegComp(ec->pattern))) {
                                fprintf(stderr,"regular expression %s is bad: 
%s",ec->pattern,TclGetRegError());
                                return_errno(EINVAL);
                          }
@@ -1156,8 +1159,6 @@ char *program;
 int
 exp_disconnect()
 {
-       int ttyfd;
-
 #ifndef EALREADY
 #define EALREADY 37
 #endif
@@ -1189,11 +1190,15 @@ exp_disconnect()
        setpgrp(0,getpid());    /* put process in our own pgrp */
 /* Pyramid lacks this defn */
 #ifdef TIOCNOTTY
-       ttyfd = open("/dev/tty", O_RDWR);
-       if (ttyfd >= 0) {
-               /* zap controlling terminal if we had one */
-               (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
-               (void) close(ttyfd);
+       {
+               int ttyfd;
+
+               ttyfd = open("/dev/tty", O_RDWR);
+               if (ttyfd >= 0) {
+                       /* zap controlling terminal if we had one */
+                       (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
+                       (void) close(ttyfd);
+               }
        }
 #endif /* TIOCNOTTY */
 #endif /* SYSV3 */
diff -BurpN source-orig/expect/exp_command.c source/expect/exp_command.c
--- source-orig/expect/exp_command.c    Tue Sep 11 21:24:03 2001
+++ source/expect/exp_command.c Thu Feb 21 06:54:55 2002
@@ -215,8 +215,10 @@ int pid;
 }
 #endif
 
+#if 0  /* old Tcl 7.6 code */
 /* Tcl needs commands in writable space */
 static char close_cmd[] = "close";
+#endif
 
 /* zero out the wait status field */
 static void
@@ -627,11 +629,8 @@ char **argv;
        int slave;
        int pid;
        char **a;
-       /* tell Saber to ignore non-use of ttyfd */
-       /*SUPPRESS 591*/
        int errorfd;    /* place to stash fileno(stderr) in child */
                        /* while we're setting up new stderr */
-       int ttyfd;
        int master;
        int write_master;       /* write fd of Tcl-opened files */
        int ttyinit = TRUE;
@@ -654,8 +653,10 @@ char **argv;
        char *argv0 = argv[0];
        char *openarg = 0;
        int leaveopen = FALSE;
+#if TCL7_4
        FILE *readfilePtr;
        FILE *writefilePtr;
+#endif
        int rc, wc;
        char *stty_init;
        int slave_write_ioctls = 1;
@@ -917,7 +918,7 @@ when trapping, see below in child half o
 #endif /* TCL_MAJOR_VERSION < 8 */
                }
 
-               master = ((mode & TCL_READABLE)?rfd:wfd);
+               master = (int)((mode & TCL_READABLE)?rfd:wfd);
 
                /* make a new copy of file descriptor */
                if (-1 == (write_master = master = dup(master))) {
@@ -927,7 +928,7 @@ when trapping, see below in child half o
 
                /* if writefilePtr is different, dup that too */
                if ((mode & TCL_READABLE) && (mode & TCL_WRITABLE) && (wfd != 
rfd)) {
-                       if (-1 == (write_master = dup(wfd))) {
+                       if (-1 == (write_master = dup((int)wfd))) {
                                exp_error(interp,"fdopen: 
%s",Tcl_PosixError(interp));
                                return TCL_ERROR;
                        }
@@ -1229,10 +1230,14 @@ parent_error:
 
 /* Pyramid lacks this defn */
 #ifdef TIOCNOTTY
-       ttyfd = open("/dev/tty", O_RDWR);
-       if (ttyfd >= 0) {
-               (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
-               (void) close(ttyfd);
+       {
+               int ttyfd;
+
+               ttyfd = open("/dev/tty", O_RDWR);
+               if (ttyfd >= 0) {
+                       (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
+                       (void) close(ttyfd);
+               }
        }
 #endif /* TIOCNOTTY */
 
@@ -1390,7 +1395,7 @@ parent_error:
        /* wait for master to let us go on */
        /* debuglog("child: waiting for go ahead from parent\r\n"); */
 
-/*     close(master);  /* force master-side close so we can read */
+/*     close(master);*/        /* force master-side close so we can read */
 
        while (((rc = read(sync2_fds[0],&sync_byte,1)) < 0) && (errno == 
EINTR)) {
                /* empty */;
@@ -2230,7 +2235,9 @@ char **argv;
        int append = TRUE;
        char *filename = 0;
        char *type;
+#if TCL7_4
        FILE *writefilePtr;
+#endif
        int usage_error_occurred = FALSE;
 
        openarg = 0;
@@ -2327,7 +2334,9 @@ char **argv;
                        goto error;
                }
        } else if (openarg) {
+#if TCL7_4
                int cc;
+#endif
                int fd;
                Tcl_Channel chan;
                int mode;
@@ -3125,10 +3134,6 @@ Tcl_Interp *interp;
 int argc;
 char **argv;
 {
-       /* tell Saber to ignore non-use of ttyfd */
-       /*SUPPRESS 591*/
-       int ttyfd;
-
        if (argc > 1) {
                exp_error(interp,"usage: disconnect");
                return(TCL_ERROR);
@@ -3197,11 +3202,15 @@ char **argv;
 
 /* Pyramid lacks this defn */
 #ifdef TIOCNOTTY
-       ttyfd = open("/dev/tty", O_RDWR);
-       if (ttyfd >= 0) {
-               /* zap controlling terminal if we had one */
-               (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
-               (void) close(ttyfd);
+       {
+               int ttyfd;
+
+               ttyfd = open("/dev/tty", O_RDWR);
+               if (ttyfd >= 0) {
+                       /* zap controlling terminal if we had one */
+                       (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
+                       (void) close(ttyfd);
+               }
        }
 #endif /* TIOCNOTTY */
 


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]