procmail
[Top] [All Lists]

Re: subject processing

1997-07-07 00:32:00
Talking to myself again. It's not like I'm trying to set a record or
something :-]

On Sat, 5 Jul 1997 13:05:01 +0300 (EET DST), I wrote:
On Fri, 4 Jul 1997 21:52:01 +0300 (EET DST), I wrote:
(Eli the Bearded) wrote:
era eriksson <era(_at_)iki(_dot_)fi> wrote:
:0fhw
* ^\/Subject:[    ]*((re|fw|sv|betr|antw)( ?[[][0-9]+])?[-:>][    ]*)+
| ... some suitable program which does essentially \
sed "s/^$MATCH/Subject: /"
[] are metacharacters remember.
Much to my surprise, I find that there is actually a simple fix in
3.11pre4 and newer which I had not noticed: $\VAR will quote the
variable with magical characters escaped. However, it seems that this
helpful substitution will add a set of empty parens at the beginning
of the interpolated value. Duh. How do we solve that? 

Well, that wasn't so hard. 

  :0
  * ^\/Subject:[        ]*((re|fw|sv|betr|antw)( ?[[][0-9]+])?[-:>][    ]*)+
  {
      MMATCH="$\MATCH"
      :0fhw
      * MMATCH ?? ^^\(\)\/.*
      | sed "/^$MATCH[  ]*/Subject: Re: /
  }

I liked David's suggestion, but it will be somewhat expensive in
pathological cases. This should consume only one external process, no
matter what. (The Perl solution posted by Eli might be almost as good
-- test this if you really want to know :^)
  This still leaves leading whitespace of the actual Subject out of
the MATCH, which is something one ought to fix before putting this to
real use, but that shouldn't be too hard. (Can anyone spot the error?)
I fixed it temporarily by adding trailing whitespace to the sed script.
  There's also the case of Re>>> which should be covered as well, but
that, too, should be easy to add.

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

<Prev in Thread] Current Thread [Next in Thread>