X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Ffmt_scan.c;h=630cfc5c2f4b4db49a75a1abab89043dcf349d7c;hb=910f3846bb30636fe25bdc6e06e72d50c6779bd9;hp=2086a94c5a6eeb635d31567caf33921a1cda724c;hpb=1691e80890e5d8ba258c51c214a3e91880e1db2b;p=mmh 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); }