9 static my_bool regex_inited=0;
10 extern my_regex_stack_check_t my_regex_enough_mem_in_stack;
12 void my_regex_init(
const CHARSET_INFO *cs, my_regex_stack_check_t func)
14 char buff[CCLASS_LAST][256];
15 int count[CCLASS_LAST];
21 my_regex_enough_mem_in_stack= func;
22 memset(&count, 0,
sizeof(count));
24 for (i=1 ; i<= 255; i++)
27 buff[CCLASS_ALNUM][count[CCLASS_ALNUM]++]=(char) i;
29 buff[CCLASS_ALPHA][count[CCLASS_ALPHA]++]=(
char)
i;
31 buff[CCLASS_CNTRL][count[CCLASS_CNTRL]++]=(
char)
i;
33 buff[CCLASS_DIGIT][count[CCLASS_DIGIT]++]=(
char)
i;
35 buff[CCLASS_GRAPH][count[CCLASS_GRAPH]++]=(
char)
i;
37 buff[CCLASS_LOWER][count[CCLASS_LOWER]++]=(
char)
i;
39 buff[CCLASS_PRINT][count[CCLASS_PRINT]++]=(
char)
i;
41 buff[CCLASS_PUNCT][count[CCLASS_PUNCT]++]=(
char)
i;
43 buff[CCLASS_SPACE][count[CCLASS_SPACE]++]=(
char)
i;
45 buff[CCLASS_UPPER][count[CCLASS_UPPER]++]=(
char)
i;
46 if (my_isxdigit(cs,i))
47 buff[CCLASS_XDIGIT][count[CCLASS_XDIGIT]++]=(
char)
i;
49 buff[CCLASS_BLANK][0]=
' ';
50 buff[CCLASS_BLANK][1]=
'\t';
51 count[CCLASS_BLANK]=2;
52 for (i=0; i < CCLASS_LAST ; i++)
54 char *tmp=(
char*) malloc(count[i]+1);
62 "Fatal error: Can't allocate memory in regex_init\n");
65 memcpy(tmp,buff[i],count[i]*
sizeof(
char));
67 cclasses[
i].chars=tmp;
78 for (i=0; i < CCLASS_LAST ; i++)
79 free((
char*) cclasses[i].chars);
80 my_regex_enough_mem_in_stack= NULL;