~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/my_strtoll10.c

  • Committer: Monty Taylor
  • Date: 2008-10-09 22:38:27 UTC
  • mto: This revision was merged to the branch mainline in revision 497.
  • Revision ID: monty@inaugust.com-20081009223827-bc9gvpiplsmvpwyq
Moved test() to its own file.
Made a new function to possibly replace int10_to_str.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "config.h"
17
 
#include "drizzled/internal/m_string.h"
 
16
#include <m_string.h>
18
17
#include <errno.h>
19
18
 
20
 
namespace drizzled
21
 
{
22
 
namespace internal
23
 
{
24
 
 
25
19
#define MAX_NEGATIVE_NUMBER     ((uint64_t) 0x8000000000000000LL)
26
20
#define INIT_CNT  9
27
21
#define LFACTOR   1000000000ULL
28
22
#define LFACTOR1  10000000000ULL
29
23
#define LFACTOR2  100000000000ULL
30
24
 
31
 
static uint64_t lfactor[9]=
 
25
static unsigned long lfactor[9]=
32
26
{
33
27
  1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L
34
28
};
35
29
 
36
30
/*
37
31
  Convert a string to an to uint64_t integer value
38
 
 
 
32
  
39
33
  SYNOPSYS
40
34
    my_strtoll10()
41
35
      nptr     in       pointer to the string to be converted
42
36
      endptr   in/out   pointer to the end of the string/
43
37
                        pointer to the stop character
44
38
      error    out      returned error code
45
 
 
 
39
 
46
40
  DESCRIPTION
47
41
    This function takes the decimal representation of integer number
48
42
    from string nptr and converts it to an signed or unsigned
54
48
    The function stops reading the string nptr at the first character
55
49
    that is not a decimal digit. If endptr is not NULL then the function
56
50
    will not read characters after *endptr.
57
 
 
 
51
 
58
52
  RETURN VALUES
59
53
    Value of string as a signed/unsigned int64_t integer
60
54
 
84
78
  unsigned long i, j, k;
85
79
  uint64_t li;
86
80
  int negative;
87
 
  uint64_t cutoff, cutoff2, cutoff3;
 
81
  unsigned long cutoff, cutoff2, cutoff3;
88
82
 
89
83
  s= nptr;
90
84
  /* If fixed length string */
239
233
  *endptr= (char *) nptr;
240
234
  return 0;
241
235
}
242
 
 
243
 
} /* namespace internal */
244
 
} /* namespace drizzled */