]> diplodocus.org Git - nmh/commitdiff
A value of 0 for the width switch of scan(1), inc(1), ap(1), dp(1),
authorDavid Levine <levinedl@acm.org>
Sun, 31 Aug 2014 20:40:57 +0000 (15:40 -0500)
committerDavid Levine <levinedl@acm.org>
Sun, 31 Aug 2014 20:40:57 +0000 (15:40 -0500)
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.

docs/pending-release-notes
man/fmttest.man
uip/ap.c
uip/dp.c
uip/inc.c
uip/rcvtty.c
uip/scan.c
uip/scansbr.c

index 941a13ed47021c31e5fc5676951d55eff32682a6..6ceb7bd646c174d1fd9acc591516de8fdde6efda 100644 (file)
@@ -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
index 908b3cbe073328d50f862adc6281599bd28e0869..a8f145bba7214dd137690ca06631776e662fce35 100644 (file)
@@ -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
index 1148871d72ddc472bb3b8606361fc757f0e5fb9f..3dd77b171a56bc1b930db8ce54f884df0d193b85 100644 (file)
--- 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;
index 82d9963d3f41aeff8f9ef220a98a937a71d5c4c4..2e07197303ad4ef3f30d1f35cf3a63c6cb502346 100644 (file)
--- 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;
index c2213f13fc1a9c91fd603ff9af9c4198d569732f..2ee1996066043789c1df9061e7227b842c0d1e6c 100644 (file)
--- 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 */
index d91b6a4ea02cf63f8a6f75b60adc2756230c44fc..c3fe470e7da937241ca23154d7885255089f2da3 100644 (file)
@@ -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;
 
index 8ba503670ba819e58c6e70fe45fad4fcc4906cbf..e556e8f2dbcffd2392955ae32f59e44d7cc83263 100644 (file)
@@ -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;
index 60acec90ab03dba38623041db7f51d9b982c8f07..2111bc16e126afbed3811595d3791be1a4b3f01d 100644 (file)
@@ -14,8 +14,6 @@
 #include <h/tws.h>
 #include <h/utils.h>
 
-#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);