ctype-simple.c:
CC comments -> C comments ctype-latin1_de.c: like_range was the same with like_range_simple so I've removed duplicated code
This commit is contained in:
parent
37fdb93d7c
commit
0a48aeb2c1
@ -336,81 +336,6 @@ static int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
|
||||
return dest - dest_orig;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Calculate min_str and max_str that ranges a LIKE string.
|
||||
* Arguments:
|
||||
* ptr IN: Pointer to LIKE string.
|
||||
* ptr_length IN: Length of LIKE string.
|
||||
* escape IN: Escape character in LIKE. (Normally '\').
|
||||
* No escape characters should appear in min_str or max_str
|
||||
* res_length IN: Length of min_str and max_str.
|
||||
* min_str IN/OUT: Smallest case sensitive string that ranges LIKE.
|
||||
* Should be space padded to res_length.
|
||||
* max_str IN/OUT: Largest case sensitive string that ranges LIKE.
|
||||
* Normally padded with the biggest character sort value.
|
||||
* min_length OUT: Length of min_str without space padding.
|
||||
* max_length OUT: Length of max_str without space padding.
|
||||
*
|
||||
* The function should return 0 if ok and 1 if the LIKE string can't be
|
||||
* optimized !
|
||||
*/
|
||||
|
||||
#define min_sort_char ((char) 0)
|
||||
#define max_sort_char ((char) 255)
|
||||
|
||||
static my_bool my_like_range_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
|
||||
const char *ptr, uint ptr_length,
|
||||
int escape, int w_one, int w_many,
|
||||
uint res_length,
|
||||
char *min_str, char *max_str,
|
||||
uint *min_length, uint *max_length)
|
||||
{
|
||||
const char *end = ptr + ptr_length;
|
||||
char *min_org = min_str;
|
||||
char *min_end = min_str + res_length;
|
||||
|
||||
for (; ptr != end && min_str != min_end; ptr++)
|
||||
{
|
||||
if (*ptr == escape && ptr + 1 != end)
|
||||
{
|
||||
ptr++; /* Skip escape */
|
||||
*min_str++ = *max_str++ = *ptr;
|
||||
continue;
|
||||
}
|
||||
if (*ptr == w_one) /* '_' in SQL */
|
||||
{
|
||||
*min_str++ = min_sort_char;
|
||||
*max_str++ = max_sort_char;
|
||||
continue;
|
||||
}
|
||||
if (*ptr == w_many) /* '%' in SQL */
|
||||
{
|
||||
*min_length = (uint)(min_str - min_org);
|
||||
*max_length = res_length;
|
||||
do {
|
||||
*min_str++ = ' '; /* Because if key compression */
|
||||
*max_str++ = max_sort_char;
|
||||
} while (min_str != min_end);
|
||||
return 0;
|
||||
}
|
||||
*min_str++ = *max_str++ = *ptr;
|
||||
}
|
||||
*min_length = *max_length = (uint) (min_str - min_org);
|
||||
|
||||
/* Temporary fix for handling w_one at end of string (key compression) */
|
||||
{
|
||||
char *tmp;
|
||||
for (tmp= min_str ; tmp > min_org && tmp[-1] == '\0';)
|
||||
*--tmp=' ';
|
||||
}
|
||||
|
||||
while (min_str != min_end)
|
||||
*min_str++ = *max_str++ = ' '; /* Because if key compression */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
CHARSET_INFO my_charset_latin1_de =
|
||||
{
|
||||
31, /* number */
|
||||
@ -427,7 +352,7 @@ CHARSET_INFO my_charset_latin1_de =
|
||||
2, /* strxfrm_multiply */
|
||||
my_strnncoll_latin1_de,
|
||||
my_strnxfrm_latin1_de,
|
||||
my_like_range_latin1_de,
|
||||
my_like_range_simple,
|
||||
my_wildcmp_8bit, /* wildcmp */
|
||||
1, /* mbmaxlen */
|
||||
NULL, /* ismbchar */
|
||||
|
@ -844,7 +844,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many)
|
||||
{
|
||||
int result= -1; // Not found, using wildcards
|
||||
int result= -1; /* Not found, using wildcards */
|
||||
|
||||
while (wildstr != wildend)
|
||||
{
|
||||
@ -854,16 +854,16 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
|
||||
wildstr++;
|
||||
|
||||
if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++))
|
||||
return(1); // No match
|
||||
return(1); /* No match */
|
||||
if (wildstr == wildend)
|
||||
return (str != str_end); // Match if both are at end
|
||||
result=1; // Found an anchor char
|
||||
return (str != str_end); /* Match if both are at end */
|
||||
result=1; /* Found an anchor char */
|
||||
}
|
||||
if (*wildstr == w_one)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (str == str_end) // Skip one char if possible
|
||||
if (str == str_end) /* Skip one char if possible */
|
||||
return (result);
|
||||
INC_PTR(cs,str,str_end);
|
||||
} while (++wildstr < wildend && *wildstr == w_one);
|
||||
@ -871,7 +871,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
|
||||
break;
|
||||
}
|
||||
if (*wildstr == w_many)
|
||||
{ // Found w_many
|
||||
{ /* Found w_many */
|
||||
uchar cmp;
|
||||
|
||||
wildstr++;
|
||||
@ -887,17 +887,17 @@ int my_wildcmp_8bit(CHARSET_INFO *cs,
|
||||
INC_PTR(cs,str,str_end);
|
||||
continue;
|
||||
}
|
||||
break; // Not a wild character
|
||||
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;
|
||||
|
||||
if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
|
||||
cmp= *++wildstr;
|
||||
|
||||
INC_PTR(cs,wildstr,wildend); // This is compared trough cmp
|
||||
INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */
|
||||
cmp=likeconv(cs,cmp);
|
||||
do
|
||||
{
|
||||
@ -949,22 +949,22 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
|
||||
{
|
||||
if (*ptr == escape && ptr+1 != end)
|
||||
{
|
||||
ptr++; // Skip escape
|
||||
ptr++; /* Skip escape */
|
||||
*min_str++= *max_str++ = *ptr;
|
||||
continue;
|
||||
}
|
||||
if (*ptr == w_one) // '_' in SQL
|
||||
if (*ptr == w_one) /* '_' in SQL */
|
||||
{
|
||||
*min_str++='\0'; // This should be min char
|
||||
*min_str++='\0'; /* This should be min char */
|
||||
*max_str++=cs->max_sort_char;
|
||||
continue;
|
||||
}
|
||||
if (*ptr == w_many) // '%' in SQL
|
||||
if (*ptr == w_many) /* '%' in SQL */
|
||||
{
|
||||
*min_length= (uint) (min_str - min_org);
|
||||
*max_length=res_length;
|
||||
do {
|
||||
*min_str++ = ' '; // Because if key compression
|
||||
*min_str++ = ' '; /* Because if key compression */
|
||||
*max_str++ = cs->max_sort_char;
|
||||
} while (min_str != min_end);
|
||||
return 0;
|
||||
@ -981,7 +981,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs,
|
||||
}
|
||||
|
||||
while (min_str != min_end)
|
||||
*min_str++ = *max_str++ = ' '; // Because if key compression
|
||||
*min_str++ = *max_str++ = ' '; /* Because if key compression */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user