Created
April 5, 2022 20:16
-
-
Save kamahen/9f54a160773125f382c81d2b5470a872 to your computer and use it in GitHub Desktop.
Output some PCRE2 values for debugging PCRE2 with MinGW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define PCRE2_CODE_UNIT_WIDTH 8 | |
#include <pcre2.h> | |
static void config_uint(const char *descr, uint32_t flag) { | |
uint32_t value; | |
uint32_t len = pcre2_config_8(flag, NULL); | |
int rc = pcre2_config_8(flag, &value); | |
if (rc >= 0) { | |
printf("%s (len=%d rc=%d) 0x%08x: 0x%08x\n", descr, len, rc, flag, value); | |
} else { | |
printf("FAILED: %s len=%d rc=%d\n", descr, len, rc); | |
} | |
} | |
static void config_str(const char *descr, uint32_t flag) { | |
char value[100]; | |
uint32_t len = pcre2_config_8(flag, NULL); | |
int rc = pcre2_config_8(flag, &value); | |
if (rc >= 0) { | |
printf("%s (len=%d rc=%d) 0x%08x: '%s'\n", descr, len, rc, flag, value); | |
} else { | |
printf("FAILED: %s len=%d rc=%d\n", descr, len, rc); | |
} | |
} | |
int main(void) { | |
config_str("VERSION", PCRE2_CONFIG_VERSION); | |
config_str("JITTARGET", PCRE2_CONFIG_JITTARGET); | |
config_str("UNICODE_VERSION", PCRE2_CONFIG_UNICODE_VERSION); | |
config_uint("JIT", PCRE2_CONFIG_JIT); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment