summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-19 22:28:32 -0400
committerRich Felker <dalias@aerifal.cx>2011-03-19 22:28:32 -0400
commit0346d5174eb0ce553cda977d91dd6cf61b7ffe82 (patch)
tree339d9665b997e2c0b8f60fc1c52680635108f86a /regex.c
downloadlibc-bench-0346d5174eb0ce553cda977d91dd6cf61b7ffe82.tar.gz
initial check-in
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/regex.c b/regex.c
new file mode 100644
index 0000000..46cfe37
--- /dev/null
+++ b/regex.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <regex.h>
+#include <locale.h>
+
+size_t b_regex_compile(void *s)
+{
+ regex_t re;
+ size_t i;
+ setlocale(LC_CTYPE, "");
+ for (i=0; i<1000; i++) {
+ regcomp(&re, s, REG_EXTENDED);
+ regfree(&re);
+ }
+}
+
+size_t b_regex_search(void *s)
+{
+ char buf[260000];
+ regex_t re;
+ size_t i;
+ setlocale(LC_CTYPE, "");
+ memset(buf, 'a', sizeof(buf)-2);
+ buf[sizeof buf - 2] = 'b';
+ buf[sizeof buf - 1] = 0;
+ regcomp(&re, s, REG_EXTENDED);
+ regexec(&re, buf, 0, 0, 0);
+ regfree(&re);
+}