Add == as a filtering operator in unlang, and document it.
authoraland <aland>
Wed, 26 Sep 2007 16:00:00 +0000 (16:00 +0000)
committeraland <aland>
Wed, 26 Sep 2007 16:00:00 +0000 (16:00 +0000)
It's the opposite of -=

man/man5/unlang.5
src/include/conffile.h
src/main/conffile.c
src/main/evaluate.c
src/main/modcall.c

index a845f1d..6b060a0 100644 (file)
@@ -487,6 +487,10 @@ same name are already present in the list.
 Remove all matching attributes from the list.  Both the attribute name
 and value have to match in order for the attribute to be removed from
 the list.
+.IP ==
+Remove all non-matching attributes from the list.  Both the attribute
+name and value have to match in order for the attribute to remain in
+the list.
 .IP <=
 Enforce that the integer value of the attribute is less than or equal
 to the value given here.  If there is no attribute of the same name in
index 646e077..ff48a6b 100644 (file)
@@ -72,7 +72,7 @@ char *cf_pair_value(CONF_PAIR *pair);
 VALUE_PAIR *cf_pairtovp(CONF_PAIR *pair);
 const char *cf_section_name1(const CONF_SECTION *);
 const char *cf_section_name2(const CONF_SECTION *);
-int dump_config(void);
+int dump_config(CONF_SECTION *cs);
 CONF_SECTION *cf_subsection_find_next(CONF_SECTION *section,
                                      CONF_SECTION *subsection,
                                      const char *name1);
index 02e33b1..5f4f1ec 100644 (file)
@@ -1299,6 +1299,7 @@ static int cf_section_read(const char *filename, int *lineno, FILE *fp,
                        goto do_set;
 
                case T_OP_ADD:
+               case T_OP_CMP_EQ:
                case T_OP_SUB:
                case T_OP_LE:
                case T_OP_GE:
@@ -2248,8 +2249,8 @@ static int dump_config_section(CONF_SECTION *cs, int indent)
        return 0;
 }
 
-int dump_config(void)
+int dump_config(CONF_SECTION *cs)
 {
-       return dump_config_section(mainconfig.config, 0);
+       return dump_config_section(cs, 0);
 }
 #endif
index 76de114..9482e7c 100644 (file)
@@ -786,6 +786,7 @@ static void my_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from)
                         *      "to"
                         */
                        if ((from_list[i]->operator == T_OP_SUB) ||
+                           (from_list[i]->operator == T_OP_CMP_EQ) ||
                            (from_list[i]->operator == T_OP_LE) ||
                            (from_list[i]->operator == T_OP_GE)) {
                                int rcode;
@@ -811,8 +812,13 @@ static void my_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from)
                                from_list[i]->operator = old_op;
 
                                switch (old_op) {
+                               case T_OP_CMP_EQ:
+                                       if (rcode != 0) goto delete;
+                                       break;
+
                                case T_OP_SUB:
                                        if (rcode == 0) {
+                                       delete:
                                                DEBUG4("::: DELETING %s FROM %d TO %d",
                                                       from_list[i]->name, i, j);
                                                pairfree(&to_list[j]);
index 7d1ad65..f076932 100644 (file)
@@ -1122,6 +1122,7 @@ static modcallable *do_compile_modupdate(modcallable *parent,
                }
 
                if ((vp->operator != T_OP_EQ) &&
+                   (vp->operator != T_OP_CMP_EQ) &&
                    (vp->operator != T_OP_ADD) &&
                    (vp->operator != T_OP_SUB) &&
                    (vp->operator != T_OP_LE) &&