~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to drizzled/function/find_in_set.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include <config.h>
21
21
 
22
 
#include <drizzled/charset_info.h>
 
22
#include <drizzled/charset.h>
23
23
#include <drizzled/function/find_in_set.h>
24
24
 
25
25
/* Search after a string in a string of strings separated by ',' */
61
61
  }
62
62
  null_value=0;
63
63
 
64
 
  int diff;
65
 
  if ((diff=buffer->length() - find->length()) >= 0)
 
64
  if (buffer->length() >= find->length())  
66
65
  {
67
66
    my_wc_t wc;
68
 
    const CHARSET_INFO * const cs= cmp_collation.collation;
 
67
    const charset_info_st * const cs= cmp_collation.collation;
69
68
    const char *str_begin= buffer->ptr();
70
69
    const char *str_end= buffer->ptr();
71
70
    const char *real_end= str_end+buffer->length();
75
74
    while (1)
76
75
    {
77
76
      int symbol_len;
78
 
      if ((symbol_len= cs->cset->mb_wc(cs, &wc, (unsigned char*) str_end,
79
 
                                       (unsigned char*) real_end)) > 0)
 
77
      if ((symbol_len= cs->cset->mb_wc(cs, &wc, (unsigned char*) str_end, (unsigned char*) real_end)) > 0)
80
78
      {
81
79
        const char *substr_end= str_end + symbol_len;
82
80
        bool is_last_item= (substr_end == real_end);
100
98
               wc == (my_wc_t) separator)
101
99
        return (int64_t) ++position;
102
100
      else
103
 
        return 0L;
 
101
        return 0;
104
102
    }
105
103
  }
106
104
  return 0;