~drizzle-pbxt/drizzle/drizzle-pbxt-2

« back to all changes in this revision

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

  • Committer: Paul McCullagh
  • Date: 2009-11-10 14:18:39 UTC
  • mfrom: (1038.1.7 drizzle-pbxt-pre-merge)
  • Revision ID: paul.mccullagh@primebase.org-20091110141839-2j3k43b17ag6f605
Merged Drizzle trunk and PBXT 1.0.09

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