From: markus schnalke Date: Thu, 22 Mar 2012 18:05:02 +0000 (+0100) Subject: scansbr: Further refactoring. X-Git-Tag: mmh-thesis-end~233 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=b0f7bd3419973481892d77ab5937ce520700e185 scansbr: Further refactoring. --- diff --git a/uip/scansbr.c b/uip/scansbr.c index ca98c5a..9f4143e 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -49,7 +49,7 @@ static int dat[5]; /* aux. data for format routine */ char *scanl = NULL; /* text of most recent scanline */ #define FPUTS(buf) {\ - if (fputs(buf,scnout) == EOF)\ + if (fputs(buf, scnout) == EOF)\ adios(scnmsg, "write error on");\ } @@ -81,7 +81,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, char returnpath[BUFSIZ]; char deliverydate[BUFSIZ]; int incing = (outnum > 0); - int ismbox = (outnum != 0); + int scanfolder = (outnum == 0); /* first-time only initialization */ if (!scanl) { @@ -167,8 +167,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, compnum++; if (incing) { FPUTS(name); - if (putc(':', scnout) == EOF) - adios(scnmsg, "write error on"); + FPUTS(":"); FPUTS(tmpbuf); } /* @@ -210,8 +209,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, state = FILEEOF; /* stop here if scan cmd */ goto finished; } - if (putc('\n', scnout) == EOF) - adios(scnmsg, "write error on"); + FPUTS("\n"); FPUTS(tmpbuf); /* ** performance hack: some people like to run "inc" @@ -259,14 +257,11 @@ body:; if (incing) { FPUTS("\n\nBAD MSG:\n"); FPUTS(name); - if (putc('\n', scnout) == EOF) - adios(scnmsg, "write error on"); - } - if (ismbox) { + FPUTS("\n"); state = BODY; goto body; } - /* fall through */ + /* fall through if we scan only */ case FILEEOF: goto finished; @@ -295,14 +290,14 @@ finished: adios(scnmsg, "write error on"); } - if ((datecomp && !datecomp->c_text) || !ismbox) { + if ((datecomp && !datecomp->c_text) || scanfolder) { struct stat st; fstat(fileno(inb), &st); - if (!ismbox) + if (scanfolder) dat[2] = st.st_size; if (datecomp) { - if (! datecomp->c_text) { + if (!datecomp->c_text) { if (datecomp->c_tws == NULL) datecomp->c_tws = (struct tws *) calloc((size_t) 1, sizeof(*datecomp->c_tws)); if (datecomp->c_tws == NULL)