List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:July 26 2010 1:01pm
Subject:bzr push into mysql-next-mr-bugfixing branch (tor.didriksen:3330 to 3332)
Bug#55553
View as plain text  
 3332 Tor Didriksen	2010-07-26
      Bug #55553 hp_test2 is flaky
     @ storage/heap/hp_test2.c
        Don't save the heap position if heap_scan() returns error.

    modified:
      storage/heap/hp_test2.c
 3331 Tor Didriksen	2010-07-26
      Bug #54805 definitions in regex/my_regex.h conflict with /usr/include/regex.h
      
      The mysql source has its own version of regcomp etc. compiled in.
      All symbols with linkage (i.e. global functions) have been renamed
      (added my_ prefix) to avoid linkage problems.
      
      This bugfix renames compile-time symbols in a similar fashion,
      REG_STARTEND => MY_REG_STARTEND etc.
     @ client/mysqltest.cc
        Rename REG_xxx macros to MY_REG_xxx
     @ mysql-test/r/func_regexp.result
        Add test case showing that '\t' is not considered a blank by MySQL.
     @ mysql-test/t/func_regexp.test
        Add test case showing that '\t' is not considered a blank by MySQL.
     @ regex/CMakeLists.txt
        Add target for building regression test main program.
        Add test targets as well.
     @ regex/engine.c
        Rename REG_xxx macros to MY_REG_xxx
     @ regex/main.c
        Rename REG_xxx macros to MY_REG_xxx
        Add getopt for windows.
     @ regex/my_regex.h
        Move inclusion of m_ctype.h outside of 'extern "C"' declaration
        (gave error: template with C linkage)
        
        Rename REG_xxx macros to MY_REG_xxx
        
        Use my_regoff_t rather than regoff_t.
     @ regex/regcomp.c
        Rename REG_xxx macros to MY_REG_xxx
     @ regex/regerror.c
        Rename REG_xxx macros to MY_REG_xxx
     @ regex/regex2.h
        Use my_regoff_t rather than regoff_t
     @ regex/regexec.c
        Rename REG_xxx macros to MY_REG_xxx
     @ regex/tests
        Change one test case in regression test,
        as MySQL does not recognize '\t' as blank.
     @ sql/item_cmpfunc.cc
        Rename REG_xxx macros to MY_REG_xxx
     @ unittest/gunit/CMakeLists.txt
        Add unit test for my_regex.
     @ unittest/gunit/my_regex-t.cc
        New unit test.

    added:
      unittest/gunit/my_regex-t.cc
    modified:
      client/mysqltest.cc
      mysql-test/r/func_regexp.result
      mysql-test/t/func_regexp.test
      regex/CMakeLists.txt
      regex/engine.c
      regex/main.c
      regex/my_regex.h
      regex/regcomp.c
      regex/regerror.c
      regex/regex2.h
      regex/regexec.c
      regex/tests
      sql/item_cmpfunc.cc
      unittest/gunit/CMakeLists.txt
 3330 Alexander Nozdrin	2010-07-26 [merge]
      Auto-merge from mysql-trunk-bugfixing.

    modified:
      mysql-test/collections/default.experimental
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2010-07-24 13:47:42 +0000
+++ b/client/mysqltest.cc	2010-07-26 10:39:38 +0000
@@ -7478,15 +7478,14 @@ void run_query(struct st_connection *cn,
 char *re_eprint(int err)
 {
   static char epbuf[100];
-  size_t len= my_regerror(REG_ITOA|err, (my_regex_t *)NULL,
-			  epbuf, sizeof(epbuf));
+  size_t len= my_regerror(MY_REG_ITOA | err, NULL, epbuf, sizeof(epbuf));
   assert(len <= sizeof(epbuf));
   return(epbuf);
 }
 
 void init_re_comp(my_regex_t *re, const char* str)
 {
-  int err= my_regcomp(re, str, (REG_EXTENDED | REG_ICASE | REG_NOSUB),
+  int err= my_regcomp(re, str, (MY_REG_EXTENDED | MY_REG_ICASE | MY_REG_NOSUB),
                       &my_charset_latin1);
   if (err)
   {
@@ -7542,7 +7541,7 @@ int match_re(my_regex_t *re, char *str)
 
   if (err == 0)
     return 1;
-  else if (err == REG_NOMATCH)
+  else if (err == MY_REG_NOMATCH)
     return 0;
 
   {
@@ -8943,7 +8942,7 @@ int reg_replace(char** buf_p, int* buf_l
   char *buf= *buf_p;
   int len;
   int buf_len, need_buf_len;
-  int cflags= REG_EXTENDED;
+  int cflags= MY_REG_EXTENDED;
   int err_code;
   char *res_p,*str_p,*str_end;
 
@@ -8960,7 +8959,7 @@ int reg_replace(char** buf_p, int* buf_l
   SECURE_REG_BUF
 
   if (icase)
-    cflags|= REG_ICASE;
+    cflags|= MY_REG_ICASE;
 
   if ((err_code= my_regcomp(&r,pattern,cflags,&my_charset_latin1)))
   {
@@ -8980,10 +8979,10 @@ int reg_replace(char** buf_p, int* buf_l
   {
     /* find the match */
     err_code= my_regexec(&r,str_p, r.re_nsub+1, subs,
-                         (str_p == string) ? REG_NOTBOL : 0);
+                         (str_p == string) ? MY_REG_NOTBOL : 0);
 
     /* if regular expression error (eg. bad syntax, or out of memory) */
-    if (err_code && err_code != REG_NOMATCH)
+    if (err_code && err_code != MY_REG_NOMATCH)
     {
       check_regerr(&r,err_code);
       my_regfree(&r);
@@ -9016,7 +9015,7 @@ int reg_replace(char** buf_p, int* buf_l
         /* found a valid back_ref (eg. \1)*/
         if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub)
         {
-          regoff_t start_off, end_off;
+          my_regoff_t start_off, end_off;
           if ((start_off=subs[back_ref_num].rm_so) > -1 &&
               (end_off=subs[back_ref_num].rm_eo) > -1)
           {
@@ -9059,7 +9058,7 @@ int reg_replace(char** buf_p, int* buf_l
 
         if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub)
         {
-          regoff_t start_off, end_off;
+          my_regoff_t start_off, end_off;
           if ((start_off=subs[back_ref_num].rm_so) > -1 &&
               (end_off=subs[back_ref_num].rm_eo) > -1)
           {

=== modified file 'mysql-test/r/func_regexp.result'
--- a/mysql-test/r/func_regexp.result	2009-10-19 11:13:26 +0000
+++ b/mysql-test/r/func_regexp.result	2010-07-26 10:39:38 +0000
@@ -145,3 +145,15 @@ a
 DEALLOCATE PREPARE stmt1;
 DROP TABLE t1;
 End of 5.1 tests
+SELECT ' '  REGEXP '[[:blank:]]';
+' '  REGEXP '[[:blank:]]'
+1
+SELECT '\t' REGEXP '[[:blank:]]';
+'\t' REGEXP '[[:blank:]]'
+0
+SELECT ' '  REGEXP '[[:space:]]';
+' '  REGEXP '[[:space:]]'
+1
+SELECT '\t' REGEXP '[[:space:]]';
+'\t' REGEXP '[[:space:]]'
+1

=== modified file 'mysql-test/t/func_regexp.test'
--- a/mysql-test/t/func_regexp.test	2008-09-05 08:36:02 +0000
+++ b/mysql-test/t/func_regexp.test	2010-07-26 10:39:38 +0000
@@ -92,3 +92,17 @@ DROP TABLE t1;
 
 
 --echo End of 5.1 tests
+
+#
+# Bug #54805 definitions in regex/my_regex.h conflict with /usr/include/regex.h
+#
+# This test verifies that '\t' is recognized as space, but not as blank.
+# This is *not* according to the POSIX standard, but seems to have been MySQL
+# behaviour ever since regular expressions were introduced.
+# See: Bug #55427 REGEXP does not recognize '\t' as [:blank:]
+#
+SELECT ' '  REGEXP '[[:blank:]]';
+SELECT '\t' REGEXP '[[:blank:]]';
+
+SELECT ' '  REGEXP '[[:space:]]';
+SELECT '\t' REGEXP '[[:space:]]';

=== modified file 'regex/CMakeLists.txt'
--- a/regex/CMakeLists.txt	2010-07-03 23:17:03 +0000
+++ b/regex/CMakeLists.txt	2010-07-26 10:39:38 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,3 +18,10 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/
 
 SET(REGEX_SOURCES regcomp.c regerror.c regexec.c regfree.c reginit.c)
 ADD_CONVENIENCE_LIBRARY(regex ${REGEX_SOURCES})
+
+ADD_EXECUTABLE(re main.c split.c debug.c)
+TARGET_LINK_LIBRARIES(re regex strings)
+
+ADD_TEST(regex1 re     -i${CMAKE_CURRENT_SOURCE_DIR}/tests)
+ADD_TEST(regex2 re -el -i${CMAKE_CURRENT_SOURCE_DIR}/tests)
+ADD_TEST(regex3 re -er -i${CMAKE_CURRENT_SOURCE_DIR}/tests)

=== modified file 'regex/engine.c'
--- a/regex/engine.c	2005-09-29 01:20:31 +0000
+++ b/regex/engine.c	2010-07-26 10:39:38 +0000
@@ -50,7 +50,7 @@ struct match {
 #ifdef REDEBUG
 #define	SP(t, s, c)	print(m, t, s, c, stdout)
 #define	AT(t, p1, p2, s1, s2)	at(m, t, p1, p2, s1, s2)
-#define	NOTE(str)	{ if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }
+#define	NOTE(str)	{ if (m->eflags&MY_REG_TRACE) printf("=%s\n", (str)); }
 #else
 #define	SP(t, s, c)	/* nothing */
 #define	AT(t, p1, p2, s1, s2)	/* nothing */
@@ -62,7 +62,7 @@ struct match {
  == static int matcher(register struct re_guts *g, char *string, \
  ==	size_t nmatch, regmatch_t pmatch[], int eflags);
  */
-static int			/* 0 success, REG_NOMATCH failure */
+static int			/* 0 success, MY_REG_NOMATCH failure */
 matcher(charset,g, str, nmatch, pmatch, eflags)
 CHARSET_INFO *charset;
 register struct re_guts *g;
@@ -82,9 +82,9 @@ int eflags;
 	char *stop;
 
 	/* simplify the situation where possible */
-	if (g->cflags&REG_NOSUB)
+	if (g->cflags&MY_REG_NOSUB)
 		nmatch = 0;
-	if (eflags&REG_STARTEND) {
+	if (eflags&MY_REG_STARTEND) {
 		start = str + pmatch[0].rm_so;
 		stop = str + pmatch[0].rm_eo;
 	} else {
@@ -92,7 +92,7 @@ int eflags;
 		stop = start + strlen(start);
 	}
 	if (stop < start)
-		return(REG_INVARG);
+		return(MY_REG_INVARG);
 
 	/* prescreening; this does wonders for this rather slow code */
 	if (g->must != NULL) {
@@ -101,7 +101,7 @@ int eflags;
 				memcmp(dp, g->must, (size_t)g->mlen) == 0)
 				break;
 		if (dp == stop)		/* we didn't find g->must */
-			return(REG_NOMATCH);
+			return(MY_REG_NOMATCH);
 	}
 
 	/* match struct setup */
@@ -128,7 +128,7 @@ int eflags;
 		  if (m->lastpos != NULL)
 		    free((char *)m->lastpos);
 		  STATETEARDOWN(m);
-		  return(REG_NOMATCH);
+		  return(MY_REG_NOMATCH);
 		}
 		if (nmatch == 0 && !g->backrefs)
 			break;		/* no further info needed */
@@ -154,11 +154,11 @@ int eflags;
 		  	if (m->lastpos != NULL)
 		    	free((char *)m->lastpos);
 			STATETEARDOWN(m);
-			return(REG_ESPACE);
+			return(MY_REG_ESPACE);
 		}
 		for (i = 1; i <= m->g->nsub; i++)
 			m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
-		if (!g->backrefs && !(m->eflags&REG_BACKR)) {
+		if (!g->backrefs && !(m->eflags&MY_REG_BACKR)) {
 			NOTE("dissecting");
 			dp = dissect(charset, m, m->coldp, endp, gf, gl);
 		} else {
@@ -168,7 +168,7 @@ int eflags;
 			if (g->nplus > 0 && m->lastpos == NULL) {
 				free(m->pmatch);
 				STATETEARDOWN(m);
-				return(REG_ESPACE);
+				return(MY_REG_ESPACE);
 			}
 			NOTE("backref dissect");
 			dp = backref(charset, m, m->coldp, endp, gf, gl, (sopno)0);
@@ -444,7 +444,7 @@ sopno lev;			/* PLUS nesting level */
 	register size_t len;
 	register int hard;
 	register sop s;
-	register regoff_t offsave;
+	register my_regoff_t offsave;
 	register cset *cs;
 
 	AT("back", start, stop, startst, stopst);
@@ -469,25 +469,25 @@ sopno lev;			/* PLUS nesting level */
 				return(NULL);
 			break;
 		case OBOL:
-			if ( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
+			if ( (sp == m->beginp && !(m->eflags&MY_REG_NOTBOL)) ||
 					(sp < m->endp && *(sp-1) == '\n' &&
-						(m->g->cflags&REG_NEWLINE)) )
+						(m->g->cflags&MY_REG_NEWLINE)) )
 				{ /* yes */ }
 			else
 				return(NULL);
 			break;
 		case OEOL:
-			if ( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
+			if ( (sp == m->endp && !(m->eflags&MY_REG_NOTEOL)) ||
 					(sp < m->endp && *sp == '\n' &&
-						(m->g->cflags&REG_NEWLINE)) )
+						(m->g->cflags&MY_REG_NEWLINE)) )
 				{ /* yes */ }
 			else
 				return(NULL);
 			break;
 		case OBOW:
-			if (( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
+			if (( (sp == m->beginp && !(m->eflags&MY_REG_NOTBOL)) ||
 					(sp < m->endp && *(sp-1) == '\n' &&
-						(m->g->cflags&REG_NEWLINE)) ||
+						(m->g->cflags&MY_REG_NEWLINE)) ||
 					(sp > m->beginp &&
 							!ISWORD(charset,*(sp-1))) ) &&
 					(sp < m->endp && ISWORD(charset,*sp)) )
@@ -496,9 +496,9 @@ sopno lev;			/* PLUS nesting level */
 				return(NULL);
 			break;
 		case OEOW:
-			if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
+			if (( (sp == m->endp && !(m->eflags&MY_REG_NOTEOL)) ||
 					(sp < m->endp && *sp == '\n' &&
-						(m->g->cflags&REG_NEWLINE)) ||
+						(m->g->cflags&MY_REG_NEWLINE)) ||
 					(sp < m->endp && !ISWORD(charset,*sp)) ) &&
 					(sp > m->beginp && ISWORD(charset,*(sp-1))) )
 				{ /* yes */ }
@@ -665,13 +665,13 @@ sopno stopst;
 		/* is there an EOL and/or BOL between lastc and c? */
 		flagch = '\0';
 		i = 0;
-		if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
-				(lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
+		if ( (lastc == '\n' && m->g->cflags&MY_REG_NEWLINE) ||
+				(lastc == OUT && !(m->eflags&MY_REG_NOTBOL)) ) {
 			flagch = BOL;
 			i = m->g->nbol;
 		}
-		if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
-				(c == OUT && !(m->eflags&REG_NOTEOL)) ) {
+		if ( (c == '\n' && m->g->cflags&MY_REG_NEWLINE) ||
+				(c == OUT && !(m->eflags&MY_REG_NOTEOL)) ) {
 			flagch = (flagch == BOL) ? BOLEOL : EOL;
 			i += m->g->neol;
 		}
@@ -755,13 +755,13 @@ sopno stopst;
 		/* is there an EOL and/or BOL between lastc and c? */
 		flagch = '\0';
 		i = 0;
-		if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
-				(lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
+		if ( (lastc == '\n' && m->g->cflags&MY_REG_NEWLINE) ||
+				(lastc == OUT && !(m->eflags&MY_REG_NOTBOL)) ) {
 			flagch = BOL;
 			i = m->g->nbol;
 		}
-		if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
-				(c == OUT && !(m->eflags&REG_NOTEOL)) ) {
+		if ( (c == '\n' && m->g->cflags&MY_REG_NEWLINE) ||
+				(c == OUT && !(m->eflags&MY_REG_NOTEOL)) ) {
 			flagch = (flagch == BOL) ? BOLEOL : EOL;
 			i += m->g->neol;
 		}
@@ -954,7 +954,7 @@ FILE *d;
 	register int first = 1;
 	char buf[10];
 
-	if (!(m->eflags&REG_TRACE))
+	if (!(m->eflags&MY_REG_TRACE))
 		return;
 
 	fprintf(d, "%s", caption);
@@ -985,7 +985,7 @@ sopno startst;
 sopno stopst;
 {
 	char buf[10];
-	if (!(m->eflags&REG_TRACE))
+	if (!(m->eflags&MY_REG_TRACE))
 		return;
 
 	printf("%s %s-", title, printchar(*start,buf));

=== modified file 'regex/main.c'
--- a/regex/main.c	2005-09-29 01:20:31 +0000
+++ b/regex/main.c	2010-07-26 10:39:38 +0000
@@ -11,15 +11,45 @@ int debug = 0;
 int line = 0;
 int status = 0;
 
-int copts = REG_EXTENDED;
+int copts = MY_REG_EXTENDED;
 int eopts = 0;
-regoff_t startoff = 0;
-regoff_t endoff = 0;
+my_regoff_t startoff = 0;
+my_regoff_t endoff = 0;
 
 
 extern int split();
 extern void regprint();
 
+
+#ifdef __WIN__
+char *optarg= "";
+int optind= 1;
+int opterr;
+
+/* A (very) simplified version of getopt, enough to run the registered tests. */
+int getopt(int argc, char *argv[], const char *optstring)
+{
+  char *opt= NULL;
+  int retval= -1;
+  if (optind >= argc)
+    return retval;
+
+  opt= argv[optind];
+  if (*opt != '-')
+    return retval;
+
+  retval= *(opt+1);
+  if (*(opt+1) && *(opt+2))
+    optarg= opt + 2;
+  else
+    optarg= "";
+
+  ++optind;
+  return retval;
+}
+#endif
+
+
 /*
  - main - do the simple case, hand off to regress() for regression
  */
@@ -36,12 +66,13 @@ char *argv[];
 	int c;
 	int errflg = 0;
 	register int i;
+        char *input_file_name= NULL;
 	extern int optind;
 	extern char *optarg;
 
 	progname = argv[0];
 
-	while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF)
+	while ((c = getopt(argc, argv, "c:e:i:S:E:x")) != EOF)
 		switch (c) {
 		case 'c':	/* compile options */
 			copts = options('c', optarg);
@@ -49,11 +80,14 @@ char *argv[];
 		case 'e':	/* execute options */
 			eopts = options('e', optarg);
 			break;
+                case 'i':
+                        input_file_name= optarg;
+			break;
 		case 'S':	/* start offset */
-			startoff = (regoff_t)atoi(optarg);
+			startoff = (my_regoff_t)atoi(optarg);
 			break;
 		case 'E':	/* end offset */
-			endoff = (regoff_t)atoi(optarg);
+			endoff = (my_regoff_t)atoi(optarg);
 			break;
 		case 'x':	/* Debugging. */
 			debug++;
@@ -65,15 +99,28 @@ char *argv[];
 		}
 	if (errflg) {
 		fprintf(stderr, "usage: %s ", progname);
-		fprintf(stderr, "[-c copt][-C][-d] [re]\n");
+		fprintf(stderr,
+                        "[-c copt][-e eopt][-i filename][-S][-E][-x] [re]\n");
 		exit(2);
 	}
 
-	if (optind >= argc) {
+	if (optind >= argc && !input_file_name) {
 		regress(stdin);
 		exit(status);
 	}
 
+        if (input_file_name) {
+          FILE *input_file= fopen(input_file_name, "r");
+          if (!input_file) {
+            fprintf(stderr, "Could not open '%s' : ", input_file_name);
+            perror(NULL);
+            exit(EXIT_FAILURE);
+          }
+          regress(input_file);
+          fclose(input_file);
+          exit(status);
+        }
+
 	err = my_regcomp(&re, argv[optind++], copts, &my_charset_latin1);
 	if (err) {
 		len = my_regerror(err, &re, erbuf, sizeof(erbuf));
@@ -88,7 +135,7 @@ char *argv[];
 		exit(status);
 	}
 
-	if (eopts&REG_STARTEND) {
+	if (eopts&MY_REG_STARTEND) {
 		subs[0].rm_so = startoff;
 		subs[0].rm_eo = strlen(argv[optind]) - endoff;
 	}
@@ -99,7 +146,7 @@ char *argv[];
 			eprint(err), (int) len, (int) sizeof(erbuf), erbuf);
 		exit(status);
 	}
-	if (!(copts&REG_NOSUB)) {
+	if (!(copts&MY_REG_NOSUB)) {
 		len = (int)(subs[0].rm_eo - subs[0].rm_so);
 		if (subs[0].rm_so != -1) {
 			if (len != 0)
@@ -135,7 +182,7 @@ FILE *in;
 	size_t ne;
 	const char *badpat = "invalid regular expression";
 #	define	SHORT	10
-	const char *bpname = "REG_BADPAT";
+	const char *bpname = "MY_REG_BADPAT";
 	my_regex_t re;
 
 	while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
@@ -160,37 +207,37 @@ FILE *in;
 		rx_try(f[0], f[1], f[2], f[3], f[4], options('c', f[1]));
 		if (opt('&', f[1]))	/* try with either type of RE */
 			rx_try(f[0], f[1], f[2], f[3], f[4],
-					options('c', f[1]) &~ REG_EXTENDED);
+					options('c', f[1]) &~ MY_REG_EXTENDED);
 	}
 
-	ne = my_regerror(REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
+	ne = my_regerror(MY_REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
 	if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
 		fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
 							erbuf, badpat);
 		status = 1;
 	}
-	ne = my_regerror(REG_BADPAT, (my_regex_t *)NULL, erbuf, (size_t)SHORT);
+	ne = my_regerror(MY_REG_BADPAT, (my_regex_t *)NULL, erbuf, (size_t)SHORT);
 	if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
 						ne != strlen(badpat)+1) {
 		fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
 						erbuf, SHORT-1, badpat);
 		status = 1;
 	}
-	ne = my_regerror(REG_ITOA|REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
+	ne = my_regerror(MY_REG_ITOA|MY_REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
 	if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
 		fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
 						erbuf, bpname);
 		status = 1;
 	}
 	re.re_endp = bpname;
-	ne = my_regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
-	if (atoi(erbuf) != (int)REG_BADPAT) {
+	ne = my_regerror(MY_REG_ATOI, &re, erbuf, sizeof(erbuf));
+	if (atoi(erbuf) != (int)MY_REG_BADPAT) {
 		fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
-						erbuf, (long)REG_BADPAT);
+						erbuf, (long)MY_REG_BADPAT);
 		status = 1;
 	} else if (ne != strlen(erbuf)+1) {
 		fprintf(stderr, "end: regerror() ATOI test len(`%s') = %ld\n",
-						erbuf, (long)REG_BADPAT);
+						erbuf, (long)MY_REG_BADPAT);
 		status = 1;
 	}
 }
@@ -217,14 +264,14 @@ int opts;			/* may not match f1 */
 	char erbuf[100];
 	int err;
 	int len;
-	const char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
+	const char *type = (opts & MY_REG_EXTENDED) ? "ERE" : "BRE";
 	register int i;
 	char *grump;
 	char f0copy[1000];
 	char f2copy[1000];
 
 	strcpy(f0copy, f0);
-	re.re_endp = (opts&REG_PEND) ? f0copy + strlen(f0copy) : NULL;
+	re.re_endp = (opts&MY_REG_PEND) ? f0copy + strlen(f0copy) : NULL;
 	fixstr(f0copy);
 	err = my_regcomp(&re, f0copy, opts, &my_charset_latin1);
 	if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
@@ -236,7 +283,7 @@ int opts;			/* may not match f1 */
 		status = 1;
 	} else if (err == 0 && opt('C', f1)) {
 		/* unexpected success */
-		fprintf(stderr, "%d: %s should have given REG_%s\n",
+		fprintf(stderr, "%d: %s should have given MY_REG_%s\n",
 						line, type, f2);
 		status = 1;
 		err = 1;	/* so we won't try regexec */
@@ -250,7 +297,7 @@ int opts;			/* may not match f1 */
 	strcpy(f2copy, f2);
 	fixstr(f2copy);
 
-	if (options('e', f1)&REG_STARTEND) {
+	if (options('e', f1)&MY_REG_STARTEND) {
 		if (strchr(f2, '(') == NULL || strchr(f2, ')') == NULL)
 			fprintf(stderr, "%d: bad STARTEND syntax\n", line);
 		subs[0].rm_so = strchr(f2, '(') - f2 + 1;
@@ -258,7 +305,7 @@ int opts;			/* may not match f1 */
 	}
 	err = my_regexec(&re, f2copy, NSUBS, subs, options('e', f1));
 
-	if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
+	if (err != 0 && (f3 != NULL || err != MY_REG_NOMATCH)) {
 		/* unexpected error or wrong error */
 		len = my_regerror(err, &re, erbuf, sizeof(erbuf));
 		fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
@@ -273,7 +320,7 @@ int opts;			/* may not match f1 */
 						line, type);
 		status = 1;
 		err = 1;		/* just on principle */
-	} else if (opts&REG_NOSUB) {
+	} else if (opts&MY_REG_NOSUB) {
 		/* nothing more to check */
 	} else if ((grump = check(f2, subs[0], f3)) != NULL) {
 		fprintf(stderr, "%d: %s %s\n", line, type, grump);
@@ -323,41 +370,41 @@ char *s;
 		if (strchr(legal, *p) != NULL)
 			switch (*p) {
 			case 'b':
-				o &= ~REG_EXTENDED;
+				o &= ~MY_REG_EXTENDED;
 				break;
 			case 'i':
-				o |= REG_ICASE;
+				o |= MY_REG_ICASE;
 				break;
 			case 's':
-				o |= REG_NOSUB;
+				o |= MY_REG_NOSUB;
 				break;
 			case 'n':
-				o |= REG_NEWLINE;
+				o |= MY_REG_NEWLINE;
 				break;
 			case 'm':
-				o &= ~REG_EXTENDED;
-				o |= REG_NOSPEC;
+				o &= ~MY_REG_EXTENDED;
+				o |= MY_REG_NOSPEC;
 				break;
 			case 'p':
-				o |= REG_PEND;
+				o |= MY_REG_PEND;
 				break;
 			case '^':
-				o |= REG_NOTBOL;
+				o |= MY_REG_NOTBOL;
 				break;
 			case '$':
-				o |= REG_NOTEOL;
+				o |= MY_REG_NOTEOL;
 				break;
 			case '#':
-				o |= REG_STARTEND;
+				o |= MY_REG_STARTEND;
 				break;
 			case 't':	/* trace */
-				o |= REG_TRACE;
+				o |= MY_REG_TRACE;
 				break;
 			case 'l':	/* force long representation */
-				o |= REG_LARGE;
+				o |= MY_REG_LARGE;
 				break;
 			case 'r':	/* force backref use */
-				o |= REG_BACKR;
+				o |= MY_REG_BACKR;
 				break;
 			}
 	return(o);
@@ -485,7 +532,7 @@ int err;
 	static char epbuf[100];
 	size_t len;
 
-	len = my_regerror(REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
+	len = my_regerror(MY_REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
 	assert(len <= sizeof(epbuf));
 	return(epbuf);
 }
@@ -501,9 +548,9 @@ char *name;
 	static char efbuf[100];
 	my_regex_t re;
 
-	sprintf(efbuf, "REG_%s", name);
+	sprintf(efbuf, "MY_REG_%s", name);
 	assert(strlen(efbuf) < sizeof(efbuf));
 	re.re_endp = efbuf;
-	(void) my_regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
+	(void) my_regerror(MY_REG_ATOI, &re, efbuf, sizeof(efbuf));
 	return(atoi(efbuf));
 }

=== modified file 'regex/my_regex.h'
--- a/regex/my_regex.h	2005-09-29 00:08:24 +0000
+++ b/regex/my_regex.h	2010-07-26 10:39:38 +0000
@@ -1,74 +1,75 @@
 #ifndef _REGEX_H_
 #define	_REGEX_H_	/* never again */
 /* ========= begin header generated by ./mkh ========= */
+
+#include "m_ctype.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "m_ctype.h"
-
 /* === regex2.h === */
 #ifdef _WIN64
-typedef __int64 regoff_t;
+typedef __int64 my_regoff_t;
 #else
-typedef off_t regoff_t;
+typedef off_t my_regoff_t;
 #endif
 struct re_guts;			/* none of your business :-) */
 typedef struct {
 	int re_magic;
 	size_t re_nsub;		/* number of parenthesized subexpressions */
-	const char *re_endp;	/* end pointer for REG_PEND */
+	const char *re_endp;	/* end pointer for MY_REG_PEND */
 	struct re_guts *re_g;	/* none of your business :-) */
 	CHARSET_INFO *charset;	/* For ctype things */
 } my_regex_t;
 typedef struct {
-	regoff_t rm_so;		/* start of match */
-	regoff_t rm_eo;		/* end of match */
+	my_regoff_t rm_so;		/* start of match */
+	my_regoff_t rm_eo;		/* end of match */
 } my_regmatch_t;
 
 
 /* === regcomp.c === */
 extern int my_regcomp(my_regex_t *, const char *, int, CHARSET_INFO *charset);
-#define	REG_BASIC	0000
-#define	REG_EXTENDED	0001
-#define	REG_ICASE	0002
-#define	REG_NOSUB	0004
-#define	REG_NEWLINE	0010
-#define	REG_NOSPEC	0020
-#define	REG_PEND	0040
-#define	REG_DUMP	0200
+#define	MY_REG_BASIC	0000
+#define	MY_REG_EXTENDED	0001
+#define	MY_REG_ICASE	0002
+#define	MY_REG_NOSUB	0004
+#define	MY_REG_NEWLINE	0010
+#define	MY_REG_NOSPEC	0020
+#define	MY_REG_PEND	0040
+#define	MY_REG_DUMP	0200
 
 
 /* === regerror.c === */
-#define	REG_NOMATCH	 1
-#define	REG_BADPAT	 2
-#define	REG_ECOLLATE	 3
-#define	REG_ECTYPE	 4
-#define	REG_EESCAPE	 5
-#define	REG_ESUBREG	 6
-#define	REG_EBRACK	 7
-#define	REG_EPAREN	 8
-#define	REG_EBRACE	 9
-#define	REG_BADBR	10
-#define	REG_ERANGE	11
-#define	REG_ESPACE	12
-#define	REG_BADRPT	13
-#define	REG_EMPTY	14
-#define	REG_ASSERT	15
-#define	REG_INVARG	16
-#define	REG_ATOI	255	/* convert name to number (!) */
-#define	REG_ITOA	0400	/* convert number to name (!) */
+#define	MY_REG_NOMATCH	 1
+#define	MY_REG_BADPAT	 2
+#define	MY_REG_ECOLLATE	 3
+#define	MY_REG_ECTYPE	 4
+#define	MY_REG_EESCAPE	 5
+#define	MY_REG_ESUBREG	 6
+#define	MY_REG_EBRACK	 7
+#define	MY_REG_EPAREN	 8
+#define	MY_REG_EBRACE	 9
+#define	MY_REG_BADBR	10
+#define	MY_REG_ERANGE	11
+#define	MY_REG_ESPACE	12
+#define	MY_REG_BADRPT	13
+#define	MY_REG_EMPTY	14
+#define	MY_REG_ASSERT	15
+#define	MY_REG_INVARG	16
+#define	MY_REG_ATOI	255	/* convert name to number (!) */
+#define	MY_REG_ITOA	0400	/* convert number to name (!) */
 extern size_t my_regerror(int, const my_regex_t *, char *, size_t);
 
 
 /* === regexec.c === */
 extern int my_regexec(const my_regex_t *, const char *, size_t, my_regmatch_t [], int);
-#define	REG_NOTBOL	00001
-#define	REG_NOTEOL	00002
-#define	REG_STARTEND	00004
-#define	REG_TRACE	00400	/* tracing of execution */
-#define	REG_LARGE	01000	/* force large representation */
-#define	REG_BACKR	02000	/* force use of backref code */
+#define	MY_REG_NOTBOL	00001
+#define	MY_REG_NOTEOL	00002
+#define	MY_REG_STARTEND	00004
+#define	MY_REG_TRACE	00400	/* tracing of execution */
+#define	MY_REG_LARGE	01000	/* force large representation */
+#define	MY_REG_BACKR	02000	/* force use of backref code */
 
 
 /* === regfree.c === */

=== modified file 'regex/regcomp.c'
--- a/regex/regcomp.c	2010-07-23 20:16:29 +0000
+++ b/regex/regcomp.c	2010-07-26 10:39:38 +0000
@@ -90,16 +90,16 @@ static int never = 0;		/* for use in ass
 /*
  - regcomp - interface for parser and compilation
  = extern int regcomp(regex_t *, const char *, int);
- = #define	REG_BASIC	0000
- = #define	REG_EXTENDED	0001
- = #define	REG_ICASE	0002
- = #define	REG_NOSUB	0004
- = #define	REG_NEWLINE	0010
- = #define	REG_NOSPEC	0020
- = #define	REG_PEND	0040
- = #define	REG_DUMP	0200
+ = #define	MY_REG_BASIC	0000
+ = #define	MY_REG_EXTENDED	0001
+ = #define	MY_REG_ICASE	0002
+ = #define	MY_REG_NOSUB	0004
+ = #define	MY_REG_NEWLINE	0010
+ = #define	MY_REG_NOSPEC	0020
+ = #define	MY_REG_PEND	0040
+ = #define	MY_REG_DUMP	0200
  */
-int				/* 0 success, otherwise REG_something */
+int				/* 0 success, otherwise MY_REG_something */
 my_regcomp(preg, pattern, cflags, charset)
 my_regex_t *preg;
 const char *pattern;
@@ -114,18 +114,18 @@ CHARSET_INFO *charset;
 #ifdef REDEBUG
 #	define	GOODFLAGS(f)	(f)
 #else
-#	define	GOODFLAGS(f)	((f)&~REG_DUMP)
+#	define	GOODFLAGS(f)	((f)&~MY_REG_DUMP)
 #endif
 
 	my_regex_init(charset);	/* Init cclass if neaded */
 	preg->charset=charset;
 	cflags = GOODFLAGS(cflags);
-	if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC))
-		return(REG_INVARG);
+	if ((cflags&MY_REG_EXTENDED) && (cflags&MY_REG_NOSPEC))
+		return(MY_REG_INVARG);
 
-	if (cflags&REG_PEND) {
+	if (cflags&MY_REG_PEND) {
 		if (preg->re_endp < pattern)
-			return(REG_INVARG);
+			return(MY_REG_INVARG);
 		len = preg->re_endp - pattern;
 	} else
 		len = strlen((char *)pattern);
@@ -134,13 +134,13 @@ CHARSET_INFO *charset;
 	g = (struct re_guts *)malloc(sizeof(struct re_guts) +
 							(NC-1)*sizeof(cat_t));
 	if (g == NULL)
-		return(REG_ESPACE);
+		return(MY_REG_ESPACE);
 	p->ssize = (long) (len/(size_t)2*(size_t)3 + (size_t)1); /* ugh */
 	p->strip = (sop *)malloc(p->ssize * sizeof(sop));
 	p->slen = 0;
 	if (p->strip == NULL) {
 		free((char *)g);
-		return(REG_ESPACE);
+		return(MY_REG_ESPACE);
 	}
 
 	/* set things up */
@@ -173,9 +173,9 @@ CHARSET_INFO *charset;
 	/* do it */
 	EMIT(OEND, 0);
 	g->firststate = THERE();
-	if (cflags&REG_EXTENDED)
+	if (cflags&MY_REG_EXTENDED)
 		p_ere(p, OUT);
-	else if (cflags&REG_NOSPEC)
+	else if (cflags&MY_REG_NOSPEC)
 		p_str(p);
 	else
 		p_bre(p, OUT, OUT);
@@ -194,7 +194,7 @@ CHARSET_INFO *charset;
 #ifndef REDEBUG
 	/* not debugging, so can't rely on the assert() in regexec() */
 	if (g->iflags&BAD)
-		SETERROR(REG_ASSERT);
+		SETERROR(MY_REG_ASSERT);
 #endif
 
 	/* win or lose, we're done */
@@ -223,7 +223,7 @@ int stop;			/* character this ERE should
 		conc = HERE();
 		while (MORE() && (c = PEEK()) != '|' && c != stop)
 			p_ere_exp(p);
-		if(REQUIRE(HERE() != conc, REG_EMPTY)) {}/* require nonempty */
+		if(REQUIRE(HERE() != conc, MY_REG_EMPTY)) {}/* require nonempty */
 
 		if (!EAT('|'))
 			break;		/* NOTE BREAK OUT */
@@ -270,7 +270,7 @@ register struct parse *p;
 	pos = HERE();
 	switch (c) {
 	case '(':
-		if(REQUIRE(MORE(), REG_EPAREN)) {}
+		if(REQUIRE(MORE(), MY_REG_EPAREN)) {}
 		p->g->nsub++;
 		subno = (sopno) p->g->nsub;
 		if (subno < NPAREN)
@@ -283,7 +283,7 @@ register struct parse *p;
 			assert(p->pend[subno] != 0);
 		}
 		EMIT(ORPAREN, subno);
-		if(MUSTEAT(')', REG_EPAREN)) {}
+		if(MUSTEAT(')', MY_REG_EPAREN)) {}
 		break;
 	case '^':
 		EMIT(OBOL, 0);
@@ -297,15 +297,15 @@ register struct parse *p;
 		p->g->neol++;
 		break;
 	case '|':
-		SETERROR(REG_EMPTY);
+		SETERROR(MY_REG_EMPTY);
 		break;
 	case '*':
 	case '+':
 	case '?':
-		SETERROR(REG_BADRPT);
+		SETERROR(MY_REG_BADRPT);
 		break;
 	case '.':
-		if (p->g->cflags&REG_NEWLINE)
+		if (p->g->cflags&MY_REG_NEWLINE)
 			nonnewline(p);
 		else
 			EMIT(OANY, 0);
@@ -314,12 +314,12 @@ register struct parse *p;
 		p_bracket(p);
 		break;
 	case '\\':
-		if(REQUIRE(MORE(), REG_EESCAPE)) {}
+		if(REQUIRE(MORE(), MY_REG_EESCAPE)) {}
 		c = GETNEXT();
 		ordinary(p, c);
 		break;
 	case '{':		/* okay as ordinary except if digit follows */
-		if(REQUIRE(!MORE() || !my_isdigit(p->charset,PEEK()), REG_BADRPT)) {}
+		if(REQUIRE(!MORE() || !my_isdigit(p->charset,PEEK()), MY_REG_BADRPT)) {}
 		/* FALLTHROUGH */
 	default:
 		ordinary(p, c);
@@ -336,7 +336,7 @@ register struct parse *p;
 		return;		/* no repetition, we're done */
 	NEXT();
 
-	if(REQUIRE(!wascaret, REG_BADRPT)) {}
+	if(REQUIRE(!wascaret, MY_REG_BADRPT)) {}
 	switch (c) {
 	case '*':	/* implemented as +? */
 		/* this case does not require the (y|) trick, noKLUDGE */
@@ -363,7 +363,7 @@ register struct parse *p;
 		if (EAT(',')) {
 			if (my_isdigit(p->charset,PEEK())) {
 				count2 = p_count(p);
-				if(REQUIRE(count <= count2, REG_BADBR)) {}
+				if(REQUIRE(count <= count2, MY_REG_BADBR)) {}
 			} else		/* single number with comma */
 				count2 = RE_INFINITY;
 		} else		/* just a single number */
@@ -372,8 +372,8 @@ register struct parse *p;
 		if (!EAT('}')) {	/* error heuristics */
 			while (MORE() && PEEK() != '}')
 				NEXT();
-			if(REQUIRE(MORE(), REG_EBRACE)) {}
-			SETERROR(REG_BADBR);
+			if(REQUIRE(MORE(), MY_REG_EBRACE)) {}
+			SETERROR(MY_REG_BADBR);
 		}
 		break;
 	}
@@ -385,7 +385,7 @@ register struct parse *p;
 				(c == '{' && MORE2() && 
 				 my_isdigit(p->charset,PEEK2())) ) )
 		return;
-	SETERROR(REG_BADRPT);
+	SETERROR(MY_REG_BADRPT);
 }
 
 /*
@@ -396,7 +396,7 @@ static void
 p_str(p)
 register struct parse *p;
 {
-	if(REQUIRE(MORE(), REG_EMPTY)) {}
+	if(REQUIRE(MORE(), MY_REG_EMPTY)) {}
 	while (MORE())
 		ordinary(p, GETNEXT());
 }
@@ -439,7 +439,7 @@ register int end2;		/* second terminatin
 		p->g->neol++;
 	}
 
-	if(REQUIRE(HERE() != start, REG_EMPTY)) {}	/* require nonempty */
+	if(REQUIRE(HERE() != start, MY_REG_EMPTY)) {}	/* require nonempty */
 }
 
 /*
@@ -464,12 +464,12 @@ int starordinary;		/* is a leading * an 
 	assert(MORE());		/* caller should have ensured this */
 	c = GETNEXT();
 	if (c == '\\') {
-		if(REQUIRE(MORE(), REG_EESCAPE)) {}
+		if(REQUIRE(MORE(), MY_REG_EESCAPE)) {}
 		c = BACKSL | (unsigned char)GETNEXT();
 	}
 	switch (c) {
 	case '.':
-		if (p->g->cflags&REG_NEWLINE)
+		if (p->g->cflags&MY_REG_NEWLINE)
 			nonnewline(p);
 		else
 			EMIT(OANY, 0);
@@ -478,7 +478,7 @@ int starordinary;		/* is a leading * an 
 		p_bracket(p);
 		break;
 	case BACKSL|'{':
-		SETERROR(REG_BADRPT);
+		SETERROR(MY_REG_BADRPT);
 		break;
 	case BACKSL|'(':
 		p->g->nsub++;
@@ -494,11 +494,11 @@ int starordinary;		/* is a leading * an 
 			assert(p->pend[subno] != 0);
 		}
 		EMIT(ORPAREN, subno);
-		if(REQUIRE(EATTWO('\\', ')'), REG_EPAREN)) {}
+		if(REQUIRE(EATTWO('\\', ')'), MY_REG_EPAREN)) {}
 		break;
 	case BACKSL|')':	/* should not get here -- must be user */
 	case BACKSL|'}':
-		SETERROR(REG_EPAREN);
+		SETERROR(MY_REG_EPAREN);
 		break;
 	case BACKSL|'1':
 	case BACKSL|'2':
@@ -520,11 +520,11 @@ int starordinary;		/* is a leading * an 
 			(void) dupl(p, p->pbegin[i]+1, p->pend[i]);
 			EMIT(O_BACK, i);
 		} else
-			SETERROR(REG_ESUBREG);
+			SETERROR(MY_REG_ESUBREG);
 		p->g->backrefs = 1;
 		break;
 	case '*':
-		if(REQUIRE(starordinary, REG_BADRPT)) {}
+		if(REQUIRE(starordinary, MY_REG_BADRPT)) {}
 		/* FALLTHROUGH */
 	default:
 		ordinary(p, c &~ BACKSL);
@@ -542,7 +542,7 @@ int starordinary;		/* is a leading * an 
 		if (EAT(',')) {
 			if (MORE() && my_isdigit(p->charset,PEEK())) {
 				count2 = p_count(p);
-				if(REQUIRE(count <= count2, REG_BADBR)) {}
+				if(REQUIRE(count <= count2, MY_REG_BADBR)) {}
 			} else		/* single number with comma */
 				count2 = RE_INFINITY;
 		} else		/* just a single number */
@@ -551,8 +551,8 @@ int starordinary;		/* is a leading * an 
 		if (!EATTWO('\\', '}')) {	/* error heuristics */
 			while (MORE() && !SEETWO('\\', '}'))
 				NEXT();
-			if(REQUIRE(MORE(), REG_EBRACE)) {}
-			SETERROR(REG_BADBR);
+			if(REQUIRE(MORE(), MY_REG_EBRACE)) {}
+			SETERROR(MY_REG_BADBR);
 		}
 	} else if (c == (unsigned char)'$')	/* $ (but not \$) ends it */
 		return(1);
@@ -576,7 +576,7 @@ register struct parse *p;
 		ndigits++;
 	}
 
-	if(REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR)) {}
+	if(REQUIRE(ndigits > 0 && count <= DUPMAX, MY_REG_BADBR)) {}
 	return(count);
 }
 
@@ -616,12 +616,12 @@ register struct parse *p;
 		p_b_term(p, cs);
 	if (EAT('-'))
 		CHadd(cs, '-');
-	if(MUSTEAT(']', REG_EBRACK)) {}
+	if(MUSTEAT(']', MY_REG_EBRACK)) {}
 
 	if (p->error != 0)	/* don't mess things up further */
 		return;
 
-	if (p->g->cflags&REG_ICASE) {
+	if (p->g->cflags&MY_REG_ICASE) {
 		register int i;
 		register int ci;
 
@@ -642,7 +642,7 @@ register struct parse *p;
 				CHsub(cs, i);
 			else
 				CHadd(cs, i);
-		if (p->g->cflags&REG_NEWLINE)
+		if (p->g->cflags&MY_REG_NEWLINE)
 			CHsub(cs, '\n');
 		if (cs->multis != NULL)
 			mcinvert(p, cs);
@@ -676,7 +676,7 @@ register cset *cs;
 		c = (MORE2()) ? PEEK2() : '\0';
 		break;
 	case '-':
-		SETERROR(REG_ERANGE);
+		SETERROR(MY_REG_ERANGE);
 		return;			/* NOTE RETURN */
 	default:
 		c = '\0';
@@ -686,21 +686,21 @@ register cset *cs;
 	switch (c) {
 	case ':':		/* character class */
 		NEXT2();
-		if(REQUIRE(MORE(), REG_EBRACK)) {}
+		if(REQUIRE(MORE(), MY_REG_EBRACK)) {}
 		c = PEEK();
-		if(REQUIRE(c != '-' && c != ']', REG_ECTYPE)) {}
+		if(REQUIRE(c != '-' && c != ']', MY_REG_ECTYPE)) {}
 		p_b_cclass(p, cs);
-		if(REQUIRE(MORE(), REG_EBRACK)) {}
-		if(REQUIRE(EATTWO(':', ']'), REG_ECTYPE)) {}
+		if(REQUIRE(MORE(), MY_REG_EBRACK)) {}
+		if(REQUIRE(EATTWO(':', ']'), MY_REG_ECTYPE)) {}
 		break;
 	case '=':		/* equivalence class */
 		NEXT2();
-		if(REQUIRE(MORE(), REG_EBRACK)) {}
+		if(REQUIRE(MORE(), MY_REG_EBRACK)) {}
 		c = PEEK();
-		if(REQUIRE(c != '-' && c != ']', REG_ECOLLATE)) {}
+		if(REQUIRE(c != '-' && c != ']', MY_REG_ECOLLATE)) {}
 		p_b_eclass(p, cs);
-		if(REQUIRE(MORE(), REG_EBRACK)) {}
-		if(REQUIRE(EATTWO('=', ']'), REG_ECOLLATE)) {}
+		if(REQUIRE(MORE(), MY_REG_EBRACK)) {}
+		if(REQUIRE(EATTWO('=', ']'), MY_REG_ECOLLATE)) {}
 		break;
 	default:		/* symbol, ordinary character, or range */
 /* xxx revision needed for multichar stuff */
@@ -715,7 +715,7 @@ register cset *cs;
 		} else
 			finish = start;
 /* xxx what about signed chars here... */
-		if(REQUIRE(start <= finish, REG_ERANGE)) {}
+		if(REQUIRE(start <= finish, MY_REG_ERANGE)) {}
 		for (i = start; i <= finish; i++)
 			CHadd(cs, i);
 		break;
@@ -743,7 +743,7 @@ register cset *cs;
 			break;
 	if (cp->name == NULL) {
 		/* oops, didn't find it */
-		SETERROR(REG_ECTYPE);
+		SETERROR(MY_REG_ECTYPE);
 		return;
 	}
 
@@ -796,13 +796,13 @@ register struct parse *p;
 {
 	register char value;
 
-	if(REQUIRE(MORE(), REG_EBRACK)) {}
+	if(REQUIRE(MORE(), MY_REG_EBRACK)) {}
 	if (!EATTWO('[', '.'))
 		return(GETNEXT());
 
 	/* collating symbol */
 	value = p_b_coll_elem(p, '.');
-	if(REQUIRE(EATTWO('.', ']'), REG_ECOLLATE)) {}
+	if(REQUIRE(EATTWO('.', ']'), MY_REG_ECOLLATE)) {}
 	return(value);
 }
 
@@ -825,7 +825,7 @@ int endc;			/* name ended by endc,']' */
 	while (MORE() && !SEETWO(endc, ']'))
 		NEXT();
 	if (!MORE()) {
-		SETERROR(REG_EBRACK);
+		SETERROR(MY_REG_EBRACK);
 		return(0);
 	}
 	len = p->next - sp;
@@ -834,7 +834,7 @@ int endc;			/* name ended by endc,']' */
 			return(cp->code);	/* known name */
 	if (len == 1)
 		return(*sp);	/* single character */
-	SETERROR(REG_ECOLLATE);			/* neither */
+	SETERROR(MY_REG_ECOLLATE);			/* neither */
 	return(0);
 }
 
@@ -911,7 +911,7 @@ register int ch;
 {
 	register cat_t *cap = p->g->categories;
 
-	if ((p->g->cflags&REG_ICASE) && my_isalpha(p->charset,ch) && 
+	if ((p->g->cflags&MY_REG_ICASE) && my_isalpha(p->charset,ch) && 
 	     othercase(p->charset,ch) != ch)
 		bothcases(p, ch);
 	else {
@@ -922,7 +922,7 @@ register int ch;
 }
 
 /*
- - nonnewline - emit REG_NEWLINE version of OANY
+ - nonnewline - emit MY_REG_NEWLINE version of OANY
  == static void nonnewline(register struct parse *p);
  *
  * Boy, is this implementation ever a kludge...
@@ -1014,7 +1014,7 @@ int to;				/* to this number of times (m
 		repeat(p, copy, from-1, to);
 		break;
 	default:			/* "can't happen" */
-		SETERROR(REG_ASSERT);	/* just in case */
+		SETERROR(MY_REG_ASSERT);	/* just in case */
 		break;
 	}
 }
@@ -1074,7 +1074,7 @@ register struct parse *p;
 								0, css);
 		else {
 			no = 0;
-			SETERROR(REG_ESPACE);
+			SETERROR(MY_REG_ESPACE);
 			/* caller's responsibility not to do set ops */
 		}
 	}
@@ -1115,7 +1115,7 @@ register cset *cs;
  *
  * The main task here is merging identical sets.  This is usually a waste
  * of time (although the hash code minimizes the overhead), but can win
- * big if REG_ICASE is being used.  REG_ICASE, by the way, is why the hash
+ * big if MY_REG_ICASE is being used.  MY_REG_ICASE, by the way, is why the hash
  * is done using addition rather than xor -- all ASCII [aA] sets xor to
  * the same value!
  */
@@ -1207,7 +1207,7 @@ register char *cp;
 	else
 		cs->multis = realloc(cs->multis, cs->smultis);
 	if (cs->multis == NULL) {
-		SETERROR(REG_ESPACE);
+		SETERROR(MY_REG_ESPACE);
 		return;
 	}
 
@@ -1451,7 +1451,7 @@ register sopno size;
 
 	sp = (sop *)realloc(p->strip, size*sizeof(sop));
 	if (sp == NULL) {
-		SETERROR(REG_ESPACE);
+		SETERROR(MY_REG_ESPACE);
 		return;
 	}
 	p->strip = sp;
@@ -1470,7 +1470,7 @@ register struct re_guts *g;
 	g->nstates = p->slen;
 	g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop));
 	if (g->strip == NULL) {
-		SETERROR(REG_ESPACE);
+		SETERROR(MY_REG_ESPACE);
 		g->strip = p->strip;
 	}
 }

=== modified file 'regex/regerror.c'
--- a/regex/regerror.c	2005-09-29 01:20:31 +0000
+++ b/regex/regerror.c	2010-07-26 10:39:38 +0000
@@ -7,46 +7,46 @@
 #include "regerror.ih"
 
 /*
- = #define	REG_NOMATCH	 1
- = #define	REG_BADPAT	 2
- = #define	REG_ECOLLATE	 3
- = #define	REG_ECTYPE	 4
- = #define	REG_EESCAPE	 5
- = #define	REG_ESUBREG	 6
- = #define	REG_EBRACK	 7
- = #define	REG_EPAREN	 8
- = #define	REG_EBRACE	 9
- = #define	REG_BADBR	10
- = #define	REG_ERANGE	11
- = #define	REG_ESPACE	12
- = #define	REG_BADRPT	13
- = #define	REG_EMPTY	14
- = #define	REG_ASSERT	15
- = #define	REG_INVARG	16
- = #define	REG_ATOI	255	// convert name to number (!)
- = #define	REG_ITOA	0400	// convert number to name (!)
+ = #define	MY_REG_NOMATCH	 1
+ = #define	MY_REG_BADPAT	 2
+ = #define	MY_REG_ECOLLATE	 3
+ = #define	MY_REG_ECTYPE	 4
+ = #define	MY_REG_EESCAPE	 5
+ = #define	MY_REG_ESUBREG	 6
+ = #define	MY_REG_EBRACK	 7
+ = #define	MY_REG_EPAREN	 8
+ = #define	MY_REG_EBRACE	 9
+ = #define	MY_REG_BADBR	10
+ = #define	MY_REG_ERANGE	11
+ = #define	MY_REG_ESPACE	12
+ = #define	MY_REG_BADRPT	13
+ = #define	MY_REG_EMPTY	14
+ = #define	MY_REG_ASSERT	15
+ = #define	MY_REG_INVARG	16
+ = #define	MY_REG_ATOI	255	// convert name to number (!)
+ = #define	MY_REG_ITOA	0400	// convert number to name (!)
  */
 static struct rerr {
 	int code;
 	const char *name;
         const char *explain;
 } rerrs[] = {
-	{REG_NOMATCH,	"REG_NOMATCH",	"regexec() failed to match"},
-	{REG_BADPAT,	"REG_BADPAT",	"invalid regular expression"},
-	{REG_ECOLLATE,	"REG_ECOLLATE",	"invalid collating element"},
-	{REG_ECTYPE,	"REG_ECTYPE",	"invalid character class"},
-	{REG_EESCAPE,	"REG_EESCAPE",	"trailing backslash (\\)"},
-	{REG_ESUBREG,	"REG_ESUBREG",	"invalid backreference number"},
-	{REG_EBRACK,	"REG_EBRACK",	"brackets ([ ]) not balanced"},
-	{REG_EPAREN,	"REG_EPAREN",	"parentheses not balanced"},
-	{REG_EBRACE,	"REG_EBRACE",	"braces not balanced"},
-	{REG_BADBR,	"REG_BADBR",	"invalid repetition count(s)"},
-	{REG_ERANGE,	"REG_ERANGE",	"invalid character range"},
-	{REG_ESPACE,	"REG_ESPACE",	"out of memory"},
-	{REG_BADRPT,	"REG_BADRPT",	"repetition-operator operand invalid"},
-	{REG_EMPTY,	"REG_EMPTY",	"empty (sub)expression"},
-	{REG_ASSERT,	"REG_ASSERT",	"\"can't happen\" -- you found a bug"},
-	{REG_INVARG,	"REG_INVARG",	"invalid argument to regex routine"},
+	{MY_REG_NOMATCH,	"MY_REG_NOMATCH",	"regexec() failed to match"},
+	{MY_REG_BADPAT,	"MY_REG_BADPAT",	"invalid regular expression"},
+	{MY_REG_ECOLLATE,	"MY_REG_ECOLLATE",	"invalid collating element"},
+	{MY_REG_ECTYPE,	"MY_REG_ECTYPE",	"invalid character class"},
+	{MY_REG_EESCAPE,	"MY_REG_EESCAPE",	"trailing backslash (\\)"},
+	{MY_REG_ESUBREG,	"MY_REG_ESUBREG",	"invalid backreference number"},
+	{MY_REG_EBRACK,	"MY_REG_EBRACK",	"brackets ([ ]) not balanced"},
+	{MY_REG_EPAREN,	"MY_REG_EPAREN",	"parentheses not balanced"},
+	{MY_REG_EBRACE,	"MY_REG_EBRACE",	"braces not balanced"},
+	{MY_REG_BADBR,	"MY_REG_BADBR",	"invalid repetition count(s)"},
+	{MY_REG_ERANGE,	"MY_REG_ERANGE",	"invalid character range"},
+	{MY_REG_ESPACE,	"MY_REG_ESPACE",	"out of memory"},
+	{MY_REG_BADRPT,	"MY_REG_BADRPT",	"repetition-operator operand invalid"},
+	{MY_REG_EMPTY,	"MY_REG_EMPTY",	"empty (sub)expression"},
+	{MY_REG_ASSERT,	"MY_REG_ASSERT",	"\"can't happen\" -- you found a bug"},
+	{MY_REG_INVARG,	"MY_REG_INVARG",	"invalid argument to regex routine"},
 	{0,		"",		"*** unknown regexp error code ***"},
 };
 
@@ -60,22 +60,22 @@ my_regerror(int errcode, const my_regex_
 {
 	register struct rerr *r;
 	register size_t len;
-	register int target = errcode &~ REG_ITOA;
+	register int target = errcode &~ MY_REG_ITOA;
 	register char *s;
 	char convbuf[50];
 
-	if (errcode == REG_ATOI)
+	if (errcode == MY_REG_ATOI)
 		s = regatoi(preg, convbuf);
 	else {
 		for (r = rerrs; r->code != 0; r++)
 			if (r->code == target)
 				break;
 
-		if (errcode&REG_ITOA) {
+		if (errcode&MY_REG_ITOA) {
 			if (r->code != 0)
 				(void) strcpy(convbuf, r->name);
 			else
-				sprintf(convbuf, "REG_0x%x", target);
+				sprintf(convbuf, "MY_REG_0x%x", target);
 			assert(strlen(convbuf) < sizeof(convbuf));
 			s = convbuf;
 		} else
@@ -96,7 +96,7 @@ my_regerror(int errcode, const my_regex_
 }
 
 /*
- - regatoi - internal routine to implement REG_ATOI
+ - regatoi - internal routine to implement MY_REG_ATOI
  == static char *regatoi(const regex_t *preg, char *localbuf);
  */
 static char *

=== modified file 'regex/regex2.h'
--- a/regex/regex2.h	2009-11-09 11:32:48 +0000
+++ b/regex/regex2.h	2010-07-26 10:39:38 +0000
@@ -1,15 +1,15 @@
 /*
  * First, the stuff that ends up in the outside-world include file
- = typedef off_t regoff_t;
+ = typedef off_t my_regoff_t;
  = typedef struct {
  = 	int re_magic;
  = 	size_t re_nsub;		// number of parenthesized subexpressions
- = 	const char *re_endp;	// end pointer for REG_PEND
+ = 	const char *re_endp;	// end pointer for MY_REG_PEND
  = 	struct re_guts *re_g;	// none of your business :-)
  = } regex_t;
  = typedef struct {
- = 	regoff_t rm_so;		// start of match
- = 	regoff_t rm_eo;		// end of match
+ = 	my_regoff_t rm_so;		// start of match
+ = 	my_regoff_t rm_eo;		// end of match
  = } regmatch_t;
  */
 /*

=== modified file 'regex/regexec.c'
--- a/regex/regexec.c	2007-03-28 17:46:42 +0000
+++ b/regex/regexec.c	2010-07-26 10:39:38 +0000
@@ -76,7 +76,7 @@
 #define	EQ(a, b)	(memcmp(a, b, m->g->nstates) == 0)
 #define	STATEVARS	int vn; char *space
 #define	STATESETUP(m, nv)	{ (m)->space = malloc((nv)*(m)->g->nstates); \
-				if ((m)->space == NULL) return(REG_ESPACE); \
+				if ((m)->space == NULL) return(MY_REG_ESPACE); \
 				(m)->vn = 0; }
 #define	STATETEARDOWN(m)	{ free((m)->space); }
 #define	SETUP(v)	((v) = &m->space[m->vn++ * m->g->nstates])
@@ -98,18 +98,18 @@
  - regexec - interface for matching
  = extern int regexec(const regex_t *, const char *, size_t, \
  =					regmatch_t [], int);
- = #define	REG_NOTBOL	00001
- = #define	REG_NOTEOL	00002
- = #define	REG_STARTEND	00004
- = #define	REG_TRACE	00400	// tracing of execution
- = #define	REG_LARGE	01000	// force large representation
- = #define	REG_BACKR	02000	// force use of backref code
+ = #define	MY_REG_NOTBOL	00001
+ = #define	MY_REG_NOTEOL	00002
+ = #define	MY_REG_STARTEND	00004
+ = #define	MY_REG_TRACE	00400	// tracing of execution
+ = #define	MY_REG_LARGE	01000	// force large representation
+ = #define	MY_REG_BACKR	02000	// force use of backref code
  *
  * We put this here so we can exploit knowledge of the state representation
  * when choosing which matcher to call.  Also, by this point the matchers
  * have been prototyped.
  */
-int				/* 0 success, REG_NOMATCH failure */
+int				/* 0 success, MY_REG_NOMATCH failure */
 my_regexec(preg, str, nmatch, pmatch, eflags)
 const my_regex_t *preg;
 const char *str;
@@ -121,18 +121,18 @@ int eflags;
 #ifdef REDEBUG
 #	define	GOODFLAGS(f)	(f)
 #else
-#	define	GOODFLAGS(f)	((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
+#	define	GOODFLAGS(f)	((f)&(MY_REG_NOTBOL|MY_REG_NOTEOL|MY_REG_STARTEND))
 #endif
 
 	if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
-		return(REG_BADPAT);
+		return(MY_REG_BADPAT);
 	assert(!(g->iflags&BAD));
 	if (g->iflags&BAD)		/* backstop for no-debug case */
-		return(REG_BADPAT);
+		return(MY_REG_BADPAT);
 	eflags = GOODFLAGS(eflags);
 
 	if ((size_t) g->nstates <= CHAR_BIT*sizeof(states1) &&
-	    !(eflags&REG_LARGE))
+	    !(eflags&MY_REG_LARGE))
 		return(smatcher(preg->charset, g, (char *)str, nmatch, pmatch, eflags));
 	else
 		return(lmatcher(preg->charset, g, (char *)str, nmatch, pmatch, eflags));

=== modified file 'regex/tests'
--- a/regex/tests	2000-07-31 19:29:14 +0000
+++ b/regex/tests	2010-07-26 10:39:38 +0000
@@ -283,7 +283,10 @@ a[[:alph:]]	&C	ECTYPE
 a[[:alphabet:]]	&C	ECTYPE
 [[:alnum:]]+	-	-%@a�-	a�
 [[:alpha:]]+	-	-%@aX0-	aX
-[[:blank:]]+	-	aSSTb	SST
+# ctype_latin1 does not tag '\t' as blank, so we will match only two spaces.
+# See: Bug #55427 REGEXP does not recognize '\t' as [:blank:]
+#[[:blank:]]+	-	aSSTb	SST
+[[:blank:]]+	-	aSSTb	SS
 [[:cntrl:]]+	-	aNTb	NT
 [[:digit:]]+	-	a019b	019
 [[:graph:]]+	-	Sa%bS	a%b

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2010-07-23 20:59:42 +0000
+++ b/sql/item_cmpfunc.cc	2010-07-26 10:39:38 +0000
@@ -4795,8 +4795,8 @@ Item_func_regex::fix_fields(THD *thd, It
 
   regex_lib_flags= (cmp_collation.collation->state &
                     (MY_CS_BINSORT | MY_CS_CSSORT)) ?
-                   REG_EXTENDED | REG_NOSUB :
-                   REG_EXTENDED | REG_NOSUB | REG_ICASE;
+                   MY_REG_EXTENDED | MY_REG_NOSUB :
+                   MY_REG_EXTENDED | MY_REG_NOSUB | MY_REG_ICASE;
   /*
     If the case of UCS2 and other non-ASCII character sets,
     we will convert patterns and strings to UTF8.

=== modified file 'storage/heap/hp_test2.c'
--- a/storage/heap/hp_test2.c	2010-07-23 20:09:27 +0000
+++ b/storage/heap/hp_test2.c	2010-07-26 11:17:39 +0000
@@ -385,7 +385,7 @@ int main(int argc, char *argv[])
   {
     if (!error)
       pos--;
-    if (i-- == 0)
+    if (!error && (i-- == 0))
     {
       bmove(record3,record,reclength);
       position=heap_position(file);
@@ -593,6 +593,7 @@ end:
   printf("\nFollowing test have been made:\n");
   printf("Write records: %d\nUpdate records: %d\nDelete records: %d\n", write_count,update,opt_delete);
   heap_clear(file);
+  heap_clear(file2);
   if (heap_close(file) || (file2 && heap_close(file2)))
     goto err;
   heap_delete_table(filename2);

=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt	2010-06-18 09:09:40 +0000
+++ b/unittest/gunit/CMakeLists.txt	2010-07-26 10:39:38 +0000
@@ -185,6 +185,7 @@ ENDIF()
 INCLUDE_DIRECTORIES(
   ${GTEST_INCLUDE_DIRS}
   ${CMAKE_SOURCE_DIR}/include
+  ${CMAKE_SOURCE_DIR}/regex
   ${CMAKE_SOURCE_DIR}/sql
   ${CMAKE_SOURCE_DIR}/unittest/mytap
 )
@@ -206,7 +207,7 @@ IF (CMAKE_CXX_COMPILER_ID STREQUAL "SunP
 ENDIF()
 
 # Add tests (link them with sql library) 
-SET(TESTS sql_list mdl mdl_mytap thread_utils)
+SET(TESTS sql_list mdl mdl_mytap my_regex thread_utils)
 FOREACH(test ${TESTS})
   ADD_EXECUTABLE(${test}-t ${test}-t.cc)
   TARGET_LINK_LIBRARIES(${test}-t gunit sql)

=== added file 'unittest/gunit/my_regex-t.cc'
--- a/unittest/gunit/my_regex-t.cc	1970-01-01 00:00:00 +0000
+++ b/unittest/gunit/my_regex-t.cc	2010-07-26 10:39:38 +0000
@@ -0,0 +1,82 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+// Must include gtest first, since MySQL source has macros for min() etc ....
+#include <gtest/gtest.h>
+
+#include "my_regex.h"
+
+/*
+  Thist is just a *very* basic test that things compile/link and execute.
+  The test data is taken from the first few lines in regex/tests.
+  For a full test suite, see regex/main.c which parses test input
+  and tests expected sucess/failure with basic/extended regexps etc. etc.
+ */
+
+namespace {
+
+const int NSUBS= 10;
+
+class Regex_test : public ::testing::Test
+{
+protected:
+  Regex_test()
+  {
+    memset(&re, 0, sizeof(re));
+  }
+  static void TearDownTestCase()
+  {
+    my_regex_end();
+  }
+
+  my_regmatch_t subs[NSUBS];
+  my_regex_t re;
+};
+
+struct Re_test_data
+{
+  const char* pattern;                          // Column 1 in regex/tests.
+  const int   cflags;                           // Column 2 in regex/tests.
+  const char* input;                            // Column 3 in regex/tests.
+};
+
+Re_test_data basic_data[]= 
+{
+  { "a",      MY_REG_BASIC,    "a"   },
+  { "abc",    MY_REG_BASIC,    "abc" },
+  { "abc|de", MY_REG_EXTENDED, "abc" },
+  { "a|b|c",  MY_REG_EXTENDED, "abc" },
+  { NULL, 0, NULL }
+};
+
+TEST_F(Regex_test, basic_test)
+{
+  for (int ix=0; basic_data[ix].pattern; ++ix)
+  {
+    EXPECT_EQ(0, my_regcomp(&re,
+                            basic_data[ix].pattern,
+                            basic_data[ix].cflags,
+                            &my_charset_latin1));
+
+    int err= my_regexec(&re, basic_data[ix].input, NSUBS, subs, 0);
+    EXPECT_EQ(0, err)
+      << "my_regexec returned " << err
+      << " for pattern '" << basic_data[ix].pattern << "'"
+      << " with input '" << basic_data[ix].input << "'";
+    my_regfree(&re);
+  }
+}
+
+}  // namespace

Attachment: [text/bzr-bundle] bzr/tor.didriksen@oracle.com-20100726111739-0p3udx197422llkc.bundle
Thread
bzr push into mysql-next-mr-bugfixing branch (tor.didriksen:3330 to 3332)Bug#55553Tor Didriksen26 Jul