]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: acl: alphanumerically sort the ACL dump
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Mar 2022 09:49:59 +0000 (11:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Mar 2022 09:49:59 +0000 (11:49 +0200)
The mechanism is similar to others. We take care of sorting on the
keyword only and not the fetch_kw which is not unique.

src/acl.c

index 77d67172fe51f356ca6335890deaea8999cdd183..15ca7668e24ce6a5830435fa59e4765e2ff2da2c 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -1312,17 +1312,28 @@ int init_acl()
 void acl_dump_kwd(void)
 {
        struct acl_kw_list *kwl;
+       const struct acl_keyword *kwp, *kw;
        const char *name;
        int index;
 
-       list_for_each_entry(kwl, &acl_keywords.list, list) {
-               for (index = 0; kwl->kw[index].kw != NULL; index++) {
-                       name = kwl->kw[index].fetch_kw;
-                       if (!name)
-                               name = kwl->kw[index].kw;
-
-                       printf("%s = %s -m %s\n", kwl->kw[index].kw, name, pat_match_names[kwl->kw[index].match_type]);
+       for (kw = kwp = NULL;; kwp = kw) {
+               list_for_each_entry(kwl, &acl_keywords.list, list) {
+                       for (index = 0; kwl->kw[index].kw != NULL; index++) {
+                               if (strordered(kwp ? kwp->kw : NULL,
+                                              kwl->kw[index].kw,
+                                              kw != kwp ? kw->kw : NULL))
+                                       kw = &kwl->kw[index];
+                       }
                }
+
+               if (kw == kwp)
+                       break;
+
+               name = kw->fetch_kw;
+               if (!name)
+                       name = kw->kw;
+
+               printf("%s = %s -m %s\n", kw->kw, name, pat_match_names[kw->match_type]);
        }
 }