summaryrefslogtreecommitdiff
path: root/src
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 /src
parent14702f5b13007409b29615f2a2ad1b141a4b9561 (diff)
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 "").
Diffstat (limited to 'src')
-rw-r--r--src/src/expand.c23
1 files changed, 15 insertions, 8 deletions
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;
}