macro and text revision (-mdoc version 3)
[unix-history] / usr / src / lib / libc / stdlib / atoi.c
index 7382fc2..42e3fea 100644 (file)
@@ -1,25 +1,19 @@
-/* @(#)atoi.c  4.1 (Berkeley) %G% */
-atoi(ap)
-char *ap;
-{
-       register int  n, c;
-       register char *p;
-       int f;
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)atoi.c     5.7 (Berkeley) %G%";
+#endif /* LIBC_SCCS and not lint */
 
 
-       p = ap;
-       n = 0;
-       f = 0;
-loop:
-       while(*p == ' ' || *p == '      ')
-               p++;
-       if(*p == '-') {
-               f++;
-               p++;
-               goto loop;
-       }
-       while(*p >= '0' && *p <= '9')
-               n = n*10 + *p++ - '0';
-       if(f)
-               n = -n;
-       return(n);
+#include <stdlib.h>
+#include <stddef.h>
+
+atoi(str)
+       const char *str;
+{
+       return((int)strtol(str, (char **)NULL, 10));
 }
 }