mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 01:04:19 +01:00
654db69b82
to allow usage of many character sets at a time. include/m_ctype.h: Added condition to simplify migrating from old ctype Added new style toupper, tolower which accepts charset in first argument regex/debug.c: Added charset argument regex/debug.ih: added charset argument regex/engine.c: added charset argument regex/engine.ih: added charset arguent regex/main.c: added charset argument regex/regcomp.c: added CHARSET_INFO field regex/regcomp.ih: Added charset argument regex/regex.h: Added #include <m_ctype.h> for CHARSET_INFO Added charset argument for regcomp() regex/regex2.h: New charset argument for ISWORD() regex/regexec.c: New charset argument regex/reginit.c: Move to new style ctype. However still needs fixes: instead of single static cclass variable, each charset must have it's own variable. sql/item_cmpfunc.cc: Pass charset field into regcomp() This will be fixed tommorow to use String->charset instead of default_charset_info
72 lines
1.7 KiB
C
72 lines
1.7 KiB
C
/* Init cclasses array from ctypes */
|
|
|
|
#include <my_global.h>
|
|
#include <m_ctype.h>
|
|
#include <m_string.h>
|
|
#include "cclass.h"
|
|
|
|
static bool regex_inited=0;
|
|
|
|
void regex_init()
|
|
{
|
|
char buff[CCLASS_LAST][256];
|
|
int count[CCLASS_LAST];
|
|
uint i;
|
|
CHARSET_INFO *cs=default_charset_info;
|
|
|
|
if (!regex_inited)
|
|
{
|
|
regex_inited=1;
|
|
bzero((gptr) &count,sizeof(count));
|
|
|
|
for (i=1 ; i<= 255; i++)
|
|
{
|
|
if (my_isalnum(cs,i))
|
|
buff[CCLASS_ALNUM][count[CCLASS_ALNUM]++]=(char) i;
|
|
if (my_isalpha(cs,i))
|
|
buff[CCLASS_ALPHA][count[CCLASS_ALPHA]++]=(char) i;
|
|
if (my_iscntrl(cs,i))
|
|
buff[CCLASS_CNTRL][count[CCLASS_CNTRL]++]=(char) i;
|
|
if (my_isdigit(cs,i))
|
|
buff[CCLASS_DIGIT][count[CCLASS_DIGIT]++]=(char) i;
|
|
if (my_isgraph(cs,i))
|
|
buff[CCLASS_GRAPH][count[CCLASS_GRAPH]++]=(char) i;
|
|
if (my_islower(cs,i))
|
|
buff[CCLASS_LOWER][count[CCLASS_LOWER]++]=(char) i;
|
|
if (my_isprint(cs,i))
|
|
buff[CCLASS_PRINT][count[CCLASS_PRINT]++]=(char) i;
|
|
if (my_ispunct(cs,i))
|
|
buff[CCLASS_PUNCT][count[CCLASS_PUNCT]++]=(char) i;
|
|
if (my_isspace(cs,i))
|
|
buff[CCLASS_SPACE][count[CCLASS_SPACE]++]=(char) i;
|
|
if (my_isupper(cs,i))
|
|
buff[CCLASS_UPPER][count[CCLASS_UPPER]++]=(char) i;
|
|
if (my_isxdigit(cs,i))
|
|
buff[CCLASS_XDIGIT][count[CCLASS_XDIGIT]++]=(char) i;
|
|
}
|
|
buff[CCLASS_BLANK][0]=' ';
|
|
buff[CCLASS_BLANK][1]='\t';
|
|
count[CCLASS_BLANK]=2;
|
|
for (i=0; i < CCLASS_LAST ; i++)
|
|
{
|
|
char *tmp=(char*) malloc(count[i]+1);
|
|
memcpy(tmp,buff[i],count[i]*sizeof(char));
|
|
tmp[count[i]]=0;
|
|
cclasses[i].chars=tmp;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
void regex_end()
|
|
{
|
|
if (regex_inited)
|
|
{
|
|
int i;
|
|
for (i=0; i < CCLASS_LAST ; i++)
|
|
free((char*) cclasses[i].chars);
|
|
regex_inited=0;
|
|
}
|
|
}
|
|
|
|
|