Mercurial > sdl-ios-xcode
diff src/SDL_compat.c @ 3581:15eea7a1fa97
Implemented SDL_setenv(), moved SDL_putenv() to compat.
Fixes Bugzilla #779.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 16 Dec 2009 10:59:51 +0000 |
parents | abefdc334970 |
children | f8816ffa210b |
line wrap: on
line diff
--- a/src/SDL_compat.c Wed Dec 16 08:17:05 2009 +0000 +++ b/src/SDL_compat.c Wed Dec 16 10:59:51 2009 +0000 @@ -1754,4 +1754,26 @@ return previous; } + +int +SDL_putenv(const char *_var) +{ + char *ptr = NULL; + char *var = SDL_strdup(_var); + if (var == NULL) { + return -1; /* we don't set errno. */ + } + + ptr = strchr(var, '='); + if (ptr == NULL) { + SDL_free(var); + return -1; + } + + *ptr = '\0'; /* split the string into name and value. */ + SDL_setenv(var, ptr + 1, 1); + SDL_free(var); + return 0; +} + /* vi: set ts=4 sw=4 expandtab: */