Last change
on this file since bc11fc1 was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
Use standard integer types.
|
-
Property mode
set to
100644
|
File size:
541 bytes
|
Rev | Line | |
---|
[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | atol.c -- ascii to long conversion
|
---|
| 4 | Version 3 -- 1987-06-29 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stddefs.h"
|
---|
| 9 | #include "ctype.h"
|
---|
| 10 |
|
---|
[7258c6a] | 11 | int32_t atol(int8_t *cp)
|
---|
[f40a309] | 12 | {
|
---|
[7258c6a] | 13 | register int32_t n;
|
---|
| 14 | register int16_t sign;
|
---|
[f40a309] | 15 |
|
---|
| 16 | sign = 0;
|
---|
| 17 |
|
---|
| 18 | if (*cp EQ '-') {
|
---|
| 19 |
|
---|
| 20 | ++cp;
|
---|
| 21 | sign = 1;
|
---|
| 22 |
|
---|
| 23 | } else {
|
---|
| 24 |
|
---|
| 25 | if (*cp EQ '+')
|
---|
| 26 | ++cp;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | for (n = 0; isdigit(*cp); )
|
---|
| 30 | n = n * 10 + *cp++ - '0';
|
---|
| 31 |
|
---|
| 32 | return(sign ? -n : n);
|
---|
| 33 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.