Last change
on this file since c3aee8a was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Use standard integer types.
|
-
Property mode
set to
100644
|
File size:
558 bytes
|
Rev | Line | |
---|
[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | atoi.c -- ascii to integer conversion
|
---|
| 4 | Version 4 -- 1987-07-09 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stddefs.h"
|
---|
| 9 | #include "ctype.h"
|
---|
| 10 |
|
---|
[7258c6a] | 11 | int16_t atoi(int8_t *cp)
|
---|
[f40a309] | 12 | {
|
---|
[7258c6a] | 13 | register uint16_t i;
|
---|
| 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 (i = 0; isdigit(*cp); )
|
---|
| 30 | i = i * 10 + (0x7F & *cp++) - '0';
|
---|
| 31 |
|
---|
| 32 | return(sign ? -i : i);
|
---|
| 33 | }
|
---|
| 34 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.