added depend label
[unix-history] / usr / src / usr.bin / ex / ex_get.c
index 843cfef..7dbcc91 100644 (file)
@@ -1,5 +1,13 @@
-/* Copyright (c) 1980 Regents of the University of California */
-static char *sccsid = "@(#)ex_get.c    5.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_get.c    7.7 (Berkeley) %G%";
+#endif not lint
+
 #include "ex.h"
 #include "ex_tty.h"
 
 #include "ex.h"
 #include "ex_tty.h"
 
@@ -13,10 +21,10 @@ short       lastc = '\n';
 
 ignchar()
 {
 
 ignchar()
 {
-       ignore(getchar());
+       ignore(ex_getchar());
 }
 
 }
 
-getchar()
+ex_getchar()
 {
        register int c;
 
 {
        register int c;
 
@@ -49,13 +57,12 @@ peekchar()
 {
 
        if (peekc == 0)
 {
 
        if (peekc == 0)
-               peekc = getchar();
+               peekc = ex_getchar();
        return (peekc);
 }
 
 peekcd()
 {
        return (peekc);
 }
 
 peekcd()
 {
-
        if (peekc == 0)
                peekc = getcd();
        return (peekc);
        if (peekc == 0)
                peekc = getcd();
        return (peekc);
@@ -64,7 +71,7 @@ peekcd()
 getach()
 {
        register int c;
 getach()
 {
        register int c;
-       static char inline[128];
+       static char inline[BUFSIZ];
 
        c = peekc;
        if (c != 0) {
 
        c = peekc;
        if (c != 0) {
@@ -102,9 +109,12 @@ top:
                input = inline;
                goto top;
        }
                input = inline;
                goto top;
        }
-       if (read(0, (char *) &lastc, 1) != 1)
-               lastc = EOF;
-       return (lastc);
+       c = read(0, inline, sizeof inline - 1);
+       if(c <= 0)
+               return(lastc = EOF);
+       inline[c] = '\0';
+       input = inline;
+       goto top;
 }
 
 /*
 }
 
 /*
@@ -126,7 +136,7 @@ gettty()
        if (intty && !inglobal) {
                if (offset) {
                        holdcm = 1;
        if (intty && !inglobal) {
                if (offset) {
                        holdcm = 1;
-                       printf("  %4d  ", lineDOT() + 1);
+                       ex_printf("  %4d  ", lineDOT() + 1);
                        flush();
                        holdcm = 0;
                }
                        flush();
                        holdcm = 0;
                }
@@ -154,13 +164,13 @@ gettty()
                                        if (c == '0')
                                                lastin = 0;
                                        if (!OS) {
                                        if (c == '0')
                                                lastin = 0;
                                        if (!OS) {
-                                               putchar('\b' | QUOTE);
-                                               putchar(' ' | QUOTE);
-                                               putchar('\b' | QUOTE);
+                                               ex_putchar('\b' | QUOTE);
+                                               ex_putchar(' ' | QUOTE);
+                                               ex_putchar('\b' | QUOTE);
                                        }
                                        tab(offset);
                                        hadup = 1;
                                        }
                                        tab(offset);
                                        hadup = 1;
-                                       c = getchar();
+                                       c = ex_getchar();
                                } else
                                        ungetchar(ch);
                                break;
                                } else
                                        ungetchar(ch);
                                break;
@@ -183,12 +193,12 @@ gettty()
                holdcm = 0;
        }
        if (c == 0)
                holdcm = 0;
        }
        if (c == 0)
-               c = getchar();
+               c = ex_getchar();
        while (c != EOF && c != '\n') {
                if (cp > &genbuf[LBSIZE - 2])
                        error("Input line too long");
                *cp++ = c;
        while (c != EOF && c != '\n') {
                if (cp > &genbuf[LBSIZE - 2])
                        error("Input line too long");
                *cp++ = c;
-               c = getchar();
+               c = ex_getchar();
        }
        if (c == EOF) {
                if (inglobal)
        }
        if (c == EOF) {
                if (inglobal)