~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_string.cc

  • Committer: Brian Aker
  • Date: 2008-08-07 16:29:49 UTC
  • mfrom: (264.1.20 codestyle)
  • Revision ID: brian@tangent.org-20080807162949-7o8eyjgdn8ms3n1a
Merge from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* This file is originally from the mysql distribution. Coded by monty */
17
17
 
18
 
#ifdef USE_PRAGMA_IMPLEMENTATION
19
 
#pragma implementation                          // gcc: Class implementation
20
 
#endif
21
 
 
22
18
#include "global.h"
23
19
#include <mysys/my_sys.h>
24
20
#include <mystrings/m_string.h>
91
87
  return false;
92
88
}
93
89
 
94
 
bool String::set_int(int64_t num, bool unsigned_flag, CHARSET_INFO *cs)
 
90
bool String::set_int(int64_t num, bool unsigned_flag, const CHARSET_INFO * const cs)
95
91
{
96
92
  uint l=20*cs->mbmaxlen+1;
97
93
  int base= unsigned_flag ? 10 : -10;
103
99
  return false;
104
100
}
105
101
 
106
 
bool String::set_real(double num,uint decimals, CHARSET_INFO *cs)
 
102
bool String::set_real(double num,uint decimals, const CHARSET_INFO * const cs)
107
103
{
108
104
  char buff[FLOATING_POINT_BUFFER];
109
105
  uint dummy_errors;
142
138
  return false;
143
139
}
144
140
 
145
 
bool String::copy(const char *str,uint32_t arg_length, CHARSET_INFO *cs)
 
141
bool String::copy(const char *str,uint32_t arg_length, const CHARSET_INFO * const cs)
146
142
{
147
143
  if (alloc(arg_length))
148
144
    return true;
177
173
*/
178
174
 
179
175
bool String::needs_conversion(uint32_t arg_length,
180
 
                              CHARSET_INFO *from_cs,
181
 
                              CHARSET_INFO *to_cs,
 
176
                              const CHARSET_INFO * const from_cs,
 
177
                              const CHARSET_INFO * const to_cs,
182
178
                              uint32_t *offset)
183
179
{
184
180
  *offset= 0;
219
215
*/
220
216
 
221
217
bool String::copy_aligned(const char *str,uint32_t arg_length, uint32_t offset,
222
 
                          CHARSET_INFO *cs)
 
218
                          const CHARSET_INFO * const cs)
223
219
{
224
220
  /* How many bytes are in incomplete character */
225
221
  offset= cs->mbmaxlen - offset; /* How many zeros we should prepend */
245
241
 
246
242
 
247
243
bool String::set_or_copy_aligned(const char *str,uint32_t arg_length,
248
 
                                 CHARSET_INFO *cs)
 
244
                                 const CHARSET_INFO * const cs)
249
245
{
250
246
  /* How many bytes are in incomplete character */
251
247
  uint32_t offset= (arg_length % cs->mbminlen); 
261
257
        /* Copy with charset conversion */
262
258
 
263
259
bool String::copy(const char *str, uint32_t arg_length,
264
 
                  CHARSET_INFO *from_cs, CHARSET_INFO *to_cs, uint *errors)
 
260
                          const CHARSET_INFO * const from_cs,
 
261
                                  const CHARSET_INFO * const to_cs, uint *errors)
265
262
{
266
263
  uint32_t offset;
267
264
  if (!needs_conversion(arg_length, from_cs, to_cs, &offset))
400
397
  with character set recoding
401
398
*/
402
399
 
403
 
bool String::append(const char *s,uint32_t arg_length, CHARSET_INFO *cs)
 
400
bool String::append(const char *s,uint32_t arg_length, const CHARSET_INFO * const cs)
404
401
{
405
402
  uint32_t dummy_offset;
406
403
  
628
625
*/
629
626
 
630
627
 
631
 
int sortcmp(const String *s,const String *t, CHARSET_INFO *cs)
 
628
int sortcmp(const String *s,const String *t, const CHARSET_INFO * const cs)
632
629
{
633
630
 return cs->coll->strnncollsp(cs,
634
631
                              (uchar *) s->ptr(),s->length(),
704
701
 
705
702
 
706
703
static uint32_t
707
 
copy_and_convert_extended(char *to, uint32_t to_length, CHARSET_INFO *to_cs, 
 
704
copy_and_convert_extended(char *to, uint32_t to_length,
 
705
                          const CHARSET_INFO * const to_cs, 
708
706
                          const char *from, uint32_t from_length,
709
 
                          CHARSET_INFO *from_cs,
 
707
                          const CHARSET_INFO * const from_cs,
710
708
                          uint *errors)
711
709
{
712
710
  int         cnvres;
763
761
  Optimized for quick copying of ASCII characters in the range 0x00..0x7F.
764
762
*/
765
763
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)
 
764
copy_and_convert(char *to, uint32_t to_length, const CHARSET_INFO * const to_cs, 
 
765
                 const char *from, uint32_t from_length,
 
766
                                 const CHARSET_INFO * const from_cs, uint *errors)
769
767
{
770
768
  /*
771
769
    If any of the character sets is not ASCII compatible,
839
837
*/
840
838
 
841
839
size_t
842
 
my_copy_with_hex_escaping(CHARSET_INFO *cs,
 
840
my_copy_with_hex_escaping(const CHARSET_INFO * const cs,
843
841
                          char *dst, size_t dstlen,
844
842
                          const char *src, size_t srclen)
845
843
{
908
906
 
909
907
 
910
908
uint32_t
911
 
well_formed_copy_nchars(CHARSET_INFO *to_cs,
 
909
well_formed_copy_nchars(const CHARSET_INFO * const to_cs,
912
910
                        char *to, uint to_length,
913
 
                        CHARSET_INFO *from_cs,
 
911
                        const CHARSET_INFO * const from_cs,
914
912
                        const char *from, uint from_length,
915
913
                        uint nchars,
916
914
                        const char **well_formed_error_pos,
1086
1084
  swap_variables(uint32_t, str_length, s.str_length);
1087
1085
  swap_variables(uint32_t, Alloced_length, s.Alloced_length);
1088
1086
  swap_variables(bool, alloced, s.alloced);
1089
 
  swap_variables(CHARSET_INFO*, str_charset, s.str_charset);
 
1087
  swap_variables(const CHARSET_INFO *, str_charset, s.str_charset);
1090
1088
}