- while ((column + (need + gaps)) > used) {
- size = used;
- if (size > ((int) strlen(fill) - step)) {
- size = ((int) strlen(fill) - step);
- }
- if (step) {
- strcpy_DYN(&outbuf, align);
- size -= base;
+ /* "pretty" overrides wrapping if it already split the line */
+ if (!pretty || strchr(fill, '\n') == 0) {
+ while ((column + (need + gaps)) > used) {
+ size = used;
+ if (step) {
+ strcpy_DYN(&outbuf, align);
+ size -= base;
+ }
+ if (size > (last - step)) {
+ size = (last - step);
+ }
+ size = find_split(fill, step, size);
+ strncpy_DYN(&outbuf, fill + step, (size_t) size);
+ step += size;
+ need -= size;
+ if (need > 0) {
+ force_wrap();
+ did_wrap = TRUE;
+ }