Bill added more buffers, and I put in sccs.
[unix-history] / usr / src / usr.bin / ex / ex_re.c
index cf06929..60415b3 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/* Copyright (c) 1980 Regents of the University of California */
+static char *sccsid = "@(#)ex_re.c     4.2 %G%";
 #include "ex.h"
 #include "ex_re.h"
 
 #include "ex.h"
 #include "ex_re.h"
 
@@ -104,7 +105,7 @@ out:
        }
 }
 
        }
 }
 
-bool   xflag;
+bool   cflag;
 int    scount, slines, stotal;
 
 substitute(c)
 int    scount, slines, stotal;
 
 substitute(c)
@@ -145,7 +146,7 @@ substitute(c)
                        addr2 += n;
                }
        }
                        addr2 += n;
                }
        }
-       if (stotal == 0 && !inglobal && !xflag)
+       if (stotal == 0 && !inglobal && !cflag)
                error("Fail|Substitute pattern match failed");
        snote(stotal, slines);
        return (stotal);
                error("Fail|Substitute pattern match failed");
        snote(stotal, slines);
        return (stotal);
@@ -157,7 +158,7 @@ compsub(ch)
        static int gsubf;
 
        if (!value(EDCOMPATIBLE))
        static int gsubf;
 
        if (!value(EDCOMPATIBLE))
-               gsubf = xflag = 0;
+               gsubf = cflag = 0;
        uselastre = 0;
        switch (ch) {
 
        uselastre = 0;
        switch (ch) {
 
@@ -174,7 +175,7 @@ compsub(ch)
                uselastre = 1;
                comprhs(seof);
                gsubf = 0;
                uselastre = 1;
                comprhs(seof);
                gsubf = 0;
-               xflag = 0;
+               cflag = 0;
                break;
 
        case '~':
                break;
 
        case '~':
@@ -184,6 +185,8 @@ compsub(ch)
        redo:
                if (re.Expbuf[0] == 0)
                        error("No previous re|No previous regular expression");
        redo:
                if (re.Expbuf[0] == 0)
                        error("No previous re|No previous regular expression");
+               if (subre.Expbuf[0] == 0)
+                       error("No previous substitute re|No previous substitute to repeat");
                break;
        }
        for (;;) {
                break;
        }
        for (;;) {
@@ -195,7 +198,7 @@ compsub(ch)
                        continue;
 
                case 'c':
                        continue;
 
                case 'c':
-                       xflag = !xflag;
+                       cflag = !cflag;
                        continue;
 
                case 'r':
                        continue;
 
                case 'r':
@@ -307,7 +310,7 @@ confirmed(a)
 {
        register int c, ch;
 
 {
        register int c, ch;
 
-       if (xflag == 0)
+       if (cflag == 0)
                return (1);
        pofix();
        pline(lineno(a));
                return (1);
        pofix();
        pline(lineno(a));
@@ -522,7 +525,7 @@ complex:
                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");
-                       *ep++ = CEOF;
+                       *ep++ = CEOFC;
                        if (c == EOF)
                                ungetchar(c);
                        return (eof);
                        if (c == EOF)
                                ungetchar(c);
                        return (eof);
@@ -647,7 +650,7 @@ cerror("Bad \\n|\\n in regular expression with n greater than the number of \\('
                case '\n':
                        if (oknl) {
                                ungetchar(c);
                case '\n':
                        if (oknl) {
                                ungetchar(c);
-                               *ep++ = CEOF;
+                               *ep++ = CEOFC;
                                return (eof);
                        }
 cerror("Badly formed re|Missing closing delimiter for regular expression");
                                return (eof);
                        }
 cerror("Badly formed re|Missing closing delimiter for regular expression");
@@ -701,10 +704,6 @@ execute(gf, addr)
        if (gf) {
                if (circfl)
                        return (0);
        if (gf) {
                if (circfl)
                        return (0);
-#ifdef notdef
-               if (loc1 == loc2)
-                       loc2++;
-#endif
                locs = p1 = loc2;
        } else {
                if (addr == zero)
                locs = p1 = loc2;
        } else {
                if (addr == zero)
@@ -783,7 +782,7 @@ advance(lp, ep)
                        continue;
                return (0);
 
                        continue;
                return (0);
 
-       case CEOF:
+       case CEOFC:
                loc2 = lp;
                return (1);
 
                loc2 = lp;
                return (1);