source:
buchla-68k/libcio/atoi.c@
a95b757
| Last change on this file since a95b757 was 8973acd, checked in by , 8 years ago | |
|---|---|
|
|
| File size: 535 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 | ||
| [b28a12e] | 8 | #include "ram.h" |
| [f40a309] | 9 | |
| [7258c6a] | 10 | int16_t atoi(int8_t *cp) |
| [f40a309] | 11 | { |
| [8973acd] | 12 | register int16_t i; |
| [7258c6a] | 13 | register int16_t sign; |
| [f40a309] | 14 | |
| 15 | sign = 0; | |
| 16 | ||
| 17 | if ( *cp EQ '-' ) { | |
| 18 | ||
| 19 | ++cp; | |
| 20 | sign = 1; | |
| 21 | ||
| 22 | } else { | |
| 23 | ||
| 24 | if (*cp EQ '+') | |
| 25 | ++cp; | |
| 26 | } | |
| 27 | ||
| 28 | for (i = 0; isdigit(*cp); ) | |
| 29 | i = i * 10 + (0x7F & *cp++) - '0'; | |
| 30 | ||
| 31 | return(sign ? -i : i); | |
| 32 | } | |
| 33 | ||
| [6262b5c] | 34 |
Note:
See TracBrowser
for help on using the repository browser.
![(please configure the [header_logo] section in trac.ini)](http://bob.lopatic.de/chrome/site/logo.png)