build a regex_t object

This commit is contained in:
Josh Holtrop 2018-03-15 22:31:37 -04:00
parent e71a4dcd47
commit 421805e990

15
main.cc
View File

@ -1,5 +1,6 @@
#include <oniguruma.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char * argv[])
{
@ -20,5 +21,19 @@ int main(int argc, char * argv[])
return 1;
}
static const char pattern[] = "\\<Foo\\d";
OnigErrorInfo einfo;
regex_t regex;
rc = onig_new_without_alloc(&regex, (const OnigUChar *)pattern,
(const OnigUChar *)(pattern + strlen(pattern)), ONIG_OPTION_NONE,
ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, &einfo);
if (rc != ONIG_NORMAL)
{
OnigUChar s[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str(s, rc, &einfo);
fprintf(stderr, "Error: %s\n", s);
return 1;
}
return 0;
}