I know that this code is not used. I kept it available in case it would be useful again. It wasn't because of the copy code but because of the dash-stuffing code. I just wasn't sure if we would need that again. So much for the background.
... but well, not that I read the comment about the sed equivalent ... seems as if we can apply your patch then. If we need dash-stuffing again, we'd better use sed for it. meillo [2016-09-08 13:03] [email protected] > > From: Dmitry Bogatov <[email protected]> > > --- > sbr/Makefile.in | 3 +-- > sbr/cpydgst.c | 68 > --------------------------------------------------------- > 2 files changed, 1 insertion(+), 70 deletions(-) > delete mode 100644 sbr/cpydgst.c > > diff --git a/sbr/Makefile.in b/sbr/Makefile.in > index f60bd9a..e264454 100644 > --- a/sbr/Makefile.in > +++ b/sbr/Makefile.in > @@ -49,7 +49,7 @@ SRCS = addrsbr.c ambigsw.c brkstring.c \ > charset.c concat.c context_del.c \ > context_find.c context_read.c \ > context_replace.c context_save.c \ > - cpydata.c cpydgst.c crawl_folders.c \ > + cpydata.c crawl_folders.c \ > dtime.c dtimep.c \ > error.c execprog.c ext_hook.c folder_addmsg.c folder_delmsgs.c \ > folder_free.c folder_read.c \ > @@ -128,4 +128,3 @@ subdir = sbr > > Makefile: Makefile.in ../config.status > cd .. && ./config.status $(subdir)/$@ > - > diff --git a/sbr/cpydgst.c b/sbr/cpydgst.c > deleted file mode 100644 > index 5e5ef87..0000000 > --- a/sbr/cpydgst.c > +++ /dev/null > @@ -1,68 +0,0 @@ > -/* > -** cpydgst.c -- copy from one fd to another in encapsulating mode > -** -- (do dashstuffing of input data). > -** > -** This code is Copyright (c) 2002, by the authors of nmh. See the > -** COPYRIGHT file in the root directory of the nmh distribution for > -** complete copyright information. > -*/ > - > -#include <sysexits.h> > -#include <unistd.h> > -#include <h/mh.h> > - > -/* > -** We want to perform the substitution > -** > -** \n(-.*)\n --> \n- \1\n > -** > -** This is equivalent to the sed substitution > -** > -** sed -e 's%^-%- -%' < ifile > ofile > -** > -** but the routine below is faster than the pipe, fork, and exec. > -*/ > - > -#define S1 0 > -#define S2 1 > - > -#define output(c) if (bp >= dp) {flush(); *bp++ = c;} else *bp++ = c > -#define flush() if ((j = bp - outbuf) && write(out, outbuf, j) != j) \ > - adios(EX_IOERR, ofile, "error writing"); \ > - else \ > - bp = outbuf > - > - > -void > -cpydgst(int in, int out, char *ifile, char *ofile) > -{ > - int i, j, state; > - char *cp, *ep; > - char *bp, *dp; > - char buffer[BUFSIZ], outbuf[BUFSIZ]; > - > - dp = (bp = outbuf) + sizeof outbuf; > - for (state = S1; (i = read(in, buffer, sizeof buffer)) > 0;) > - for (ep = (cp = buffer) + i; cp < ep; cp++) { > - if (*cp == '\0') > - continue; > - switch (state) { > - case S1: > - if (*cp == '-') { > - output('-'); > - output(' '); > - } > - state = S2; /* fall */ > - > - case S2: > - output(*cp); > - if (*cp == '\n') > - state = S1; > - break; > - } > - } > - > - if (i == -1) > - adios(EX_IOERR, ifile, "error reading"); > - flush(); > -} > -- > I may be not subscribed. Please, keep me in carbon copy. > > >
