From da9f87ba7057cb018c02b0a546eaf45ff366cc44 Mon Sep 17 00:00:00 2001 From: Maximilian Szengel Date: Thu, 13 Sep 2012 09:25:55 +0000 Subject: comments --- src/regex/regex.c | 11 +++++++++-- src/regex/regex_internal.h | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/regex') 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, struct GNUNET_REGEX_Transition *t; struct GNUNET_REGEX_Transition *t_next; - if (1 > stride_len) + if (1 > stride_len || GNUNET_YES == dfa->is_multistrided) return; // Compute the new transitions. @@ -660,6 +660,8 @@ GNUNET_REGEX_add_multi_strides_to_dfa (struct GNUNET_REGEX_Context *regex_ctx, GNUNET_free_non_null (t->label); GNUNET_free (t); } + + dfa->is_multistrided = GNUNET_YES; } @@ -1383,7 +1385,7 @@ dfa_state_create (struct GNUNET_REGEX_Context *ctx, if (nfa_states->len < 1) return s; - // Create a name based on 'sset' + // Create a name based on 'nfa_states' s->name = GNUNET_malloc (sizeof (char) * 2); strcat (s->name, "{"); name = NULL; @@ -2255,11 +2257,15 @@ GNUNET_REGEX_construct_nfa (const char *regex, const size_t len) goto error; } + /* Remember the regex that was used to generate this NFA */ nfa->regex = GNUNET_strdup (regex); /* create depth-first numbering of the states for pretty printing */ GNUNET_REGEX_automaton_traverse (nfa, NULL, NULL, NULL, &number_states, NULL); + /* No multistriding added so far */ + nfa->is_multistrided = GNUNET_NO; + return nfa; error: @@ -2367,6 +2373,7 @@ GNUNET_REGEX_construct_dfa (const char *regex, const size_t len) dfa->states_head = NULL; dfa->states_tail = NULL; dfa->regex = GNUNET_strdup (regex); + dfa->is_multistrided = GNUNET_NO; // Create DFA start state from epsilon closure 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 * Canonical regex (result of RX->NFA->DFA->RX) */ char *canonical_regex; + + /** + * GNUNET_YES, if multi strides have been added to the Automaton. + */ + int is_multistrided; }; -- cgit v1.2.3