fixed argv bug and more flags
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 30 Jul 1983 08:07:27 +0000 (00:07 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 30 Jul 1983 08:07:27 +0000 (00:07 -0800)
also turn off ^\ except with -d or a.out.

SCCS-vsn: usr.bin/window/main.c 1.9

usr/src/usr.bin/window/main.c

index 462888e..0f3c6ec 100644 (file)
@@ -1,12 +1,12 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)main.c      1.8 83/07/28";
+static char *sccsid = "@(#)main.c      1.9 83/07/29";
 #endif
 
 #include "defs.h"
 
 #endif
 
 #include "defs.h"
 
-char escapec = CTRL(l);
+char escapec = CTRL(p);
 
 
-#define next(a) (**(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
+#define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
 
 /*ARGUSED*/
 main(argc, argv)
 
 /*ARGUSED*/
 main(argc, argv)
@@ -14,30 +14,54 @@ char **argv;
 {
        register n;
        register char *p;
 {
        register n;
        register char *p;
+       char fast = 0;
        int wwchild();
        int imask;
        int wwchild();
        int imask;
+       char *rindex();
+       char *getenv();
 
 
+       if (p = rindex(*argv, '/'))
+               p++;
+       else
+               p = *argv;
+       debug = strcmp(p, "a.out") == 0;
        while (*++argv) {
                if (**argv == '-') {
                        switch (*++*argv) {
        while (*++argv) {
                if (**argv == '-') {
                        switch (*++*argv) {
+                       case 'f':
+                               fast++;
+                               break;
                        case 'e':
                                setescape(next(argv));
                                break;
                        case 't':
                                terse++;
                                break;
                        case 'e':
                                setescape(next(argv));
                                break;
                        case 't':
                                terse++;
                                break;
+                       case 'd':
+                               debug++;
+                               break;
                        default:
                                usage();
                        }
                } else
                        usage();
        }
                        default:
                                usage();
                        }
                } else
                        usage();
        }
+       if ((shell = getenv("SHELL")) == 0)
+               shell = "/bin/csh";
+       if (shellname = rindex(shell, '/'))
+               shellname++;
+       else
+               shellname = shell;
        gettimeofday(&starttime, &timezone);
        if (wwinit() < 0) {
                fflush(stdout);
                fprintf("Can't do windows on this terminal.\n");
                exit(1);
        }
        gettimeofday(&starttime, &timezone);
        if (wwinit() < 0) {
                fflush(stdout);
                fprintf("Can't do windows on this terminal.\n");
                exit(1);
        }
+       if (debug) {
+               wwnewtty.ww_tchars.t_quitc = wwoldtty.ww_tchars.t_quitc;
+               wwsettty(0, &wwnewtty);
+       }
        if ((cmdwin = wwopen(WW_NONE, 0, 1, wwncol, 0, 0)) == 0) {
                fflush(stdout);
                fprintf(stderr, "Can't open command window.\r\n");
        if ((cmdwin = wwopen(WW_NONE, 0, 1, wwncol, 0, 0)) == 0) {
                fflush(stdout);
                fprintf(stderr, "Can't open command window.\r\n");
@@ -50,10 +74,12 @@ char **argv;
                Waputc(0, WINVERSE|WBUF, cmdwin->ww_win);
        wwflush();
        (void) signal(SIGCHLD, wwchild);
                Waputc(0, WINVERSE|WBUF, cmdwin->ww_win);
        wwflush();
        (void) signal(SIGCHLD, wwchild);
-       if (doconfig() < 0)
-               dodefault();
-       if (selwin != 0)
-               wwsetcurwin(selwin);
+       if (!fast) {
+               if (doconfig() < 0)
+                       dodefault();
+               if (selwin != 0)
+                       wwsetcurwin(selwin);
+       }
        while (!quit) {
                if (curwin == cmdwin) {
                        docmd();
        while (!quit) {
                if (curwin == cmdwin) {
                        docmd();