~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.cc

  • Committer: Andrey Hristov
  • Date: 2008-08-06 00:04:45 UTC
  • mto: (264.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 266.
  • Revision ID: ahristov@mysql.com-20080806000445-84urmltikgwk9v5d
Constify the usage of CHARSET_INFO almost to the last place in the code.
99% of the parameters are const CHARSET_INFO * const cs.
Wherever possible stack variables are also double consted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
  return false;
92
92
}
93
93
 
94
 
bool String::set_int(int64_t num, bool unsigned_flag, CHARSET_INFO *cs)
 
94
bool String::set_int(int64_t num, bool unsigned_flag, const CHARSET_INFO * const cs)
95
95
{
96
96
  uint l=20*cs->mbmaxlen+1;
97
97
  int base= unsigned_flag ? 10 : -10;
103
103
  return false;
104
104
}
105
105
 
106
 
bool String::set_real(double num,uint decimals, CHARSET_INFO *cs)
 
106
bool String::set_real(double num,uint decimals, const CHARSET_INFO * const cs)
107
107
{
108
108
  char buff[FLOATING_POINT_BUFFER];
109
109
  uint dummy_errors;
142
142
  return false;
143
143
}
144
144
 
145
 
bool String::copy(const char *str,uint32_t arg_length, CHARSET_INFO *cs)
 
145
bool String::copy(const char *str,uint32_t arg_length, const CHARSET_INFO * const cs)
146
146
{
147
147
  if (alloc(arg_length))
148
148
    return true;
177
177
*/
178
178
 
179
179
bool String::needs_conversion(uint32_t arg_length,
180
 
                              CHARSET_INFO *from_cs,
181
 
                              CHARSET_INFO *to_cs,
 
180
                              const CHARSET_INFO * const from_cs,
 
181
                              const CHARSET_INFO * const to_cs,
182
182
                              uint32_t *offset)
183
183
{
184
184
  *offset= 0;
219
219
*/
220
220
 
221
221
bool String::copy_aligned(const char *str,uint32_t arg_length, uint32_t offset,
222
 
                          CHARSET_INFO *cs)
 
222
                          const CHARSET_INFO * const cs)
223
223
{
224
224
  /* How many bytes are in incomplete character */
225
225
  offset= cs->mbmaxlen - offset; /* How many zeros we should prepend */
245
245
 
246
246
 
247
247
bool String::set_or_copy_aligned(const char *str,uint32_t arg_length,
248
 
                                 CHARSET_INFO *cs)
 
248
                                 const CHARSET_INFO * const cs)
249
249
{
250
250
  /* How many bytes are in incomplete character */
251
251
  uint32_t offset= (arg_length % cs->mbminlen); 
261
261
        /* Copy with charset conversion */
262
262
 
263
263
bool String::copy(const char *str, uint32_t arg_length,
264
 
                  CHARSET_INFO *from_cs, CHARSET_INFO *to_cs, uint *errors)
 
264
                          const CHARSET_INFO * const from_cs,
 
265
                                  const CHARSET_INFO * const to_cs, uint *errors)
265
266
{
266
267
  uint32_t offset;
267
268
  if (!needs_conversion(arg_length, from_cs, to_cs, &offset))
400
401
  with character set recoding
401
402
*/
402
403
 
403
 
bool String::append(const char *s,uint32_t arg_length, CHARSET_INFO *cs)
 
404
bool String::append(const char *s,uint32_t arg_length, const CHARSET_INFO * const cs)
404
405
{
405
406
  uint32_t dummy_offset;
406
407
  
628
629
*/
629
630
 
630
631
 
631
 
int sortcmp(const String *s,const String *t, CHARSET_INFO *cs)
 
632
int sortcmp(const String *s,const String *t, const CHARSET_INFO * const cs)
632
633
{
633
634
 return cs->coll->strnncollsp(cs,
634
635
                              (uchar *) s->ptr(),s->length(),
704
705
 
705
706
 
706
707
static uint32_t
707
 
copy_and_convert_extended(char *to, uint32_t to_length, CHARSET_INFO *to_cs, 
 
708
copy_and_convert_extended(char *to, uint32_t to_length,
 
709
                          const CHARSET_INFO * const to_cs, 
708
710
                          const char *from, uint32_t from_length,
709
 
                          CHARSET_INFO *from_cs,
 
711
                          const CHARSET_INFO * const from_cs,
710
712
                          uint *errors)
711
713
{
712
714
  int         cnvres;
763
765
  Optimized for quick copying of ASCII characters in the range 0x00..0x7F.
764
766
*/
765
767
uint32_t
766
 
copy_and_convert(char *to, uint32_t to_length, CHARSET_INFO *to_cs, 
767
 
                 const char *from, uint32_t from_length, CHARSET_INFO *from_cs,
768
 
                 uint *errors)
 
768
copy_and_convert(char *to, uint32_t to_length, const CHARSET_INFO * const to_cs, 
 
769
                 const char *from, uint32_t from_length,
 
770
                                 const CHARSET_INFO * const from_cs, uint *errors)
769
771
{
770
772
  /*
771
773
    If any of the character sets is not ASCII compatible,
839
841
*/
840
842
 
841
843
size_t
842
 
my_copy_with_hex_escaping(CHARSET_INFO *cs,
 
844
my_copy_with_hex_escaping(const CHARSET_INFO * const cs,
843
845
                          char *dst, size_t dstlen,
844
846
                          const char *src, size_t srclen)
845
847
{
908
910
 
909
911
 
910
912
uint32_t
911
 
well_formed_copy_nchars(CHARSET_INFO *to_cs,
 
913
well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
912
914
                        char *to, uint to_length,
913
 
                        CHARSET_INFO *from_cs,
 
915
                        const CHARSET_INFO * const from_cs,
914
916
                        const char *from, uint from_length,
915
917
                        uint nchars,
916
918
                        const char **well_formed_error_pos,
1086
1088
  swap_variables(uint32_t, str_length, s.str_length);
1087
1089
  swap_variables(uint32_t, Alloced_length, s.Alloced_length);
1088
1090
  swap_variables(bool, alloced, s.alloced);
1089
 
  swap_variables(CHARSET_INFO*, str_charset, s.str_charset);
 
1091
  swap_variables(const CHARSET_INFO *, str_charset, s.str_charset);
1090
1092
}