projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replace obsolete autoconf macros
[mmh]
/
uip
/
replsbr.c
diff --git
a/uip/replsbr.c
b/uip/replsbr.c
index
1ea411c
..
0b0ba6e
100644
(file)
--- a/
uip/replsbr.c
+++ b/
uip/replsbr.c
@@
-13,6
+13,7
@@
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
#include <sys/file.h> /* L_SET */
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
#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;
@@
-76,14
+77,16
@@
replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
register char **nxtbuf;
register char **ap;
register struct comp **savecomp;
register char **nxtbuf;
register char **ap;
register struct comp **savecomp;
- int char_read = 0, format_len;
+ int char_read = 0, format_len, mask;
char name[NAMESZ], *scanl, *cp;
FILE *out;
char name[NAMESZ], *scanl, *cp;
FILE *out;
- umask(~m_gmprot());
+ mask = umask(~m_gmprot());
if ((out = fopen (drft, "w")) == NULL)
adios (drft, "unable to create");
if ((out = fopen (drft, "w")) == NULL)
adios (drft, "unable to create");
+ umask(mask);
+
/* get new format string */
cp = new_fs (form, NULL, NULL);
format_len = strlen (cp);
/* get new format string */
cp = new_fs (form, NULL, NULL);
format_len = strlen (cp);
@@
-245,12
+248,17
@@
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",
mp->foldpath, m_name (mp->lowsel));
}
replfilter (inb, out, filter);
} else if (mime && mp) {
fprintf (out, "#forw [original message] +%s %s\n",
mp->foldpath, m_name (mp->lowsel));
}
+ fflush(out);
if (ferror (out))
adios (drft, "error writing");
fclose (out);
if (ferror (out))
adios (drft, "error writing");
fclose (out);
@@
-410,6
+418,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
@@
-417,6
+427,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;
@@
-428,7
+439,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:
@@
-440,8
+450,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: