]> git.marmaro.de Git - mmh/commitdiff
Fix order of (trim) and (decode) in repl*comps
authormarkus schnalke <meillo@marmaro.de>
Wed, 20 Apr 2016 07:02:06 +0000 (09:02 +0200)
committermarkus schnalke <meillo@marmaro.de>
Thu, 21 Apr 2016 08:07:59 +0000 (10:07 +0200)
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.

etc/replcomps
etc/replgroupcomps
man/mh-format.man5

index 5c981428b3a4a234bd658723f4157bf99f8a41dc..523070078752b3ce44b27c383c965871be39c01e 100644 (file)
 %(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.
-%; 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: \
-%<{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})%>\
-%(trim)%(decode)\n\
+%(putstr(trim(decode)))\n\
    message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
 --------
 [%4(year{date})-%02(mon{date})-%02(mday{date}) \
index ffbe6ff97ff99213f2e847fa1a179d83a9df4545..09d6360627a922cfdc05aa9cfdc906101f0f0225 100644 (file)
 %<(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.
-%; 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: \
-%<{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})%>\
-%(trim)%(decode)\n\
+%(putstr(trim(decode)))\n\
    message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
 --------
 [%4(year{date})-%02(mon{date})-%02(mday{date}) \
index 20b3937b362933eb28fccb1c5d0d7577b8039cf0..ed0a2dc67bc5b4c874d718a408a0881f84001ebb 100644 (file)
@@ -215,6 +215,13 @@ or
 .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 .