+ size_t size = strlen(fill);
+ char *result = 0;
+ int pass;
+ int s, d;
+ for (pass = 0; pass < 2; ++pass) {
+ for (s = d = 0; src[s] != '\0'; ++s) {
+ if (src[s] == ' ') {
+ if (pass) {
+ strcpy(&result[d], fill);
+ d += (int) size;
+ } else {
+ need += size;
+ }
+ } else {
+ if (pass) {
+ result[d++] = src[s];
+ } else {
+ ++d;
+ }
+ }
+ }
+ if (pass) {
+ result[d] = '\0';
+ } else {
+ result = malloc(need + 1);
+ if (result == 0)
+ failed("fill_spaces");
+ }
+ }
+ return result;
+}
+
+typedef enum {
+ wOFF = 0
+ ,w1ST = 1
+ ,w2ND = 2
+ ,wEND = 4
+ ,wERR = 8
+} WRAPMODE;
+
+#define wrap_1ST(mode) ((mode)&w1ST)
+#define wrap_END(mode) ((mode)&wEND)
+#define wrap_ERR(mode) ((mode)&wERR)
+
+static void
+wrap_concat(const char *src, int need, unsigned mode)
+{
+ int gaps = (int) strlen(separator);
+ int want = gaps + need;
+
+ did_wrap = (width <= 0);
+ if (wrap_1ST(mode)
+ && column > indent
+ && column + want > width) {
+ force_wrap();
+ }
+ if ((wrap_END(mode) && !wrap_ERR(mode)) &&
+ wrapped &&
+ (width >= 0) &&
+ (column + want) > width) {
+ int step = 0;
+ int used = width > WRAPPED ? width : WRAPPED;
+ int size;
+ int base = 0;
+ char *p, align[9];
+ const char *my_t = trailer;
+ char *fill = fill_spaces(src);
+ int last = (int) strlen(fill);
+
+ need = last;
+
+ if (TcOutput())
+ trailer = "\\\n\t ";
+
+ if (!TcOutput() && (p = strchr(fill, '=')) != 0) {
+ base = (int) (p + 1 - fill);
+ if (base > 8)
+ base = 8;
+ _nc_SPRINTF(align, _nc_SLIMIT(align) "%*s", base, " ");
+ } else if (column > 8) {
+ base = column - 8;
+ if (base > 8)
+ base = 8;
+ _nc_SPRINTF(align, _nc_SLIMIT(align) "%*s", base, " ");
+ } else {
+ align[base] = '\0';
+ }
+ /* "pretty" overrides wrapping if it already split the line */
+ if (!pretty || strchr(fill, '\n') == 0) {
+ int tag = 0;
+
+ if (TcOutput() && outbuf.used && !wrap_1ST(mode)) {
+ tag = 3;
+ }