1
/* Init cclasses array from ctypes */
8
static my_bool regex_inited=0;
10
void my_regex_init(CHARSET_INFO *cs)
12
char buff[CCLASS_LAST][256];
13
int count[CCLASS_LAST];
19
bzero((uchar*) &count,sizeof(count));
21
for (i=1 ; i<= 255; i++)
24
buff[CCLASS_ALNUM][count[CCLASS_ALNUM]++]=(char) i;
26
buff[CCLASS_ALPHA][count[CCLASS_ALPHA]++]=(char) i;
28
buff[CCLASS_CNTRL][count[CCLASS_CNTRL]++]=(char) i;
30
buff[CCLASS_DIGIT][count[CCLASS_DIGIT]++]=(char) i;
32
buff[CCLASS_GRAPH][count[CCLASS_GRAPH]++]=(char) i;
34
buff[CCLASS_LOWER][count[CCLASS_LOWER]++]=(char) i;
36
buff[CCLASS_PRINT][count[CCLASS_PRINT]++]=(char) i;
38
buff[CCLASS_PUNCT][count[CCLASS_PUNCT]++]=(char) i;
40
buff[CCLASS_SPACE][count[CCLASS_SPACE]++]=(char) i;
42
buff[CCLASS_UPPER][count[CCLASS_UPPER]++]=(char) i;
43
if (my_isxdigit(cs,i))
44
buff[CCLASS_XDIGIT][count[CCLASS_XDIGIT]++]=(char) i;
46
buff[CCLASS_BLANK][0]=' ';
47
buff[CCLASS_BLANK][1]='\t';
48
count[CCLASS_BLANK]=2;
49
for (i=0; i < CCLASS_LAST ; i++)
51
char *tmp=(char*) malloc(count[i]+1);
55
This is very unlikely to happen as this function is called once
59
"Fatal error: Can't allocate memory in regex_init\n");
62
memcpy(tmp,buff[i],count[i]*sizeof(char));
64
cclasses[i].chars=tmp;
75
for (i=0; i < CCLASS_LAST ; i++)
76
free((char*) cclasses[i].chars);