diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-04-03 13:46:35 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-04-03 13:46:35 +0000 |
commit | d7c871cc85896f2603e69fae17161b326193cc0d (patch) | |
tree | 0e3b1b89cb143f51dee42cbcad84c4f16b704885 /src/regex/regex.c | |
parent | 68abbca95b880082f37a21f244e87503f6dacc06 (diff) | |
download | gnunet-d7c871cc85896f2603e69fae17161b326193cc0d.tar.gz gnunet-d7c871cc85896f2603e69fae17161b326193cc0d.zip |
fix
Diffstat (limited to 'src/regex/regex.c')
-rw-r--r-- | src/regex/regex.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/regex/regex.c b/src/regex/regex.c index a524ace29..6432075a5 100644 --- a/src/regex/regex.c +++ b/src/regex/regex.c | |||
@@ -721,7 +721,10 @@ nfa_closure_set_create (struct StateSet *states, const char literal) | |||
721 | for (k = 0; k < cls->len; k++) | 721 | for (k = 0; k < cls->len; k++) |
722 | { | 722 | { |
723 | if (sset->states[j]->id == cls->states[k]->id) | 723 | if (sset->states[j]->id == cls->states[k]->id) |
724 | { | ||
724 | contains = 1; | 725 | contains = 1; |
726 | break; | ||
727 | } | ||
725 | } | 728 | } |
726 | if (!contains) | 729 | if (!contains) |
727 | GNUNET_array_append (cls->states, cls->len, sset->states[j]); | 730 | GNUNET_array_append (cls->states, cls->len, sset->states[j]); |
@@ -1249,7 +1252,7 @@ GNUNET_REGEX_automaton_save_graph (struct GNUNET_REGEX_Automaton *a, | |||
1249 | * @param a automaton, type must be DFA | 1252 | * @param a automaton, type must be DFA |
1250 | * @param string string that should be evaluated | 1253 | * @param string string that should be evaluated |
1251 | * | 1254 | * |
1252 | * @return GNUNET_YES if string matches, GNUNET_NO if not, GNUNET_SYSERR otherwise | 1255 | * @return 0 if string matches, non 0 otherwise |
1253 | */ | 1256 | */ |
1254 | static int | 1257 | static int |
1255 | evaluate_dfa (struct GNUNET_REGEX_Automaton *a, const char *string) | 1258 | evaluate_dfa (struct GNUNET_REGEX_Automaton *a, const char *string) |
@@ -1261,7 +1264,7 @@ evaluate_dfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
1261 | { | 1264 | { |
1262 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1265 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1263 | "Tried to evaluate DFA, but NFA automaton given"); | 1266 | "Tried to evaluate DFA, but NFA automaton given"); |
1264 | return GNUNET_SYSERR; | 1267 | return -1; |
1265 | } | 1268 | } |
1266 | 1269 | ||
1267 | s = a->start; | 1270 | s = a->start; |
@@ -1274,9 +1277,9 @@ evaluate_dfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
1274 | } | 1277 | } |
1275 | 1278 | ||
1276 | if (NULL != s && s->accepting) | 1279 | if (NULL != s && s->accepting) |
1277 | return GNUNET_YES; | 1280 | return 0; |
1278 | 1281 | ||
1279 | return GNUNET_NO; | 1282 | return 1; |
1280 | } | 1283 | } |
1281 | 1284 | ||
1282 | /** | 1285 | /** |
@@ -1285,7 +1288,7 @@ evaluate_dfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
1285 | * @param a automaton, type must be NFA | 1288 | * @param a automaton, type must be NFA |
1286 | * @param string string that should be evaluated | 1289 | * @param string string that should be evaluated |
1287 | * | 1290 | * |
1288 | * @return GNUNET_YES if string matches, GNUNET_NO if not, GNUNET_SYSERR otherwise | 1291 | * @return 0 if string matches, non 0 otherwise |
1289 | */ | 1292 | */ |
1290 | static int | 1293 | static int |
1291 | evaluate_nfa (struct GNUNET_REGEX_Automaton *a, const char *string) | 1294 | evaluate_nfa (struct GNUNET_REGEX_Automaton *a, const char *string) |
@@ -1301,13 +1304,12 @@ evaluate_nfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
1301 | { | 1304 | { |
1302 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1305 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1303 | "Tried to evaluate NFA, but DFA automaton given"); | 1306 | "Tried to evaluate NFA, but DFA automaton given"); |
1304 | return GNUNET_SYSERR; | 1307 | return -1; |
1305 | } | 1308 | } |
1306 | 1309 | ||
1307 | result = GNUNET_NO; | 1310 | result = 1; |
1308 | strp = string; | 1311 | strp = string; |
1309 | sset = GNUNET_malloc (sizeof (struct StateSet)); | 1312 | sset = nfa_closure_create (a->start, 0); |
1310 | GNUNET_array_append (sset->states, sset->len, a->start); | ||
1311 | 1313 | ||
1312 | for (strp = string; NULL != strp && *strp; strp++) | 1314 | for (strp = string; NULL != strp && *strp; strp++) |
1313 | { | 1315 | { |
@@ -1322,7 +1324,7 @@ evaluate_nfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
1322 | s = sset->states[i]; | 1324 | s = sset->states[i]; |
1323 | if (NULL != s && s->accepting) | 1325 | if (NULL != s && s->accepting) |
1324 | { | 1326 | { |
1325 | result = GNUNET_YES; | 1327 | result = 0; |
1326 | break; | 1328 | break; |
1327 | } | 1329 | } |
1328 | } | 1330 | } |
@@ -1338,7 +1340,7 @@ evaluate_nfa (struct GNUNET_REGEX_Automaton *a, const char *string) | |||
1338 | * @param a automaton | 1340 | * @param a automaton |
1339 | * @param string string to check | 1341 | * @param string string to check |
1340 | * | 1342 | * |
1341 | * @return GNUNET_YES if 'a' matches 'string', GNUNET_NO otherwise | 1343 | * @return 0 if string matches, non 0 otherwise |
1342 | */ | 1344 | */ |
1343 | int | 1345 | int |
1344 | GNUNET_REGEX_eval (struct GNUNET_REGEX_Automaton *a, const char *string) | 1346 | GNUNET_REGEX_eval (struct GNUNET_REGEX_Automaton *a, const char *string) |