bug from last time
[unix-history] / usr / src / usr.bin / window / cmd3.c
index b15abb6..2d5fa27 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)cmd3.c      3.2 83/08/15";
+static char *sccsid = "@(#)cmd3.c      3.11 84/04/07";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
+#include "string.h"
 
 c_close(w)
 register struct ww *w;
 
 c_close(w)
 register struct ww *w;
@@ -17,33 +18,24 @@ register struct ww *w;
                for (i = 0; i < NWINDOW; i++) {
                        if ((w = window[i]) == 0)
                                continue;
                for (i = 0; i < NWINDOW; i++) {
                        if ((w = window[i]) == 0)
                                continue;
-                       closewin(w);            /* GROT */
+                       closewin(w);
                        didit++;
                }
        }
        if (selwin == 0) {
                        didit++;
                }
        }
        if (selwin == 0) {
-               for (i = 0; i < NWINDOW && window[i] == 0; i++)
-                       ;
-               if (i < NWINDOW)
-                       setselwin(window[i]);
+               if (lastselwin != 0)
+                       setselwin(lastselwin);
+               else {
+                       for (i = 0; i < NWINDOW && window[i] == 0; i++)
+                               ;
+                       if (i < NWINDOW)
+                               setselwin(window[i]);
+               }
        }
        if (didit)
                reframe();
 }
 
        }
        if (didit)
                reframe();
 }
 
-closewin(w)
-register struct ww *w;
-{
-       if (w == selwin)
-               setselwin((struct ww *)0);
-       if (w->ww_id >= 0 && w->ww_id < NWINDOW)
-               window[w->ww_id] = 0;
-       if (w->ww_label)
-               free(w->ww_label);
-       wwdelete(w);
-       wwclose(w);
-}
-
 setescape(esc)
 register char *esc;
 {
 setescape(esc)
 register char *esc;
 {
@@ -60,12 +52,9 @@ setlabel(w, label)
 register struct ww *w;
 char *label;
 {
 register struct ww *w;
 char *label;
 {
-       char *malloc();
-
        if (w->ww_label != 0)
        if (w->ww_label != 0)
-               free(w->ww_label);
-       if ((w->ww_label = malloc((unsigned)strlen(label) + 1)) == 0)
+               str_free(w->ww_label);
+       if ((w->ww_label = str_cpy(label)) == 0)
                return -1;
                return -1;
-       (void) strcpy(w->ww_label, label);
        return 0;
 }
        return 0;
 }