~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/my_strtoll10.cc

  • Committer: Brian Aker
  • Date: 2009-05-11 17:50:22 UTC
  • Revision ID: brian@gaz-20090511175022-y35q9ky6uh9ldcjt
Replacing Sun employee copyright headers (aka... anything done by a Sun
employee is copyright by Sun).

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 <m_string.h>
 
16
#include <drizzled/global.h>
 
17
#include <mystrings/m_string.h>
17
18
#include <errno.h>
18
19
 
19
20
#define MAX_NEGATIVE_NUMBER     ((uint64_t) 0x8000000000000000LL)
22
23
#define LFACTOR1  10000000000ULL
23
24
#define LFACTOR2  100000000000ULL
24
25
 
25
 
static unsigned long lfactor[9]=
 
26
static uint64_t lfactor[9]=
26
27
{
27
28
  1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L
28
29
};
29
30
 
30
31
/*
31
 
  Convert a string to an to unsigned long long integer value
32
 
  
 
32
  Convert a string to an to uint64_t integer value
 
33
 
33
34
  SYNOPSYS
34
35
    my_strtoll10()
35
36
      nptr     in       pointer to the string to be converted
36
37
      endptr   in/out   pointer to the end of the string/
37
38
                        pointer to the stop character
38
39
      error    out      returned error code
39
 
 
 
40
 
40
41
  DESCRIPTION
41
42
    This function takes the decimal representation of integer number
42
43
    from string nptr and converts it to an signed or unsigned
43
 
    long long integer value.
 
44
    int64_t value.
44
45
    Space characters and tab are ignored.
45
46
    A sign character might precede the digit characters. The number
46
47
    may have any number of pre-zero digits.
48
49
    The function stops reading the string nptr at the first character
49
50
    that is not a decimal digit. If endptr is not NULL then the function
50
51
    will not read characters after *endptr.
51
 
 
 
52
 
52
53
  RETURN VALUES
53
54
    Value of string as a signed/unsigned int64_t integer
54
55
 
59
60
    -1          Number was an ok negative number
60
61
    0           ok
61
62
    ERANGE      If the the value of the converted number exceeded the
62
 
                maximum negative/unsigned long long integer.
 
63
                maximum negative/uint64_t integer.
63
64
                In this case the return value is UINT64_MAX if value was
64
65
                positive and UINT64_MIN if value was negative.
65
66
    EDOM        If the string didn't contain any digits. In this case
78
79
  unsigned long i, j, k;
79
80
  uint64_t li;
80
81
  int negative;
81
 
  unsigned long cutoff, cutoff2, cutoff3;
 
82
  uint64_t cutoff, cutoff2, cutoff3;
82
83
 
83
84
  s= nptr;
84
85
  /* If fixed length string */