Before MH had (decode), the format escapes used to be:
%(void{comp})%(trim)%(putstr)
i.e. set the internal str register to the component text, trim
trailing whitespace from it, then print the value. Later (putstr)
was simply replaced by (decode), which first RFC-2047 decodes the
string and then prints it (if it is the outermost function). That
almost always produced the correct result. But this way the
whitespace trimming is done at the wrong point. Correct is to first
decode the string and then trim it. tests/scan/test-mh-format
checks for that.
%(formataddr(me))\
%(void(width))%(void(decode))%(putaddr Cc: )
Fcc: +sent
%(formataddr(me))\
%(void(width))%(void(decode))%(putaddr Cc: )
Fcc: +sent
-Subject: %<{subject}Re: %(void{subject})%(trim)%(decode)%>
+Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%>
%;
%; Make References: and In-reply-to: fields for threading.
%;
%; Make References: and In-reply-to: fields for threading.
-%; Use (void), (trim) and (putstr) to eat trailing whitespace.
+%; Use (trim) to eat trailing whitespace.
%;
%<{message-id}In-reply-to: %{message-id}\n%>\
%<{message-id}References: \
%;
%<{message-id}In-reply-to: %{message-id}\n%>\
%<{message-id}References: \
-%<{references}%(void{references})%(trim)%(putstr) %>\
-%(void{message-id})%(trim)%(putstr)\n%>\
+%<{references}%(trim{references})%(putstr) %>\
+%(trim{message-id})%(putstr)\n%>\
Comments: In-reply-to \
%<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\
Comments: In-reply-to \
%<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\
+%(putstr(trim(decode)))\n\
message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
--------
[%4(year{date})-%02(mon{date})-%02(mday{date}) \
message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
--------
[%4(year{date})-%02(mon{date})-%02(mday{date}) \
%<(nonnull)%(void(width))%(void(decode))%(putaddr Cc: )\n%>%>\
%;
Fcc: +sent
%<(nonnull)%(void(width))%(void(decode))%(putaddr Cc: )\n%>%>\
%;
Fcc: +sent
-Subject: %<{subject}Re: %(void{subject})%(trim)%(decode)%>
+Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%>
%;
%; Make References: and In-reply-to: fields for threading.
%;
%; Make References: and In-reply-to: fields for threading.
-%; Use (void), (trim) and (putstr) to eat trailing whitespace.
+%; Use (trim) to eat trailing whitespace.
%;
%<{message-id}In-reply-to: %{message-id}\n%>\
%<{message-id}References: \
%;
%<{message-id}In-reply-to: %{message-id}\n%>\
%<{message-id}References: \
-%<{references}%(void{references})%(trim)%(putstr) %>\
-%(void{message-id})%(trim)%(putstr)\n%>\
+%<{references}%(trim{references})%(putstr) %>\
+%(trim{message-id})%(putstr)\n%>\
Comments: In-reply-to \
%<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\
Comments: In-reply-to \
%<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\
+%(putstr(trim(decode)))\n\
message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
--------
[%4(year{date})-%02(mon{date})-%02(mday{date}) \
message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
--------
[%4(year{date})-%02(mon{date})-%02(mday{date}) \
.I str
is used as the argument: which register is
used depends on the function, as listed below.
.I str
is used as the argument: which register is
used depends on the function, as listed below.
+.\" What is the difference between these two lines:
+.\" %(void{comp})%(trim)%(putstr)
+.\" %(putstr(trim{comp}))
+.\" The latter can be used as a single expression for %<.
+.\" It does make a difference for (decode) because in the former
+.\" way, wrapping (decode) with (void) can be necessary.
+.\" What is the prefered way?
.PP
Component escapes write the value of their message header in
.IR str .
.PP
Component escapes write the value of their message header in
.IR str .