4577543 [rkeene@sledge /home/rkeene/devel/libconfig-0.2.5]$ cat -n strtoll.c
 1 #include <sys/types.h>
 2 #include <stdlib.h>
 3 #include <limits.h>
 4 #include <ctype.h>
 5 #include <stdio.h>
 6 
 7 /* We only handle base 10. */
 8 long long int strtoll(const char *nptr, char **endptr, int base) {
 9     long long int retval = 0;
10     const char **endptrd = (const char **) endptr;
11     const char *idx = NULL;
12     int allowspace = 1;
13 
14     idx = nptr;
15     while (1) {
16         if (*idx == '\0') {
17             break;
18         }
19 
20         if (!isdigit(*idx)) {
21             if (*idx == '-') {
22                 retval *= -1;
23                 continue;
24             }
25             if ((*idx == ' ' || *idx == '\t') && allowspace) {
26                 continue;
27             }
28             break;
29         }
30 
31         retval *= 10;
32         retval += (*idx - '0');
33 
34         allowspace = 0;
35         idx++;
36     }
37 
38     if (endptrd != NULL) {
39         *endptrd = idx;
40     }
41 
42     return(retval);
43 }
4577544 [rkeene@sledge /home/rkeene/devel/libconfig-0.2.5]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2004-12-20 06:42:10