(1) Typo in redirect router; (2) Update version number; (3) Update
[exim.git] / src / src / match.c
index 9d2a1c0bd892b120557f9c582332b3c9018dd0d3..7c30e056c8ab86d6beea6493f2b28ada96706f4d 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/match.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
+/* $Cambridge: exim/src/src/match.c,v 1.3 2005/01/04 10:00:42 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2005 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* Functions for matching strings */
@@ -932,32 +932,24 @@ error = error;  /* Keep clever compilers from complaining */
 DEBUG(D_lists) debug_printf("address match: subject=%s pattern=%s\n",
   subject, pattern);
 
-/* Handle a regular expression, which must match the entire incoming address. */
+/* Handle a regular expression, which must match the entire incoming address. 
+This may be the empty address. */
 
 if (*pattern == '^')
   return match_check_string(subject, pattern, cb->expand_setup, TRUE,
     cb->caseless, FALSE, NULL);
 
-/* If the subject is the empty string, the only pattern it can match (other
-than a regular expression) is the empty pattern. */
-
-if (*subject == 0) return (*pattern == 0)? OK : FAIL;
-
-/* Find the domain in the subject */
-
-sdomain = Ustrrchr(subject, '@');
-
-/* Handle the case of a pattern that is just a lookup. Skip over possible
-lookup names (letters, digits, hyphens). Skip over a possible * or *@ at
-the end. Then we must have a semicolon for it to be a lookup. */
+/* Handle a pattern that is just a lookup. Skip over possible lookup names
+(letters, digits, hyphens). Skip over a possible * or *@ at the end. Then we
+must have a semicolon for it to be a lookup. */
 
 for (s = pattern; isalnum(*s) || *s == '-'; s++);
 if (*s == '*') s++;
 if (*s == '@') s++;
 
-/* If it is a straight lookup, do a lookup for the whole address. Partial
-matching doesn't make sense here, so we ignore it, but write a panic log entry.
-However, *@ matching will be honoured. */
+/* If it is a straight lookup, do a lookup for the whole address. This may be 
+the empty address. Partial matching doesn't make sense here, so we ignore it,
+but write a panic log entry. However, *@ matching will be honoured. */
 
 if (*s == ';')
   {
@@ -968,6 +960,16 @@ if (*s == ';')
     valueptr);
   }
 
+/* For the remaining cases, an empty subject matches only an empty pattern, 
+because other patterns expect to have a local part and a domain to match 
+against. */
+
+if (*subject == 0) return (*pattern == 0)? OK : FAIL;
+
+/* Find the subject's domain */
+
+sdomain = Ustrrchr(subject, '@');
+
 /* If the pattern starts with "@@" we have a split lookup, where the domain is
 looked up to obtain a list of local parts. If the subject's local part is just
 "*" (called from retry) the match always fails. */