summaryrefslogtreecommitdiff
path: root/strings/ctype-uca.c
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-11-06 08:41:48 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2018-11-06 08:41:48 +0200
commit32062cc61cd00e4cd3b7939c8a09f9c3ac34ec76 (patch)
tree098d64b7c988bab8cca25b0f716d92f6f7e72ed9 /strings/ctype-uca.c
parentaf9649c722810eb1754953eb406a84ec876ce693 (diff)
parentbae21bfb5de17328c33c3da8d191c6d3af14ae02 (diff)
downloadmariadb-git-32062cc61cd00e4cd3b7939c8a09f9c3ac34ec76.tar.gz
Merge 10.1 into 10.2
Diffstat (limited to 'strings/ctype-uca.c')
-rw-r--r--strings/ctype-uca.c116
1 files changed, 59 insertions, 57 deletions
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index f75b5c7c7a4..04820510cdb 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -32428,11 +32428,11 @@ int my_wildcmp_uca_impl(CHARSET_INFO *cs,
const char *wildstr,const char *wildend,
int escape, int w_one, int w_many, int recurse_level)
{
- int result= -1; /* Not found, using wildcards */
+ int result= -1; /* Not found, using wildcards */
my_wc_t s_wc, w_wc;
int scan;
my_charset_conv_mb_wc mb_wc= cs->cset->mb_wc;
-
+
if (my_string_stack_guard && my_string_stack_guard(recurse_level))
return 1;
while (wildstr != wildend)
@@ -32441,119 +32441,121 @@ int my_wildcmp_uca_impl(CHARSET_INFO *cs,
{
my_bool escaped= 0;
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
- (const uchar*)wildend)) <= 0)
- return 1;
+ (const uchar*)wildend)) <= 0)
+ return 1;
- if (w_wc == (my_wc_t)w_many)
+ if (w_wc == (my_wc_t) w_many)
{
- result= 1; /* Found an anchor char */
+ result= 1; /* Found an anchor char */
break;
}
wildstr+= scan;
- if (w_wc == (my_wc_t)escape)
+ if (w_wc == (my_wc_t) escape && wildstr < wildend)
{
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
- (const uchar*)wildend)) <= 0)
+ (const uchar*)wildend)) <= 0)
return 1;
wildstr+= scan;
escaped= 1;
}
-
+
if ((scan= mb_wc(cs, &s_wc, (const uchar*)str,
- (const uchar*)str_end)) <= 0)
+ (const uchar*)str_end)) <= 0)
return 1;
str+= scan;
-
- if (!escaped && w_wc == (my_wc_t)w_one)
+
+ if (!escaped && w_wc == (my_wc_t) w_one)
{
- result= 1; /* Found an anchor char */
+ result= 1; /* Found an anchor char */
}
else
{
if (my_uca_charcmp(cs,s_wc,w_wc))
- return 1;
+ return 1; /* No match */
}
if (wildstr == wildend)
- return (str != str_end); /* Match if both are at end */
+ return (str != str_end); /* Match if both are at end */
}
-
-
- if (w_wc == (my_wc_t)w_many)
- { /* Found w_many */
-
+
+ if (w_wc == (my_wc_t) w_many)
+ { /* Found w_many */
/* Remove any '%' and '_' from the wild search string */
for ( ; wildstr != wildend ; )
{
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
- (const uchar*)wildend)) <= 0)
+ (const uchar*)wildend)) <= 0)
return 1;
-
- if (w_wc == (my_wc_t)w_many)
- {
- wildstr+= scan;
- continue;
- }
-
- if (w_wc == (my_wc_t)w_one)
- {
- wildstr+= scan;
- if ((scan= mb_wc(cs, &s_wc, (const uchar*)str,
- (const uchar*)str_end)) <= 0)
+
+ if (w_wc == (my_wc_t) w_many)
+ {
+ wildstr+= scan;
+ continue;
+ }
+
+ if (w_wc == (my_wc_t) w_one)
+ {
+ wildstr+= scan;
+ if ((scan= mb_wc(cs, &s_wc, (const uchar*)str,
+ (const uchar*)str_end)) <= 0)
return 1;
str+= scan;
- continue;
- }
- break; /* Not a wild character */
+ continue;
+ }
+ break; /* Not a wild character */
}
-
+
if (wildstr == wildend)
- return 0; /* Ok if w_many is last */
-
+ return 0; /* Ok if w_many is last */
+
if (str == str_end)
- return -1;
-
+ return -1;
+
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
- (const uchar*)wildend)) <= 0)
+ (const uchar*)wildend)) <= 0)
return 1;
-
- if (w_wc == (my_wc_t)escape)
+ wildstr+= scan;
+
+ if (w_wc == (my_wc_t) escape)
{
- wildstr+= scan;
- if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
- (const uchar*)wildend)) <= 0)
- return 1;
+ if (wildstr < wildend)
+ {
+ if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
+ (const uchar*)wildend)) <= 0)
+ return 1;
+ wildstr+= scan;
+ }
}
-
+
while (1)
{
/* Skip until the first character from wildstr is found */
while (str != str_end)
{
if ((scan= mb_wc(cs, &s_wc, (const uchar*)str,
- (const uchar*)str_end)) <= 0)
+ (const uchar*)str_end)) <= 0)
return 1;
-
+
if (!my_uca_charcmp(cs,s_wc,w_wc))
break;
str+= scan;
}
if (str == str_end)
return -1;
-
+
+ str+= scan;
result= my_wildcmp_uca_impl(cs, str, str_end, wildstr, wildend,
- escape, w_one, w_many, recurse_level+1);
-
+ escape, w_one, w_many,
+ recurse_level + 1);
if (result <= 0)
return result;
-
- str+= scan;
- }
+ }
}
}
return (str != str_end ? 1 : 0);
}
+
int my_wildcmp_uca(CHARSET_INFO *cs,
const char *str,const char *str_end,
const char *wildstr,const char *wildend,