8 awk ' BEGIN { found=0; }
12 printf("%s\n", "'$LINE'");
20 # extract the description from the top of a patch
22 # collapse adjacent blank lines to a single blank line
23 # remove any lines that look like diffstat output
24 # stop output on encountering a line beginning with '---' (beginning of patch)
26 TMPFILE=`mktemp /tmp/xdtmp.XXXXXX` || exit 1
27 formail -kfcb -X 'From:' -X 'Subject:' |\
29 BEGIN { found_end=0; lastone="x"; }
30 /^ .* [|] +[0-9]+ [+-]+$/ {
31 #/* we found something like diffstat output... */
33 /* we are past end of diffstat, let it pass */
38 /^ [1-9][0-9]* files changed/ {
39 #/* end of diffstat output, stop filtering diffstat */
45 #/* collapse adjacent blank lines to 1 blank line */
46 if ( $0 == "" && lastone == "" )
52 ' | awk '{ if ($0 == "" && FNR == 1) next; print; }' > "$TMPFILE"
54 descs=`head -10 $TMPFILE | grep -c '^[ ]*DESC[ ]*$'`
57 # DESC is not 1st non blank line in the file
61 edescs=`grep -c '^EDESC$' "$TMPFILE"`
62 subjects=`grep -c '^[ ]*Subject[:]' "$TMPFILE"`
63 froms=`grep -c '^[ ]*From[:]' "$TMPFILE"`
64 if [ "$edescs" = "0" ]
66 if [ "$subjects" != "0" ]
68 insert_line '^Subject[:]' 'EDESC' "$TMPFILE"
70 if [ "$froms" != "0" ]
72 insert_line '^From[:]' 'EDESC' "$TMPFILE"
77 echo '(undescribed patch)'
81 insert_line '^DESC$' "EDESC" "$TMPFILE"