changed INDEX operator to handle multiple subscript arrays correctly
[unix-history] / usr / src / usr.bin / ex / ex_get.c
index 4d19535..4fd5135 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/* Copyright (c) 1981 Regents of the University of California */
+static char *sccsid = "@(#)ex_get.c    7.1     %G%";
 #include "ex.h"
 #include "ex_tty.h"
 
 #include "ex.h"
 #include "ex_tty.h"
 
@@ -12,11 +13,7 @@ short        lastc = '\n';
 
 ignchar()
 {
 
 ignchar()
 {
-       register int c;
-
-       do
-               c = getcd();
-       while (c == CTRL(d));
+       ignore(getchar());
 }
 
 getchar()
 }
 
 getchar()
@@ -25,7 +22,7 @@ getchar()
 
        do
                c = getcd();
 
        do
                c = getcd();
-       while (c == CTRL(d));
+       while (!globp && c == CTRL(d));
        return (c);
 }
 
        return (c);
 }
 
@@ -39,7 +36,7 @@ again:
                return (c);
        c &= TRIM;
        if (!inopen)
                return (c);
        c &= TRIM;
        if (!inopen)
-               if (c == CTRL(d))
+               if (!globp && c == CTRL(d))
                        setlastchar('\n');
                else if (junk(c)) {
                        checkjunk(c);
                        setlastchar('\n');
                else if (junk(c)) {
                        checkjunk(c);
@@ -58,7 +55,6 @@ peekchar()
 
 peekcd()
 {
 
 peekcd()
 {
-
        if (peekc == 0)
                peekc = getcd();
        return (peekc);
        if (peekc == 0)
                peekc = getcd();
        return (peekc);
@@ -68,6 +64,7 @@ getach()
 {
        register int c;
        static char inline[128];
 {
        register int c;
        static char inline[128];
+       struct stat statb;
 
        c = peekc;
        if (c != 0) {
 
        c = peekc;
        if (c != 0) {
@@ -105,8 +102,11 @@ top:
                input = inline;
                goto top;
        }
                input = inline;
                goto top;
        }
-       if (read(0, (char *) &lastc, 1) != 1)
+/* mjm:        if (read(0, (char *) &lastc, 1) != 1)   CHANGED and added else */
+       if (read(0, inline, 1) != 1)
                lastc = EOF;
                lastc = EOF;
+       else                            /* mjm: lastc is a short! */
+               lastc = inline[0];      /* mjm: in rightmost 8 bits ! */
        return (lastc);
 }
 
        return (lastc);
 }