BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / ex / ex_set.c
index 2b39eff..ee8d8eb 100644 (file)
@@ -1,7 +1,16 @@
-/* Copyright (c) 1980 Regents of the University of California */
-static char *sccsid = "@(#)ex_set.c    6.1 %G%";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char *sccsid = "@(#)ex_set.c    7.5 (Berkeley) 3/9/87";
+#endif not lint
+
 #include "ex.h"
 #include "ex_temp.h"
 #include "ex.h"
 #include "ex_temp.h"
+#include "ex_tty.h"
 
 /*
  * Set command.
 
 /*
  * Set command.
@@ -27,7 +36,7 @@ set()
                cp = optname;
                do {
                        if (cp < &optname[ONMSZ - 2])
                cp = optname;
                do {
                        if (cp < &optname[ONMSZ - 2])
-                               *cp++ = getchar();
+                               *cp++ = ex_getchar();
                } while (isalnum(peekchar()));
                *cp = 0;
                cp = optname;
                } while (isalnum(peekchar()));
                *cp = 0;
                cp = optname;
@@ -46,7 +55,7 @@ set()
                if (eq(cp, "w300")) {
                        if (ospeed >= B1200) {
 dontset:
                if (eq(cp, "w300")) {
                        if (ospeed >= B1200) {
 dontset:
-                               ignore(getchar());      /* = */
+                               ignore(ex_getchar());   /* = */
                                ignore(getnum());       /* value */
                                continue;
                        }
                                ignore(getnum());       /* value */
                                continue;
                        }
@@ -83,7 +92,7 @@ printone:
                        serror("Option %s is not a toggle", op->oname);
                if (c != 0 || setend())
                        goto printone;
                        serror("Option %s is not a toggle", op->oname);
                if (c != 0 || setend())
                        goto printone;
-               if (getchar() != '=')
+               if (ex_getchar() != '=')
                        serror("Missing =@in assignment to option %s", op->oname);
                switch (op->otype) {
 
                        serror("Missing =@in assignment to option %s", op->oname);
                switch (op->otype) {
 
@@ -93,8 +102,13 @@ printone:
                        op->ovalue = getnum();
                        if (value(TABSTOP) <= 0)
                                value(TABSTOP) = TABS;
                        op->ovalue = getnum();
                        if (value(TABSTOP) <= 0)
                                value(TABSTOP) = TABS;
-                       if (op == &options[WINDOW])
+                       if (value(HARDTABS) <= 0)
+                               value(HARDTABS) = TABS;
+                       if (op == &options[WINDOW]) {
+                               if (value(WINDOW) >= LINES)
+                                       value(WINDOW) = LINES-1;
                                vsetsiz(value(WINDOW));
                                vsetsiz(value(WINDOW));
+                       }
                        break;
 
                case STRING:
                        break;
 
                case STRING:
@@ -104,9 +118,9 @@ printone:
                                if (cp >= &optname[ONMSZ])
                                        error("String too long@in option assignment");
                                /* adb change:  allow whitepace in strings */
                                if (cp >= &optname[ONMSZ])
                                        error("String too long@in option assignment");
                                /* adb change:  allow whitepace in strings */
-                               if( (*cp = getchar()) == '\\')
+                               if( (*cp = ex_getchar()) == '\\')
                                        if( peekchar() != EOF)
                                        if( peekchar() != EOF)
-                                               *cp = getchar();
+                                               *cp = ex_getchar();
                                cp++;
                        }
                        *cp = 0;
                                cp++;
                        }
                        *cp = 0;
@@ -190,7 +204,7 @@ propts()
                        break;
                }
                propt(op);
                        break;
                }
                propt(op);
-               putchar(' ');
+               ex_putchar(' ');
        }
        noonl();
        flush();
        }
        noonl();
        flush();
@@ -206,16 +220,16 @@ propt(op)
        switch (op->otype) {
 
        case ONOFF:
        switch (op->otype) {
 
        case ONOFF:
-               printf("%s%s", op->ovalue ? "" : "no", name);
+               ex_printf("%s%s", op->ovalue ? "" : "no", name);
                break;
 
        case NUMERIC:
                break;
 
        case NUMERIC:
-               printf("%s=%d", name, op->ovalue);
+               ex_printf("%s=%d", name, op->ovalue);
                break;
 
        case STRING:
        case OTERM:
                break;
 
        case STRING:
        case OTERM:
-               printf("%s=%s", name, op->osvalue);
+               ex_printf("%s=%s", name, op->osvalue);
                break;
        }
 }
                break;
        }
 }