diff options
author | Maximilian Szengel <gnunet@maxsz.de> | 2012-11-16 13:08:51 +0000 |
---|---|---|
committer | Maximilian Szengel <gnunet@maxsz.de> | 2012-11-16 13:08:51 +0000 |
commit | b6908a90bf1a1f8008bffa8bfb0416da3c7bc1d5 (patch) | |
tree | b0768f32b98c4e04588577508b4316a41ac4156b /src/regex/test_regex_graph_api.c | |
parent | 58857960c4d0329b1e19636b07672db320b24ec0 (diff) | |
download | gnunet-b6908a90bf1a1f8008bffa8bfb0416da3c7bc1d5.tar.gz gnunet-b6908a90bf1a1f8008bffa8bfb0416da3c7bc1d5.zip |
Cleaup, indentation, comments etc.
Diffstat (limited to 'src/regex/test_regex_graph_api.c')
-rw-r--r-- | src/regex/test_regex_graph_api.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/regex/test_regex_graph_api.c b/src/regex/test_regex_graph_api.c index c2c1c74e1..3ae607352 100644 --- a/src/regex/test_regex_graph_api.c +++ b/src/regex/test_regex_graph_api.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "gnunet_regex_lib.h" | 28 | #include "gnunet_regex_lib.h" |
29 | #include "regex_internal.h" | 29 | #include "regex_internal.h" |
30 | 30 | ||
31 | #define KEEP_FILES 0 | 31 | #define KEEP_FILES 1 |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Check if 'filename' exists and is not empty. | 34 | * Check if 'filename' exists and is not empty. |
@@ -43,7 +43,7 @@ filecheck (const char *filename) | |||
43 | int error = 0; | 43 | int error = 0; |
44 | FILE *fp; | 44 | FILE *fp; |
45 | 45 | ||
46 | // Check if file was created and delete it again | 46 | /* Check if file was created and delete it again */ |
47 | if (NULL == (fp = fopen (filename, "r"))) | 47 | if (NULL == (fp = fopen (filename, "r"))) |
48 | { | 48 | { |
49 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find graph %s\n", filename); | 49 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not find graph %s\n", filename); |
@@ -54,18 +54,16 @@ filecheck (const char *filename) | |||
54 | if (1 > ftell (fp)) | 54 | if (1 > ftell (fp)) |
55 | { | 55 | { |
56 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 56 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
57 | "Graph writing failed, got empty file (%s)!\n", | 57 | "Graph writing failed, got empty file (%s)!\n", filename); |
58 | filename); | ||
59 | error = 2; | 58 | error = 2; |
60 | } | 59 | } |
61 | 60 | ||
62 | GNUNET_assert (0 == fclose (fp)); | 61 | GNUNET_assert (0 == fclose (fp)); |
63 | 62 | ||
64 | if (!KEEP_FILES) | 63 | if (!KEEP_FILES) |
65 | { | 64 | { |
66 | if (0 != unlink (filename)) | 65 | if (0 != unlink (filename)) |
67 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 66 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink", filename); |
68 | "unlink", filename); | ||
69 | } | 67 | } |
70 | return error; | 68 | return error; |
71 | } | 69 | } |
@@ -78,6 +76,7 @@ main (int argc, char *argv[]) | |||
78 | struct GNUNET_REGEX_Automaton *a; | 76 | struct GNUNET_REGEX_Automaton *a; |
79 | unsigned int i; | 77 | unsigned int i; |
80 | const char *filename = "test_graph.dot"; | 78 | const char *filename = "test_graph.dot"; |
79 | |||
81 | const char *regex[12] = { | 80 | const char *regex[12] = { |
82 | "ab(c|d)+c*(a(b|c)+d)+(bla)+", | 81 | "ab(c|d)+c*(a(b|c)+d)+(bla)+", |
83 | "(bla)*", | 82 | "(bla)*", |
@@ -90,7 +89,6 @@ main (int argc, char *argv[]) | |||
90 | "a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*", | 89 | "a+X*y+c|p|R|Z*K*y*R+w|Y*6+n+h*k*w+V*F|W*B*e*", |
91 | "a", | 90 | "a", |
92 | "a|b", | 91 | "a|b", |
93 | // "abc(d+|e)fgh" | ||
94 | "PADPADPADPADPADPabcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd" | 92 | "PADPADPADPADPADPabcdefghixxxxxxxxxxxxxjklmnop*qstoisdjfguisdfguihsdfgbdsuivggsd" |
95 | }; | 93 | }; |
96 | 94 | ||
@@ -98,7 +96,7 @@ main (int argc, char *argv[]) | |||
98 | error = 0; | 96 | error = 0; |
99 | for (i = 0; i < 12; i++) | 97 | for (i = 0; i < 12; i++) |
100 | { | 98 | { |
101 | // Check NFA graph creation | 99 | /* Check NFA graph creation */ |
102 | a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); | 100 | a = GNUNET_REGEX_construct_nfa (regex[i], strlen (regex[i])); |
103 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); | 101 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); |
104 | GNUNET_REGEX_automaton_destroy (a); | 102 | GNUNET_REGEX_automaton_destroy (a); |
@@ -127,7 +125,7 @@ main (int argc, char *argv[]) | |||
127 | error += filecheck (filename); | 125 | error += filecheck (filename); |
128 | 126 | ||
129 | 127 | ||
130 | // Check DFA graph creation | 128 | /* Check DFA graph creation */ |
131 | a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); | 129 | a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); |
132 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); | 130 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); |
133 | GNUNET_REGEX_automaton_destroy (a); | 131 | GNUNET_REGEX_automaton_destroy (a); |
@@ -148,10 +146,8 @@ main (int argc, char *argv[]) | |||
148 | error += filecheck (filename); | 146 | error += filecheck (filename); |
149 | 147 | ||
150 | 148 | ||
151 | a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 0); | 149 | a = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]), 4); |
152 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); //| | 150 | GNUNET_REGEX_automaton_save_graph (a, filename, GNUNET_REGEX_GRAPH_DEFAULT); |
153 | // GNUNET_REGEX_GRAPH_VERBOSE | | ||
154 | //GNUNET_REGEX_GRAPH_COLORING); | ||
155 | GNUNET_REGEX_automaton_destroy (a); | 151 | GNUNET_REGEX_automaton_destroy (a); |
156 | error += filecheck (filename); | 152 | error += filecheck (filename); |
157 | 153 | ||