less -> more
[unix-history] / usr / src / usr.bin / window / wwpty.c
index f3e931c..3dc383d 100644 (file)
@@ -1,47 +1,47 @@
-#ifndef lint
-static char sccsid[] = "@(#)wwpty.c    3.12 %G%";
-#endif
-
 /*
 /*
- * Copyright (c) 1983 Regents of the University of California,
- * All rights reserved.  Redistribution permitted subject to
- * the terms of the Berkeley Software License Agreement.
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
  */
 
+#ifndef lint
+static char sccsid[] = "@(#)wwpty.c    3.15 (Berkeley) %G%";
+#endif /* not lint */
+
 #include "ww.h"
 
 #include "ww.h"
 
-/*
- * To satisfy Chris, we allocate pty's backwards, and if
- * there are more than the ptyp's (i.e. the ptyq's)
- * on the machine, we don't use the p's.
- */
 wwgetpty(w)
 register struct ww *w;
 {
 wwgetpty(w)
 register struct ww *w;
 {
-       register char c;
-       register int i;
+       register char c, *p;
        int tty;
        int on = 1;
        int tty;
        int on = 1;
-       char hasq = 0;
 #define PTY "/dev/XtyXX"
 #define _PT    5
 #define _PQRS  8
 #define _0_9   9
 
        (void) strcpy(w->ww_ttyname, PTY);
 #define PTY "/dev/XtyXX"
 #define _PT    5
 #define _PQRS  8
 #define _0_9   9
 
        (void) strcpy(w->ww_ttyname, PTY);
-       for (c = 's'; c >= 'p'; c--) {
+       for (c = 'p'; c <= 'u'; c++) {
                w->ww_ttyname[_PT] = 'p';
                w->ww_ttyname[_PQRS] = c;
                w->ww_ttyname[_0_9] = '0';
                if (access(w->ww_ttyname, 0) < 0)
                w->ww_ttyname[_PT] = 'p';
                w->ww_ttyname[_PQRS] = c;
                w->ww_ttyname[_0_9] = '0';
                if (access(w->ww_ttyname, 0) < 0)
-                       continue;
-               if (c != 'p')
-                       hasq = 1;
-               else if (hasq)
                        break;
                        break;
-               for (i = 15; i >= 0; i--) {
+               for (p = "0123456789abcdef"; *p; p++) {
                        w->ww_ttyname[_PT] = 'p';
                        w->ww_ttyname[_PT] = 'p';
-                       w->ww_ttyname[_0_9] = "0123456789abcdef"[i];
+                       w->ww_ttyname[_0_9] = *p;
                        if ((w->ww_pty = open(w->ww_ttyname, 2)) < 0)
                                continue;
                        w->ww_ttyname[_PT] = 't';
                        if ((w->ww_pty = open(w->ww_ttyname, 2)) < 0)
                                continue;
                        w->ww_ttyname[_PT] = 't';