~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/my_strtoll10.c

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

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
 
  Convert a string to an to uint64_t integer value
38
 
 
 
31
  Convert a string to an to unsigned long long integer value
 
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
49
 
    int64_t value.
 
43
    long long integer value.
50
44
    Space characters and tab are ignored.
51
45
    A sign character might precede the digit characters. The number
52
46
    may have any number of pre-zero digits.
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
 
65
59
    -1          Number was an ok negative number
66
60
    0           ok
67
61
    ERANGE      If the the value of the converted number exceeded the
68
 
                maximum negative/uint64_t integer.
 
62
                maximum negative/unsigned long long integer.
69
63
                In this case the return value is UINT64_MAX if value was
70
64
                positive and UINT64_MIN if value was negative.
71
65
    EDOM        If the string didn't contain any digits. In this case
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 */