CLEANUP: regex: use the build options list to report the regex type

This removes 3 #ifdef from haproxy.c.
This commit is contained in:
Willy Tarreau 2016-12-21 19:13:14 +01:00
parent bb57d94a96
commit 7a9ac6dac6
2 changed files with 29 additions and 23 deletions

View 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);
}

View 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