~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/typelib.cc

Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
int TYPELIB::find_type(const char *x, e_find_options full_name) const
74
74
{
75
75
  assert(full_name & e_dont_complete);
76
 
  return find_type(const_cast<char*>(x), full_name);
77
 
}
78
 
 
79
 
int TYPELIB::find_type(char *x, e_find_options full_name) const
80
 
{
81
76
  if (!count)
82
77
    return 0;
83
78
  int find= 0;
85
80
  const char *j;
86
81
  for (int pos= 0; (j= type_names[pos]); pos++)
87
82
  {
88
 
    const char *i;
89
 
    for (i= x;
90
 
        *i && *i != field_separator &&
91
 
        my_toupper(&my_charset_utf8_general_ci,*i) ==
92
 
                my_toupper(&my_charset_utf8_general_ci,*j) ; i++, j++) ;
93
 
    if (! *j)
 
83
    const char *i= x;
 
84
    for (; *i && *i != field_separator &&
 
85
      my_toupper(&my_charset_utf8_general_ci, *i) == my_toupper(&my_charset_utf8_general_ci, *j); i++, j++)
 
86
    {
 
87
    }
 
88
    if (not *j)
94
89
    {
95
90
      while (*i == ' ')
96
 
        i++;                                    /* skip_end_space */
 
91
        i++;                                    /* skip_end_space */
97
92
      if (not *i)
98
 
        return(pos+1);
 
93
        return pos + 1;
99
94
    }
100
 
    if ((!*i && *i != field_separator) &&
101
 
        (!*j || !(full_name & e_match_full)))
 
95
    if (not *i && *i != field_separator && (not *j || not (full_name & e_match_full)))
102
96
    {
103
97
      find++;
104
 
      findpos=pos;
 
98
      findpos= pos;
105
99
    }
106
100
  }
107
101
  if (find == 0 || not x[0])
108
102
    return 0;
109
103
  if (find != 1 || (full_name & e_match_full))
110
104
    return -1;
111
 
  if (!(full_name & e_dont_complete))
112
 
    strcpy(x, type_names[findpos]);
113
105
  return findpos + 1;
114
106
} /* find_type */
115
107