Source-Changes-HG archive

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

[src/trunk]: src/distrib/utils/sysinst Just convert \r\n to \n\r when relayin...



details:   https://anonhg.NetBSD.org/src/rev/706fa4eeaf15
branches:  trunk
changeset: 552561:706fa4eeaf15
user:      dsl <dsl%NetBSD.org@localhost>
date:      Sat Sep 27 10:38:05 2003 +0000

description:
Just convert \r\n to \n\r when relaying program output.
Ensure we never write an undefined error message.
Remove support for RUN_SYSTEM - it isn't used and there are too many paths
through this code....

diffstat:

 distrib/utils/sysinst/run.c |  44 +++++++++++++++-----------------------------
 1 files changed, 15 insertions(+), 29 deletions(-)

diffs (100 lines):

diff -r a352f382d94c -r 706fa4eeaf15 distrib/utils/sysinst/run.c
--- a/distrib/utils/sysinst/run.c       Sat Sep 27 10:16:33 2003 +0000
+++ b/distrib/utils/sysinst/run.c       Sat Sep 27 10:38:05 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: run.c,v 1.51 2003/08/09 19:26:38 dsl Exp $     */
+/*     $NetBSD: run.c,v 1.52 2003/09/27 10:38:05 dsl Exp $     */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -50,6 +50,7 @@
 #include <termios.h>
 #include <dirent.h>
 #include <util.h>
+#include <signal.h>
 #include <err.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
@@ -336,11 +337,6 @@
                return(1);
        }
 
-#if 0
-       rtt = tt;
-       rtt.c_lflag |= (ICANON|ECHO); 
-       (void)tcsetattr(STDIN_FILENO, TCSAFLUSH, &rtt);
-#endif
        rtt = tt;
 
        /* ignore tty signals until we're done with subprocess setup */
@@ -365,6 +361,11 @@
                rtt = tt;
                rtt.c_lflag |= (ICANON|ECHO); 
                (void)tcsetattr(slave, TCSANOW, &rtt);
+#if 0  /* This doesn't work (yet) */
+               i = 1;
+               /* steal console output */
+               ioctl(slave, TIOCCONS, &i);
+#endif
                login_tty(slave);
                if (logging) {
                        fprintf(logfp, "executing:");
@@ -453,22 +454,11 @@
                                }
                                /* posix curses is braindead wrt \r\n so... */
                                ncp = cp;
-                               do  {
-                                       ncp = strchr(ncp, '\r');
-                                       if (ncp != NULL) {
-                                               switch (*++ncp) {
-                                               case 0:
-                                                       break;
-                                               case '\n':
-                                                       ncp[-1] = 0;
-                                                       break;
-                                               default:
-                                                       continue;
-                                               }
-                                       }
-                                       waddstr(actionwin, cp);
-                                       cp = ncp;
-                               } while (cp != NULL);
+                               for (; (ncp = strstr(ncp, "\r\n")); ncp += 2) {
+                                       ncp[0] = '\n';
+                                       ncp[1] = '\r';
+                               }
+                               waddstr(actionwin, cp);
                                wrefresh(actionwin);
                        }
                }
@@ -512,7 +502,7 @@
        WINDOW *actionwin, *statuswin, *boxwin;
        char *scmd;
        char **args;
-       const char *errstr;
+       const char *errstr = NULL;
 
        va_start(ap, cmd);
        vasprintf(&scmd, cmd, ap);
@@ -531,11 +521,7 @@
        if (win.ws_col == 0)
                win.ws_col = 80;
 
-       if ((flags & RUN_SYSTEM) != 0) {
-               if ((flags & RUN_CHROOT) != 0)
-                       chroot(target_prefix());
-               ret = system(scmd);
-       } else if ((flags & RUN_DISPLAY) != 0) {
+       if ((flags & RUN_DISPLAY) != 0) {
                wclear(stdscr);
                clearok(stdscr, 1);
                touchwin(stdscr);
@@ -602,7 +588,7 @@
 
                wmove(statuswin, 0, 13);
                wstandout(statuswin);
-               if (ret) {
+               if (ret && errstr != NULL) {
                        waddstr(statuswin, "Failed: ");
                        waddstr(statuswin, errstr);
                } else



Home | Main Index | Thread Index | Old Index