summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mnogosearch.org>2013-09-26 18:02:17 +0400
committerAlexander Barkov <bar@mnogosearch.org>2013-09-26 18:02:17 +0400
commit285e7aa179a6081531be3274772b89e8989fd107 (patch)
tree71836ea6e49f48fff6e957bcef38628e7b979001 /client
parent9d83468e78ba23f024ce3c11443913ad75cf1ea5 (diff)
downloadmariadb-git-285e7aa179a6081531be3274772b89e8989fd107.tar.gz
MDEV-4425 REGEXP enhancements
Diffstat (limited to 'client')
-rw-r--r--client/CMakeLists.txt5
-rw-r--r--client/mysqltest.cc52
2 files changed, 28 insertions, 29 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index e4507f9c8ba..27f974ba7a5 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -18,7 +18,7 @@ INCLUDE_DIRECTORIES(
${ZLIB_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/libmysql
- ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/pcre
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/strings
${MY_READLINE_INCLUDE_DIR}
@@ -36,7 +36,8 @@ ENDIF(UNIX)
MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc COMPONENT Test)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
-TARGET_LINK_LIBRARIES(mysqltest mysqlclient regex)
+TARGET_LINK_LIBRARIES(mysqltest mysqlclient pcre)
+TARGET_LINK_LIBRARIES(mysqltest mysqlclient pcreposix)
SET_TARGET_PROPERTIES(mysqltest PROPERTIES ENABLE_EXPORTS TRUE)
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 30b83c940fe..99a89dd52c3 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -44,7 +44,7 @@
#include <hash.h>
#include <stdarg.h>
#include <violite.h>
-#include "my_regex.h" /* Our own version of regex */
+#include <pcreposix.h> /* pcreposix regex library */
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
@@ -250,12 +250,12 @@ static const char *opt_suite_dir, *opt_overlay_dir;
static size_t suite_dir_len, overlay_dir_len;
/* Precompiled re's */
-static my_regex_t ps_re; /* the query can be run using PS protocol */
-static my_regex_t sp_re; /* the query can be run as a SP */
-static my_regex_t view_re; /* the query can be run as a view*/
+static regex_t ps_re; /* the query can be run using PS protocol */
+static regex_t sp_re; /* the query can be run as a SP */
+static regex_t view_re; /* the query can be run as a view*/
static void init_re(void);
-static int match_re(my_regex_t *, char *);
+static int match_re(regex_t *, char *);
static void free_re(void);
static char *get_string(char **to_ptr, char **from_ptr,
@@ -7246,13 +7246,13 @@ void str_to_file(const char *fname, char *str, int size)
}
-void check_regerr(my_regex_t* r, int err)
+void check_regerr(regex_t* r, int err)
{
char err_buf[1024];
if (err)
{
- my_regerror(err,r,err_buf,sizeof(err_buf));
+ regerror(err,r,err_buf,sizeof(err_buf));
die("Regex error: %s\n", err_buf);
}
}
@@ -8544,19 +8544,18 @@ char *re_eprint(int err)
{
static char epbuf[100];
size_t len __attribute__((unused))=
- my_regerror(REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
+ regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
assert(len <= sizeof(epbuf));
return(epbuf);
}
-void init_re_comp(my_regex_t *re, const char* str)
+void init_re_comp(regex_t *re, const char* str)
{
- int err= my_regcomp(re, str, (REG_EXTENDED | REG_ICASE | REG_NOSUB),
- &my_charset_latin1);
+ int err= regcomp(re, str, (REG_EXTENDED | REG_ICASE | REG_NOSUB | REG_DOTALL));
if (err)
{
char erbuf[100];
- int len= my_regerror(err, re, erbuf, sizeof(erbuf));
+ int len= regerror(err, re, erbuf, sizeof(erbuf));
die("error %s, %d/%d `%s'\n",
re_eprint(err), (int)len, (int)sizeof(erbuf), erbuf);
}
@@ -8601,7 +8600,7 @@ void init_re(void)
}
-int match_re(my_regex_t *re, char *str)
+int match_re(regex_t *re, char *str)
{
while (my_isspace(charset_info, *str))
str++;
@@ -8613,7 +8612,7 @@ int match_re(my_regex_t *re, char *str)
str= comm_end + 2;
}
- int err= my_regexec(re, str, (size_t)0, NULL, 0);
+ int err= regexec(re, str, (size_t)0, NULL, 0);
if (err == 0)
return 1;
@@ -8622,7 +8621,7 @@ int match_re(my_regex_t *re, char *str)
{
char erbuf[100];
- int len= my_regerror(err, re, erbuf, sizeof(erbuf));
+ int len= regerror(err, re, erbuf, sizeof(erbuf));
die("error %s, %d/%d `%s'\n",
re_eprint(err), (int)len, (int)sizeof(erbuf), erbuf);
}
@@ -8631,10 +8630,9 @@ int match_re(my_regex_t *re, char *str)
void free_re(void)
{
- my_regfree(&ps_re);
- my_regfree(&sp_re);
- my_regfree(&view_re);
- my_regex_end();
+ regfree(&ps_re);
+ regfree(&sp_re);
+ regfree(&view_re);
}
/****************************************************************************/
@@ -10071,13 +10069,13 @@ void free_replace_regex()
int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
char *replace, char *string, int icase)
{
- my_regex_t r;
- my_regmatch_t *subs;
+ regex_t r;
+ regmatch_t *subs;
char *replace_end;
char *buf= *buf_p;
int len;
int buf_len, need_buf_len;
- int cflags= REG_EXTENDED;
+ int cflags= REG_EXTENDED | REG_DOTALL;
int err_code;
char *res_p,*str_p,*str_end;
@@ -10096,13 +10094,13 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
if (icase)
cflags|= REG_ICASE;
- if ((err_code= my_regcomp(&r,pattern,cflags,&my_charset_latin1)))
+ if ((err_code= regcomp(&r,pattern,cflags)))
{
check_regerr(&r,err_code);
return 1;
}
- subs= (my_regmatch_t*)my_malloc(sizeof(my_regmatch_t) * (r.re_nsub+1),
+ subs= (regmatch_t*)my_malloc(sizeof(regmatch_t) * (r.re_nsub+1),
MYF(MY_WME+MY_FAE));
*res_p= 0;
@@ -10113,14 +10111,14 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
while (!err_code)
{
/* find the match */
- err_code= my_regexec(&r,str_p, r.re_nsub+1, subs,
+ err_code= regexec(&r,str_p, r.re_nsub+1, subs,
(str_p == string) ? REG_NOTBOL : 0);
/* if regular expression error (eg. bad syntax, or out of memory) */
if (err_code && err_code != REG_NOMATCH)
{
check_regerr(&r,err_code);
- my_regfree(&r);
+ regfree(&r);
return 1;
}
@@ -10233,7 +10231,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
}
}
my_free(subs);
- my_regfree(&r);
+ regfree(&r);
*res_p= 0;
*buf_p= buf;
*buf_len_p= buf_len;