28 lines
681 B
C
28 lines
681 B
C
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
|
|
/* Copyright (c) 1988 AT&T */
|
|
/* All Rights Reserved */
|
|
|
|
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
|
|
/* UNIX System Laboratories, Inc. */
|
|
/* The copyright notice above does not evidence any */
|
|
/* actual or intended publication of such source code. */
|
|
|
|
#ident "@(#)sccs:lib/mpwlib/patoi.c 6.2"
|
|
/*
|
|
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);
|
|
}
|