diff options
Diffstat (limited to 'src/regex/regex_internal.c')
-rw-r--r-- | src/regex/regex_internal.c | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index 6789b2f72..4e0d5acc5 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c | |||
@@ -552,7 +552,7 @@ struct StringBuffer | |||
552 | * Allocated buffer. | 552 | * Allocated buffer. |
553 | */ | 553 | */ |
554 | char *abuf; | 554 | char *abuf; |
555 | 555 | ||
556 | /** | 556 | /** |
557 | * Length of the string in the buffer. | 557 | * Length of the string in the buffer. |
558 | */ | 558 | */ |
@@ -575,10 +575,10 @@ struct StringBuffer | |||
575 | * change). This is used in an optimization that improves | 575 | * change). This is used in an optimization that improves |
576 | * performance by about 1% --- if we use int16_t here. With just | 576 | * performance by about 1% --- if we use int16_t here. With just |
577 | * "int" for both flags, performance drops (on my system) significantly, | 577 | * "int" for both flags, performance drops (on my system) significantly, |
578 | * most likely due to increased cache misses. | 578 | * most likely due to increased cache misses. |
579 | */ | 579 | */ |
580 | int16_t synced; | 580 | int16_t synced; |
581 | 581 | ||
582 | }; | 582 | }; |
583 | 583 | ||
584 | 584 | ||
@@ -604,10 +604,10 @@ sb_nullstrcmp (const struct StringBuffer *s1, | |||
604 | return -1; | 604 | return -1; |
605 | return memcmp (s1->sbuf, s2->sbuf, s1->slen); | 605 | return memcmp (s1->sbuf, s2->sbuf, s1->slen); |
606 | } | 606 | } |
607 | 607 | ||
608 | 608 | ||
609 | /** | 609 | /** |
610 | * Compare two strings for equality. | 610 | * Compare two strings for equality. |
611 | * | 611 | * |
612 | * @param s1 first string for comparison. | 612 | * @param s1 first string for comparison. |
613 | * @param s2 second string for comparison. | 613 | * @param s2 second string for comparison. |
@@ -622,7 +622,7 @@ sb_strcmp (const struct StringBuffer *s1, | |||
622 | return -1; | 622 | return -1; |
623 | return memcmp (s1->sbuf, s2->sbuf, s1->slen); | 623 | return memcmp (s1->sbuf, s2->sbuf, s1->slen); |
624 | } | 624 | } |
625 | 625 | ||
626 | 626 | ||
627 | /** | 627 | /** |
628 | * Reallocate the buffer of 'ret' to fit 'nlen' characters; | 628 | * Reallocate the buffer of 'ret' to fit 'nlen' characters; |
@@ -647,7 +647,7 @@ sb_realloc (struct StringBuffer *ret, | |||
647 | ret->sbuf = ret->abuf; | 647 | ret->sbuf = ret->abuf; |
648 | GNUNET_free_non_null (old); | 648 | GNUNET_free_non_null (old); |
649 | } | 649 | } |
650 | 650 | ||
651 | 651 | ||
652 | /** | 652 | /** |
653 | * Append a string. | 653 | * Append a string. |
@@ -669,7 +669,7 @@ sb_append (struct StringBuffer *ret, | |||
669 | sarg->slen); | 669 | sarg->slen); |
670 | ret->slen += sarg->slen; | 670 | ret->slen += sarg->slen; |
671 | } | 671 | } |
672 | 672 | ||
673 | 673 | ||
674 | /** | 674 | /** |
675 | * Append a C string. | 675 | * Append a C string. |
@@ -693,7 +693,7 @@ sb_append_cstr (struct StringBuffer *ret, | |||
693 | cstr_len); | 693 | cstr_len); |
694 | ret->slen += cstr_len; | 694 | ret->slen += cstr_len; |
695 | } | 695 | } |
696 | 696 | ||
697 | 697 | ||
698 | /** | 698 | /** |
699 | * Wrap a string buffer, that is, set ret to the format string | 699 | * Wrap a string buffer, that is, set ret to the format string |
@@ -854,7 +854,7 @@ sb_free (struct StringBuffer *sb) | |||
854 | static void | 854 | static void |
855 | sb_strdup (struct StringBuffer *out, | 855 | sb_strdup (struct StringBuffer *out, |
856 | const struct StringBuffer *in) | 856 | const struct StringBuffer *in) |
857 | 857 | ||
858 | { | 858 | { |
859 | out->null_flag = in->null_flag; | 859 | out->null_flag = in->null_flag; |
860 | if (GNUNET_YES == out->null_flag) | 860 | if (GNUNET_YES == out->null_flag) |
@@ -935,7 +935,7 @@ needs_parentheses (const struct StringBuffer *str) | |||
935 | } | 935 | } |
936 | /* while '(' before ')', count opening parens */ | 936 | /* while '(' before ')', count opening parens */ |
937 | while ( (NULL != (op = memchr (pos, '(', end - pos))) && | 937 | while ( (NULL != (op = memchr (pos, '(', end - pos))) && |
938 | (op < cl) ) | 938 | (op < cl) ) |
939 | { | 939 | { |
940 | cnt++; | 940 | cnt++; |
941 | pos = op + 1; | 941 | pos = op + 1; |
@@ -971,7 +971,7 @@ remove_parentheses (struct StringBuffer *str) | |||
971 | if (0) | 971 | if (0) |
972 | return; | 972 | return; |
973 | sbuf = str->sbuf; | 973 | sbuf = str->sbuf; |
974 | if ( (GNUNET_YES == str->null_flag) || | 974 | if ( (GNUNET_YES == str->null_flag) || |
975 | (1 >= (slen = str->slen)) || | 975 | (1 >= (slen = str->slen)) || |
976 | ('(' != str->sbuf[0]) || | 976 | ('(' != str->sbuf[0]) || |
977 | (')' != str->sbuf[slen - 1]) ) | 977 | (')' != str->sbuf[slen - 1]) ) |
@@ -981,7 +981,7 @@ remove_parentheses (struct StringBuffer *str) | |||
981 | end = &sbuf[slen - 1]; | 981 | end = &sbuf[slen - 1]; |
982 | op = memchr (pos, '(', end - pos); | 982 | op = memchr (pos, '(', end - pos); |
983 | cp = memchr (pos, ')', end - pos); | 983 | cp = memchr (pos, ')', end - pos); |
984 | while (NULL != cp) | 984 | while (NULL != cp) |
985 | { | 985 | { |
986 | while ( (NULL != op) && | 986 | while ( (NULL != op) && |
987 | (op < cp) ) | 987 | (op < cp) ) |
@@ -1007,7 +1007,7 @@ remove_parentheses (struct StringBuffer *str) | |||
1007 | return; | 1007 | return; |
1008 | } | 1008 | } |
1009 | str->sbuf++; | 1009 | str->sbuf++; |
1010 | str->slen -= 2; | 1010 | str->slen -= 2; |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | 1013 | ||
@@ -1022,10 +1022,10 @@ remove_parentheses (struct StringBuffer *str) | |||
1022 | static int | 1022 | static int |
1023 | has_epsilon (const struct StringBuffer *str) | 1023 | has_epsilon (const struct StringBuffer *str) |
1024 | { | 1024 | { |
1025 | return | 1025 | return |
1026 | (GNUNET_YES != str->null_flag) && | 1026 | (GNUNET_YES != str->null_flag) && |
1027 | (0 < str->slen) && | 1027 | (0 < str->slen) && |
1028 | ('(' == str->sbuf[0]) && | 1028 | ('(' == str->sbuf[0]) && |
1029 | ('|' == str->sbuf[1]) && | 1029 | ('|' == str->sbuf[1]) && |
1030 | (')' == str->sbuf[str->slen - 1]); | 1030 | (')' == str->sbuf[str->slen - 1]); |
1031 | } | 1031 | } |
@@ -1048,8 +1048,8 @@ remove_epsilon (const struct StringBuffer *str, | |||
1048 | { | 1048 | { |
1049 | ret->null_flag = GNUNET_YES; | 1049 | ret->null_flag = GNUNET_YES; |
1050 | return; | 1050 | return; |
1051 | } | 1051 | } |
1052 | if ( (str->slen > 1) && | 1052 | if ( (str->slen > 1) && |
1053 | ('(' == str->sbuf[0]) && | 1053 | ('(' == str->sbuf[0]) && |
1054 | ('|' == str->sbuf[1]) && | 1054 | ('|' == str->sbuf[1]) && |
1055 | (')' == str->sbuf[str->slen - 1]) ) | 1055 | (')' == str->sbuf[str->slen - 1]) ) |
@@ -1080,11 +1080,11 @@ remove_epsilon (const struct StringBuffer *str, | |||
1080 | * @return -1 if any of the strings is NULL, 0 if equal, non 0 otherwise | 1080 | * @return -1 if any of the strings is NULL, 0 if equal, non 0 otherwise |
1081 | */ | 1081 | */ |
1082 | static int | 1082 | static int |
1083 | sb_strncmp (const struct StringBuffer *str1, | 1083 | sb_strncmp (const struct StringBuffer *str1, |
1084 | const struct StringBuffer *str2, size_t n) | 1084 | const struct StringBuffer *str2, size_t n) |
1085 | { | 1085 | { |
1086 | size_t max; | 1086 | size_t max; |
1087 | 1087 | ||
1088 | if ( (str1->slen != str2->slen) && | 1088 | if ( (str1->slen != str2->slen) && |
1089 | ( (str1->slen < n) || | 1089 | ( (str1->slen < n) || |
1090 | (str2->slen < n) ) ) | 1090 | (str2->slen < n) ) ) |
@@ -1106,17 +1106,17 @@ sb_strncmp (const struct StringBuffer *str1, | |||
1106 | * @return -1 if any of the strings is NULL, 0 if equal, non 0 otherwise | 1106 | * @return -1 if any of the strings is NULL, 0 if equal, non 0 otherwise |
1107 | */ | 1107 | */ |
1108 | static int | 1108 | static int |
1109 | sb_strncmp_cstr (const struct StringBuffer *str1, | 1109 | sb_strncmp_cstr (const struct StringBuffer *str1, |
1110 | const char *str2, size_t n) | 1110 | const char *str2, size_t n) |
1111 | { | 1111 | { |
1112 | if (str1->slen < n) | 1112 | if (str1->slen < n) |
1113 | return -1; | 1113 | return -1; |
1114 | return memcmp (str1->sbuf, str2, n); | 1114 | return memcmp (str1->sbuf, str2, n); |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | 1117 | ||
1118 | /** | 1118 | /** |
1119 | * Initialize string buffer for storing strings of up to n | 1119 | * Initialize string buffer for storing strings of up to n |
1120 | * characters. | 1120 | * characters. |
1121 | * | 1121 | * |
1122 | * @param sb buffer to initialize | 1122 | * @param sb buffer to initialize |
@@ -1143,7 +1143,7 @@ sb_init (struct StringBuffer *sb, | |||
1143 | * @return -1 if any of the strings is NULL, 0 if equal, non 0 otherwise | 1143 | * @return -1 if any of the strings is NULL, 0 if equal, non 0 otherwise |
1144 | */ | 1144 | */ |
1145 | static int | 1145 | static int |
1146 | sb_strkcmp (const struct StringBuffer *str1, | 1146 | sb_strkcmp (const struct StringBuffer *str1, |
1147 | const struct StringBuffer *str2, size_t k) | 1147 | const struct StringBuffer *str2, size_t k) |
1148 | { | 1148 | { |
1149 | if ( (GNUNET_YES == str1->null_flag) || | 1149 | if ( (GNUNET_YES == str1->null_flag) || |
@@ -1196,7 +1196,7 @@ number_states (void *cls, const unsigned int count, | |||
1196 | * @param R_cur_r optimization -- kept between iterations to avoid realloc | 1196 | * @param R_cur_r optimization -- kept between iterations to avoid realloc |
1197 | */ | 1197 | */ |
1198 | static void | 1198 | static void |
1199 | automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | 1199 | automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, |
1200 | const struct StringBuffer *R_last_ik, | 1200 | const struct StringBuffer *R_last_ik, |
1201 | const struct StringBuffer *R_last_kk, | 1201 | const struct StringBuffer *R_last_kk, |
1202 | const struct StringBuffer *R_last_kj, | 1202 | const struct StringBuffer *R_last_kj, |
@@ -1227,8 +1227,8 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1227 | * R_cur_r == R^{(k-1)}_{ik} ( R^{(k-1)}_{kk} )^* R^{(k-1)}_{kj} | 1227 | * R_cur_r == R^{(k-1)}_{ik} ( R^{(k-1)}_{kk} )^* R^{(k-1)}_{kj} |
1228 | */ | 1228 | */ |
1229 | 1229 | ||
1230 | if ( (GNUNET_YES == R_last_ij->null_flag) && | 1230 | if ( (GNUNET_YES == R_last_ij->null_flag) && |
1231 | ( (GNUNET_YES == R_last_ik->null_flag) || | 1231 | ( (GNUNET_YES == R_last_ik->null_flag) || |
1232 | (GNUNET_YES == R_last_kj->null_flag))) | 1232 | (GNUNET_YES == R_last_kj->null_flag))) |
1233 | { | 1233 | { |
1234 | /* R^{(k)}_{ij} = N | N */ | 1234 | /* R^{(k)}_{ij} = N | N */ |
@@ -1237,13 +1237,13 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1237 | return; | 1237 | return; |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | if ( (GNUNET_YES == R_last_ik->null_flag) || | 1240 | if ( (GNUNET_YES == R_last_ik->null_flag) || |
1241 | (GNUNET_YES == R_last_kj->null_flag) ) | 1241 | (GNUNET_YES == R_last_kj->null_flag) ) |
1242 | { | 1242 | { |
1243 | /* R^{(k)}_{ij} = R^{(k-1)}_{ij} | N */ | 1243 | /* R^{(k)}_{ij} = R^{(k-1)}_{ij} | N */ |
1244 | if (GNUNET_YES == R_last_ij->synced) | 1244 | if (GNUNET_YES == R_last_ij->synced) |
1245 | { | 1245 | { |
1246 | R_cur_ij->synced = GNUNET_YES; | 1246 | R_cur_ij->synced = GNUNET_YES; |
1247 | R_cur_ij->null_flag = GNUNET_NO; | 1247 | R_cur_ij->null_flag = GNUNET_NO; |
1248 | return; | 1248 | return; |
1249 | } | 1249 | } |
@@ -1256,10 +1256,10 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1256 | /* $R^{(k)}_{ij} = N | R^{(k-1)}_{ik} ( R^{(k-1)}_{kk} )^* R^{(k-1)}_{kj} OR | 1256 | /* $R^{(k)}_{ij} = N | R^{(k-1)}_{ik} ( R^{(k-1)}_{kk} )^* R^{(k-1)}_{kj} OR |
1257 | * $R^{(k)}_{ij} = R^{(k-1)}_{ij} | R^{(k-1)}_{ik} ( R^{(k-1)}_{kk} )^* R^{(k-1)}_{kj} */ | 1257 | * $R^{(k)}_{ij} = R^{(k-1)}_{ij} | R^{(k-1)}_{ik} ( R^{(k-1)}_{kk} )^* R^{(k-1)}_{kj} */ |
1258 | 1258 | ||
1259 | R_cur_r->null_flag = GNUNET_YES; | 1259 | R_cur_r->null_flag = GNUNET_YES; |
1260 | R_cur_r->slen = 0; | 1260 | R_cur_r->slen = 0; |
1261 | R_cur_l->null_flag = GNUNET_YES; | 1261 | R_cur_l->null_flag = GNUNET_YES; |
1262 | R_cur_l->slen = 0; | 1262 | R_cur_l->slen = 0; |
1263 | 1263 | ||
1264 | /* cache results from strcmp, we might need these many times */ | 1264 | /* cache results from strcmp, we might need these many times */ |
1265 | ij_kj_cmp = sb_nullstrcmp (R_last_ij, R_last_kj); | 1265 | ij_kj_cmp = sb_nullstrcmp (R_last_ij, R_last_kj); |
@@ -1291,8 +1291,8 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1291 | remove_epsilon (R_last_ij, &R_temp_ij); | 1291 | remove_epsilon (R_last_ij, &R_temp_ij); |
1292 | remove_parentheses (&R_temp_ij); | 1292 | remove_parentheses (&R_temp_ij); |
1293 | 1293 | ||
1294 | if ( (0 == sb_strcmp (&R_temp_ij, &R_temp_ik)) && | 1294 | if ( (0 == sb_strcmp (&R_temp_ij, &R_temp_ik)) && |
1295 | (0 == sb_strcmp (&R_temp_ik, &R_temp_kk)) && | 1295 | (0 == sb_strcmp (&R_temp_ik, &R_temp_kk)) && |
1296 | (0 == sb_strcmp (&R_temp_kk, &R_temp_kj)) ) | 1296 | (0 == sb_strcmp (&R_temp_kk, &R_temp_kj)) ) |
1297 | { | 1297 | { |
1298 | if (0 == R_temp_ij.slen) | 1298 | if (0 == R_temp_ij.slen) |
@@ -1395,16 +1395,16 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1395 | length = R_temp_kk.slen - R_last_ik->slen; | 1395 | length = R_temp_kk.slen - R_last_ik->slen; |
1396 | 1396 | ||
1397 | /* a(ba)*bx = (ab)+x */ | 1397 | /* a(ba)*bx = (ab)+x */ |
1398 | if ( (length > 0) && | 1398 | if ( (length > 0) && |
1399 | (GNUNET_YES != R_last_kk->null_flag) && | 1399 | (GNUNET_YES != R_last_kk->null_flag) && |
1400 | (0 < R_last_kk->slen) && | 1400 | (0 < R_last_kk->slen) && |
1401 | (GNUNET_YES != R_last_kj->null_flag) && | 1401 | (GNUNET_YES != R_last_kj->null_flag) && |
1402 | (0 < R_last_kj->slen) && | 1402 | (0 < R_last_kj->slen) && |
1403 | (GNUNET_YES != R_last_ik->null_flag) && | 1403 | (GNUNET_YES != R_last_ik->null_flag) && |
1404 | (0 < R_last_ik->slen) && | 1404 | (0 < R_last_ik->slen) && |
1405 | (0 == sb_strkcmp (&R_temp_kk, R_last_ik, length)) && | 1405 | (0 == sb_strkcmp (&R_temp_kk, R_last_ik, length)) && |
1406 | (0 == sb_strncmp (&R_temp_kk, R_last_kj, length)) ) | 1406 | (0 == sb_strncmp (&R_temp_kk, R_last_kj, length)) ) |
1407 | { | 1407 | { |
1408 | struct StringBuffer temp_a; | 1408 | struct StringBuffer temp_a; |
1409 | struct StringBuffer temp_b; | 1409 | struct StringBuffer temp_b; |
1410 | 1410 | ||
@@ -1452,7 +1452,7 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1452 | sb_printf1 (R_cur_r, "%.*s*", 1, &R_temp_kk); | 1452 | sb_printf1 (R_cur_r, "%.*s*", 1, &R_temp_kk); |
1453 | } | 1453 | } |
1454 | /* aa*a = a+a */ | 1454 | /* aa*a = a+a */ |
1455 | else if ( (0 == clean_ik_kk_cmp) && | 1455 | else if ( (0 == clean_ik_kk_cmp) && |
1456 | (0 == clean_kk_kj_cmp) && | 1456 | (0 == clean_kk_kj_cmp) && |
1457 | (! has_epsilon (R_last_ik)) ) | 1457 | (! has_epsilon (R_last_ik)) ) |
1458 | { | 1458 | { |
@@ -1550,7 +1550,7 @@ automaton_create_proofs_simplify (const struct StringBuffer *R_last_ij, | |||
1550 | sb_free (&R_temp_kk); | 1550 | sb_free (&R_temp_kk); |
1551 | sb_free (&R_temp_kj); | 1551 | sb_free (&R_temp_kj); |
1552 | 1552 | ||
1553 | if ( (GNUNET_YES == R_cur_l->null_flag) && | 1553 | if ( (GNUNET_YES == R_cur_l->null_flag) && |
1554 | (GNUNET_YES == R_cur_r->null_flag) ) | 1554 | (GNUNET_YES == R_cur_r->null_flag) ) |
1555 | { | 1555 | { |
1556 | R_cur_ij->null_flag = GNUNET_YES; | 1556 | R_cur_ij->null_flag = GNUNET_YES; |
@@ -1670,7 +1670,7 @@ automaton_create_proofs (struct REGEX_INTERNAL_Automaton *a) | |||
1670 | for (i = 0; i < n; i++) | 1670 | for (i = 0; i < n; i++) |
1671 | for (j = 0; j < n; j++) | 1671 | for (j = 0; j < n; j++) |
1672 | if (needs_parentheses (&R_last[i * n + j])) | 1672 | if (needs_parentheses (&R_last[i * n + j])) |
1673 | sb_wrap (&R_last[i * n + j], "(%.*s)", 2); | 1673 | sb_wrap (&R_last[i * n + j], "(%.*s)", 2); |
1674 | /* Compute regular expressions of length "k" between each pair of states per | 1674 | /* Compute regular expressions of length "k" between each pair of states per |
1675 | * induction */ | 1675 | * induction */ |
1676 | memset (&R_cur_l, 0, sizeof (struct StringBuffer)); | 1676 | memset (&R_cur_l, 0, sizeof (struct StringBuffer)); |
@@ -1726,14 +1726,14 @@ automaton_create_proofs (struct REGEX_INTERNAL_Automaton *a) | |||
1726 | if ( (0 == complete_regex.slen) && | 1726 | if ( (0 == complete_regex.slen) && |
1727 | (0 < R_last[a->start->dfs_id * n + i].slen) ) | 1727 | (0 < R_last[a->start->dfs_id * n + i].slen) ) |
1728 | { | 1728 | { |
1729 | sb_append (&complete_regex, | 1729 | sb_append (&complete_regex, |
1730 | &R_last[a->start->dfs_id * n + i]); | 1730 | &R_last[a->start->dfs_id * n + i]); |
1731 | } | 1731 | } |
1732 | else if ( (GNUNET_YES != R_last[a->start->dfs_id * n + i].null_flag) && | 1732 | else if ( (GNUNET_YES != R_last[a->start->dfs_id * n + i].null_flag) && |
1733 | (0 < R_last[a->start->dfs_id * n + i].slen) ) | 1733 | (0 < R_last[a->start->dfs_id * n + i].slen) ) |
1734 | { | 1734 | { |
1735 | sb_append_cstr (&complete_regex, "|"); | 1735 | sb_append_cstr (&complete_regex, "|"); |
1736 | sb_append (&complete_regex, | 1736 | sb_append (&complete_regex, |
1737 | &R_last[a->start->dfs_id * n + i]); | 1737 | &R_last[a->start->dfs_id * n + i]); |
1738 | } | 1738 | } |
1739 | } | 1739 | } |
@@ -1742,11 +1742,11 @@ automaton_create_proofs (struct REGEX_INTERNAL_Automaton *a) | |||
1742 | 1742 | ||
1743 | /* cleanup */ | 1743 | /* cleanup */ |
1744 | sb_free (&complete_regex); | 1744 | sb_free (&complete_regex); |
1745 | for (i = 0; i < n; i++) | 1745 | for (i = 0; i < n; i++) |
1746 | for (j = 0; j < n; j++) | 1746 | for (j = 0; j < n; j++) |
1747 | { | 1747 | { |
1748 | sb_free (&R_cur[i * n + j]); | 1748 | sb_free (&R_cur[i * n + j]); |
1749 | sb_free (&R_last[i * n + j]); | 1749 | sb_free (&R_last[i * n + j]); |
1750 | } | 1750 | } |
1751 | GNUNET_free (R_cur); | 1751 | GNUNET_free (R_cur); |
1752 | GNUNET_free (R_last); | 1752 | GNUNET_free (R_last); |
@@ -1804,15 +1804,15 @@ dfa_state_create (struct REGEX_INTERNAL_Context *ctx, | |||
1804 | pos += strlen (pos); | 1804 | pos += strlen (pos); |
1805 | 1805 | ||
1806 | /* Add a transition for each distinct label to NULL state */ | 1806 | /* Add a transition for each distinct label to NULL state */ |
1807 | for (ctran = cstate->transitions_head; NULL != ctran; ctran = ctran->next) | 1807 | for (ctran = cstate->transitions_head; NULL != ctran; ctran = ctran->next) |
1808 | if (NULL != ctran->label) | 1808 | if (NULL != ctran->label) |
1809 | state_add_transition (ctx, s, ctran->label, NULL); | 1809 | state_add_transition (ctx, s, ctran->label, NULL); |
1810 | 1810 | ||
1811 | /* If the nfa_states contain an accepting state, the new dfa state is also | 1811 | /* If the nfa_states contain an accepting state, the new dfa state is also |
1812 | * accepting. */ | 1812 | * accepting. */ |
1813 | if (cstate->accepting) | 1813 | if (cstate->accepting) |
1814 | s->accepting = 1; | 1814 | s->accepting = 1; |
1815 | } | 1815 | } |
1816 | pos[-1] = '}'; | 1816 | pos[-1] = '}'; |
1817 | s->name = GNUNET_realloc (s->name, strlen (s->name) + 1); | 1817 | s->name = GNUNET_realloc (s->name, strlen (s->name) + 1); |
1818 | 1818 | ||
@@ -2495,7 +2495,7 @@ nfa_closure_set_create (struct REGEX_INTERNAL_StateSet *ret, | |||
2495 | /* Add start state to closure only for epsilon closure */ | 2495 | /* Add start state to closure only for epsilon closure */ |
2496 | if (NULL == label) | 2496 | if (NULL == label) |
2497 | state_set_append (ret, s); | 2497 | state_set_append (ret, s); |
2498 | 2498 | ||
2499 | /* initialize work stack */ | 2499 | /* initialize work stack */ |
2500 | cls_stack.head = NULL; | 2500 | cls_stack.head = NULL; |
2501 | cls_stack.tail = NULL; | 2501 | cls_stack.tail = NULL; |
@@ -2506,7 +2506,7 @@ nfa_closure_set_create (struct REGEX_INTERNAL_StateSet *ret, | |||
2506 | { | 2506 | { |
2507 | GNUNET_CONTAINER_MDLL_remove (ST, cls_stack.head, cls_stack.tail, | 2507 | GNUNET_CONTAINER_MDLL_remove (ST, cls_stack.head, cls_stack.tail, |
2508 | currentstate); | 2508 | currentstate); |
2509 | cls_stack.len--; | 2509 | cls_stack.len--; |
2510 | for (ctran = currentstate->transitions_head; NULL != ctran; | 2510 | for (ctran = currentstate->transitions_head; NULL != ctran; |
2511 | ctran = ctran->next) | 2511 | ctran = ctran->next) |
2512 | { | 2512 | { |
@@ -2521,7 +2521,7 @@ nfa_closure_set_create (struct REGEX_INTERNAL_StateSet *ret, | |||
2521 | clsstate); | 2521 | clsstate); |
2522 | cls_stack.len++; | 2522 | cls_stack.len++; |
2523 | clsstate->contained = 1; | 2523 | clsstate->contained = 1; |
2524 | } | 2524 | } |
2525 | } | 2525 | } |
2526 | } | 2526 | } |
2527 | for (i = 0; i < ret->off; i++) | 2527 | for (i = 0; i < ret->off; i++) |
@@ -3429,9 +3429,9 @@ REGEX_INTERNAL_iterate_all_edges (struct REGEX_INTERNAL_Automaton *a, | |||
3429 | unsigned int num_edges; | 3429 | unsigned int num_edges; |
3430 | 3430 | ||
3431 | num_edges = state_get_edges (s, edges); | 3431 | num_edges = state_get_edges (s, edges); |
3432 | if ( ( (NULL != s->proof) && | 3432 | if ( ( (NULL != s->proof) && |
3433 | (0 < strlen (s->proof)) ) || s->accepting) | 3433 | (0 < strlen (s->proof)) ) || s->accepting) |
3434 | iterator (iterator_cls, &s->hash, s->proof, | 3434 | iterator (iterator_cls, &s->hash, s->proof, |
3435 | s->accepting, | 3435 | s->accepting, |
3436 | num_edges, edges); | 3436 | num_edges, edges); |
3437 | s->marked = GNUNET_NO; | 3437 | s->marked = GNUNET_NO; |
@@ -3439,7 +3439,7 @@ REGEX_INTERNAL_iterate_all_edges (struct REGEX_INTERNAL_Automaton *a, | |||
3439 | 3439 | ||
3440 | iterate_initial_edge (GNUNET_REGEX_INITIAL_BYTES, | 3440 | iterate_initial_edge (GNUNET_REGEX_INITIAL_BYTES, |
3441 | GNUNET_REGEX_INITIAL_BYTES, | 3441 | GNUNET_REGEX_INITIAL_BYTES, |
3442 | NULL, a->start, | 3442 | NULL, a->start, |
3443 | iterator, iterator_cls); | 3443 | iterator, iterator_cls); |
3444 | } | 3444 | } |
3445 | 3445 | ||