Skip to content

Commit 844d964

Browse files
Many files:
Prefix regex functions/types with "my_" as our library is not compatible with normal regex lib. my_regex.h: Rename: regex/regex.h -> regex/my_regex.h
1 parent 7e6a78a commit 844d964

19 files changed

Lines changed: 97 additions & 96 deletions

client/mysqltest.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include <stdarg.h>
6060
#include <sys/stat.h>
6161
#include <violite.h>
62-
#include <regex.h> /* Our own version of lib */
62+
#include "my_regex.h" /* Our own version of lib */
6363
#ifdef HAVE_SYS_WAIT_H
6464
#include <sys/wait.h>
6565
#endif
@@ -188,7 +188,7 @@ static int got_end_timer= FALSE;
188188
static void timer_output(void);
189189
static ulonglong timer_now(void);
190190

191-
static regex_t ps_re; /* Holds precompiled re for valid PS statements */
191+
static my_regex_t ps_re; /* Holds precompiled re for valid PS statements */
192192
static void ps_init_re(void);
193193
static int ps_match_re(char *);
194194
static char *ps_eprint(int);
@@ -3585,12 +3585,13 @@ static void ps_init_re(void)
35853585
"[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|"
35863586
"[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])";
35873587

3588-
int err= regcomp(&ps_re, ps_re_str, (REG_EXTENDED | REG_ICASE | REG_NOSUB),
3589-
&my_charset_latin1);
3588+
int err= my_regcomp(&ps_re, ps_re_str,
3589+
(REG_EXTENDED | REG_ICASE | REG_NOSUB),
3590+
&my_charset_latin1);
35903591
if (err)
35913592
{
35923593
char erbuf[100];
3593-
int len= regerror(err, &ps_re, erbuf, sizeof(erbuf));
3594+
int len= my_regerror(err, &ps_re, erbuf, sizeof(erbuf));
35943595
fprintf(stderr, "error %s, %d/%d `%s'\n",
35953596
ps_eprint(err), len, (int)sizeof(erbuf), erbuf);
35963597
exit(1);
@@ -3600,7 +3601,7 @@ static void ps_init_re(void)
36003601

36013602
static int ps_match_re(char *stmt_str)
36023603
{
3603-
int err= regexec(&ps_re, stmt_str, (size_t)0, NULL, 0);
3604+
int err= my_regexec(&ps_re, stmt_str, (size_t)0, NULL, 0);
36043605

36053606
if (err == 0)
36063607
return 1;
@@ -3609,7 +3610,7 @@ static int ps_match_re(char *stmt_str)
36093610
else
36103611
{
36113612
char erbuf[100];
3612-
int len= regerror(err, &ps_re, erbuf, sizeof(erbuf));
3613+
int len= my_regerror(err, &ps_re, erbuf, sizeof(erbuf));
36133614
fprintf(stderr, "error %s, %d/%d `%s'\n",
36143615
ps_eprint(err), len, (int)sizeof(erbuf), erbuf);
36153616
exit(1);
@@ -3619,15 +3620,15 @@ static int ps_match_re(char *stmt_str)
36193620
static char *ps_eprint(int err)
36203621
{
36213622
static char epbuf[100];
3622-
size_t len= regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
3623+
size_t len= my_regerror(REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
36233624
assert(len <= sizeof(epbuf));
36243625
return(epbuf);
36253626
}
36263627

36273628

36283629
static void ps_free_reg(void)
36293630
{
3630-
regfree(&ps_re);
3631+
my_regfree(&ps_re);
36313632
}
36323633

36333634
/****************************************************************************/

os2/MySQL-Source.icc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ group client_global_pch =
1212
'm_ctype.h', 'mysqld_error.h',
1313
'my_list.h', 'my_sys.h', 'my_net.h',
1414
'myisam.h', 'myisampack.h', '.\myisam\myisamdef.h',
15-
'.\regex\regex.h'
15+
'.\regex\my_regex.h'
1616

1717
group server_global_pch =
1818
'os2.h',
@@ -38,7 +38,7 @@ group server_global_pch =
3838
'my_tree.h', '..\mysys\my_static.h', 'netdb.h',
3939
'thr_alarm.h', 'heap.h', '..\myisam\fulltext.h',
4040
'..\myisam\ftdefs.h', 'myisammrg.h',
41-
'.\regex\regex.h'
41+
'.\regex\my_regex.h'
4242

4343
group server_pch =
4444
'ha_heap.h', 'ha_myisammrg.h', 'opt_ft.h',

regex/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ INCLUDES = @MT_INCLUDES@ \
1919
-I$(top_builddir)/include -I$(top_srcdir)/include
2020
noinst_LIBRARIES = libregex.a
2121
LDADD= libregex.a $(top_builddir)/strings/libmystrings.a
22-
noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c regex.h
22+
noinst_HEADERS = cclass.h cname.h regex2.h utils.h engine.c my_regex.h
2323
libregex_a_SOURCES = regerror.c regcomp.c regexec.c regfree.c reginit.c
2424
noinst_PROGRAMS = re
2525
re_SOURCES = split.c debug.c main.c

regex/debug.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#include <m_ctype.h>
33
#include <m_string.h>
44
#include <sys/types.h>
5-
#include <regex.h>
5+
6+
#include "my_regex.h"
67
#include "utils.h"
78
#include "regex2.h"
89
#include "debug.ih"
@@ -15,7 +16,7 @@
1516
*/
1617
void
1718
regprint(r, d)
18-
regex_t *r;
19+
my_regex_t *r;
1920
FILE *d;
2021
{
2122
register struct re_guts *g = r->re_g;

regex/debug.ih

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern "C" {
44
#endif
55

66
/* === debug.c === */
7-
void regprint(regex_t *r, FILE *d);
7+
void regprint(my_regex_t *r, FILE *d);
88
static void s_print(CHARSET_INFO *charset, register struct re_guts *g, FILE *d);
99
static char *regchar(CHARSET_INFO *charset, int ch,char *buf);
1010

regex/engine.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
struct match {
3333
struct re_guts *g;
3434
int eflags;
35-
regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
35+
my_regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
3636
char *offp; /* offsets work from here */
3737
char *beginp; /* start of string -- virtual NUL precedes */
3838
char *endp; /* end of string -- virtual NUL here */
@@ -68,7 +68,7 @@ CHARSET_INFO *charset;
6868
register struct re_guts *g;
6969
char *str;
7070
size_t nmatch;
71-
regmatch_t pmatch[];
71+
my_regmatch_t pmatch[];
7272
int eflags;
7373
{
7474
register char *endp;
@@ -148,8 +148,8 @@ int eflags;
148148

149149
/* oh my, he wants the subexpressions... */
150150
if (m->pmatch == NULL)
151-
m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
152-
sizeof(regmatch_t));
151+
m->pmatch = (my_regmatch_t *)malloc((m->g->nsub + 1) *
152+
sizeof(my_regmatch_t));
153153
if (m->pmatch == NULL) {
154154
if (m->lastpos != NULL)
155155
free((char *)m->lastpos);

regex/engine.ih

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern "C" {
44
#endif
55

66
/* === engine.c === */
7-
static int matcher(CHARSET_INFO *charset,register struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
7+
static int matcher(CHARSET_INFO *charset,register struct re_guts *g, char *string, size_t nmatch, my_regmatch_t pmatch[], int eflags);
88
static char *dissect(CHARSET_INFO *charset,register struct match *m, char *start, char *stop, sopno startst, sopno stopst);
99
static char *backref(CHARSET_INFO *charset, register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev);
1010
static char *fast(CHARSET_INFO *charset, register struct match *m, char *start, char *stop, sopno startst, sopno stopst);

regex/main.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <my_global.h>
22
#include <m_string.h>
33
#include <sys/types.h>
4-
#include <regex.h>
54
#include <assert.h>
65

6+
#include "my_regex.h"
77
#include "main.ih"
88

99
char *progname;
@@ -27,9 +27,9 @@ int main(argc, argv)
2727
int argc;
2828
char *argv[];
2929
{
30-
regex_t re;
30+
my_regex_t re;
3131
# define NS 10
32-
regmatch_t subs[NS];
32+
my_regmatch_t subs[NS];
3333
char erbuf[100];
3434
int err;
3535
size_t len;
@@ -74,27 +74,27 @@ char *argv[];
7474
exit(status);
7575
}
7676

77-
err = regcomp(&re, argv[optind++], copts, &my_charset_latin1);
77+
err = my_regcomp(&re, argv[optind++], copts, &my_charset_latin1);
7878
if (err) {
79-
len = regerror(err, &re, erbuf, sizeof(erbuf));
79+
len = my_regerror(err, &re, erbuf, sizeof(erbuf));
8080
fprintf(stderr, "error %s, %d/%d `%s'\n",
8181
eprint(err), len, (int) sizeof(erbuf), erbuf);
8282
exit(status);
8383
}
8484
regprint(&re, stdout);
8585

8686
if (optind >= argc) {
87-
regfree(&re);
87+
my_regfree(&re);
8888
exit(status);
8989
}
9090

9191
if (eopts&REG_STARTEND) {
9292
subs[0].rm_so = startoff;
9393
subs[0].rm_eo = strlen(argv[optind]) - endoff;
9494
}
95-
err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
95+
err = my_regexec(&re, argv[optind], (size_t)NS, subs, eopts);
9696
if (err) {
97-
len = regerror(err, &re, erbuf, sizeof(erbuf));
97+
len = my_regerror(err, &re, erbuf, sizeof(erbuf));
9898
fprintf(stderr, "error %s, %d/%d `%s'\n",
9999
eprint(err), (int) len, (int) sizeof(erbuf), erbuf);
100100
exit(status);
@@ -136,7 +136,7 @@ FILE *in;
136136
const char *badpat = "invalid regular expression";
137137
# define SHORT 10
138138
const char *bpname = "REG_BADPAT";
139-
regex_t re;
139+
my_regex_t re;
140140

141141
while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
142142
line++;
@@ -163,27 +163,27 @@ FILE *in;
163163
options('c', f[1]) &~ REG_EXTENDED);
164164
}
165165

166-
ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
166+
ne = my_regerror(REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
167167
if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
168168
fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
169169
erbuf, badpat);
170170
status = 1;
171171
}
172-
ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, (size_t)SHORT);
172+
ne = my_regerror(REG_BADPAT, (my_regex_t *)NULL, erbuf, (size_t)SHORT);
173173
if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
174174
ne != strlen(badpat)+1) {
175175
fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
176176
erbuf, SHORT-1, badpat);
177177
status = 1;
178178
}
179-
ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
179+
ne = my_regerror(REG_ITOA|REG_BADPAT, (my_regex_t *)NULL, erbuf, sizeof(erbuf));
180180
if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
181181
fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
182182
erbuf, bpname);
183183
status = 1;
184184
}
185185
re.re_endp = bpname;
186-
ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
186+
ne = my_regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
187187
if (atoi(erbuf) != (int)REG_BADPAT) {
188188
fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
189189
erbuf, (long)REG_BADPAT);
@@ -208,9 +208,9 @@ char *f3;
208208
char *f4;
209209
int opts; /* may not match f1 */
210210
{
211-
regex_t re;
211+
my_regex_t re;
212212
# define NSUBS 10
213-
regmatch_t subs[NSUBS];
213+
my_regmatch_t subs[NSUBS];
214214
# define NSHOULD 15
215215
char *should[NSHOULD];
216216
int nshould;
@@ -226,10 +226,10 @@ int opts; /* may not match f1 */
226226
strcpy(f0copy, f0);
227227
re.re_endp = (opts&REG_PEND) ? f0copy + strlen(f0copy) : NULL;
228228
fixstr(f0copy);
229-
err = regcomp(&re, f0copy, opts, &my_charset_latin1);
229+
err = my_regcomp(&re, f0copy, opts, &my_charset_latin1);
230230
if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
231231
/* unexpected error or wrong error */
232-
len = regerror(err, &re, erbuf, sizeof(erbuf));
232+
len = my_regerror(err, &re, erbuf, sizeof(erbuf));
233233
fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
234234
line, type, eprint(err), len,
235235
(int) sizeof(erbuf), erbuf);
@@ -243,7 +243,7 @@ int opts; /* may not match f1 */
243243
}
244244

245245
if (err != 0) {
246-
regfree(&re);
246+
my_regfree(&re);
247247
return;
248248
}
249249

@@ -256,11 +256,11 @@ int opts; /* may not match f1 */
256256
subs[0].rm_so = strchr(f2, '(') - f2 + 1;
257257
subs[0].rm_eo = strchr(f2, ')') - f2;
258258
}
259-
err = regexec(&re, f2copy, NSUBS, subs, options('e', f1));
259+
err = my_regexec(&re, f2copy, NSUBS, subs, options('e', f1));
260260

261261
if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
262262
/* unexpected error or wrong error */
263-
len = regerror(err, &re, erbuf, sizeof(erbuf));
263+
len = my_regerror(err, &re, erbuf, sizeof(erbuf));
264264
fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
265265
line, type, eprint(err), len,
266266
(int) sizeof(erbuf), erbuf);
@@ -282,7 +282,7 @@ int opts; /* may not match f1 */
282282
}
283283

284284
if (err != 0 || f4 == NULL) {
285-
regfree(&re);
285+
my_regfree(&re);
286286
return;
287287
}
288288

@@ -303,7 +303,7 @@ int opts; /* may not match f1 */
303303
}
304304
}
305305

306-
regfree(&re);
306+
my_regfree(&re);
307307
}
308308

309309
/*
@@ -404,7 +404,7 @@ register char *p;
404404
char * /* NULL or complaint */
405405
check(str, sub, should)
406406
char *str;
407-
regmatch_t sub;
407+
my_regmatch_t sub;
408408
char *should;
409409
{
410410
register int len;
@@ -485,7 +485,7 @@ int err;
485485
static char epbuf[100];
486486
size_t len;
487487

488-
len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
488+
len = my_regerror(REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
489489
assert(len <= sizeof(epbuf));
490490
return(epbuf);
491491
}
@@ -499,11 +499,11 @@ efind(name)
499499
char *name;
500500
{
501501
static char efbuf[100];
502-
regex_t re;
502+
my_regex_t re;
503503

504504
sprintf(efbuf, "REG_%s", name);
505505
assert(strlen(efbuf) < sizeof(efbuf));
506506
re.re_endp = efbuf;
507-
(void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
507+
(void) my_regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
508508
return(atoi(efbuf));
509509
}

regex/main.ih

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void rx_try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
99
int options(int type, char *s);
1010
int opt(int c, char *s);
1111
void fixstr(register char *p);
12-
char *check(char *str, regmatch_t sub, char *should);
12+
char *check(char *str, my_regmatch_t sub, char *should);
1313
static char *eprint(int err);
1414
static int efind(char *name);
1515

0 commit comments

Comments
 (0)