macro and text revision (-mdoc version 3)
[unix-history] / usr / src / lib / libc / stdlib / atoi.c
index e382eb7..42e3fea 100644 (file)
@@ -1,25 +1,19 @@
-/* @(#)atoi.c  4.3 (Berkeley) 81/02/28 */
-atoi(p)
-register char *p;
-{
-       register int n;
-       register 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 */
 
 
-       n = 0;
-       f = 0;
-       for(;;p++) {
-               switch(*p) {
-               case ' ':
-               case '\t':
-                       continue;
-               case '-':
-                       f++;
-               case '+':
-                       p++;
-               }
-               break;
-       }
-       while(*p >= '0' && *p <= '9')
-               n = n*10 + *p++ - '0';
-       return(f? -n: n);
+#include <stdlib.h>
+#include <stddef.h>
+
+atoi(str)
+       const char *str;
+{
+       return((int)strtol(str, (char **)NULL, 10));
 }
 }