From: markus schnalke Date: Thu, 22 Mar 2012 17:50:10 +0000 (+0100) Subject: scansbr: Only write to file if we're incing, but not when scanning. X-Git-Tag: mmh-thesis-end~234 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=aa60b0ab5e804f8befa890c0a6df0e3143ce0723 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! :-/ --- 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);