SysIII/usr/src/lib/libPW/patoi.c

Compare this file to the similar file:
Show the results in this format:

static char Sccsid[]="@(#)patoi	3.1";
/*
	Function to convert ascii string to integer.  Converts
	positive numbers only.  Returns -1 if non-numeric
	character encountered.
*/

patoi(s)
register char *s;
{
	register int i;

	i = 0;
	while(*s >= '0' && *s <= '9') i = 10 * i + *s++ - '0';

	if(*s) return(-1);
	return(i);
}