summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2004-11-17 16:12:26 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2004-11-17 16:12:26 +0000
commit063b1e99b3c8f8fd646b4db4ad87f36952cc9366 (patch)
tree1a72df4371d4a3f46bb6e4995bf90c93fc8b9c0f
parent14702f5b13007409b29615f2a2ad1b141a4b9561 (diff)
downloadexim4-063b1e99b3c8f8fd646b4db4ad87f36952cc9366.tar.gz
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 "").
-rw-r--r--doc/doc-txt/ChangeLog7
-rw-r--r--doc/doc-txt/NewStuff20
-rw-r--r--src/src/expand.c23
3 files changed, 40 insertions, 10 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 251de3fd4..59bc0b94c 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.30 2004/11/17 15:21:10 ph10 Exp $
+$Cambridge: 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
-------------------------------------------
@@ -129,6 +129,11 @@ Exim version 4.44
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
-----------------
diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff
index 7421078bc..d5d340713 100644
--- a/doc/doc-txt/NewStuff
+++ b/doc/doc-txt/NewStuff
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.10 2004/11/17 14:32:25 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.11 2004/11/17 16:12:26 ph10 Exp $
New Features in Exim
--------------------
@@ -90,6 +90,24 @@ Version 4.44
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
------------
diff --git a/src/src/expand.c b/src/src/expand.c
index 916659f5e..f580d3820 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/expand.c,v 1.5 2004/11/17 15:21:10 ph10 Exp $ */
+/* $Cambridge: 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 *s = *sptr; /* Local value */
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;
}