From aa60b0ab5e804f8befa890c0a6df0e3143ce0723 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Thu, 22 Mar 2012 18:50:10 +0100 Subject: [PATCH] scansbr: Only write to file if we're incing, but not when scanning. If the original author would have used logical flags instead of magic values in `outnum', the code wouldn't have been broken all the time. Writing to /dev/null instead of not writing at all ... oh my! :-/ --- uip/scansbr.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/uip/scansbr.c b/uip/scansbr.c index dca761c..ca98c5a 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -139,14 +139,10 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, } } - if (ismbox) { - if (incing) { - scnmsg = m_name(outnum); - if (*scnmsg == '?') /* msg num out of range */ - return SCNNUM; - } else { - scnmsg = "/dev/null"; - } + if (incing) { + scnmsg = m_name(outnum); + if (*scnmsg == '?') /* msg num out of range */ + return SCNNUM; if ((scnout = fopen(scnmsg, "w")) == NULL) adios(scnmsg, "unable to write"); /* @@ -211,7 +207,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, case BODY: compnum = -1; if (!incing) { - state = FILEEOF; /* stop now if scan cmd */ + state = FILEEOF; /* stop here if scan cmd */ goto finished; } if (putc('\n', scnout) == EOF) @@ -334,7 +330,7 @@ finished: } *--nxtbuf = tmpbuf; - if (ismbox && (ferror(scnout) || fclose(scnout) == EOF)) + if (incing && (ferror(scnout) || fclose(scnout) == EOF)) adios(scnmsg, "write error on"); return (state != FILEEOF ? SCNERR : SCNMSG); -- 1.7.10.4