be able to match the inverse of a class using the $~x syntax
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 10 Dec 1982 03:17:43 +0000 (19:17 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Fri, 10 Dec 1982 03:17:43 +0000 (19:17 -0800)
SCCS-mr: usr.sbin/sendmail/src/main.c 095
SCCS-mr: usr.sbin/sendmail/src/sendmail.h 095
SCCS-mr: usr.sbin/sendmail/src/parseaddr.c 095
SCCS-vsn: usr.sbin/sendmail/src/main.c 3.144
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.104
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 3.68

usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/parseaddr.c
usr/src/usr.sbin/sendmail/src/sendmail.h

index 45a3e48..5bc0825 100644 (file)
@@ -3,7 +3,7 @@
 # include <sys/ioctl.h>
 # include "sendmail.h"
 
 # include <sys/ioctl.h>
 # include "sendmail.h"
 
-SCCSID(@(#)main.c      3.143           %G%);
+SCCSID(@(#)main.c      3.144           %G%);
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
@@ -630,6 +630,7 @@ struct metamac      MetaMacros[] =
 {
        /* these are important on the LHS */
        '*', MATCHZANY, '+', MATCHANY,  '-', MATCHONE,  '=', MATCHCLASS,
 {
        /* these are important on the LHS */
        '*', MATCHZANY, '+', MATCHANY,  '-', MATCHONE,  '=', MATCHCLASS,
+       '~', MATCHNCLASS,
 
        /* these are RHS metasymbols */
        '#', CANONNET,  '@', CANONHOST, ':', CANONUSER, '>', CALLSUBR,
 
        /* these are RHS metasymbols */
        '#', CANONNET,  '@', CANONHOST, ':', CANONUSER, '>', CALLSUBR,
index 668ebed..6175070 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-SCCSID(@(#)parseaddr.c 3.67            %G%);
+SCCSID(@(#)parseaddr.c 3.68            %G%);
 
 /*
 **  PARSE -- Parse an address
 
 /*
 **  PARSE -- Parse an address
@@ -400,7 +400,7 @@ toktype(c)
                expand("$o", buf, &buf[sizeof buf - 1], CurEnv);
                (void) strcat(buf, DELIMCHARS);
        }
                expand("$o", buf, &buf[sizeof buf - 1], CurEnv);
                (void) strcat(buf, DELIMCHARS);
        }
-       if (c == MATCHCLASS || c == MATCHREPL)
+       if (c == MATCHCLASS || c == MATCHREPL || c == MATCHNCLASS)
                return (ONE);
        if (c == '"')
                return (QST);
                return (ONE);
        if (c == '"')
                return (QST);
@@ -422,11 +422,11 @@ toktype(c)
 **     For each rewrite rule, 'avp' points the address vector we
 **     are trying to match against, and 'pvp' points to the pattern.
 **     If pvp points to a special match value (MATCHZANY, MATCHANY,
 **     For each rewrite rule, 'avp' points the address vector we
 **     are trying to match against, and 'pvp' points to the pattern.
 **     If pvp points to a special match value (MATCHZANY, MATCHANY,
-**     MATCHONE, MATCHCLASS) then the address in avp matched is
-**     saved away in the match vector (pointed to by 'mvp').
+**     MATCHONE, MATCHCLASS, MATCHNCLASS) then the address in avp
+**     matched is saved away in the match vector (pointed to by 'mvp').
 **
 **     When a match between avp & pvp does not match, we try to
 **
 **     When a match between avp & pvp does not match, we try to
-**     back out.  If we back up over a MATCHONE or a MATCHCLASS
+**     back out.  If we back up over MATCHONE, MATCHCLASS, or MATCHNCLASS
 **     we must also back out the match in mvp.  If we reach a
 **     MATCHANY or MATCHZANY we just extend the match and start
 **     over again.
 **     we must also back out the match in mvp.  If we reach a
 **     MATCHANY or MATCHZANY we just extend the match and start
 **     over again.
@@ -524,7 +524,8 @@ rewrite(pvp, ruleset)
                                register int class;
 
                          case MATCHCLASS:
                                register int class;
 
                          case MATCHCLASS:
-                               /* match any token in a class */
+                         case MATCHNCLASS:
+                               /* match any token in (not in) a class */
                                class = rp[1];
                                if (!isalpha(class))
                                        goto backup;
                                class = rp[1];
                                if (!isalpha(class))
                                        goto backup;
@@ -534,6 +535,11 @@ rewrite(pvp, ruleset)
                                        class -= 'a';
                                s = stab(ap, ST_CLASS, ST_FIND);
                                if (s == NULL || (s->s_class & (1L << class)) == 0)
                                        class -= 'a';
                                s = stab(ap, ST_CLASS, ST_FIND);
                                if (s == NULL || (s->s_class & (1L << class)) == 0)
+                               {
+                                       if (*rp == MATCHCLASS)
+                                               goto backup;
+                               }
+                               else if (*rp == MATCHNCLASS)
                                        goto backup;
 
                                /* explicit fall-through */
                                        goto backup;
 
                                /* explicit fall-through */
@@ -579,7 +585,8 @@ rewrite(pvp, ruleset)
                                        break;
                                }
                                avp--;
                                        break;
                                }
                                avp--;
-                               if (*rp == MATCHONE || *rp == MATCHCLASS)
+                               if (*rp == MATCHONE || *rp == MATCHCLASS ||
+                                   *rp == MATCHNCLASS)
                                {
                                        /* back out binding */
                                        mlp--;
                                {
                                        /* back out binding */
                                        mlp--;
index f8197ef..5b1f18d 100644 (file)
@@ -7,7 +7,7 @@
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
-static char SmailSccsId[] =    "@(#)sendmail.h 3.103           %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 3.104           %G%";
 # endif lint
 # else  _DEFINE
 # define EXTERN extern
 # endif lint
 # else  _DEFINE
 # define EXTERN extern
@@ -258,6 +258,7 @@ EXTERN struct rewrite       *RewriteRules[MAXRWSETS];
 # define MATCHANY      '\021'  /* match one or more tokens */
 # define MATCHONE      '\022'  /* match exactly one token */
 # define MATCHCLASS    '\023'  /* match one token in a class */
 # define MATCHANY      '\021'  /* match one or more tokens */
 # define MATCHONE      '\022'  /* match exactly one token */
 # define MATCHCLASS    '\023'  /* match one token in a class */
+# define MATCHNCLASS   '\034'  /* match anything not in class */
 # define MATCHREPL     '\024'  /* replacement on RHS for above */
 
 /* right hand side items */
 # define MATCHREPL     '\024'  /* replacement on RHS for above */
 
 /* right hand side items */