]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: regex: use the build options list to report the regex type
authorWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2016 18:13:14 +0000 (19:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2016 20:30:54 +0000 (21:30 +0100)
This removes 3 #ifdef from haproxy.c.

src/haproxy.c
src/regex.c

index bf7dfc1d40f285678f85b40d6a7cc4d20380b72e..4de12cd08fcc98d33992c0eafaa9a8881a2e0842 100644 (file)
@@ -402,29 +402,6 @@ static void display_build_opts()
        printf("Built without OpenSSL support (USE_OPENSSL not set)\n");
 #endif
 
-#ifdef USE_PCRE
-       printf("Built with PCRE version : %s\n", (HAP_XSTRING(Z PCRE_PRERELEASE)[1] == 0)?
-               HAP_XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) :
-               HAP_XSTRING(PCRE_MAJOR.PCRE_MINOR) HAP_XSTRING(PCRE_PRERELEASE PCRE_DATE));
-       printf("Running on PCRE version : %s", pcre_version());
-       printf("\nPCRE library supports JIT : ");
-#ifdef USE_PCRE_JIT
-       {
-               int r;
-               pcre_config(PCRE_CONFIG_JIT, &r);
-               if (r)
-                       printf("yes");
-               else
-                       printf("no (libpcre build without JIT?)");
-       }
-#else
-       printf("no (USE_PCRE_JIT not set)");
-#endif
-       printf("\n");
-#else
-       printf("Built without PCRE support (using libc's regex instead)\n");
-#endif
-
        list_for_each_entry(item, &build_opts_list, list) {
                puts(item->str);
        }
index be4fe5b24596dc0594a8bad4b0a02833fb08b654..dd7719405fdcb0d9baeb2d07ef4b96d940af0414 100644 (file)
@@ -14,6 +14,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <types/global.h>
 #include <common/config.h>
 #include <common/defaults.h>
 #include <common/regex.h>
@@ -326,6 +327,34 @@ int regex_comp(const char *str, struct my_regex *regex, int cs, int cap, char **
        return 1;
 }
 
+__attribute__((constructor))
+static void __regex_init(void)
+{
+       char *ptr = NULL;
+
+#ifdef USE_PCRE
+       memprintf(&ptr, "Built with PCRE version : %s", (HAP_XSTRING(Z PCRE_PRERELEASE)[1] == 0)?
+               HAP_XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) :
+               HAP_XSTRING(PCRE_MAJOR.PCRE_MINOR) HAP_XSTRING(PCRE_PRERELEASE PCRE_DATE));
+       memprintf(&ptr, "%s\nRunning on PCRE version : %s", ptr, pcre_version());
+
+       memprintf(&ptr, "%s\nPCRE library supports JIT : %s", ptr,
+#ifdef USE_PCRE_JIT
+                 ({
+                         int r;
+                         pcre_config(PCRE_CONFIG_JIT, &r);
+                         r ? "yes" : "no (libpcre build without JIT?)";
+                 })
+#else
+                 "no (USE_PCRE_JIT not set)"
+#endif
+                 );
+#else
+       memprintf(&ptr, "Built without PCRE support (using libc's regex instead)");
+#endif
+       hap_register_build_opts(ptr, 1);
+}
+
 /*
  * Local variables:
  *  c-indent-level: 8