aboutsummaryrefslogtreecommitdiff
path: root/src/regex/perf-regex.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-12-17 12:35:19 +0000
committerBart Polot <bart@net.in.tum.de>2012-12-17 12:35:19 +0000
commit11cc044427e734c83af65ee340dd10ec70c97b1c (patch)
tree2c807dc234644519ff2f341cf6ca2f1cb2a084f2 /src/regex/perf-regex.c
parent07ce0aaf09b4bcdf37b1524a9a497d4a185aba91 (diff)
- move regex_from_file and combine to separate lib file
Diffstat (limited to 'src/regex/perf-regex.c')
-rw-r--r--src/regex/perf-regex.c50
1 files changed, 3 insertions, 47 deletions
diff --git a/src/regex/perf-regex.c b/src/regex/perf-regex.c
index e0ac7b3d2b..f1d21f564b 100644
--- a/src/regex/perf-regex.c
+++ b/src/regex/perf-regex.c
@@ -19,7 +19,7 @@
*/
/**
- * @file regex/prof-regex.c
+ * @file src/regex/prof-regex.c
* @brief Test how long it takes to create a automaton from a string regex.
* @author Bartlomiej Polot
*/
@@ -27,6 +27,7 @@
#include <time.h>
#include "platform.h"
#include "gnunet_regex_lib.h"
+#include "regex_test_lib.h"
static const char *exe;
@@ -54,8 +55,6 @@ main (int argc, char *const *argv)
unsigned int i;
int compression;
long size;
- size_t len;
- FILE *f;
GNUNET_log_setup ("perf-regex", "DEBUG", NULL);
exe = argv[0];
@@ -64,50 +63,7 @@ main (int argc, char *const *argv)
usage();
return 1;
}
- f = fopen (argv[1], "r");
- if (NULL == f)
- {
- fprintf (stderr, "Can't open file %s\n", argv[1]);
- usage();
- return 2;
- }
- fseek (f, 0, SEEK_END);
- size = ftell (f);
- fprintf (stderr, "using file %s, size %ld\n", argv[1], size);
- fseek (f, 0, SEEK_SET);
- buffer = GNUNET_malloc (size + 1);
- regexes = GNUNET_malloc (sizeof (char *));
- nr = 1;
- do
- {
- if (NULL == fgets (buffer, size + 1, f))
- {
- fprintf (stderr, "Can't read file %s\n", argv[1]);
- usage();
- return 3;
- }
- len = strlen (buffer);
- if (len < 1)
- continue;
- if ('\n' == buffer[len - 1])
- {
- len--;
- buffer[len] = '\0';
- }
- if (len < 6 || strncmp (&buffer[len - 6], "(0|1)*", 6) != 0)
- {
- fprintf (stderr, "\nWARNING:\n");
- fprintf (stderr, "%s (line %u) does not end in (0|1)*\n", buffer, nr);
- }
- else
- {
- buffer[len - 6] = '\0';
- }
- GNUNET_array_grow (regexes, nr, nr+1);
- regexes[nr - 2] = GNUNET_strdup (buffer);
- regexes[nr - 1] = NULL;
- } while (ftell(f) < size);
- GNUNET_free (buffer);
+ regexes = GNUNET_REGEX_read_from_file (argv[1]);
buffer = GNUNET_REGEX_combine (regexes);