diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-09-13 09:25:55 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-09-13 09:25:55 +0000 |
commit | da9f87ba7057cb018c02b0a546eaf45ff366cc44 (patch) | |
tree | 853739276d24023ad4adf92d2569a54919967ebb /src/regex | |
parent | 68f4f594c97ca28b04495badd300bc2eac39cdaa (diff) | |
download | gnunet-da9f87ba7057cb018c02b0a546eaf45ff366cc44.tar.gz gnunet-da9f87ba7057cb018c02b0a546eaf45ff366cc44.zip |
comments
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/regex.c | 11 | ||||
-rw-r--r-- | src/regex/regex_internal.h | 5 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/regex/regex.c b/src/regex/regex.c index 68313664d..4c0f28851 100644 --- a/src/regex/regex.c +++ b/src/regex/regex.c | |||
@@ -644,7 +644,7 @@ GNUNET_REGEX_add_multi_strides_to_dfa (struct GNUNET_REGEX_Context *regex_ctx, | |||
644 | struct GNUNET_REGEX_Transition *t; | 644 | struct GNUNET_REGEX_Transition *t; |
645 | struct GNUNET_REGEX_Transition *t_next; | 645 | struct GNUNET_REGEX_Transition *t_next; |
646 | 646 | ||
647 | if (1 > stride_len) | 647 | if (1 > stride_len || GNUNET_YES == dfa->is_multistrided) |
648 | return; | 648 | return; |
649 | 649 | ||
650 | // Compute the new transitions. | 650 | // Compute the new transitions. |
@@ -660,6 +660,8 @@ GNUNET_REGEX_add_multi_strides_to_dfa (struct GNUNET_REGEX_Context *regex_ctx, | |||
660 | GNUNET_free_non_null (t->label); | 660 | GNUNET_free_non_null (t->label); |
661 | GNUNET_free (t); | 661 | GNUNET_free (t); |
662 | } | 662 | } |
663 | |||
664 | dfa->is_multistrided = GNUNET_YES; | ||
663 | } | 665 | } |
664 | 666 | ||
665 | 667 | ||
@@ -1383,7 +1385,7 @@ dfa_state_create (struct GNUNET_REGEX_Context *ctx, | |||
1383 | if (nfa_states->len < 1) | 1385 | if (nfa_states->len < 1) |
1384 | return s; | 1386 | return s; |
1385 | 1387 | ||
1386 | // Create a name based on 'sset' | 1388 | // Create a name based on 'nfa_states' |
1387 | s->name = GNUNET_malloc (sizeof (char) * 2); | 1389 | s->name = GNUNET_malloc (sizeof (char) * 2); |
1388 | strcat (s->name, "{"); | 1390 | strcat (s->name, "{"); |
1389 | name = NULL; | 1391 | name = NULL; |
@@ -2255,11 +2257,15 @@ GNUNET_REGEX_construct_nfa (const char *regex, const size_t len) | |||
2255 | goto error; | 2257 | goto error; |
2256 | } | 2258 | } |
2257 | 2259 | ||
2260 | /* Remember the regex that was used to generate this NFA */ | ||
2258 | nfa->regex = GNUNET_strdup (regex); | 2261 | nfa->regex = GNUNET_strdup (regex); |
2259 | 2262 | ||
2260 | /* create depth-first numbering of the states for pretty printing */ | 2263 | /* create depth-first numbering of the states for pretty printing */ |
2261 | GNUNET_REGEX_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL); | 2264 | GNUNET_REGEX_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL); |
2262 | 2265 | ||
2266 | /* No multistriding added so far */ | ||
2267 | nfa->is_multistrided = GNUNET_NO; | ||
2268 | |||
2263 | return nfa; | 2269 | return nfa; |
2264 | 2270 | ||
2265 | error: | 2271 | error: |
@@ -2367,6 +2373,7 @@ GNUNET_REGEX_construct_dfa (const char *regex, const size_t len) | |||
2367 | dfa->states_head = NULL; | 2373 | dfa->states_head = NULL; |
2368 | dfa->states_tail = NULL; | 2374 | dfa->states_tail = NULL; |
2369 | dfa->regex = GNUNET_strdup (regex); | 2375 | dfa->regex = GNUNET_strdup (regex); |
2376 | dfa->is_multistrided = GNUNET_NO; | ||
2370 | 2377 | ||
2371 | // Create DFA start state from epsilon closure | 2378 | // Create DFA start state from epsilon closure |
2372 | nfa_start_eps_cls = nfa_closure_create (nfa, nfa->start, 0); | 2379 | nfa_start_eps_cls = nfa_closure_create (nfa, nfa->start, 0); |
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h index c132f2e23..8b576a90e 100644 --- a/src/regex/regex_internal.h +++ b/src/regex/regex_internal.h | |||
@@ -253,6 +253,11 @@ struct GNUNET_REGEX_Automaton | |||
253 | * Canonical regex (result of RX->NFA->DFA->RX) | 253 | * Canonical regex (result of RX->NFA->DFA->RX) |
254 | */ | 254 | */ |
255 | char *canonical_regex; | 255 | char *canonical_regex; |
256 | |||
257 | /** | ||
258 | * GNUNET_YES, if multi strides have been added to the Automaton. | ||
259 | */ | ||
260 | int is_multistrided; | ||
256 | }; | 261 | }; |
257 | 262 | ||
258 | 263 | ||