ph10 2004/11/17 16:12:26 GMT
Modified files:
exim-doc/doc-txt ChangeLog NewStuff
exim-src/src expand.c
exim-test-orig/AutoTest/scripts 082
exim-test-orig/AutoTest/stdout 082
Log:
Allow both strings to be omitted in "${if" expansions: the true value
defaults to "true", which works nicely for "condition" conditions (the
false value has always defaulted to "").
Revision Changes Path
1.31 +5 -0 exim/exim-doc/doc-txt/ChangeLog
1.11 +18 -0 exim/exim-doc/doc-txt/NewStuff
1.6 +14 -7 exim/exim-src/src/expand.c
1.4 +5 -2 exim/exim-test-orig/AutoTest/scripts/082
1.4 +5 -2 exim/exim-test-orig/AutoTest/stdout/082
Index: ChangeLog
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ChangeLog 17 Nov 2004 15:21:10 -0000 1.30
+++ ChangeLog 17 Nov 2004 16:12:26 -0000 1.31
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.30 2004/11/17 15:21:10 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.31 2004/11/17 16:12:26 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -128,6 +128,11 @@
generates multiple encoded words if necessary. To be on the safe side, I
have increased the buffer size for the ${rfc2047: expansion operator from
1024 to 2048 bytes.
+
+33. It is now permitted to omit both strings after an "if" condition; if the
+ condition is true, the result is "true". As before, when the second string
+ is omitted, a false condition yields an empty string. This makes it less
+ cumbersome to write custom ACL and router conditions.
Exim version 4.43
Index: NewStuff
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/NewStuff,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- NewStuff 17 Nov 2004 14:32:25 -0000 1.10
+++ NewStuff 17 Nov 2004 16:12:26 -0000 1.11
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.10 2004/11/17 14:32:25 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.11 2004/11/17 16:12:26 ph10 Exp $
New Features in Exim
--------------------
@@ -89,6 +89,24 @@
of those variables is -1. If the operating system does not have the ability
to find the amount of free space (only true for experimental systems), the
space value is -1.
+
+11. It is now permitted to omit both strings after an "if" condition; if the
+ condition is true, the result is the string "true". As before, when the
+ second string is omitted, a false condition yields an empty string. This
+ makes it less cumbersome to write custom ACL and router conditions. For
+ example, instead of
+
+ condition = ${if eq {$acl_m4}{1}{yes}{no}}
+
+ or the shorter form
+
+ condition = ${if eq {$acl_m4}{1}{yes}}
+
+ (because the second string has always defaulted to ""), you can now write
+
+ condition = ${if eq {$acl_m4}{1}}
+
+ Previously this was a syntax error.
Version 4.43
Index: expand.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/expand.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- expand.c 17 Nov 2004 15:21:10 -0000 1.5
+++ expand.c 17 Nov 2004 16:12:26 -0000 1.6
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/expand.c,v 1.5 2004/11/17 15:21:10 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/expand.c,v 1.6 2004/11/17 16:12:26 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -2175,17 +2175,24 @@
uschar *sub1, *sub2;
/* If there are no following strings, we substitute the contents of $value for
-lookups and for extractions in the success case. In the fail case, nothing is
-substituted. In the case of "if", lack of following strings is an error. */
+lookups and for extractions in the success case. For the ${if item, the string
+"true" is substituted. In the fail case, nothing is substituted for all three
+items. */
while (isspace(*s)) s++;
if (*s == '}')
{
- if (type[0] == 'i') goto FAILED_CURLY;
- if (yes && lookup_value != NULL)
- *yieldptr = string_cat(*yieldptr, sizeptr, ptrptr, lookup_value,
- Ustrlen(lookup_value));
- lookup_value = save_lookup;
+ if (type[0] == 'i')
+ {
+ if (yes) *yieldptr = string_cat(*yieldptr, sizeptr, ptrptr, US"true", 4);
+ }
+ else
+ {
+ if (yes && lookup_value != NULL)
+ *yieldptr = string_cat(*yieldptr, sizeptr, ptrptr, lookup_value,
+ Ustrlen(lookup_value));
+ lookup_value = save_lookup;
+ }
s++;
goto RETURN;
}
Index: 082
===================================================================
RCS file: /home/cvs/exim/exim-test-orig/AutoTest/scripts/082,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- 082 17 Nov 2004 15:21:10 -0000 1.3
+++ 082 17 Nov 2004 16:12:26 -0000 1.4
@@ -257,6 +257,11 @@
queue_running after or: ${if or{{eq {0}{0}}{queue_running}}{y}{n}}
first_delivery after or: ${if or{{eq {0}{0}}{first_delivery}}{y}{n}}
+# Default values for both if strings
+
+\${if eq{1}{1}} >${if eq{1}{1}}<
+\${if eq{1}{2}} >${if eq{1}{2}}<
+
# Encrypted comparisons
BadCrypt: ${if crypteq{MySecret}{}{yes}{no}}
@@ -536,12 +541,10 @@
${expand:abcd
${expand:abcd${tod_log}
${hmac{xxx}{a}{b}}
-${if eq {a}{b}}
${if and {xyz}{a}{b}}
${if and {{xya}}{a}{b}}
${if and {{${lookup{x}lsearch{/a/b}}}}{a}{b}}
${if eq {$h_xyz}{1}{y}{n}}
-${if eq {$h_xyz}{1} {y} {n}}
${if or {eq {}{}{yes}{no}}
${if or {{eq {}{}{yes}{no}}
${if or {{eq {}{}}{yes}{no}}
Index: 082
===================================================================
RCS file: /home/cvs/exim/exim-test-orig/AutoTest/stdout/082,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- 082 17 Nov 2004 15:21:10 -0000 1.3
+++ 082 17 Nov 2004 16:12:26 -0000 1.4
@@ -253,6 +253,11 @@
> queue_running after or: y
> first_delivery after or: y
>
+> # Default values for both if strings
+>
+> ${if eq{1}{1}} >true<
+> ${if eq{1}{2}} ><
+>
> # Encrypted comparisons
>
> BadCrypt: no
@@ -539,12 +544,10 @@
> Failed: missing } at end of string
> Failed: missing } at end of string
> Failed: hmac algorithm "xxx" is not recognised
-> Failed: missing or misplaced { or }
> Failed: each subcondition inside an "and{...}" condition must be in its own {}
> Failed: unknown condition "xya" inside "and{...}" condition
> Failed: condition name expected, but found "${lookup{x}lsear" inside "and{...}" condition
> Failed: missing } at end of string - could be header name not terminated by colon
-> Failed: missing or misplaced { or } - could be header name not terminated by colon
> Failed: each subcondition inside an "or{...}" condition must be in its own {}
> Failed: missing } at end of condition inside "or" group
> Failed: unknown condition "yes" inside "or{...}" condition