~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-06-16 00:53:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1094.
  • Revision ID: brian@gaz-20090616005322-w0ode4jul9z8s2y9
Partial fix for tests for tmp

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
 
92
92
  ptr= (char*) res->ptr();
93
93
  end= ptr+res->length();
 
94
#ifdef USE_MB
94
95
  char *p=ptr;
95
96
  register uint32_t l;
 
97
#endif
96
98
  if (remove_length == 1)
97
99
  {
98
100
    char chr=(*remove_str)[0];
 
101
#ifdef USE_MB
99
102
    if (use_mb(res->charset()))
100
103
    {
101
104
      while (ptr < end)
102
105
      {
103
 
        if ((l=my_ismbchar(res->charset(), ptr,end))) ptr+=l,p=ptr;
104
 
        else ++ptr;
 
106
        if ((l=my_ismbchar(res->charset(), ptr,end))) ptr+=l,p=ptr;
 
107
        else ++ptr;
105
108
      }
106
109
      ptr=p;
107
110
    }
 
111
#endif
108
112
    while (ptr != end  && end[-1] == chr)
109
113
      end--;
110
114
  }
111
115
  else
112
116
  {
113
117
    const char *r_ptr=remove_str->ptr();
 
118
#ifdef USE_MB
114
119
    if (use_mb(res->charset()))
115
120
    {
116
 
loop:
 
121
  loop:
117
122
      while (ptr + remove_length < end)
118
123
      {
119
 
        if ((l=my_ismbchar(res->charset(), ptr,end))) ptr+=l;
120
 
        else ++ptr;
 
124
        if ((l=my_ismbchar(res->charset(), ptr,end))) ptr+=l;
 
125
        else ++ptr;
121
126
      }
122
127
      if (ptr + remove_length == end && !memcmp(ptr,r_ptr,remove_length))
123
128
      {
124
 
        end-=remove_length;
125
 
        ptr=p;
126
 
        goto loop;
 
129
        end-=remove_length;
 
130
        ptr=p;
 
131
        goto loop;
127
132
      }
128
133
    }
129
134
    else
 
135
#endif /* USE_MB */
130
136
    {
131
137
      while (ptr + remove_length <= end &&
132
 
          !memcmp(end-remove_length, r_ptr, remove_length))
133
 
        end-=remove_length;
 
138
             !memcmp(end-remove_length, r_ptr, remove_length))
 
139
        end-=remove_length;
134
140
    }
135
141
  }
136
142
  if (end == res->ptr()+res->length())
169
175
  r_ptr= remove_str->ptr();
170
176
  while (ptr+remove_length <= end && !memcmp(ptr,r_ptr,remove_length))
171
177
    ptr+=remove_length;
 
178
#ifdef USE_MB
172
179
  if (use_mb(res->charset()))
173
180
  {
174
181
    char *p=ptr;
188
195
    ptr=p;
189
196
  }
190
197
  else
 
198
#endif /* USE_MB */
191
199
  {
192
200
    while (ptr + remove_length <= end &&
193
201
           !memcmp(end-remove_length,r_ptr,remove_length))