mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
85213f6235
value" error even though the value was correct): a C function in my_getopt.c was taking bool* in parameter and was called from C++ sql_plugin.cc, but on some Mac OS X sizeof(bool) is 1 in C and 4 in C++, giving funny mismatches. Fixed, all other occurences of bool in C are removed, future ones are blocked by a "C-bool-catcher" in my_global.h (use my_bool). client/mysqldump.c: my_bool for C client/mysqltest.c: my_bool for C extra/replace.c: my_bool for C include/my_getopt.h: my_bool for C include/my_global.h: Prevent people from using bool in C, it causes real bugs. include/my_sys.h: my_bool for C include/my_time.h: my_bool for C include/thr_lock.h: my_bool for C libmysql/libmysql.c: my_bool for C mysys/charset.c: my_bool for C mysys/my_getopt.c: my_bool for C mysys/queues.c: my_bool for C mysys/thr_lock.c: my_bool for C regex/reginit.c: my_bool for C sql/set_var.cc: C functions use my_bool so we must use my_bool too. sql/sql_plugin.cc: C functions use my_bool so we must use my_bool too. This fixes a real observed bug of Maria, because on some Mac OS X, sizeof(bool) is 1 in C and 4 in C++, so the bool* does wrong. Removing useless line. storage/heap/hp_update.c: my_bool for C storage/myisam/mi_check.c: my_bool for C storage/myisam/mi_dynrec.c: my_bool for C storage/myisam/mi_search.c: my_bool for C storage/myisam/mi_update.c: my_bool for C storage/myisam/mi_write.c: my_bool for C storage/myisam/myisamdef.h: my_bool for C storage/myisam/myisamlog.c: my_bool for C storage/myisam/myisampack.c: my_bool for C tests/mysql_client_test.c: my_bool for C unittest/mysys/bitmap-t.c: my_bool for C vio/viosslfactories.c: my_bool for C
81 lines
1.9 KiB
C
81 lines
1.9 KiB
C
/* Init cclasses array from ctypes */
|
|
|
|
#include <my_global.h>
|
|
#include <m_ctype.h>
|
|
#include <m_string.h>
|
|
#include "cclass.h"
|
|
|
|
static my_bool regex_inited=0;
|
|
|
|
void my_regex_init(CHARSET_INFO *cs)
|
|
{
|
|
char buff[CCLASS_LAST][256];
|
|
int count[CCLASS_LAST];
|
|
uint i;
|
|
|
|
if (!regex_inited)
|
|
{
|
|
regex_inited=1;
|
|
bzero((uchar*) &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);
|
|
if (!tmp)
|
|
{
|
|
/*
|
|
This is very unlikely to happen as this function is called once
|
|
at program startup
|
|
*/
|
|
fprintf(stderr,
|
|
"Fatal error: Can't allocate memory in regex_init\n");
|
|
exit(1);
|
|
}
|
|
memcpy(tmp,buff[i],count[i]*sizeof(char));
|
|
tmp[count[i]]=0;
|
|
cclasses[i].chars=tmp;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
void my_regex_end()
|
|
{
|
|
if (regex_inited)
|
|
{
|
|
int i;
|
|
for (i=0; i < CCLASS_LAST ; i++)
|
|
free((char*) cclasses[i].chars);
|
|
regex_inited=0;
|
|
}
|
|
}
|
|
|
|
|