only count header lines that are actually going to be displayed
when deciding whether to run $PAGER, otherwise it may start up the pager for a two line message if all 55 header lines are the subject of a .mailrc ignore command. (And no, I don't find this program directly useful for reading today's mail volumes, but it's great as a component run from wrapper scripts, pretty good for scanning archived mail, and more than adequate for sending mail.)
This commit is contained in:
parent
ea03e4fc22
commit
3038d491a5
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cmd1.c,v 1.18 2002/03/05 21:29:30 wiz Exp $ */
|
||||
/* $NetBSD: cmd1.c,v 1.19 2002/03/29 15:07:52 ross Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: cmd1.c,v 1.18 2002/03/05 21:29:30 wiz Exp $");
|
||||
__RCSID("$NetBSD: cmd1.c,v 1.19 2002/03/29 15:07:52 ross Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -201,7 +201,7 @@ printhead(int mesg)
|
||||
if (mp->m_flag & MBOX)
|
||||
dispc = 'M';
|
||||
parse(headline, &hl, pbuf);
|
||||
snprintf(wcount, LINESIZE, "%3ld/%-5ld", mp->m_lines, mp->m_size);
|
||||
snprintf(wcount, LINESIZE, "%3ld/%-5ld", mp->m_blines, mp->m_size);
|
||||
subjlen = screenwidth - 50 - strlen(wcount);
|
||||
name = value("show-rcpt") != NULL ?
|
||||
skin(hfield("to", mp)) : nameof(mp, 0);
|
||||
@ -317,7 +317,7 @@ type1(int *msgvec, int doign, int page)
|
||||
nlines = 0;
|
||||
if (!page) {
|
||||
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++)
|
||||
nlines += message[*ip - 1].m_lines;
|
||||
nlines += message[*ip - 1].m_blines;
|
||||
}
|
||||
if (page || nlines > (*cp ? atoi(cp) : realscreenheight)) {
|
||||
cp = value("PAGER");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cmd3.c,v 1.17 2002/03/05 21:29:30 wiz Exp $ */
|
||||
/* $NetBSD: cmd3.c,v 1.18 2002/03/29 15:07:52 ross Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: cmd3.c,v 1.17 2002/03/05 21:29:30 wiz Exp $");
|
||||
__RCSID("$NetBSD: cmd3.c,v 1.18 2002/03/29 15:07:52 ross Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -337,7 +337,7 @@ messize(void *v)
|
||||
for (ip = msgvec; *ip != 0; ip++) {
|
||||
mesg = *ip;
|
||||
mp = &message[mesg-1];
|
||||
printf("%d: %ld/%ld\n", mesg, mp->m_lines, mp->m_size);
|
||||
printf("%d: %ld/%ld\n", mesg, mp->m_blines, mp->m_size);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: def.h,v 1.14 2002/03/04 03:16:10 wiz Exp $ */
|
||||
/* $NetBSD: def.h,v 1.15 2002/03/29 15:07:52 ross Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)def.h 8.4 (Berkeley) 4/20/95
|
||||
* $NetBSD: def.h,v 1.14 2002/03/04 03:16:10 wiz Exp $
|
||||
* $NetBSD: def.h,v 1.15 2002/03/29 15:07:52 ross Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -83,6 +83,7 @@ struct message {
|
||||
short m_offset; /* offset in block of message */
|
||||
long m_size; /* Bytes in the message */
|
||||
long m_lines; /* Lines in the message */
|
||||
long m_blines; /* Body (non-header) lines */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: edit.c,v 1.14 2002/03/06 13:45:51 wiz Exp $ */
|
||||
/* $NetBSD: edit.c,v 1.15 2002/03/29 15:07:52 ross Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: edit.c,v 1.14 2002/03/06 13:45:51 wiz Exp $");
|
||||
__RCSID("$NetBSD: edit.c,v 1.15 2002/03/29 15:07:52 ross Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -120,11 +120,22 @@ edit1(int *msgvec, int editortype)
|
||||
mp->m_offset = offsetof(size);
|
||||
mp->m_size = fsize(fp);
|
||||
mp->m_lines = 0;
|
||||
mp->m_blines = 0;
|
||||
mp->m_flag |= MODIFY;
|
||||
rewind(fp);
|
||||
while ((c = getc(fp)) != EOF) {
|
||||
if (c == '\n')
|
||||
//
|
||||
// XXX. if you edit a message, we treat
|
||||
// header lines as body lines in the recount.
|
||||
// This is because the original message copy
|
||||
// and the edit reread use different code to
|
||||
// count the lines, and this one here is
|
||||
// simple-minded.
|
||||
//
|
||||
if (c == '\n') {
|
||||
mp->m_lines++;
|
||||
mp->m_blines++;
|
||||
}
|
||||
if (putc(c, otf) == EOF)
|
||||
break;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fio.c,v 1.20 2002/03/05 21:29:30 wiz Exp $ */
|
||||
/* $NetBSD: fio.c,v 1.21 2002/03/29 15:07:52 ross Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: fio.c,v 1.20 2002/03/05 21:29:30 wiz Exp $");
|
||||
__RCSID("$NetBSD: fio.c,v 1.21 2002/03/29 15:07:52 ross Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -96,6 +96,7 @@ setptr(FILE *ibuf, off_t offset)
|
||||
this.m_flag = MUSED|MNEW;
|
||||
this.m_size = 0;
|
||||
this.m_lines = 0;
|
||||
this.m_blines = 0;
|
||||
this.m_block = 0;
|
||||
this.m_offset = 0;
|
||||
for (;;) {
|
||||
@ -133,6 +134,7 @@ setptr(FILE *ibuf, off_t offset)
|
||||
this.m_flag = MUSED|MNEW;
|
||||
this.m_size = 0;
|
||||
this.m_lines = 0;
|
||||
this.m_blines = 0;
|
||||
this.m_block = blockof(offset);
|
||||
this.m_offset = offsetof(offset);
|
||||
inhead = 1;
|
||||
@ -160,6 +162,17 @@ setptr(FILE *ibuf, off_t offset)
|
||||
offset += len;
|
||||
this.m_size += len;
|
||||
this.m_lines++;
|
||||
if (!inhead) {
|
||||
int lines_plus_wraps = 1;
|
||||
int linelen = strlen(linebuf);
|
||||
|
||||
if (linelen > screenwidth) {
|
||||
lines_plus_wraps = linelen / screenwidth;
|
||||
if (linelen % screenwidth != 0)
|
||||
++lines_plus_wraps;
|
||||
}
|
||||
this.m_blines += lines_plus_wraps;
|
||||
}
|
||||
maybe = linebuf[0] == 0;
|
||||
}
|
||||
}
|
||||
@ -242,6 +255,7 @@ makemessage(FILE *f, int omsgCount)
|
||||
errx(1, "Message temporary file corrupted");
|
||||
message[msgCount].m_size = 0;
|
||||
message[msgCount].m_lines = 0;
|
||||
message[msgCount].m_blines = 0;
|
||||
Fclose(f);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user