static int find_type_eol(const char **x, const TYPELIB *typelib, uint flags, const char *eol) { int find,pos; int UNINIT_VAR(findpos); /* guarded by find */ const char *UNINIT_VAR(termptr); const char *i; const char *j; CHARSET_INFO *cs= &my_charset_latin1; DBUG_ENTER("find_type_eol"); DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", *x, (long) typelib)); DBUG_ASSERT(!(flags & ~(FIND_TYPE_NO_PREFIX | FIND_TYPE_COMMA_TERM))); if (!typelib->count) { DBUG_PRINT("exit",("no count")); DBUG_RETURN(0); } find=0; for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) { for (i=*x ; i < eol && !is_field_separator(flags, *i) && my_toupper(cs, *i) == my_toupper(cs, *j) ; i++, j++) ; if (! *j) { while (i < eol && *i == ' ') i++; /* skip_end_space */ if (i >= eol || is_field_separator(flags, *i)) { *x= i; DBUG_RETURN(pos+1); } } if ((i >= eol && !is_field_separator(flags, *i)) && (!*j || !(flags & FIND_TYPE_NO_PREFIX))) { find++; findpos=pos; termptr=i; } } if (find == 0 || *x == eol) { DBUG_PRINT("exit",("Couldn't find type")); DBUG_RETURN(0); } else if (find != 1 || (flags & FIND_TYPE_NO_PREFIX)) { DBUG_PRINT("exit",("Too many possibilities")); DBUG_RETURN(-1); } *x= termptr; DBUG_RETURN(findpos+1); } /* find_type_eol */
int find_type(const char *x, const TYPELIB *typelib, uint flags) { int find,pos; int UNINIT_VAR(findpos); /* guarded by find */ const char *i; const char *j; DBUG_ENTER("find_type"); DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", x, (long) typelib)); DBUG_ASSERT(!(flags & ~(FIND_TYPE_NO_PREFIX | FIND_TYPE_ALLOW_NUMBER | FIND_TYPE_NO_OVERWRITE | FIND_TYPE_COMMA_TERM))); if (!typelib->count) { DBUG_PRINT("exit",("no count")); DBUG_RETURN(0); } find=0; for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) { for (i=x ; *i && (!(flags & FIND_TYPE_COMMA_TERM) || !is_field_separator(*i)) && my_toupper(&my_charset_latin1,*i) == my_toupper(&my_charset_latin1,*j) ; i++, j++) ; if (! *j) { while (*i == ' ') i++; /* skip_end_space */ if (! *i || ((flags & FIND_TYPE_COMMA_TERM) && is_field_separator(*i))) DBUG_RETURN(pos+1); } if ((!*i && (!(flags & FIND_TYPE_COMMA_TERM) || !is_field_separator(*i))) && (!*j || !(flags & FIND_TYPE_NO_PREFIX))) { find++; findpos=pos; } } if (find == 0 && (flags & FIND_TYPE_ALLOW_NUMBER) && x[0] == '#' && strend(x)[-1] == '#' && (findpos=atoi(x+1)-1) >= 0 && (uint) findpos < typelib->count) find=1; else if (find == 0 || ! x[0]) { DBUG_PRINT("exit",("Couldn't find type")); DBUG_RETURN(0); } else if (find != 1 || (flags & FIND_TYPE_NO_PREFIX)) { DBUG_PRINT("exit",("Too many possybilities")); DBUG_RETURN(-1); } DBUG_RETURN(findpos+1); } /* find_type */
my_ulonglong find_typeset(char *x, TYPELIB *lib, int *err) { my_ulonglong result; int find; char *i; DBUG_ENTER("find_set"); DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", x, (long) lib)); if (!lib->count) { DBUG_PRINT("exit",("no count")); DBUG_RETURN(0); } result= 0; *err= 0; while (*x) { (*err)++; i= x; while (*x && !is_field_separator(*x)) x++; if (x[0] && x[1]) /* skip separator if found */ x++; if ((find= find_type(i, lib, FIND_TYPE_COMMA_TERM) - 1) < 0) DBUG_RETURN(0); result|= (ULL(1) << find); } *err= 0; DBUG_RETURN(result); } /* find_set */