int incing = (outnum != SCN_MBOX && outnum != SCN_FOLD);
int scanfolder = (outnum == SCN_FOLD);
long fpos;
+ struct stat st;
/* first-time only initialization */
if (!scanl) {
- if (width == 0) {
- if ((width = sc_width()) < WIDTH/2)
- width = WIDTH/2;
- else if (width > MAXSCANL)
- width = MAXSCANL;
- }
- dat[3] = slwidth = width;
- scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH *
- (slwidth + 2)); /* probably for \n and \0 */
if (incing)
umask(~m_gmprot());
- /* Compile format string */
- ncomps = fmt_compile(fmtstr, &fmt) + 1;
+ if (fmtstr) {
+ if (width == 0) {
+ if ((width = sc_width()) < WIDTH/2)
+ width = WIDTH/2;
+ else if (width > MAXSCANL)
+ width = MAXSCANL;
+ }
+ dat[3] = slwidth = width;
+ scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH *
+ (slwidth + 2)); /* probably for \n and \0 */
+ /* Compile format string */
+ ncomps = fmt_compile(fmtstr, &fmt) + 1;
+ FINDCOMP(datecomp, "date");
+ } else {
+ ncomps = 1;
+ datecomp = NULL;
+ }
- FINDCOMP(datecomp, "date");
nxtbuf = compbuffers = (char **) calloc((size_t) ncomps,
sizeof(char *));
if (!nxtbuf)
** temp buffer (buffer switching saves an extra
** copy of the component text).
*/
- if ((cptr = wantcomp[CHASH(name)])) {
+ if (fmtstr && (cptr = wantcomp[CHASH(name)])) {
do {
- if (!mh_strcasecmp(name, cptr->c_name)) {
- if (! cptr->c_text) {
- cptr->c_text = tmpbuf;
- for (cp = tmpbuf + strlen(tmpbuf) - 1; cp >= tmpbuf; cp--)
- if (isspace(*cp))
- *cp = 0;
- else
- break;
- *--savecomp = cptr;
- tmpbuf = *nxtbuf++;
+ if (mh_strcasecmp(name, cptr->c_name)!=0) {
+ continue;
+ }
+ if (!cptr->c_text) {
+ cptr->c_text = tmpbuf;
+ cp = tmpbuf+strlen(tmpbuf)-1;
+ for (; cp >= tmpbuf; cp--) {
+ if (isspace(*cp))
+ *cp = '\0';
+ else
+ break;
}
- break;
+ *--savecomp = cptr;
+ tmpbuf = *nxtbuf++;
}
+ break;
} while ((cptr = cptr->c_next));
}
dat[2] -= fpos;
}
- if ((datecomp && !datecomp->c_text) || scanfolder) {
- struct stat st;
-
+ if (fmtstr) {
fstat(fileno(inb), &st);
- if (scanfolder)
+ if (scanfolder) {
dat[2] = st.st_size;
- if (datecomp) {
+ }
+ if (datecomp && !datecomp->c_text) {
if (!datecomp->c_text) {
if (!datecomp->c_tws)
datecomp->c_tws = (struct tws *) calloc((size_t) 1, sizeof(*datecomp->c_tws));
datecomp->c_flags &= ~CF_DATEFAB;
}
}
- }
- /* print the scan line */
- fmt_scan(fmt, scanl, slwidth, dat);
- if (fmtstr)
+ /* print the scan line */
+ fmt_scan(fmt, scanl, slwidth, dat);
fputs(scanl, stdout);
+ }
/* return dynamically allocated buffers to pool */
while ((cptr = *savecomp++)) {