src/stdlib/SDL_string.c
changeset 1341 d02b552e5304
parent 1338 604d73db6802
child 1343 d5c4f8f6855e
     1.1 --- a/src/stdlib/SDL_string.c	Tue Feb 07 11:18:21 2006 +0000
     1.2 +++ b/src/stdlib/SDL_string.c	Tue Feb 07 12:11:33 2006 +0000
     1.3 @@ -25,6 +25,7 @@
     1.4  
     1.5  #include "SDL_types.h"
     1.6  #include "SDL_ctype.h"
     1.7 +#include "SDL_stdlib.h"
     1.8  #include "SDL_string.h"
     1.9  
    1.10  
    1.11 @@ -175,7 +176,7 @@
    1.12  #endif
    1.13  #endif /* SDL_HAS_64BIT_TYPE */
    1.14  
    1.15 -#ifndef HAVE_SSCANF
    1.16 +#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD)
    1.17  static size_t SDL_ScanFloat(const char *text, double *valuep)
    1.18  {
    1.19      const char *textstart = text;
    1.20 @@ -322,6 +323,18 @@
    1.21  }
    1.22  #endif
    1.23  
    1.24 +#ifndef HAVE_STRDUP
    1.25 +char *SDL_strdup(const char *string)
    1.26 +{
    1.27 +    size_t len = SDL_strlen(string);
    1.28 +    char *newstr = SDL_malloc(len+1);
    1.29 +    if ( newstr ) {
    1.30 +        SDL_strcpy(newstr, string);
    1.31 +    }
    1.32 +    return newstr;
    1.33 +}
    1.34 +#endif
    1.35 +
    1.36  #ifndef HAVE__STRREV
    1.37  char *SDL_strrev(char *string)
    1.38  {
    1.39 @@ -549,6 +562,20 @@
    1.40  
    1.41  #endif /* SDL_HAS_64BIT_TYPE */
    1.42  
    1.43 +#ifndef HAVE_STRTOD
    1.44 +double SDL_strtod(const char *string, char **endp)
    1.45 +{
    1.46 +    size_t len;
    1.47 +    double value;
    1.48 +
    1.49 +    len = SDL_ScanFloat(string, &value);
    1.50 +    if ( endp ) {
    1.51 +        *endp = (char *)string + len;
    1.52 +    }
    1.53 +    return value;
    1.54 +}
    1.55 +#endif
    1.56 +
    1.57  #ifndef HAVE_STRCMP
    1.58  int SDL_strcmp(const char *str1, const char *str2)
    1.59  {