From: Dan Harkless Date: Thu, 13 May 1999 01:22:03 +0000 (+0000) Subject: Don't add line breaks in the middle of long addresses when building a X-Git-Tag: nmh-1_0~190 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=e49cacf800179ed9650c07f9fc13c5e8736cb9e7 Don't add line breaks in the middle of long addresses when building a draft. Fixes a bug where repl would generate invalid headers. From Ruud de Rooij . --- diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 2086a94..630cfc5 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -729,16 +729,22 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) *cp++ = c; while (len > wid) { /* try to break at a comma; failing that, break at a - * space, failing that, just split the line. + * space. */ lastb = 0; sp = lp + wid; while (sp > lp && (c = *--sp) != ',') { if (! lastb && isspace(c)) lastb = sp - 1; } - if (sp == lp) - if (! (sp = lastb)) + if (sp == lp) { + if (! (sp = lastb)) { sp = lp + wid - 1; + while (*sp && *sp != ',' && !isspace(*sp)) + sp++; + if (*sp != ',') + sp--; + } + } len -= sp - lp + 1; while (cp < ep && lp <= sp) *cp++ = *lp++; @@ -747,6 +753,12 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) *cp++ = ' '; while (isspace(*lp)) lp++, len--; + if (*lp) { + if (cp < ep) + *cp++ = '\n'; + for (i=indent; cp < ep && i > 0; i--) + *cp++ = ' '; + } } PUTS (cp, lp); }