source: buchla-68k/libcio/atoi.c@ 7848656

Last change on this file since 7848656 was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Use standard integer types.

  • Property mode set to 100644
File size: 558 bytes
Line 
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
11int16_t atoi(int8_t *cp)
12{
13 register uint16_t i;
14 register int16_t sign;
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.