| 72 | |
| 73 | |
| 74 | longlong my_strtoll10(const char *nptr, char **endptr, int *error) |
| 75 | { |
| 76 | const char *s, *end, *start, *n_end, *true_end; |
| 77 | char *dummy; |
| 78 | uchar c; |
| 79 | unsigned long i, j, k; |
| 80 | ulonglong li; |
| 81 | int negative; |
| 82 | ulong cutoff, cutoff2, cutoff3; |
| 83 | |
| 84 | s= nptr; |
| 85 | /* If fixed length string */ |
| 86 | if (endptr) |
| 87 | { |
| 88 | end= *endptr; |
| 89 | while (s != end && (*s == ' ' || *s == '\t')) |
| 90 | s++; |
| 91 | if (s == end) |
| 92 | goto no_conv; |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | endptr= &dummy; /* Easier end test */ |
| 97 | while (*s == ' ' || *s == '\t') |
| 98 | s++; |
| 99 | if (!*s) |
| 100 | goto no_conv; |
| 101 | /* This number must be big to guard against a lot of pre-zeros */ |
| 102 | end= s+65535; /* Can't be longer than this */ |
| 103 | } |
| 104 | |
| 105 | /* Check for a sign. */ |
| 106 | negative= 0; |
| 107 | if (*s == '-') |
| 108 | { |
| 109 | *error= -1; /* Mark as negative number */ |
| 110 | negative= 1; |
| 111 | if (++s == end) |
| 112 | goto no_conv; |
| 113 | cutoff= MAX_NEGATIVE_NUMBER / LFACTOR2; |
| 114 | cutoff2= (MAX_NEGATIVE_NUMBER % LFACTOR2) / 100; |
| 115 | cutoff3= MAX_NEGATIVE_NUMBER % 100; |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | *error= 0; |
| 120 | if (*s == '+') |
| 121 | { |
| 122 | if (++s == end) |
| 123 | goto no_conv; |
| 124 | } |
| 125 | cutoff= ULONGLONG_MAX / LFACTOR2; |
| 126 | cutoff2= ULONGLONG_MAX % LFACTOR2 / 100; |
| 127 | cutoff3= ULONGLONG_MAX % 100; |
| 128 | } |
| 129 | |
| 130 | /* Handle case where we have a lot of pre-zero */ |
| 131 | if (*s == '0') |
no outgoing calls
no test coverage detected