summaryrefslogtreecommitdiff
path: root/regex.c
blob: 46cfe37fbc1308c4685f08c5aa9969dabf850fd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);
}