source: buchla-68k/orig/IOLIB/ATOI.C@ 66b48e7

Last change on this file since 66b48e7 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 599 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
11int
12atoi(cp)
13register char *cp;
14{
15 register unsigned i;
16 register short sign;
17
18 sign = 0;
19
20 if ( *cp EQ '-' ) {
21
22 ++cp;
23 sign = 1;
24
25 } else {
26
27 if (*cp EQ '+')
28 ++cp;
29 }
30
31 for (i = 0; isdigit(*cp); )
32 i = i * 10 + (0x7F & *cp++) - '0';
33
34 return(sign ? -i : i);
35}
36
Note: See TracBrowser for help on using the repository browser.