65 static int str_eval_like (
const unsigned char *tar,
const unsigned char *expr,
unsigned char escape);
68 static void str_tolower (
char *str);
72 str_like (
char *src,
char *pattern,
char esc_char)
81 if (low_src ==
NULL || low_pattern ==
NULL)
92 str_eval_like ((
const unsigned char *) low_src, (
const unsigned char *) low_pattern, (
unsigned char) esc_char);
102 str_eval_like (
const unsigned char *tar,
const unsigned char *expr,
unsigned char escape)
104 const int IN_CHECK = 0;
105 const int IN_PERCENT = 1;
106 const int IN_PERCENT_UNDERSCORE = 2;
108 int status = IN_CHECK;
119 if (status == IN_CHECK)
124 if (*expr ==
'%' || *expr ==
'_')
131 || (
is_korean (*tar) && *tar == *expr && *(tar + 1) == *(expr + 1))))
162 if (stackp >= 0 && stackp <
STK_SIZE)
164 tar = tarstack[stackp];
173 expr = exprstack[stackp--];
198 if (stackp >= 0 && stackp <
STK_SIZE)
200 tar = tarstack[stackp];
209 expr = exprstack[stackp--];
217 else if (*expr ==
'%')
220 while (*(expr + 1) ==
'%')
225 else if ((*expr ==
'_') || (!
is_korean (*tar) && *tar == *expr)
226 || (
is_korean (*tar) && *tar == *expr && *(tar + 1) == *(expr + 1)))
245 else if (stackp >= 0 && stackp <
STK_SIZE)
247 tar = tarstack[stackp];
257 expr = exprstack[stackp--];
268 else if (status == IN_PERCENT)
270 if (*(expr + 1) ==
'_')
276 tarstack[++stackp] = tar;
277 exprstack[stackp] = expr;
281 status = IN_PERCENT_UNDERSCORE;
285 if (*(expr + 1) == escape)
289 if (*(expr + 1) !=
'%' && *(expr + 1) !=
'_')
295 while (*tar && *tar != *(expr + 1))
307 if (*tar == *(expr + 1))
313 tarstack[++stackp] = tar;
314 exprstack[stackp] = expr;
328 if (status == IN_PERCENT_UNDERSCORE)
334 if (*expr !=
'%' && *expr !=
'_')
350 if (stackp >= 0 && stackp <
STK_SIZE)
352 tar = tarstack[stackp];
361 expr = exprstack[stackp--];
386 if (stackp >= 0 && stackp <
STK_SIZE)
388 tar = tarstack[stackp];
397 expr = exprstack[stackp--];
405 else if (*expr ==
'%')
408 while (*(expr + 1) ==
'%')
413 else if ((*expr ==
'_') || (!
is_korean (*tar) && *tar == *expr)
414 || (
is_korean (*tar) && *tar == *expr && *(tar + 1) == *(expr + 1)))
433 else if (stackp >= 0 && stackp <
STK_SIZE)
435 tar = tarstack[stackp];
445 expr = exprstack[stackp--];
482 return (ch >= 0xb0 && ch <= 0xc8) || (ch >= 0xa1 && ch <= 0xfe);
487 str_tolower (
char *str)
490 for (p = str; *
p; p++)
492 if (*p >=
'A' && *p <=
'Z')
static int is_korean(unsigned char ch)
static int str_eval_like(const unsigned char *tar, const unsigned char *expr, unsigned char escape)
#define ALLOC_COPY(PTR, STR)
void ut_tolower(char *str)
int str_like(char *src, char *pattern, char esc_char)