projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* uip/post.c, uip/spost.c: Move the uptolow macro from spost.c to post.c
[mmh]
/
uip
/
replsbr.c
diff --git
a/uip/replsbr.c
b/uip/replsbr.c
index
4b2b30d
..
244fdc9
100644
(file)
--- a/
uip/replsbr.c
+++ b/
uip/replsbr.c
@@
-12,7
+12,9
@@
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
+#include <h/utils.h>
#include <sys/file.h> /* L_SET */
#include <sys/file.h> /* L_SET */
+#include <errno.h>
extern short ccto; /* from repl.c */
extern short cccc;
extern short ccto; /* from repl.c */
extern short cccc;
@@
-103,8
+105,7
@@
replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
*--savecomp = NULL; /* point at zero'd end minus 1 */
for (i = ncomps; i--; )
*--savecomp = NULL; /* point at zero'd end minus 1 */
for (i = ncomps; i--; )
- if (!(*nxtbuf++ = malloc(SBUFSIZ)))
- adios (NULL, "unable to allocate component buffer");
+ *nxtbuf++ = mh_xmalloc(SBUFSIZ);
nxtbuf = compbuffers; /* point at start */
tmpbuf = *nxtbuf++;
nxtbuf = compbuffers; /* point at start */
tmpbuf = *nxtbuf++;
@@
-229,7
+230,7
@@
finished:
}
}
i = format_len + char_read + 256;
}
}
i = format_len + char_read + 256;
- scanl = malloc ((size_t) i + 2);
+ scanl = mh_xmalloc ((size_t) i + 2);
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
@@
-247,6
+248,10
@@
finished:
* or add mhn directives
*/
if (filter) {
* or add mhn directives
*/
if (filter) {
+ fflush(out);
+ if (ferror (out))
+ adios (drft, "error writing");
+
replfilter (inb, out, filter);
} else if (mime && mp) {
fprintf (out, "#forw [original message] +%s %s\n",
replfilter (inb, out, filter);
} else if (mime && mp) {
fprintf (out, "#forw [original message] +%s %s\n",
@@
-286,11
+291,9
@@
static unsigned int bufsiz=0; /* current size of buf */
int i = dst - buf;\
int n = last_dst - buf;\
bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
int i = dst - buf;\
int n = last_dst - buf;\
bufsiz += ((dst + len - bufend) / BUFINCR + 1) * BUFINCR;\
- buf = realloc (buf, bufsiz);\
+ buf = mh_xrealloc (buf, bufsiz);\
dst = buf + i;\
last_dst = buf + n;\
dst = buf + i;\
last_dst = buf + n;\
- if (! buf)\
- adios (NULL, "formataddr: couldn't get buffer space");\
bufend = buf + bufsiz;\
}
bufend = buf + bufsiz;\
}
@@
-319,9
+322,7
@@
formataddr (char *orig, char *str)
/* if we don't have a buffer yet, get one */
if (bufsiz == 0) {
/* if we don't have a buffer yet, get one */
if (bufsiz == 0) {
- buf = malloc (BUFINCR);
- if (! buf)
- adios (NULL, "formataddr: couldn't allocate buffer space");
+ buf = mh_xmalloc (BUFINCR);
last_dst = buf; /* XXX */
bufsiz = BUFINCR - 6; /* leave some slop */
bufend = buf + bufsiz;
last_dst = buf; /* XXX */
bufsiz = BUFINCR - 6; /* leave some slop */
bufend = buf + bufsiz;
@@
-413,6
+414,8
@@
insert (struct mailname *np)
/*
* Call the mhlproc
/*
* Call the mhlproc
+ *
+ * This function expects that argument out has been fflushed by the caller.
*/
static void
*/
static void
@@
-420,6
+423,7
@@
replfilter (FILE *in, FILE *out, char *filter)
{
int pid;
char *mhl;
{
int pid;
char *mhl;
+ char *errstr;
if (filter == NULL)
return;
if (filter == NULL)
return;
@@
-431,7
+435,6
@@
replfilter (FILE *in, FILE *out, char *filter)
rewind (in);
lseek (fileno(in), (off_t) 0, SEEK_SET);
rewind (in);
lseek (fileno(in), (off_t) 0, SEEK_SET);
- fflush (out);
switch (pid = vfork ()) {
case NOTOK:
switch (pid = vfork ()) {
case NOTOK:
@@
-443,8
+446,12
@@
replfilter (FILE *in, FILE *out, char *filter)
closefds (3);
execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL);
closefds (3);
execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL);
- fprintf (stderr, "unable to exec ");
- perror (mhlproc);
+ errstr = strerror(errno);
+ write(2, "unable to exec ", 15);
+ write(2, mhlproc, strlen(mhlproc));
+ write(2, ": ", 2);
+ write(2, errstr, strlen(errstr));
+ write(2, "\n", 1);
_exit (-1);
default:
_exit (-1);
default: