mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-23 00:14:25 +00:00
27 lines
397 B
C
27 lines
397 B
C
/* atoi - convert decimal number in ascii to integer */
|
|
#include <portab.h>
|
|
#include <ctype.h>
|
|
|
|
WORD atoi(s)
|
|
REG BYTE *s;
|
|
{
|
|
REG WORD val;
|
|
REG WORD isneg;
|
|
|
|
val = 0;
|
|
isneg = FALSE;
|
|
while( isspace(*s) )
|
|
s++;
|
|
if( *s == '+' )
|
|
s++;
|
|
else if( *s == '-' ) {
|
|
s++;
|
|
isneg++;
|
|
}
|
|
while( *s >= '0' && *s <= '9' )
|
|
val = 10 * val + ( *s++ - '0' );
|
|
if( isneg )
|
|
val = -val;
|
|
return( val );
|
|
}
|