added depend label
[unix-history] / usr / src / usr.bin / ex / ex_re.c
index 170477c..c12d077 100644 (file)
@@ -1,5 +1,13 @@
-/* Copyright (c) 1981 Regents of the University of California */
-static char *sccsid = "@(#)ex_re.c     7.3     %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_re.c     7.6 (Berkeley) %G%";
+#endif not lint
+
 #include "ex.h"
 #include "ex_re.h"
 
 #include "ex.h"
 #include "ex_re.h"
 
@@ -36,11 +44,11 @@ global(k)
        nonzero();
        if (skipend())
                error("Global needs re|Missing regular expression for global");
        nonzero();
        if (skipend())
                error("Global needs re|Missing regular expression for global");
-       c = getchar();
+       c = ex_getchar();
        ignore(compile(c, 1));
        savere(scanre);
        gp = globuf;
        ignore(compile(c, 1));
        savere(scanre);
        gp = globuf;
-       while ((c = getchar()) != '\n') {
+       while ((c = ex_getchar()) != '\n') {
                switch (c) {
 
                case EOF:
                switch (c) {
 
                case EOF:
@@ -48,7 +56,7 @@ global(k)
                        goto brkwh;
 
                case '\\':
                        goto brkwh;
 
                case '\\':
-                       c = getchar();
+                       c = ex_getchar();
                        switch (c) {
 
                        case '\\':
                        switch (c) {
 
                        case '\\':
@@ -70,7 +78,6 @@ global(k)
        }
 brkwh:
        ungetchar(c);
        }
 brkwh:
        ungetchar(c);
-out:
        newline();
        *gp++ = c;
        *gp++ = 0;
        newline();
        *gp++ = c;
        *gp++ = 0;
@@ -216,7 +223,7 @@ compsub(ch)
 
        case 's':
                ignore(skipwh());
 
        case 's':
                ignore(skipwh());
-               seof = getchar();
+               seof = ex_getchar();
                if (endcmd(seof) || any(seof, "gcr")) {
                        ungetchar(seof);
                        goto redo;
                if (endcmd(seof) || any(seof, "gcr")) {
                        ungetchar(seof);
                        goto redo;
@@ -242,7 +249,7 @@ compsub(ch)
                break;
        }
        for (;;) {
                break;
        }
        for (;;) {
-               c = getchar();
+               c = ex_getchar();
                switch (c) {
 
                case 'g':
                switch (c) {
 
                case 'g':
@@ -280,13 +287,13 @@ comprhs(seof)
        rp = rhsbuf;
        CP(orhsbuf, rp);
        for (;;) {
        rp = rhsbuf;
        CP(orhsbuf, rp);
        for (;;) {
-               c = getchar();
+               c = ex_getchar();
                if (c == seof)
                        break;
                switch (c) {
 
                case '\\':
                if (c == seof)
                        break;
                switch (c) {
 
                case '\\':
-                       c = getchar();
+                       c = ex_getchar();
                        if (c == EOF) {
                                ungetchar(c);
                                break;
                        if (c == EOF) {
                                ungetchar(c);
                                break;
@@ -369,7 +376,7 @@ confirmed(a)
        pofix();
        pline(lineno(a));
        if (inopen)
        pofix();
        pline(lineno(a));
        if (inopen)
-               putchar('\n' | QUOTE);
+               ex_putchar('\n' | QUOTE);
        c = column(loc1 - 1);
        ugo(c - 1 + (inopen ? 1 : 0), ' ');
        ugo(column(loc2 - 1) - c, '^');
        c = column(loc1 - 1);
        ugo(c - 1 + (inopen ? 1 : 0), ' ');
        ugo(column(loc2 - 1) - c, '^');
@@ -379,7 +386,7 @@ again:
        if (c == '\r')
                c = '\n';
        if (inopen)
        if (c == '\r')
                c = '\n';
        if (inopen)
-               putchar(c), flush();
+               ex_putchar(c), flush();
        if (c != '\n' && c != EOF) {
                c = getkey();
                goto again;
        if (c != '\n' && c != EOF) {
                c = getkey();
                goto again;
@@ -404,7 +411,7 @@ ugo(cnt, with)
 
        if (cnt > 0)
                do
 
        if (cnt > 0)
                do
-                       putchar(with);
+                       ex_putchar(with);
                while (--cnt > 0);
 }
 
                while (--cnt > 0);
 }
 
@@ -518,9 +525,9 @@ snote(total, lines)
 
        if (!notable(total))
                return;
 
        if (!notable(total))
                return;
-       printf(mesg("%d subs|%d substitutions"), total);
+       ex_printf(mesg("%d subs|%d substitutions"), total);
        if (lines != 1 && lines != total)
        if (lines != 1 && lines != total)
-               printf(" on %d lines", lines);
+               ex_printf(" on %d lines", lines);
        noonl();
        flush();
 }
        noonl();
        flush();
 }
@@ -538,7 +545,7 @@ compile(eof, oknl)
        if (isalpha(eof) || isdigit(eof))
                error("Regular expressions cannot be delimited by letters or digits");
        ep = expbuf;
        if (isalpha(eof) || isdigit(eof))
                error("Regular expressions cannot be delimited by letters or digits");
        ep = expbuf;
-       c = getchar();
+       c = ex_getchar();
        if (eof == '\\')
                switch (c) {
 
        if (eof == '\\')
                switch (c) {
 
@@ -571,7 +578,7 @@ error("No previous substitute re|No previous substitute regular expression");
        nbra = 0;
        circfl = 0;
        if (c == '^') {
        nbra = 0;
        circfl = 0;
        if (c == '^') {
-               c = getchar();
+               c = ex_getchar();
                circfl++;
        }
        ungetchar(c);
                circfl++;
        }
        ungetchar(c);
@@ -579,7 +586,7 @@ error("No previous substitute re|No previous substitute regular expression");
                if (ep >= &expbuf[ESIZE - 2])
 complex:
                        cerror("Re too complex|Regular expression too complicated");
                if (ep >= &expbuf[ESIZE - 2])
 complex:
                        cerror("Re too complex|Regular expression too complicated");
-               c = getchar();
+               c = ex_getchar();
                if (c == eof || c == EOF) {
                        if (bracketp != bracket)
 cerror("Unmatched \\(|More \\('s than \\)'s in regular expression");
                if (c == eof || c == EOF) {
                        if (bracketp != bracket)
 cerror("Unmatched \\(|More \\('s than \\)'s in regular expression");
@@ -597,7 +604,7 @@ cerror("Unmatched \\(|More \\('s than \\)'s in regular expression");
                switch (c) {
 
                case '\\':
                switch (c) {
 
                case '\\':
-                       c = getchar();
+                       c = ex_getchar();
                        switch (c) {
 
                        case '(':
                        switch (c) {
 
                        case '(':
@@ -662,23 +669,23 @@ cerror("Illegal *|Can't * a \\n in regular expression");
                                *ep++ = CCL;
                                *ep++ = 0;
                                cclcnt = 1;
                                *ep++ = CCL;
                                *ep++ = 0;
                                cclcnt = 1;
-                               c = getchar();
+                               c = ex_getchar();
                                if (c == '^') {
                                if (c == '^') {
-                                       c = getchar();
+                                       c = ex_getchar();
                                        ep[-2] = NCCL;
                                }
                                if (c == ']')
 cerror("Bad character class|Empty character class '[]' or '[^]' cannot match");
                                while (c != ']') {
                                        if (c == '\\' && any(peekchar(), "]-^\\"))
                                        ep[-2] = NCCL;
                                }
                                if (c == ']')
 cerror("Bad character class|Empty character class '[]' or '[^]' cannot match");
                                while (c != ']') {
                                        if (c == '\\' && any(peekchar(), "]-^\\"))
-                                               c = getchar() | QUOTE;
+                                               c = ex_getchar() | QUOTE;
                                        if (c == '\n' || c == EOF)
                                                cerror("Missing ]");
                                        *ep++ = c;
                                        cclcnt++;
                                        if (ep >= &expbuf[ESIZE])
                                                goto complex;
                                        if (c == '\n' || c == EOF)
                                                cerror("Missing ]");
                                        *ep++ = c;
                                        cclcnt++;
                                        if (ep >= &expbuf[ESIZE])
                                                goto complex;
-                                       c = getchar();
+                                       c = ex_getchar();
                                }
                                lastep[1] = cclcnt;
                                continue;
                                }
                                lastep[1] = cclcnt;
                                continue;
@@ -753,6 +760,7 @@ same(a, b)
 
 char   *locs;
 
 
 char   *locs;
 
+/* VARARGS1 */
 execute(gf, addr)
        line *addr;
 {
 execute(gf, addr)
        line *addr;
 {
@@ -806,8 +814,6 @@ advance(lp, ep)
        register char *lp, *ep;
 {
        register char *curlp;
        register char *lp, *ep;
 {
        register char *curlp;
-       char *sp, *sp1;
-       int c;
 
        for (;;) switch (*ep++) {
 
 
        for (;;) switch (*ep++) {