Browse Source

atoi, atol, atoll, and atof are supposed to be functions, not macros.
-Erik

Eric Andersen 23 years ago
parent
commit
fa5a15eeb2
5 changed files with 39 additions and 7 deletions
  1. 4 4
      include/stdlib.h
  2. 2 2
      libc/stdlib/Makefile
  3. 16 1
      libc/stdlib/strto_l.c
  4. 10 0
      libc/stdlib/strto_ll.c
  5. 7 0
      libc/stdlib/strtod.c

+ 4 - 4
include/stdlib.h

@@ -42,10 +42,10 @@ typedef __compar_fn_t comparison_fn_t;
 
 
 /* String to number conversion functions */
-#define atof(x) strtod((x),(char**)0)
-#define atoi(x) (int)strtol((x),(char**)0,10)
-#define atol(x) strtol((x),(char**)0,10)
-#define atoll(x) strtoll((x),(char**)0,10)
+extern double atof(const char *nptr);
+extern int atoi(const char *nptr);
+extern long atol(const char *nptr);
+extern long long atoll(const char *nptr);
 extern long strtol __P ((const char * nptr, char ** endptr, int base));
 extern unsigned long strtoul __P ((const char * nptr, char ** endptr, int base));
 extern long long strtoll __P ((const char * nptr, char ** endptr, int base));

+ 2 - 2
libc/stdlib/Makefile

@@ -27,10 +27,10 @@ DIRS = $(MALLOC)
 ALL_SUBDIRS = malloc malloc-930716 malloc-simple
 
 MSRC=strto_l.c
-MOBJ=strtol.o strtoul.o strto_l.o
+MOBJ=strtol.o strtoul.o strto_l.o atoi.o atol.o
 
 MSRC1=strto_ll.c
-MOBJ1=strtoll.o strtoull.o strto_ll.o
+MOBJ1=strtoll.o strtoull.o strto_ll.o atoll.o
 
 MSRC2=atexit.c
 MOBJ2=atexit.o exit.o

+ 16 - 1
libc/stdlib/strto_l.c

@@ -183,10 +183,25 @@ unsigned long strtoul(const char *str, char **endptr, int base)
 #endif
 
 #if L_strtol
-
 long strtol(const char *str, char **endptr, int base)
 {
     return _strto_l(str, endptr, base, 0);
 }
 
 #endif
+
+#ifdef L_atoi
+int atoi(const char *str)
+{
+    return((int)_strto_l((str),(char**)0,10, 0));
+
+}
+#endif
+
+#ifdef L_atol
+long atol(const char *str)
+{
+    return(_strto_l((str),(char**)0,10, 0));
+}
+#endif
+

+ 10 - 0
libc/stdlib/strto_ll.c

@@ -190,3 +190,13 @@ long long strtoll(const char *str, char **endptr, int base)
 }
 
 #endif
+
+#ifdef L_atoll
+long long atoll(const char *str)
+{
+    return(_strto_ll((str),(char**)0,10,0));
+}
+#endif
+
+
+

+ 7 - 0
libc/stdlib/strtod.c

@@ -261,3 +261,10 @@ double strtod(const char *str, char **endptr)
 
     return number;
 }
+
+/* This should probably be in its own .o file.  Oh well. */
+double atof(const char *str)
+{
+    return(strtod((str),(char**)0));
+
+}