diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-02 14:38:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-02 14:38:54 +0000 |
commit | 15a8471c0edc4134f57c19884c033a63f49a04dd (patch) | |
tree | 4465bb0b1198f1869163706e6cfeeaba5ff3fabf /src/regex/regex_internal.c | |
parent | 2a453cf6aec60af36f655bd053847ab15ff7ae8f (diff) | |
download | gnunet-15a8471c0edc4134f57c19884c033a63f49a04dd.tar.gz gnunet-15a8471c0edc4134f57c19884c033a63f49a04dd.zip |
-implementing regex test
Diffstat (limited to 'src/regex/regex_internal.c')
-rw-r--r-- | src/regex/regex_internal.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index 4ad27c441..a1fab7694 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c | |||
@@ -2132,7 +2132,7 @@ struct REGEX_INTERNAL_Strided_Context | |||
2132 | * @param start start state for the depth-first traversal of the graph. | 2132 | * @param start start state for the depth-first traversal of the graph. |
2133 | * @param s current state in the depth-first traversal | 2133 | * @param s current state in the depth-first traversal |
2134 | */ | 2134 | */ |
2135 | void | 2135 | static void |
2136 | dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, | 2136 | dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, |
2137 | struct REGEX_INTERNAL_State *start, | 2137 | struct REGEX_INTERNAL_State *start, |
2138 | struct REGEX_INTERNAL_State *s) | 2138 | struct REGEX_INTERNAL_State *s) |
@@ -2182,7 +2182,7 @@ dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, | |||
2182 | * @param count not used. | 2182 | * @param count not used. |
2183 | * @param s current state. | 2183 | * @param s current state. |
2184 | */ | 2184 | */ |
2185 | void | 2185 | static void |
2186 | dfa_add_multi_strides (void *cls, const unsigned int count, | 2186 | dfa_add_multi_strides (void *cls, const unsigned int count, |
2187 | struct REGEX_INTERNAL_State *s) | 2187 | struct REGEX_INTERNAL_State *s) |
2188 | { | 2188 | { |
@@ -2653,7 +2653,6 @@ nfa_add_question_op (struct REGEX_INTERNAL_Context *ctx) | |||
2653 | struct REGEX_INTERNAL_State *end; | 2653 | struct REGEX_INTERNAL_State *end; |
2654 | 2654 | ||
2655 | a = ctx->stack_tail; | 2655 | a = ctx->stack_tail; |
2656 | |||
2657 | if (NULL == a) | 2656 | if (NULL == a) |
2658 | { | 2657 | { |
2659 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2658 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -3035,7 +3034,6 @@ REGEX_INTERNAL_construct_dfa (const char *regex, const size_t len, | |||
3035 | REGEX_INTERNAL_context_init (&ctx); | 3034 | REGEX_INTERNAL_context_init (&ctx); |
3036 | 3035 | ||
3037 | /* Create NFA */ | 3036 | /* Create NFA */ |
3038 | // fprintf (stderr, "N"); | ||
3039 | nfa = REGEX_INTERNAL_construct_nfa (regex, len); | 3037 | nfa = REGEX_INTERNAL_construct_nfa (regex, len); |
3040 | 3038 | ||
3041 | if (NULL == nfa) | 3039 | if (NULL == nfa) |
@@ -3057,12 +3055,10 @@ REGEX_INTERNAL_construct_dfa (const char *regex, const size_t len, | |||
3057 | dfa->start = dfa_state_create (&ctx, &nfa_start_eps_cls); | 3055 | dfa->start = dfa_state_create (&ctx, &nfa_start_eps_cls); |
3058 | automaton_add_state (dfa, dfa->start); | 3056 | automaton_add_state (dfa, dfa->start); |
3059 | 3057 | ||
3060 | // fprintf (stderr, "D"); | ||
3061 | construct_dfa_states (&ctx, nfa, dfa, dfa->start); | 3058 | construct_dfa_states (&ctx, nfa, dfa, dfa->start); |
3062 | REGEX_INTERNAL_automaton_destroy (nfa); | 3059 | REGEX_INTERNAL_automaton_destroy (nfa); |
3063 | 3060 | ||
3064 | /* Minimize DFA */ | 3061 | /* Minimize DFA */ |
3065 | // fprintf (stderr, "M"); | ||
3066 | if (GNUNET_OK != dfa_minimize (&ctx, dfa)) | 3062 | if (GNUNET_OK != dfa_minimize (&ctx, dfa)) |
3067 | { | 3063 | { |
3068 | REGEX_INTERNAL_automaton_destroy (dfa); | 3064 | REGEX_INTERNAL_automaton_destroy (dfa); |
@@ -3310,18 +3306,17 @@ size_t | |||
3310 | REGEX_INTERNAL_get_first_key (const char *input_string, size_t string_len, | 3306 | REGEX_INTERNAL_get_first_key (const char *input_string, size_t string_len, |
3311 | struct GNUNET_HashCode * key) | 3307 | struct GNUNET_HashCode * key) |
3312 | { | 3308 | { |
3313 | unsigned int size; | 3309 | size_t size; |
3314 | 3310 | ||
3315 | size = | 3311 | size = |
3316 | string_len < | 3312 | string_len < |
3317 | GNUNET_REGEX_INITIAL_BYTES ? string_len : GNUNET_REGEX_INITIAL_BYTES; | 3313 | GNUNET_REGEX_INITIAL_BYTES ? string_len : GNUNET_REGEX_INITIAL_BYTES; |
3318 | |||
3319 | if (NULL == input_string) | 3314 | if (NULL == input_string) |
3320 | { | 3315 | { |
3321 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Given input string was NULL!\n"); | 3316 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3317 | "Given input string was NULL!\n"); | ||
3322 | return 0; | 3318 | return 0; |
3323 | } | 3319 | } |
3324 | |||
3325 | GNUNET_CRYPTO_hash (input_string, size, key); | 3320 | GNUNET_CRYPTO_hash (input_string, size, key); |
3326 | 3321 | ||
3327 | return size; | 3322 | return size; |
@@ -3351,7 +3346,6 @@ iterate_initial_edge (const unsigned int min_len, const unsigned int max_len, | |||
3351 | struct REGEX_BLOCK_Edge edge[1]; | 3346 | struct REGEX_BLOCK_Edge edge[1]; |
3352 | struct GNUNET_HashCode hash; | 3347 | struct GNUNET_HashCode hash; |
3353 | struct GNUNET_HashCode hash_new; | 3348 | struct GNUNET_HashCode hash_new; |
3354 | |||
3355 | unsigned int cur_len; | 3349 | unsigned int cur_len; |
3356 | 3350 | ||
3357 | if (NULL != consumed_string) | 3351 | if (NULL != consumed_string) |
@@ -3442,19 +3436,19 @@ REGEX_INTERNAL_iterate_all_edges (struct REGEX_INTERNAL_Automaton *a, | |||
3442 | unsigned int num_edges; | 3436 | unsigned int num_edges; |
3443 | 3437 | ||
3444 | num_edges = state_get_edges (s, edges); | 3438 | num_edges = state_get_edges (s, edges); |
3445 | 3439 | if ( ( (NULL != s->proof) && | |
3446 | if ((NULL != s->proof && 0 < strlen (s->proof)) || s->accepting) | 3440 | (0 < strlen (s->proof)) ) || s->accepting) |
3447 | iterator (iterator_cls, &s->hash, s->proof, s->accepting, num_edges, | 3441 | iterator (iterator_cls, &s->hash, s->proof, |
3448 | edges); | 3442 | s->accepting, |
3449 | 3443 | num_edges, edges); | |
3450 | s->marked = GNUNET_NO; | 3444 | s->marked = GNUNET_NO; |
3451 | } | 3445 | } |
3452 | 3446 | ||
3453 | iterate_initial_edge (GNUNET_REGEX_INITIAL_BYTES, GNUNET_REGEX_INITIAL_BYTES, | 3447 | iterate_initial_edge (GNUNET_REGEX_INITIAL_BYTES, |
3454 | NULL, a->start, iterator, iterator_cls); | 3448 | GNUNET_REGEX_INITIAL_BYTES, |
3449 | NULL, a->start, | ||
3450 | iterator, iterator_cls); | ||
3455 | } | 3451 | } |
3456 | 3452 | ||
3457 | 3453 | ||
3458 | 3454 | /* end of regex_internal.c */ | |
3459 | |||
3460 | /* end of regex.c */ | ||