SedCom *pend = pspace+MAXCMDS; /* End of command storage */
SedCom *rep = pspace; /* Current fill point */
+int dollars; /* Number of dollar (first) addresses */
+
Reprog *lastre; /* Last regular expression */
Resub subexp[MAXSUB]; /* sub-patterns of pattern match*/
int nflag; /* Command line flags */
int gflag;
+int uflag;
int dolflag; /* Set when at true EOF */
int sflag; /* Set when substitution done */
case 'n':
nflag++;
continue;
+ case 'u':
+ uflag++;
+ continue;
default:
quit("Unknown flag: %c", ARGC());
} ARGEND
address(&rep->ad1);
if (rep->ad1.type != A_NONE) {
+ if (rep->ad1.type == A_DOL)
+ dollars++;
if (rep->ad1.type == A_LAST) {
if (!lastre)
quit("First RE may not be null");
quit(CGMES, L"r.e.-using", linebuf);
}
+int
+flushout(Biobufhdr *bp, void *v, long n)
+{
+ int i;
+
+ for(i = 0; i < nfiles; i++)
+ Bflush(fcode[i]);
+ return read(bp->fid, v, n);
+}
+
void
newfile(enum PTYPE type, char *name)
{
if ((prog.bp = Bopen(name, OREAD)) == 0)
quit("Cannot open pattern-file: %s\n", name);
Blethal(prog.bp, nil);
+ if(uflag) Biofn(prog.bp, flushout);
}
prog.type = type;
}
if((fi = Bopen(buf, OREAD)) == 0)
continue;
Blethal(fi, nil);
+ if(uflag) Biofn(fi, flushout);
while((c = Bgetc(fi)) >= 0)
Bputc(&fout, c);
Bterm(fi);
p = addr;
for (c = (peekc? peekc: Bgetrune(f)); c >= 0; c = Bgetrune(f)) {
if (c == '\n') {
- if ((peekc = Bgetrune(f)) < 0 && fhead == nil)
+ if (dollars != 0 && (peekc = Bgetrune(f)) < 0 && fhead == nil)
dolflag = 1;
*p = '\0';
return p;
f = &stdin;
}
Blethal(f, nil);
+ if(uflag) Biofn(f, flushout);
fhead = fhead->next;
return 1;
}