procmail
[Top] [All Lists]

Re: \/ is driving me insane

2005-04-12 14:35:46
On Tue, Apr 12, 2005 at 11:40:40PM +1200, Volker Kuhlmann wrote:
This \/ construction in procmail is costing more time than some simple
bash string manipulations are worth... Matching simple strings to the
right is bad enough, when there are alternatives the thing turns to
custard. (Minor point: the man pages provide insufficient info to be
able to use \/.)

How can I remove a portion from the Subject: value which matches $RE?
As in
      Subject: LEFT${RE}RIGHT
to become
      Subject: LEFTRIGHT

We had a long thread concerning optimal ways to do this, about six
months ago.  Doing it's a bit kludgy, but once you recognize the
algorithm, you're half-way $HOME, so to speak.  :-)  Look in the
archives for "splitting" (a guess, but I think that's right) from
the last half of 2004 onward.  I know Ruud was in on that thread.

Here's the general approach, iirc:

  :0
  * ^Subject:.*\/[^     ].*
  {
      H_SUBJ = "$MATCH"

      :0
      * $ H_SUBJ ?? $\RE\/.+
      { H_SUBJ_R = "$MATCH" }

      INCLUDERC = build_leftpart.inc

      H_SUBJ_L = "$build_leftpart_return"
  }

In that INCLUDERC:


  :0
  * H_SUBJ ?? ()\/.
  { LEFT_INCREMENT = "$LEFT_INCREMENT$MATCH" }

  :0
  * $! H_SUBJ ?? ^^$\LEFT_INCREMENT$\RE$\H_SUBJ_R^^
  { SWITCHRC = $_ }

  build_leftpart_return = "$LEFT_INCREMENT" 


----------------

That's untested, but somewhere in my Mail dir I still have the
one that actually worked.  I rewrote this from memory, though,
to test my instincts.  It might have a couple of things imperfect
about it, but you should see the idea.

-- 
dman


      

Obtaining the right-hand part is the easy bit. Relatively speaking
anyway, if the right-hand part is empty the thing goes bust again. How
do I get the left-hand part though? The different greedynesses are a
k.o. if $RE matches more than once. I could do it a lot faster in gawk,
despite the fact that I'd have to take care of header unfolding/folding
myself. Unfortunately gawk isn't so portable though I increasingly don't
care (it's Linux or nothing), and sed is useless (no egrep). Mind you, a
barebasic Solaris awk is equally useless.

Are there any good options, other than finding something better than
procmail? Are there any bad options?

Thanks for pointers...

Volker

-- 
Volker Kuhlmann                       is possibly list0570 with the domain in 
header
http://volker.dnsalias.net/           Please do not CC list postings to me.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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