procmail
[Top] [All Lists]

Re: strlen() in procmail

2003-01-15 10:18:15
All right, Bart:

| I don't want to preserve $=, I just don't want to change it in any way
| that the existing recipe didn't already, if that makes sense.

It does.

| E.g. suppose the original recipe was
|
| :0c:
| * 1^1 ^Received:.*\<from\>.*\<for\>
| any_old_mailbox_will_do
|
| At the end, $= is the number of Recieved: fields that mention both "from"
| and "for".

... in that order.

| Now I want to add something that will extract a $MATCH without
| changing $= any further.
|
| I can't add
|
| * -1^0
| *  1^0 ^In-Reply-To:[^<]+<\/[^>]+
|
| because that decreases $= when there is no In-Reply-To.  I tried
|
| * 0^0 ^In-Reply-To:[^<]+<\/[^>]+
|
| but procmail is too clever and ignores the entire condition because it
| detects that it can't possibly change the score.

Will you settle for this?

 *  1^0 ^In-Reply-To:[^<]+<\/[^>]+
 * -1^0 ^In-Reply-To:[^<]+<[^>]+

It means an extra scan of the head, but it leaves the currently accumulating
score untouched and changes $MATCH only if it should be changed.

Another possibility is

 *  -.000001^0 ^In-Reply-To:[^<]+<\/[^>]+

which is very highly unlikely to change the reported integer value of $=, very
highly unlikely to make an otherwise positive score non-positive, and
guaranteeed not to make an otherwise non-positive score positive.

| Perhaps something along the lines of
|
| * (|^In-Reply-To:[^<]+<\/[^>]+)
|
| which appears to work, but I'm concerned that there's some oddity of which
| I'm unaware with using \/ inside parens like that.

That you'll have to test.  I'd be more comfortable putting the empty
alternative second, or writing it this way:

 * (^In-Reply-To:[^<]+<\/[^>]+)?

My concern, not having yet tested it, is not that parentheses and extraction
won't mix, but that in the absence of a weight where x!=0, procmail will match
on the null string between the opening putative newline and the first
character of the search area and extract nothing.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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