diff src/stdlib/SDL_string.c @ 1341:d02b552e5304

Configure dynamically generates SDL_config.h I'm still wrestling with autoheader, but this should work for now... Fixed lots of build problems with C library support disabled
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 12:11:33 +0000
parents 604d73db6802
children d5c4f8f6855e
line wrap: on
line diff
--- a/src/stdlib/SDL_string.c	Tue Feb 07 11:18:21 2006 +0000
+++ b/src/stdlib/SDL_string.c	Tue Feb 07 12:11:33 2006 +0000
@@ -25,6 +25,7 @@
 
 #include "SDL_types.h"
 #include "SDL_ctype.h"
+#include "SDL_stdlib.h"
 #include "SDL_string.h"
 
 
@@ -175,7 +176,7 @@
 #endif
 #endif /* SDL_HAS_64BIT_TYPE */
 
-#ifndef HAVE_SSCANF
+#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD)
 static size_t SDL_ScanFloat(const char *text, double *valuep)
 {
     const char *textstart = text;
@@ -322,6 +323,18 @@
 }
 #endif
 
+#ifndef HAVE_STRDUP
+char *SDL_strdup(const char *string)
+{
+    size_t len = SDL_strlen(string);
+    char *newstr = SDL_malloc(len+1);
+    if ( newstr ) {
+        SDL_strcpy(newstr, string);
+    }
+    return newstr;
+}
+#endif
+
 #ifndef HAVE__STRREV
 char *SDL_strrev(char *string)
 {
@@ -549,6 +562,20 @@
 
 #endif /* SDL_HAS_64BIT_TYPE */
 
+#ifndef HAVE_STRTOD
+double SDL_strtod(const char *string, char **endp)
+{
+    size_t len;
+    double value;
+
+    len = SDL_ScanFloat(string, &value);
+    if ( endp ) {
+        *endp = (char *)string + len;
+    }
+    return value;
+}
+#endif
+
 #ifndef HAVE_STRCMP
 int SDL_strcmp(const char *str1, const char *str2)
 {