build a regex_t object
This commit is contained in:
parent
e71a4dcd47
commit
421805e990
15
main.cc
15
main.cc
@ -1,5 +1,6 @@
|
|||||||
#include <oniguruma.h>
|
#include <oniguruma.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
@ -20,5 +21,19 @@ int main(int argc, char * argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char pattern[] = "\\<Foo\\d";
|
||||||
|
OnigErrorInfo einfo;
|
||||||
|
regex_t regex;
|
||||||
|
rc = onig_new_without_alloc(®ex, (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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user