]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: filters: alphabetically sort the list of filter names
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Mar 2022 10:08:00 +0000 (12:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Mar 2022 10:08:00 +0000 (12:08 +0200)
There are very few but they're registered from constructors, hence
in a random order. The scope had to be copied when retrieving the
next keyword. Note that this also has the effect of listing them
sorted in haproxy -vv.

src/filters.c

index 4594098da023b6aed97eb62a0e97a06078421ef4..12159f2b239d1caf5e2acbcce6801de42a717e75 100644 (file)
@@ -136,24 +136,38 @@ void
 flt_dump_kws(char **out)
 {
        struct flt_kw_list *kwl;
+       const struct flt_kw *kwp, *kw;
+       const char *scope = NULL;
        int index;
 
        if (out)
                *out = NULL;
-       list_for_each_entry(kwl, &flt_keywords.list, list) {
-               for (index = 0; kwl->kw[index].kw != NULL; index++) {
-                       if (kwl->kw[index].parse ||
-                           flt_find_kw(kwl->kw[index].kw) == &kwl->kw[index]) {
-                               if (out)
-                                       memprintf(out, "%s[%4s] %s%s\n", *out ? *out : "",
-                                                 kwl->scope,
-                                                 kwl->kw[index].kw,
-                                                 kwl->kw[index].parse ? "" : " (not supported)");
-                               else
-                                       printf("%s [%s]\n",
-                                              kwl->kw[index].kw, kwl->scope);
+
+       for (kw = kwp = NULL;; kwp = kw) {
+               list_for_each_entry(kwl, &flt_keywords.list, list) {
+                       for (index = 0; kwl->kw[index].kw != NULL; index++) {
+                               if ((kwl->kw[index].parse ||
+                                    flt_find_kw(kwl->kw[index].kw) == &kwl->kw[index])
+                                   && strordered(kwp ? kwp->kw : NULL,
+                                                 kwl->kw[index].kw,
+                                                 kw != kwp ? kw->kw : NULL)) {
+                                       kw = &kwl->kw[index];
+                                       scope = kwl->scope;
+                               }
                        }
                }
+
+               if (kw == kwp)
+                       break;
+
+               if (out)
+                       memprintf(out, "%s[%4s] %s%s\n", *out ? *out : "",
+                                 scope,
+                                 kw->kw,
+                                 kw->parse ? "" : " (not supported)");
+               else
+                       printf("%s [%s]\n",
+                              kw->kw, scope);
        }
 }