Surround input regex with .*( ).* in demo
This commit is contained in:
parent
656726a8c1
commit
dad687216b
@ -12,6 +12,11 @@
|
||||
|
||||
#define BUFFER_START_CAPACITY 128
|
||||
|
||||
#define PREFIX ".*("
|
||||
#define PREFIX_LEN 3
|
||||
#define SUFFIX ").*"
|
||||
#define SUFFIX_LEN 3
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2) {
|
||||
@ -19,8 +24,15 @@ int main(int argc, char *argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const int input_len = strlen(argv[1]);
|
||||
const int regex_len = input_len + 6;
|
||||
char *regex = malloc(regex_len);
|
||||
memcpy(regex, PREFIX, PREFIX_LEN);
|
||||
memcpy(regex + PREFIX_LEN, argv[1], input_len);
|
||||
memcpy(regex + PREFIX_LEN + input_len, SUFFIX, SUFFIX_LEN);
|
||||
|
||||
fsa_t dfa;
|
||||
if (!compile(argv[1], strlen(argv[1]), &dfa)) {
|
||||
if (!compile(regex, regex_len, &dfa)) {
|
||||
fprintf(stderr, "Failed to parse regex\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user