~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/longlong2str.c

  • Committer: Mark Atwood
  • Date: 2008-10-03 01:39:40 UTC
  • mto: This revision was merged to the branch mainline in revision 437.
  • Revision ID: mark@fallenpegasus.com-20081003013940-mvefjo725dltz41h
rename logging_noop to logging_query

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/*
17
17
  Defines: int64_t2str();
20
20
  converts the (int64_t) integer "val" to character form and moves it to
21
21
  the destination string "dst" followed by a terminating NUL.  The
22
22
  result is normally a pointer to this NUL character, but if the radix
23
 
  is dud the result will be NULL and nothing will be changed.
 
23
  is dud the result will be NullS and nothing will be changed.
24
24
 
25
25
  If radix is -2..-36, val is taken to be SIGNED.
26
26
  If radix is  2.. 36, val is taken to be UNSIGNED.
37
37
        itoa assumes that 10 -base numbers are allways signed and other arn't.
38
38
*/
39
39
 
40
 
#include "config.h"
41
 
 
42
40
#include "m_string.h"
43
41
 
44
 
namespace drizzled
45
 
{
46
 
namespace internal
47
 
{
48
 
 
49
42
#if !defined(int64_t2str) && !defined(HAVE_LONGLONG2STR)
50
43
 
51
 
char _dig_vec_upper[] =
52
 
  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
53
 
 
54
44
/*
55
45
  This assumes that int64_t multiplication is faster than int64_t division.
56
46
*/
87
77
 
88
78
  while (uval > (uint64_t) LONG_MAX)
89
79
  {
90
 
    uint64_t quo= uval/(uint32_t) radix;
91
 
    uint32_t rem= (uint32_t) (uval- quo* (uint32_t) radix);
 
80
    uint64_t quo= uval/(uint) radix;
 
81
    uint rem= (uint) (uval- quo* (uint) radix);
92
82
    *--p = _dig_vec_upper[rem];
93
83
    uval= quo;
94
84
  }
96
86
  while (long_val != 0)
97
87
  {
98
88
    long quo= long_val/radix;
99
 
    *--p = _dig_vec_upper[(unsigned char) (long_val - quo*radix)];
 
89
    *--p = _dig_vec_upper[(uchar) (long_val - quo*radix)];
100
90
    long_val= quo;
101
91
  }
102
92
  while ((*dst++ = *p++) != 0) ;
134
124
 
135
125
  while (uval > (uint64_t) LONG_MAX)
136
126
  {
137
 
    uint64_t quo= uval/(uint32_t) 10;
138
 
    uint32_t rem= (uint32_t) (uval- quo* (uint32_t) 10);
 
127
    uint64_t quo= uval/(uint) 10;
 
128
    uint rem= (uint) (uval- quo* (uint) 10);
139
129
    *--p = _dig_vec_upper[rem];
140
130
    uval= quo;
141
131
  }
143
133
  while (long_val != 0)
144
134
  {
145
135
    long quo= long_val/10;
146
 
    *--p = _dig_vec_upper[(unsigned char) (long_val - quo*10)];
 
136
    *--p = _dig_vec_upper[(uchar) (long_val - quo*10)];
147
137
    long_val= quo;
148
138
  }
149
139
  while ((*dst++ = *p++) != 0) ;
150
140
  return dst-1;
151
141
}
152
142
#endif
153
 
 
154
 
} /* namespace internal */
155
 
} /* namespace drizzled */