~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/str/replace.cc

  • Committer: Monty Taylor
  • Date: 2009-07-09 00:04:44 UTC
  • mto: (1093.1.9 captain)
  • mto: This revision was merged to the branch mainline in revision 1097.
  • Revision ID: mordred@inaugust.com-20090709000444-1jf6qw4gvyhdab1a
Got rid of #ifdef have utf8 stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
  Don't reallocate val_str() if not needed.
30
30
 
31
31
  @todo
32
 
    Fix that this works with binary strings when using USE_MB
 
32
    Fix that this works with binary strings
33
33
*/
34
34
 
35
35
String *Item_func_replace::val_str(String *str)
39
39
  int offset;
40
40
  uint32_t from_length,to_length;
41
41
  bool alloced=0;
42
 
#ifdef USE_MB
43
42
  const char *ptr,*end,*strend,*search,*search_end;
44
43
  register uint32_t l;
45
44
  bool binary_cmp;
46
 
#endif
47
45
 
48
46
  null_value=0;
49
47
  res=args[0]->val_str(str);
55
53
 
56
54
  res->set_charset(collation.collation);
57
55
 
58
 
#ifdef USE_MB
59
56
  binary_cmp = ((res->charset()->state & MY_CS_BINSORT) || !use_mb(res->charset()));
60
 
#endif
61
57
 
62
58
  if (res2->length() == 0)
63
59
    return res;
64
 
#ifndef USE_MB
65
 
  if ((offset=res->strstr(*res2)) < 0)
66
 
    return res;
67
 
#else
68
60
  offset=0;
69
61
  if (binary_cmp && (offset=res->strstr(*res2)) < 0)
70
62
    return res;
71
 
#endif
72
63
  if (!(res3=args[2]->val_str(&tmp_value2)))
73
64
    goto null;
74
65
  from_length= res2->length();
75
66
  to_length=   res3->length();
76
67
 
77
 
#ifdef USE_MB
78
68
  if (!binary_cmp)
79
69
  {
80
70
    search=res2->ptr();
118
108
    }
119
109
  }
120
110
  else
121
 
#endif /* USE_MB */
122
111
    do
123
112
    {
124
113
      if (res->length()-from_length + to_length >