From: David Levine Date: Sun, 31 Aug 2014 20:40:57 +0000 (-0500) Subject: A value of 0 for the width switch of scan(1), inc(1), ap(1), dp(1), X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/2adafe760a9c45b417727a3f5d9481de26471a8b?ds=inline;hp=-c A value of 0 for the width switch of scan(1), inc(1), ap(1), dp(1), fmttest(1), and mhl(1) now means as many characters as the format engine can produce [Bug #15274]. That amount is limited by internal buffers. --- 2adafe760a9c45b417727a3f5d9481de26471a8b diff --git a/docs/pending-release-notes b/docs/pending-release-notes index 941a13ed..6ceb7bd6 100644 --- a/docs/pending-release-notes +++ b/docs/pending-release-notes @@ -6,6 +6,10 @@ NEW FEATURES - builds use OpenSSL if available. - post now defaults to port 587 on 'smtp' message submission. +- A value of 0 for the width switch of scan(1), inc(1), ap(1), dp(1), + fmttest(1), and mhl(1) now means as many characters as the format + engine can produce [Bug #15274]. That amount is limited by internal + buffers. ----------------- OBSOLETE FEATURES diff --git a/man/fmttest.man b/man/fmttest.man index 908b3cbe..a8f145bb 100644 --- a/man/fmttest.man +++ b/man/fmttest.man @@ -1,4 +1,4 @@ -.TH FMTTEST %manext1% "August 24, 2014" "%nmhversion%" +.TH FMTTEST %manext1% "August 31, 2014" "%nmhversion%" .\" .\" %nmhwarning% .\" @@ -213,11 +213,14 @@ characters with zero width, and extra bytes that are part of a multibyte character are not counted against this total. Two special values are supported: .RI \*(lq max \*(rq, -which will set the value to the maximum value of an integer, and +which means as many characters as the format engine can produce +(limited by internal buffers), and .RI \*(lq width \*(rq, which will set the -value to the width of the terminal. In message mode it defaults to the -terminal width, otherwise the default is the maximum value of an integer. +value to the width of the terminal. In message mode it defaults to +.RI \*(lq width \*(rq, +otherwise the default is +.RI \*(lq max \*(rq. .PP The .B \-width diff --git a/uip/ap.c b/uip/ap.c index 1148871d..3dd77b17 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -15,7 +15,6 @@ #define NADDRS 100 #define WIDTH 78 -#define WBUFSIZ BUFSIZ #define FORMAT "%<{error}%{error}: %{text}%|%(putstr(proper{text}))%>" @@ -48,7 +47,7 @@ int main (int argc, char **argv) { int addrp = 0; - int width = 0, status = 0; + int width = -1, status = 0; char *cp, *form = NULL, *format = NULL, *nfs; char buf[BUFSIZ], **argp; char **arguments, *addrs[NADDRS]; @@ -109,13 +108,16 @@ main (int argc, char **argv) /* get new format string */ nfs = new_fs (form, format, FORMAT); - if (width == 0) { - if ((width = sc_width ()) < WIDTH / 2) + if (width == -1) { + if ((width = sc_width ()) < WIDTH / 2) { + /* Default: width of the terminal, but at least WIDTH/2. */ width = WIDTH / 2; + } else if (width == 0) { + /* Unlimited width. */ + width = INT_MAX; + } width -= 2; } - if (width > WBUFSIZ) - width = WBUFSIZ; fmt_compile (nfs, &fmt, 1); dat[0] = 0; diff --git a/uip/dp.c b/uip/dp.c index 82d9963d..2e071973 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -14,7 +14,6 @@ #define NDATES 100 #define WIDTH 78 -#define WBUFSIZ BUFSIZ #define FORMAT "%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>" @@ -46,7 +45,7 @@ static int process (char *, int); int main (int argc, char **argv) { - int datep = 0, width = 0, status = 0; + int datep = 0, width = -1, status = 0; char *cp, *form = NULL, *format = NULL, *nfs; char buf[BUFSIZ], **argp, **arguments; char *dates[NDATES]; @@ -105,13 +104,16 @@ main (int argc, char **argv) /* get new format string */ nfs = new_fs (form, format, FORMAT); - if (width == 0) { - if ((width = sc_width ()) < WIDTH / 2) + if (width == -1) { + if ((width = sc_width ()) < WIDTH / 2) { + /* Default: width of the terminal, but at least WIDTH/2. */ width = WIDTH / 2; + } else if (width == 0) { + /* Unlimited width. */ + width = INT_MAX; + } width -= 2; } - if (width > WBUFSIZ) - width = WBUFSIZ; fmt_compile (nfs, &fmt, 1); dat[0] = 0; diff --git a/uip/inc.c b/uip/inc.c index c2213f13..2ee19960 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -171,7 +171,7 @@ int main (int argc, char **argv) { int chgflag = 1, trnflag = 1; - int noisy = 1, width = 0; + int noisy = 1, width = -1; int hghnum = 0, msgnum = 0; int sasl = 0; int incerr = 0; /* <0 if inc hits an error which means it should not truncate mailspool */ diff --git a/uip/rcvtty.c b/uip/rcvtty.c index d91b6a4e..c3fe470e 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -54,7 +54,7 @@ static jmp_buf myctx; static int bell = 1; static int newline = 1; static int biff = 0; -static int width = 0; +static int width = -1; static char *form = NULL; static char *format = NULL; diff --git a/uip/scan.c b/uip/scan.c index 8ba50367..e556e8f2 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -41,7 +41,7 @@ int main (int argc, char **argv) { int clearflag = 0, hdrflag = 0, ontty; - int width = 0, revflag = 0; + int width = -1, revflag = 0; int i, state, msgnum; ivector_t seqnum = ivector_create (0); int unseen, num_unseen_seq = 0; diff --git a/uip/scansbr.c b/uip/scansbr.c index 60acec90..2111bc16 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -14,8 +14,6 @@ #include #include -#define MAXSCANL 256 /* longest possible scan line */ - /* * Buffer size for content part of header fields. We want this * to be large enough so that we don't do a lot of extra FLDPLUS @@ -68,11 +66,13 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, way the code is now, with callers initializing *scanl to NULL. scanl used to be a global. */ if (! *scanl) { - if (width == 0) { + if (width == -1) { + /* Default: width of the terminal, but at least WIDTH/2. */ if ((width = sc_width ()) < WIDTH/2) width = WIDTH/2; - else if (width > MAXSCANL) - width = MAXSCANL; + } else if (width == 0) { + /* Unlimited width. */ + width = INT_MAX; } dat[3] = slwidth = width; *scanl = charstring_create (width);