diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-31 13:03:48 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-31 13:03:48 +0100 |
commit | 7e3cf5f461eb4fbb7581672bf0835da07c378136 (patch) | |
tree | bdc3874b7894242b095b892f1ed3e81a4d4f06c0 /src/regex | |
parent | 01b480d6d026e0c537dc284a7e7df2c0320a3528 (diff) | |
download | gnunet-7e3cf5f461eb4fbb7581672bf0835da07c378136.tar.gz gnunet-7e3cf5f461eb4fbb7581672bf0835da07c378136.zip |
tighten formatting rules
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-daemon-regexprofiler.c | 10 | ||||
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 7 | ||||
-rw-r--r-- | src/regex/gnunet-regex-simulation-profiler.c | 7 | ||||
-rw-r--r-- | src/regex/perf-regex.c | 1 | ||||
-rw-r--r-- | src/regex/plugin_block_regex.c | 1 | ||||
-rw-r--r-- | src/regex/regex_api_announce.c | 2 | ||||
-rw-r--r-- | src/regex/regex_block_lib.c | 2 | ||||
-rw-r--r-- | src/regex/regex_internal.c | 62 | ||||
-rw-r--r-- | src/regex/regex_internal.h | 1 | ||||
-rw-r--r-- | src/regex/regex_internal_lib.h | 1 | ||||
-rw-r--r-- | src/regex/regex_test_graph.c | 2 | ||||
-rw-r--r-- | src/regex/regex_test_lib.c | 15 | ||||
-rw-r--r-- | src/regex/regex_test_lib.h | 1 | ||||
-rw-r--r-- | src/regex/regex_test_random.c | 4 | ||||
-rw-r--r-- | src/regex/test_regex_api.c | 1 | ||||
-rw-r--r-- | src/regex/test_regex_eval_api.c | 18 | ||||
-rw-r--r-- | src/regex/test_regex_integration.c | 1 |
17 files changed, 73 insertions, 63 deletions
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c index a23336808..fb061acc1 100644 --- a/src/regex/gnunet-daemon-regexprofiler.c +++ b/src/regex/gnunet-daemon-regexprofiler.c | |||
@@ -101,7 +101,6 @@ static unsigned int rounds = 3; | |||
101 | static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; | 101 | static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; |
102 | 102 | ||
103 | 103 | ||
104 | |||
105 | /** | 104 | /** |
106 | * Task run during shutdown. | 105 | * Task run during shutdown. |
107 | * | 106 | * |
@@ -157,7 +156,7 @@ reannounce_regex (void *cls) | |||
157 | } | 156 | } |
158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing regex: %s\n", regex); | 157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Announcing regex: %s\n", regex); |
159 | GNUNET_STATISTICS_update (stats_handle, "# regexes announced", 1, GNUNET_NO); | 158 | GNUNET_STATISTICS_update (stats_handle, "# regexes announced", 1, GNUNET_NO); |
160 | if ((NULL == announce_handle)&&(NULL != regex)) | 159 | if ((NULL == announce_handle) && (NULL != regex)) |
161 | { | 160 | { |
162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
163 | "First time, creating regex: %s\n", | 162 | "First time, creating regex: %s\n", |
@@ -196,7 +195,7 @@ announce_regex (const char *regex) | |||
196 | { | 195 | { |
197 | char *copy; | 196 | char *copy; |
198 | 197 | ||
199 | if ((NULL == regex)||(0 == strlen (regex))) | 198 | if ((NULL == regex) || (0 == strlen (regex))) |
200 | { | 199 | { |
201 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot announce empty regex\n"); | 200 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot announce empty regex\n"); |
202 | return; | 201 | return; |
@@ -393,12 +392,15 @@ main (int argc, char *const *argv) | |||
393 | /** | 392 | /** |
394 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. | 393 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. |
395 | */ | 394 | */ |
396 | void __attribute__ ((constructor)) GNUNET_ARM_memory_init () | 395 | void __attribute__ ((constructor)) |
396 | GNUNET_ARM_memory_init () | ||
397 | { | 397 | { |
398 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); | 398 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); |
399 | mallopt (M_TOP_PAD, 1 * 1024); | 399 | mallopt (M_TOP_PAD, 1 * 1024); |
400 | malloc_trim (0); | 400 | malloc_trim (0); |
401 | } | 401 | } |
402 | |||
403 | |||
402 | #endif | 404 | #endif |
403 | 405 | ||
404 | 406 | ||
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 16b7a7f0e..695d66144 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -417,7 +417,7 @@ do_shutdown (void *cls) | |||
417 | { | 417 | { |
418 | peer = &peers[peer_cnt]; | 418 | peer = &peers[peer_cnt]; |
419 | 419 | ||
420 | if ((GNUNET_YES != peer->search_str_matched) &&(NULL != data_file) ) | 420 | if ((GNUNET_YES != peer->search_str_matched) && (NULL != data_file) ) |
421 | { | 421 | { |
422 | prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time); | 422 | prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time); |
423 | size = | 423 | size = |
@@ -650,7 +650,7 @@ stats_connect_cb (void *cls, | |||
650 | { | 650 | { |
651 | struct RegexPeer *peer = cls; | 651 | struct RegexPeer *peer = cls; |
652 | 652 | ||
653 | if ((NULL == ca_result)||(NULL != emsg)) | 653 | if ((NULL == ca_result) || (NULL != emsg)) |
654 | { | 654 | { |
655 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 655 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
656 | "Failed to connect to statistics service on peer %u: %s\n", | 656 | "Failed to connect to statistics service on peer %u: %s\n", |
@@ -1043,7 +1043,7 @@ dht_connect_cb (void *cls, | |||
1043 | { | 1043 | { |
1044 | struct RegexPeer *peer = (struct RegexPeer *) cls; | 1044 | struct RegexPeer *peer = (struct RegexPeer *) cls; |
1045 | 1045 | ||
1046 | if ((NULL != emsg)||(NULL == op)||(NULL == ca_result)) | 1046 | if ((NULL != emsg) || (NULL == op) || (NULL == ca_result)) |
1047 | { | 1047 | { |
1048 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DHT connect failed: %s\n", emsg); | 1048 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DHT connect failed: %s\n", emsg); |
1049 | GNUNET_assert (0); | 1049 | GNUNET_assert (0); |
@@ -1170,6 +1170,7 @@ test_master (void *cls, | |||
1170 | GNUNET_SCHEDULER_add_delayed (search_timeout_time, &search_timed_out, NULL); | 1170 | GNUNET_SCHEDULER_add_delayed (search_timeout_time, &search_timed_out, NULL); |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | |||
1173 | /** | 1174 | /** |
1174 | * Function that will be called whenever something in the testbed changes. | 1175 | * Function that will be called whenever something in the testbed changes. |
1175 | * | 1176 | * |
diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c index 6637bafed..9adde99bd 100644 --- a/src/regex/gnunet-regex-simulation-profiler.c +++ b/src/regex/gnunet-regex-simulation-profiler.c | |||
@@ -305,6 +305,7 @@ do_abort (void *cls) | |||
305 | GNUNET_SCHEDULER_shutdown (); | 305 | GNUNET_SCHEDULER_shutdown (); |
306 | } | 306 | } |
307 | 307 | ||
308 | |||
308 | /** | 309 | /** |
309 | * Iterator over all states that inserts each state into the MySQL db. | 310 | * Iterator over all states that inserts each state into the MySQL db. |
310 | * | 311 | * |
@@ -369,7 +370,7 @@ regex_iterator (void *cls, | |||
369 | return; | 370 | return; |
370 | } | 371 | } |
371 | 372 | ||
372 | if ((-1 != total) &&(total > 0) ) | 373 | if ((-1 != total) && (total > 0) ) |
373 | { | 374 | { |
374 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Total: %llu (%s, %s)\n", | 375 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Total: %llu (%s, %s)\n", |
375 | (unsigned long long) total, | 376 | (unsigned long long) total, |
@@ -409,7 +410,7 @@ regex_iterator (void *cls, | |||
409 | num_merged_states++; | 410 | num_merged_states++; |
410 | } | 411 | } |
411 | 412 | ||
412 | if ((GNUNET_SYSERR == result) || ((1 != result) &&(0 != result) )) | 413 | if ((GNUNET_SYSERR == result) || ((1 != result) && (0 != result) )) |
413 | { | 414 | { |
414 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 415 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
415 | "Error executing prepared mysql statement for edge: Affected rows: %i, expected 0 or 1!\n", | 416 | "Error executing prepared mysql statement for edge: Affected rows: %i, expected 0 or 1!\n", |
@@ -433,7 +434,7 @@ regex_iterator (void *cls, | |||
433 | stmt_handle, | 434 | stmt_handle, |
434 | params_stmt); | 435 | params_stmt); |
435 | 436 | ||
436 | if ((1 != result) &&(0 != result) ) | 437 | if ((1 != result) && (0 != result) ) |
437 | { | 438 | { |
438 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 439 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
439 | "Error executing prepared mysql statement for edge: Affected rows: %i, expected 0 or 1!\n", | 440 | "Error executing prepared mysql statement for edge: Affected rows: %i, expected 0 or 1!\n", |
diff --git a/src/regex/perf-regex.c b/src/regex/perf-regex.c index d41887f6b..6155501f2 100644 --- a/src/regex/perf-regex.c +++ b/src/regex/perf-regex.c | |||
@@ -125,4 +125,5 @@ main (int argc, char *const *argv) | |||
125 | return 0; | 125 | return 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | |||
128 | /* end of prof-regex.c */ | 129 | /* end of prof-regex.c */ |
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index e8ff158dd..9c7aa9119 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c | |||
@@ -408,4 +408,5 @@ libgnunet_plugin_block_regex_done (void *cls) | |||
408 | return NULL; | 408 | return NULL; |
409 | } | 409 | } |
410 | 410 | ||
411 | |||
411 | /* end of plugin_block_regex.c */ | 412 | /* end of plugin_block_regex.c */ |
diff --git a/src/regex/regex_api_announce.c b/src/regex/regex_api_announce.c index 318d73263..ad8a4fab9 100644 --- a/src/regex/regex_api_announce.c +++ b/src/regex/regex_api_announce.c | |||
@@ -63,7 +63,6 @@ struct GNUNET_REGEX_Announcement | |||
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | |||
67 | /** | 66 | /** |
68 | * (Re)connect to the REGEX service with the given announcement @a a. | 67 | * (Re)connect to the REGEX service with the given announcement @a a. |
69 | * | 68 | * |
@@ -183,4 +182,5 @@ GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_Announcement *a) | |||
183 | GNUNET_free (a); | 182 | GNUNET_free (a); |
184 | } | 183 | } |
185 | 184 | ||
185 | |||
186 | /* end of regex_api_announce.c */ | 186 | /* end of regex_api_announce.c */ |
diff --git a/src/regex/regex_block_lib.c b/src/regex/regex_block_lib.c index 2c6752e09..a309c2305 100644 --- a/src/regex/regex_block_lib.c +++ b/src/regex/regex_block_lib.c | |||
@@ -218,7 +218,7 @@ REGEX_BLOCK_check (const struct RegexBlock *block, | |||
218 | GNUNET_break_op (0); | 218 | GNUNET_break_op (0); |
219 | return GNUNET_SYSERR; | 219 | return GNUNET_SYSERR; |
220 | } | 220 | } |
221 | if ((NULL != query)&& | 221 | if ((NULL != query) && |
222 | (0 != GNUNET_memcmp (&key, | 222 | (0 != GNUNET_memcmp (&key, |
223 | query)) ) | 223 | query)) ) |
224 | { | 224 | { |
diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index 78c2de8ab..1dd4f6a97 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c | |||
@@ -121,7 +121,7 @@ state_add_transition (struct REGEX_INTERNAL_Context *ctx, | |||
121 | /* Do not add duplicate state transitions */ | 121 | /* Do not add duplicate state transitions */ |
122 | for (t = from_state->transitions_head; NULL != t; t = t->next) | 122 | for (t = from_state->transitions_head; NULL != t; t = t->next) |
123 | { | 123 | { |
124 | if ((t->to_state == to_state) &&(0 == nullstrcmp (t->label, label)) && | 124 | if ((t->to_state == to_state) && (0 == nullstrcmp (t->label, label)) && |
125 | (t->from_state == from_state) ) | 125 | (t->from_state == from_state) ) |
126 | return; | 126 | return; |
127 | } | 127 | } |
@@ -162,7 +162,7 @@ static void | |||
162 | state_remove_transition (struct REGEX_INTERNAL_State *state, | 162 | state_remove_transition (struct REGEX_INTERNAL_State *state, |
163 | struct REGEX_INTERNAL_Transition *transition) | 163 | struct REGEX_INTERNAL_Transition *transition) |
164 | { | 164 | { |
165 | if ((NULL == state)||(NULL == transition)) | 165 | if ((NULL == state) || (NULL == transition)) |
166 | return; | 166 | return; |
167 | 167 | ||
168 | if (transition->from_state != state) | 168 | if (transition->from_state != state) |
@@ -247,7 +247,7 @@ state_set_compare (struct REGEX_INTERNAL_StateSet *sset1, | |||
247 | int result; | 247 | int result; |
248 | unsigned int i; | 248 | unsigned int i; |
249 | 249 | ||
250 | if ((NULL == sset1)||(NULL == sset2)) | 250 | if ((NULL == sset1) || (NULL == sset2)) |
251 | return 1; | 251 | return 1; |
252 | 252 | ||
253 | result = sset1->off - sset2->off; | 253 | result = sset1->off - sset2->off; |
@@ -339,7 +339,7 @@ automaton_remove_state (struct REGEX_INTERNAL_Automaton *a, | |||
339 | struct REGEX_INTERNAL_Transition *t_check; | 339 | struct REGEX_INTERNAL_Transition *t_check; |
340 | struct REGEX_INTERNAL_Transition *t_check_next; | 340 | struct REGEX_INTERNAL_Transition *t_check_next; |
341 | 341 | ||
342 | if ((NULL == a)||(NULL == s)) | 342 | if ((NULL == a) || (NULL == s)) |
343 | return; | 343 | return; |
344 | 344 | ||
345 | /* remove all transitions leading to this state */ | 345 | /* remove all transitions leading to this state */ |
@@ -399,7 +399,7 @@ automaton_merge_states (struct REGEX_INTERNAL_Context *ctx, | |||
399 | is_dup = GNUNET_NO; | 399 | is_dup = GNUNET_NO; |
400 | for (t = t_check->from_state->transitions_head; NULL != t; t = t->next) | 400 | for (t = t_check->from_state->transitions_head; NULL != t; t = t->next) |
401 | { | 401 | { |
402 | if ((t->to_state == s1) &&(0 == strcmp (t_check->label, t->label)) ) | 402 | if ((t->to_state == s1) && (0 == strcmp (t_check->label, t->label)) ) |
403 | is_dup = GNUNET_YES; | 403 | is_dup = GNUNET_YES; |
404 | } | 404 | } |
405 | if (GNUNET_NO == is_dup) | 405 | if (GNUNET_NO == is_dup) |
@@ -487,7 +487,7 @@ automaton_state_traverse (struct REGEX_INTERNAL_State *s, | |||
487 | for (t = s->transitions_head; NULL != t; t = t->next) | 487 | for (t = s->transitions_head; NULL != t; t = t->next) |
488 | { | 488 | { |
489 | if ((NULL == check) || | 489 | if ((NULL == check) || |
490 | ((NULL != check) &&(GNUNET_YES == check (check_cls, s, t)) )) | 490 | ((NULL != check) && (GNUNET_YES == check (check_cls, s, t)) )) |
491 | { | 491 | { |
492 | automaton_state_traverse (t->to_state, | 492 | automaton_state_traverse (t->to_state, |
493 | marks, | 493 | marks, |
@@ -525,7 +525,7 @@ REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, | |||
525 | unsigned int count; | 525 | unsigned int count; |
526 | struct REGEX_INTERNAL_State *s; | 526 | struct REGEX_INTERNAL_State *s; |
527 | 527 | ||
528 | if ((NULL == a)||(0 == a->state_count)) | 528 | if ((NULL == a) || (0 == a->state_count)) |
529 | return; | 529 | return; |
530 | 530 | ||
531 | int marks[a->state_count]; | 531 | int marks[a->state_count]; |
@@ -1197,9 +1197,7 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1197 | * R_cur_ij = R_cur_l | R_cur_r | 1197 | * R_cur_ij = R_cur_l | R_cur_r |
1198 | * R_cur_l == R^{(k-1)}_{ij} | 1198 | * R_cur_l == R^{(k-1)}_{ij} |
1199 | * R_cur_r == R^{(k-1)}_{ik} ( R^{(k-1)}_{kk} )^* R^{(k-1)}_{kj} | 1199 | * R_cur_r == R^{(k-1)}_{ik} ( R^{(k-1)}_{kk} )^* R^{(k-1)}_{kj} |
1200 | */ | 1200 | */if ((GNUNET_YES == R_last_ij->null_flag) && |
1201 | |||
1202 | if ((GNUNET_YES == R_last_ij->null_flag) && | ||
1203 | ((GNUNET_YES == R_last_ik->null_flag) || | 1201 | ((GNUNET_YES == R_last_ik->null_flag) || |
1204 | (GNUNET_YES == R_last_kj->null_flag))) | 1202 | (GNUNET_YES == R_last_kj->null_flag))) |
1205 | { | 1203 | { |
@@ -1283,8 +1281,7 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1283 | * (e|a)|(e|a)a*a = a* | 1281 | * (e|a)|(e|a)a*a = a* |
1284 | * (e|a)|(e|a)a*(e|a) = a* | 1282 | * (e|a)|(e|a)a*(e|a) = a* |
1285 | * (e|a)|(e|a)(e|a)*(e|a) = a* | 1283 | * (e|a)|(e|a)(e|a)*(e|a) = a* |
1286 | */ | 1284 | */if (GNUNET_YES == needs_parentheses (&R_temp_ij)) |
1287 | if (GNUNET_YES == needs_parentheses (&R_temp_ij)) | ||
1288 | sb_printf1 (R_cur_r, "(%.*s)*", 3, &R_temp_ij); | 1285 | sb_printf1 (R_cur_r, "(%.*s)*", 3, &R_temp_ij); |
1289 | else | 1286 | else |
1290 | sb_printf1 (R_cur_r, "%.*s*", 1, &R_temp_ij); | 1287 | sb_printf1 (R_cur_r, "%.*s*", 1, &R_temp_ij); |
@@ -1297,8 +1294,7 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1297 | * a|aa*(e|a) = a+ | 1294 | * a|aa*(e|a) = a+ |
1298 | * a|(e|a)(e|a)*a = a+ | 1295 | * a|(e|a)(e|a)*a = a+ |
1299 | * a|a(e|a)*(e|a) = a+ | 1296 | * a|a(e|a)*(e|a) = a+ |
1300 | */ | 1297 | */if (GNUNET_YES == needs_parentheses (&R_temp_ij)) |
1301 | if (GNUNET_YES == needs_parentheses (&R_temp_ij)) | ||
1302 | sb_printf1 (R_cur_r, "(%.*s)+", 3, &R_temp_ij); | 1298 | sb_printf1 (R_cur_r, "(%.*s)+", 3, &R_temp_ij); |
1303 | else | 1299 | else |
1304 | sb_printf1 (R_cur_r, "%.*s+", 1, &R_temp_ij); | 1300 | sb_printf1 (R_cur_r, "%.*s+", 1, &R_temp_ij); |
@@ -1435,8 +1431,7 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1435 | * aa*(e|a) = a+ | 1431 | * aa*(e|a) = a+ |
1436 | * a(e|a)*(e|a) = a+ | 1432 | * a(e|a)*(e|a) = a+ |
1437 | * (e|a)a*a = a+ | 1433 | * (e|a)a*a = a+ |
1438 | */ | 1434 | */else |
1439 | else | ||
1440 | { | 1435 | { |
1441 | eps_check = (has_epsilon (R_last_ik) + has_epsilon (R_last_kk) | 1436 | eps_check = (has_epsilon (R_last_ik) + has_epsilon (R_last_kk) |
1442 | + has_epsilon (R_last_kj)); | 1437 | + has_epsilon (R_last_kj)); |
@@ -1922,7 +1917,7 @@ dfa_remove_dead_states (struct REGEX_INTERNAL_Automaton *a) | |||
1922 | dead = 1; | 1917 | dead = 1; |
1923 | for (t = s->transitions_head; NULL != t; t = t->next) | 1918 | for (t = s->transitions_head; NULL != t; t = t->next) |
1924 | { | 1919 | { |
1925 | if ((NULL != t->to_state) &&(t->to_state != s) ) | 1920 | if ((NULL != t->to_state) && (t->to_state != s) ) |
1926 | { | 1921 | { |
1927 | dead = 0; | 1922 | dead = 0; |
1928 | break; | 1923 | break; |
@@ -2201,7 +2196,7 @@ REGEX_INTERNAL_dfa_add_multi_strides (struct REGEX_INTERNAL_Context *regex_ctx, | |||
2201 | struct REGEX_INTERNAL_Transition *t; | 2196 | struct REGEX_INTERNAL_Transition *t; |
2202 | struct REGEX_INTERNAL_Transition *t_next; | 2197 | struct REGEX_INTERNAL_Transition *t_next; |
2203 | 2198 | ||
2204 | if ((1 > stride_len)||(GNUNET_YES == dfa->is_multistrided)) | 2199 | if ((1 > stride_len) || (GNUNET_YES == dfa->is_multistrided)) |
2205 | return; | 2200 | return; |
2206 | 2201 | ||
2207 | /* Compute the new transitions of given stride_len */ | 2202 | /* Compute the new transitions of given stride_len */ |
@@ -2226,6 +2221,7 @@ REGEX_INTERNAL_dfa_add_multi_strides (struct REGEX_INTERNAL_Context *regex_ctx, | |||
2226 | dfa->is_multistrided = GNUNET_YES; | 2221 | dfa->is_multistrided = GNUNET_YES; |
2227 | } | 2222 | } |
2228 | 2223 | ||
2224 | |||
2229 | /** | 2225 | /** |
2230 | * Recursive Helper function for DFA path compression. Does DFS on the DFA graph | 2226 | * Recursive Helper function for DFA path compression. Does DFS on the DFA graph |
2231 | * and adds new transitions to the given transitions DLL and marks states that | 2227 | * and adds new transitions to the given transitions DLL and marks states that |
@@ -2252,11 +2248,14 @@ dfa_compress_paths_helper (struct REGEX_INTERNAL_Automaton *dfa, | |||
2252 | char *new_label; | 2248 | char *new_label; |
2253 | 2249 | ||
2254 | 2250 | ||
2255 | if ((NULL != label)&& | 2251 | if ((NULL != label) && |
2256 | (((cur->incoming_transition_count > 1)||(GNUNET_YES == cur->accepting)|| | 2252 | (((cur->incoming_transition_count > 1) || (GNUNET_YES == |
2253 | cur->accepting) || | ||
2257 | (GNUNET_YES == cur->marked) ) || | 2254 | (GNUNET_YES == cur->marked) ) || |
2258 | ((start != dfa->start)&&(max_len > 0)&&(max_len == strlen (label))) || | 2255 | ((start != dfa->start) && (max_len > 0) && (max_len == strlen ( |
2259 | ((start == dfa->start)&&(GNUNET_REGEX_INITIAL_BYTES == strlen (label))))) | 2256 | label))) || |
2257 | ((start == dfa->start) && (GNUNET_REGEX_INITIAL_BYTES == strlen ( | ||
2258 | label))))) | ||
2260 | { | 2259 | { |
2261 | t = GNUNET_new (struct REGEX_INTERNAL_Transition); | 2260 | t = GNUNET_new (struct REGEX_INTERNAL_Transition); |
2262 | t->label = GNUNET_strdup (label); | 2261 | t->label = GNUNET_strdup (label); |
@@ -2279,7 +2278,7 @@ dfa_compress_paths_helper (struct REGEX_INTERNAL_Automaton *dfa, | |||
2279 | else if (cur != start) | 2278 | else if (cur != start) |
2280 | cur->contained = GNUNET_YES; | 2279 | cur->contained = GNUNET_YES; |
2281 | 2280 | ||
2282 | if ((GNUNET_YES == cur->marked)&&(cur != start)) | 2281 | if ((GNUNET_YES == cur->marked) && (cur != start)) |
2283 | return; | 2282 | return; |
2284 | 2283 | ||
2285 | cur->marked = GNUNET_YES; | 2284 | cur->marked = GNUNET_YES; |
@@ -2398,7 +2397,7 @@ nfa_fragment_create (struct REGEX_INTERNAL_State *start, | |||
2398 | n->end = NULL; | 2397 | n->end = NULL; |
2399 | n->state_count = 0; | 2398 | n->state_count = 0; |
2400 | 2399 | ||
2401 | if ((NULL == start)||(NULL == end)) | 2400 | if ((NULL == start) || (NULL == end)) |
2402 | return n; | 2401 | return n; |
2403 | 2402 | ||
2404 | automaton_add_state (n, end); | 2403 | automaton_add_state (n, end); |
@@ -2427,7 +2426,7 @@ nfa_add_states (struct REGEX_INTERNAL_Automaton *n, | |||
2427 | { | 2426 | { |
2428 | struct REGEX_INTERNAL_State *s; | 2427 | struct REGEX_INTERNAL_State *s; |
2429 | 2428 | ||
2430 | if ((NULL == n)||(NULL == states_head)) | 2429 | if ((NULL == n) || (NULL == states_head)) |
2431 | { | 2430 | { |
2432 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not add states\n"); | 2431 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not add states\n"); |
2433 | return; | 2432 | return; |
@@ -2820,7 +2819,7 @@ REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len) | |||
2820 | int atomcount; | 2819 | int atomcount; |
2821 | } *p; | 2820 | } *p; |
2822 | 2821 | ||
2823 | if ((NULL == regex)||(0 == strlen (regex))||(0 == len)) | 2822 | if ((NULL == regex) || (0 == strlen (regex)) || (0 == len)) |
2824 | { | 2823 | { |
2825 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2824 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2826 | "Could not parse regex. Empty regex string provided.\n"); | 2825 | "Could not parse regex. Empty regex string provided.\n"); |
@@ -3009,7 +3008,7 @@ construct_dfa_states (struct REGEX_INTERNAL_Context *ctx, | |||
3009 | 3008 | ||
3010 | for (ctran = dfa_state->transitions_head; NULL != ctran; ctran = ctran->next) | 3009 | for (ctran = dfa_state->transitions_head; NULL != ctran; ctran = ctran->next) |
3011 | { | 3010 | { |
3012 | if ((NULL == ctran->label) ||(NULL != ctran->to_state) ) | 3011 | if ((NULL == ctran->label) || (NULL != ctran->to_state) ) |
3013 | continue; | 3012 | continue; |
3014 | 3013 | ||
3015 | nfa_closure_set_create (&tmp, nfa, &dfa_state->nfa_set, ctran->label); | 3014 | nfa_closure_set_create (&tmp, nfa, &dfa_state->nfa_set, ctran->label); |
@@ -3173,7 +3172,7 @@ evaluate_dfa (struct REGEX_INTERNAL_Automaton *a, const char *string) | |||
3173 | s = a->start; | 3172 | s = a->start; |
3174 | 3173 | ||
3175 | /* If the string is empty but the starting state is accepting, we accept. */ | 3174 | /* If the string is empty but the starting state is accepting, we accept. */ |
3176 | if (((NULL == string)||(0 == strlen (string))) && s->accepting) | 3175 | if (((NULL == string) || (0 == strlen (string))) && s->accepting) |
3177 | return 0; | 3176 | return 0; |
3178 | 3177 | ||
3179 | for (strp = string; NULL != strp && *strp; strp += step_len) | 3178 | for (strp = string; NULL != strp && *strp; strp += step_len) |
@@ -3184,7 +3183,7 @@ evaluate_dfa (struct REGEX_INTERNAL_Automaton *a, const char *string) | |||
3184 | break; | 3183 | break; |
3185 | } | 3184 | } |
3186 | 3185 | ||
3187 | if ((NULL != s)&& s->accepting) | 3186 | if ((NULL != s) && s->accepting) |
3188 | return 0; | 3187 | return 0; |
3189 | 3188 | ||
3190 | return 1; | 3189 | return 1; |
@@ -3218,7 +3217,7 @@ evaluate_nfa (struct REGEX_INTERNAL_Automaton *a, const char *string) | |||
3218 | } | 3217 | } |
3219 | 3218 | ||
3220 | /* If the string is empty but the starting state is accepting, we accept. */ | 3219 | /* If the string is empty but the starting state is accepting, we accept. */ |
3221 | if (((NULL == string)||(0 == strlen (string))) && a->start->accepting) | 3220 | if (((NULL == string) || (0 == strlen (string))) && a->start->accepting) |
3222 | return 0; | 3221 | return 0; |
3223 | 3222 | ||
3224 | result = 1; | 3223 | result = 1; |
@@ -3644,7 +3643,7 @@ reachability_iterator (void *cls, | |||
3644 | /* already visited and marked */ | 3643 | /* already visited and marked */ |
3645 | return GNUNET_YES; | 3644 | return GNUNET_YES; |
3646 | 3645 | ||
3647 | if ((GNUNET_REGEX_INITIAL_BYTES > strlen (state->proof))&& | 3646 | if ((GNUNET_REGEX_INITIAL_BYTES > strlen (state->proof)) && |
3648 | (GNUNET_NO == state->accepting) ) | 3647 | (GNUNET_NO == state->accepting) ) |
3649 | /* not directly reachable */ | 3648 | /* not directly reachable */ |
3650 | return GNUNET_YES; | 3649 | return GNUNET_YES; |
@@ -3685,6 +3684,7 @@ iterate_reachables (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
3685 | return GNUNET_YES; | 3684 | return GNUNET_YES; |
3686 | } | 3685 | } |
3687 | 3686 | ||
3687 | |||
3688 | /** | 3688 | /** |
3689 | * Iterate over all edges of automaton 'a' that are reachable from a state with | 3689 | * Iterate over all edges of automaton 'a' that are reachable from a state with |
3690 | * a proof of at least GNUNET_REGEX_INITIAL_BYTES characters. | 3690 | * a proof of at least GNUNET_REGEX_INITIAL_BYTES characters. |
diff --git a/src/regex/regex_internal.h b/src/regex/regex_internal.h index 1e0722136..17b038f21 100644 --- a/src/regex/regex_internal.h +++ b/src/regex/regex_internal.h | |||
@@ -446,7 +446,6 @@ REGEX_INTERNAL_dfa_add_multi_strides (struct REGEX_INTERNAL_Context *regex_ctx, | |||
446 | const unsigned int stride_len); | 446 | const unsigned int stride_len); |
447 | 447 | ||
448 | 448 | ||
449 | |||
450 | #if 0 /* keep Emacsens' auto-indent happy */ | 449 | #if 0 /* keep Emacsens' auto-indent happy */ |
451 | { | 450 | { |
452 | #endif | 451 | #endif |
diff --git a/src/regex/regex_internal_lib.h b/src/regex/regex_internal_lib.h index 531f998cc..cd955e68b 100644 --- a/src/regex/regex_internal_lib.h +++ b/src/regex/regex_internal_lib.h | |||
@@ -157,7 +157,6 @@ REGEX_INTERNAL_iterate_reachable_edges (struct REGEX_INTERNAL_Automaton *a, | |||
157 | void *iterator_cls); | 157 | void *iterator_cls); |
158 | 158 | ||
159 | 159 | ||
160 | |||
161 | /** | 160 | /** |
162 | * Handle to store cached data about a regex announce. | 161 | * Handle to store cached data about a regex announce. |
163 | */ | 162 | */ |
diff --git a/src/regex/regex_test_graph.c b/src/regex/regex_test_graph.c index c988b5aae..8e1e00fd4 100644 --- a/src/regex/regex_test_graph.c +++ b/src/regex/regex_test_graph.c | |||
@@ -282,7 +282,7 @@ REGEX_TEST_automaton_save_graph (struct REGEX_INTERNAL_Automaton *a, | |||
282 | return; | 282 | return; |
283 | } | 283 | } |
284 | 284 | ||
285 | if ((NULL == filename)||(strlen (filename) < 1)) | 285 | if ((NULL == filename) || (strlen (filename) < 1)) |
286 | { | 286 | { |
287 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No Filename given!"); | 287 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No Filename given!"); |
288 | return; | 288 | return; |
diff --git a/src/regex/regex_test_lib.c b/src/regex/regex_test_lib.c index 15d6c653a..05001b5d2 100644 --- a/src/regex/regex_test_lib.c +++ b/src/regex/regex_test_lib.c | |||
@@ -72,11 +72,11 @@ c2i (char c, int size) | |||
72 | break; | 72 | break; |
73 | 73 | ||
74 | case 16: | 74 | case 16: |
75 | if ((c >= '0') &&(c <= '9') ) | 75 | if ((c >= '0') && (c <= '9') ) |
76 | return c - '0'; | 76 | return c - '0'; |
77 | else if ((c >= 'A') &&(c <= 'F') ) | 77 | else if ((c >= 'A') && (c <= 'F') ) |
78 | return c - 'A' + 10; | 78 | return c - 'A' + 10; |
79 | else if ((c >= 'a') &&(c <= 'f') ) | 79 | else if ((c >= 'a') && (c <= 'f') ) |
80 | return c - 'a' + 10; | 80 | return c - 'a' + 10; |
81 | else | 81 | else |
82 | { | 82 | { |
@@ -324,6 +324,7 @@ get_longest_prefix (struct RegexCombineCtx *ctx, const char *regex) | |||
324 | return best; | 324 | return best; |
325 | } | 325 | } |
326 | 326 | ||
327 | |||
327 | static void | 328 | static void |
328 | regex_add_multiple (struct RegexCombineCtx *ctx, | 329 | regex_add_multiple (struct RegexCombineCtx *ctx, |
329 | const char *regex, | 330 | const char *regex, |
@@ -347,7 +348,7 @@ regex_add_multiple (struct RegexCombineCtx *ctx, | |||
347 | count = 0; | 348 | count = 0; |
348 | for (i = 1UL; i < l; i++) | 349 | for (i = 1UL; i < l; i++) |
349 | { | 350 | { |
350 | if ((regex[i] != '|') &&(regex[i] != ')') ) | 351 | if ((regex[i] != '|') && (regex[i] != ')') ) |
351 | { | 352 | { |
352 | count++; | 353 | count++; |
353 | } | 354 | } |
@@ -361,7 +362,7 @@ regex_add_multiple (struct RegexCombineCtx *ctx, | |||
361 | tmp[1] = '\0'; | 362 | tmp[1] = '\0'; |
362 | for (i = 1UL; i < l; i++) | 363 | for (i = 1UL; i < l; i++) |
363 | { | 364 | { |
364 | if ((regex[i] != '|') &&(regex[i] != ')') ) | 365 | if ((regex[i] != '|') && (regex[i] != ')') ) |
365 | { | 366 | { |
366 | tmp[0] = regex[i]; | 367 | tmp[0] = regex[i]; |
367 | newctx = new_regex_ctx (ctx->size); | 368 | newctx = new_regex_ctx (ctx->size); |
@@ -375,6 +376,7 @@ regex_add_multiple (struct RegexCombineCtx *ctx, | |||
375 | } | 376 | } |
376 | } | 377 | } |
377 | 378 | ||
379 | |||
378 | /** | 380 | /** |
379 | * Add a single regex to a context, splitting the exisiting state. | 381 | * Add a single regex to a context, splitting the exisiting state. |
380 | * | 382 | * |
@@ -482,7 +484,7 @@ regex_add (struct RegexCombineCtx *ctx, const char *regex) | |||
482 | 484 | ||
483 | /* There is no prefix match, add new */ | 485 | /* There is no prefix match, add new */ |
484 | idx = c2i (regex[0], ctx->size); | 486 | idx = c2i (regex[0], ctx->size); |
485 | if ((NULL == ctx->children[idx])&&(NULL != ctx->s)) | 487 | if ((NULL == ctx->children[idx]) && (NULL != ctx->s)) |
486 | { | 488 | { |
487 | /* this was the end before, add empty string */ | 489 | /* this was the end before, add empty string */ |
488 | newctx = new_regex_ctx (ctx->size); | 490 | newctx = new_regex_ctx (ctx->size); |
@@ -652,4 +654,5 @@ REGEX_TEST_free_from_file (char **regexes) | |||
652 | GNUNET_free (regexes); | 654 | GNUNET_free (regexes); |
653 | } | 655 | } |
654 | 656 | ||
657 | |||
655 | /* end of regex_test_lib.c */ | 658 | /* end of regex_test_lib.c */ |
diff --git a/src/regex/regex_test_lib.h b/src/regex/regex_test_lib.h index a0ad0723a..98f60d317 100644 --- a/src/regex/regex_test_lib.h +++ b/src/regex/regex_test_lib.h | |||
@@ -147,7 +147,6 @@ REGEX_TEST_automaton_save_graph (struct REGEX_INTERNAL_Automaton *a, | |||
147 | enum REGEX_TEST_GraphSavingOptions options); | 147 | enum REGEX_TEST_GraphSavingOptions options); |
148 | 148 | ||
149 | 149 | ||
150 | |||
151 | #if 0 /* keep Emacsens' auto-indent happy */ | 150 | #if 0 /* keep Emacsens' auto-indent happy */ |
152 | { | 151 | { |
153 | #endif | 152 | #endif |
diff --git a/src/regex/regex_test_random.c b/src/regex/regex_test_random.c index 29b5315db..02d59f5dc 100644 --- a/src/regex/regex_test_random.c +++ b/src/regex/regex_test_random.c | |||
@@ -123,8 +123,8 @@ REGEX_TEST_generate_random_regex (size_t rx_length, char *matching_str) | |||
123 | } | 123 | } |
124 | 124 | ||
125 | if ((NULL != matching_strp) && | 125 | if ((NULL != matching_strp) && |
126 | ((current_char != '+') &&(current_char != '*') &&(current_char != | 126 | ((current_char != '+') && (current_char != '*') && (current_char != |
127 | '?') && | 127 | '?') && |
128 | (current_char != '|') )) | 128 | (current_char != '|') )) |
129 | { | 129 | { |
130 | *matching_strp = current_char; | 130 | *matching_strp = current_char; |
diff --git a/src/regex/test_regex_api.c b/src/regex/test_regex_api.c index eaae8c682..734fbdbf3 100644 --- a/src/regex/test_regex_api.c +++ b/src/regex/test_regex_api.c | |||
@@ -128,4 +128,5 @@ main (int argc, char *argv[]) | |||
128 | return ok; | 128 | return ok; |
129 | } | 129 | } |
130 | 130 | ||
131 | |||
131 | /* end of test_regex_api.c */ | 132 | /* end of test_regex_api.c */ |
diff --git a/src/regex/test_regex_eval_api.c b/src/regex/test_regex_eval_api.c index f6078c7ef..767571156 100644 --- a/src/regex/test_regex_eval_api.c +++ b/src/regex/test_regex_eval_api.c | |||
@@ -119,8 +119,8 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
119 | /* We only want to match the whole string, because that's what our DFA does, | 119 | /* We only want to match the whole string, because that's what our DFA does, |
120 | * too. */ | 120 | * too. */ |
121 | if ((eval_check == 0) && | 121 | if ((eval_check == 0) && |
122 | ((matchptr[0].rm_so != 0) ||(matchptr[0].rm_eo != strlen ( | 122 | ((matchptr[0].rm_so != 0) || (matchptr[0].rm_eo != strlen ( |
123 | matching_str)) )) | 123 | matching_str)) )) |
124 | eval_check = 1; | 124 | eval_check = 1; |
125 | 125 | ||
126 | /* Match canonical regex */ | 126 | /* Match canonical regex */ |
@@ -150,12 +150,12 @@ test_random (unsigned int rx_length, unsigned int max_str_len, | |||
150 | /* We only want to match the whole string, because that's what our DFA does, | 150 | /* We only want to match the whole string, because that's what our DFA does, |
151 | * too. */ | 151 | * too. */ |
152 | if ((eval_canonical_check == 0) && | 152 | if ((eval_canonical_check == 0) && |
153 | ((matchptr[0].rm_so != 0) ||(matchptr[0].rm_eo != strlen ( | 153 | ((matchptr[0].rm_so != 0) || (matchptr[0].rm_eo != strlen ( |
154 | matching_str)) )) | 154 | matching_str)) )) |
155 | eval_canonical_check = 1; | 155 | eval_canonical_check = 1; |
156 | 156 | ||
157 | /* compare results */ | 157 | /* compare results */ |
158 | if ((eval_check != eval) ||(eval_canonical != eval_canonical_check) ) | 158 | if ((eval_check != eval) || (eval_canonical != eval_canonical_check) ) |
159 | { | 159 | { |
160 | regerror (eval_check, &rx, error, sizeof error); | 160 | regerror (eval_check, &rx, error, sizeof error); |
161 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 161 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -184,6 +184,7 @@ error: | |||
184 | return -1; | 184 | return -1; |
185 | } | 185 | } |
186 | 186 | ||
187 | |||
187 | /** | 188 | /** |
188 | * Automaton test that compares the result of matching regular expression 'rx' | 189 | * Automaton test that compares the result of matching regular expression 'rx' |
189 | * with the strings and expected results in 'rxstr' with the result of matching | 190 | * with the strings and expected results in 'rxstr' with the result of matching |
@@ -227,10 +228,10 @@ test_automaton (struct REGEX_INTERNAL_Automaton *a, regex_t *rx, | |||
227 | (matchptr[0].rm_eo != strlen (rxstr->strings[i])) )) | 228 | (matchptr[0].rm_eo != strlen (rxstr->strings[i])) )) |
228 | eval_check = 1; | 229 | eval_check = 1; |
229 | 230 | ||
230 | if (((rxstr->expected_results[i] == match) && ((0 != eval) ||(0 != | 231 | if (((rxstr->expected_results[i] == match) && ((0 != eval) || (0 != |
231 | eval_check) )) | 232 | eval_check) )) |
232 | || ((rxstr->expected_results[i] == nomatch) && | 233 | || ((rxstr->expected_results[i] == nomatch) && |
233 | ((0 == eval) ||(0 == eval_check) ))) | 234 | ((0 == eval) || (0 == eval_check) ))) |
234 | { | 235 | { |
235 | result = 1; | 236 | result = 1; |
236 | regerror (eval_check, rx, error, sizeof error); | 237 | regerror (eval_check, rx, error, sizeof error); |
@@ -247,6 +248,7 @@ test_automaton (struct REGEX_INTERNAL_Automaton *a, regex_t *rx, | |||
247 | return result; | 248 | return result; |
248 | } | 249 | } |
249 | 250 | ||
251 | |||
250 | int | 252 | int |
251 | main (int argc, char *argv[]) | 253 | main (int argc, char *argv[]) |
252 | { | 254 | { |
diff --git a/src/regex/test_regex_integration.c b/src/regex/test_regex_integration.c index c7a7e38b5..2e6874e4d 100644 --- a/src/regex/test_regex_integration.c +++ b/src/regex/test_regex_integration.c | |||
@@ -208,4 +208,5 @@ main (int argc, char *argv[]) | |||
208 | return ok; | 208 | return ok; |
209 | } | 209 | } |
210 | 210 | ||
211 | |||
211 | /* end of test_regex_integration.c */ | 212 | /* end of test_regex_integration.c */ |