--- mutt-x.y.z/PATCHES~ never +++ mutt-x.y.z/PATCHES Thu Jun 13 16:25:05 CDT 2002 @@ -1,0 +1 @@ +dgc.fmtpipe.1 diff -Pur mutt-1.5.1-base/muttlib.c mutt-1.5.1/muttlib.c --- mutt-1.5.1-base/muttlib.c Tue Mar 26 16:47:06 2002 +++ mutt-1.5.1/muttlib.c Thu Jun 13 15:28:23 2002 @@ -924,6 +924,10 @@ char prefix[SHORT_STRING], buf[LONG_STRING], *cp, *wptr = dest, ch; char ifstring[SHORT_STRING], elsestring[SHORT_STRING]; size_t wlen, count, len; + pid_t pid; + FILE *filter; + int n, dofilter = 0; + char *recycler; prefix[0] = '\0'; destlen--; /* save room for the terminal \0 */ @@ -1096,6 +1100,20 @@ wptr++; wlen++; } + else if (*src == '|') + { + if (*++src != '\0') + { + /* Not end of string - copy '|' */ + *wptr++ = '|'; + wlen++; + } + else + { + /* End of string - wants to be filtered */ + dofilter = 1; + } + } else { *wptr++ = *src++; @@ -1103,6 +1121,39 @@ } } *wptr = 0; + + /* Filter this string? */ + if (dofilter) + { + wptr = dest; /* reset write ptr */ + wlen = (flags & M_FORMAT_ARROWCURSOR && option (OPTARROWCURSOR)) ? 3 : 0; + if (pid = mutt_create_filter(dest, NULL, &filter, NULL)) + { + n = fread(dest, 1, destlen /* already decremented */, filter); + fclose(filter); + dest[n] = '\0'; + if (pid != -1) + mutt_wait_filter(pid); + + /* If ends with '%', recycle through FormatString :P */ + /* To really end with '%', use "%%" */ + if (dest[--n] == '%') + { + dest[n] = '\0'; /* remove '%' */ + if (dest[--n] != '%') + { + recycler = safe_strdup(dest); + mutt_FormatString(dest, destlen++, recycler, callback, data, flags); + safe_free((void **) &recycler); + } + } + } + else + { + /* Filter failed; erase write buffer */ + *wptr = '\0'; + } + } #if 0 if (flags & M_FORMAT_MAKEPRINT)