diff options
Diffstat (limited to 'src/regex/perf-regex.c')
-rw-r--r-- | src/regex/perf-regex.c | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/src/regex/perf-regex.c b/src/regex/perf-regex.c index ea331eed0..25960dc9f 100644 --- a/src/regex/perf-regex.c +++ b/src/regex/perf-regex.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/regex/perf-regex.c | 22 | * @file src/regex/perf-regex.c |
@@ -42,23 +42,23 @@ | |||
42 | * @param edges edges leaving current state. | 42 | * @param edges edges leaving current state. |
43 | */ | 43 | */ |
44 | static void | 44 | static void |
45 | print_edge (void *cls, | 45 | print_edge(void *cls, |
46 | const struct GNUNET_HashCode *key, | 46 | const struct GNUNET_HashCode *key, |
47 | const char *proof, | 47 | const char *proof, |
48 | int accepting, | 48 | int accepting, |
49 | unsigned int num_edges, | 49 | unsigned int num_edges, |
50 | const struct REGEX_BLOCK_Edge *edges) | 50 | const struct REGEX_BLOCK_Edge *edges) |
51 | { | 51 | { |
52 | unsigned int i; | 52 | unsigned int i; |
53 | 53 | ||
54 | printf ("%s: %s, proof: `%s'\n", | 54 | printf("%s: %s, proof: `%s'\n", |
55 | GNUNET_h2s (key), | 55 | GNUNET_h2s(key), |
56 | accepting ? "ACCEPTING" : "", | 56 | accepting ? "ACCEPTING" : "", |
57 | proof); | 57 | proof); |
58 | for (i = 0; i < num_edges; i++) | 58 | for (i = 0; i < num_edges; i++) |
59 | printf (" `%s': %s\n", | 59 | printf(" `%s': %s\n", |
60 | edges[i].label, | 60 | edges[i].label, |
61 | GNUNET_h2s (&edges[i].destination)); | 61 | GNUNET_h2s(&edges[i].destination)); |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
@@ -73,7 +73,7 @@ print_edge (void *cls, | |||
73 | * @return 0 ok, 1 on error | 73 | * @return 0 ok, 1 on error |
74 | */ | 74 | */ |
75 | int | 75 | int |
76 | main (int argc, char *const *argv) | 76 | main(int argc, char *const *argv) |
77 | { | 77 | { |
78 | struct REGEX_INTERNAL_Automaton* dfa; | 78 | struct REGEX_INTERNAL_Automaton* dfa; |
79 | char **regexes; | 79 | char **regexes; |
@@ -83,45 +83,45 @@ main (int argc, char *const *argv) | |||
83 | unsigned int alphabet_size; | 83 | unsigned int alphabet_size; |
84 | long size; | 84 | long size; |
85 | 85 | ||
86 | GNUNET_log_setup ("perf-regex", "DEBUG", NULL); | 86 | GNUNET_log_setup("perf-regex", "DEBUG", NULL); |
87 | if (4 != argc) | 87 | if (4 != argc) |
88 | { | 88 | { |
89 | fprintf (stderr, | 89 | fprintf(stderr, |
90 | "Usage: %s REGEX_FILE ALPHABET_SIZE COMPRESSION\n", | 90 | "Usage: %s REGEX_FILE ALPHABET_SIZE COMPRESSION\n", |
91 | argv[0]); | 91 | argv[0]); |
92 | return 1; | 92 | return 1; |
93 | } | 93 | } |
94 | regexes = REGEX_TEST_read_from_file (argv[1]); | 94 | regexes = REGEX_TEST_read_from_file(argv[1]); |
95 | if (NULL == regexes) | 95 | if (NULL == regexes) |
96 | { | 96 | { |
97 | fprintf (stderr, | 97 | fprintf(stderr, |
98 | "Failed to read regexes from `%s'\n", | 98 | "Failed to read regexes from `%s'\n", |
99 | argv[1]); | 99 | argv[1]); |
100 | return 2; | 100 | return 2; |
101 | } | 101 | } |
102 | alphabet_size = atoi (argv[2]); | 102 | alphabet_size = atoi(argv[2]); |
103 | compression = atoi (argv[3]); | 103 | compression = atoi(argv[3]); |
104 | printf ("********* PERF-REGEX *********'\n"); | 104 | printf("********* PERF-REGEX *********'\n"); |
105 | printf ("Using:\n file '%s'\n Alphabet size %u\n compression %d\n", | 105 | printf("Using:\n file '%s'\n Alphabet size %u\n compression %d\n", |
106 | argv[1], alphabet_size, compression); | 106 | argv[1], alphabet_size, compression); |
107 | fflush(stdout); | 107 | fflush(stdout); |
108 | buffer = REGEX_TEST_combine (regexes, alphabet_size); | 108 | buffer = REGEX_TEST_combine(regexes, alphabet_size); |
109 | GNUNET_asprintf (®ex, "GNUNET_REGEX_PROFILER_(%s)(0|1)*", buffer); | 109 | GNUNET_asprintf(®ex, "GNUNET_REGEX_PROFILER_(%s)(0|1)*", buffer); |
110 | size = strlen (regex); | 110 | size = strlen(regex); |
111 | 111 | ||
112 | fprintf (stderr, | 112 | fprintf(stderr, |
113 | "Combined regex (%ld bytes):\n%s\n", | 113 | "Combined regex (%ld bytes):\n%s\n", |
114 | size, | 114 | size, |
115 | regex); | 115 | regex); |
116 | dfa = REGEX_INTERNAL_construct_dfa (regex, size, compression); | 116 | dfa = REGEX_INTERNAL_construct_dfa(regex, size, compression); |
117 | printf ("********* ALL EDGES *********'\n"); | 117 | printf("********* ALL EDGES *********'\n"); |
118 | REGEX_INTERNAL_iterate_all_edges (dfa, &print_edge, NULL); | 118 | REGEX_INTERNAL_iterate_all_edges(dfa, &print_edge, NULL); |
119 | printf ("\n\n********* REACHABLE EDGES *********'\n"); | 119 | printf("\n\n********* REACHABLE EDGES *********'\n"); |
120 | REGEX_INTERNAL_iterate_reachable_edges (dfa, &print_edge, NULL); | 120 | REGEX_INTERNAL_iterate_reachable_edges(dfa, &print_edge, NULL); |
121 | REGEX_INTERNAL_automaton_destroy (dfa); | 121 | REGEX_INTERNAL_automaton_destroy(dfa); |
122 | GNUNET_free (buffer); | 122 | GNUNET_free(buffer); |
123 | REGEX_TEST_free_from_file (regexes); | 123 | REGEX_TEST_free_from_file(regexes); |
124 | GNUNET_free (regex); | 124 | GNUNET_free(regex); |
125 | return 0; | 125 | return 0; |
126 | } | 126 | } |
127 | 127 | ||