Mercurial > mplayer.hg
changeset 17245:44c24de55f9d
- move our setenv() fallback implementation to osdep
- assert that the override param is nonzero (zero is not implemented)
- correct return value type to int
based on a patch by Diego
fixes bugzilla bug #342
author | al |
---|---|
date | Mon, 26 Dec 2005 03:16:48 +0000 |
parents | 70120627f0b9 |
children | e2aae45168cf |
files | configure libao2/ao_sdl.c libvo/vo_sdl.c osdep/Makefile osdep/setenv.c |
diffstat | 5 files changed, 51 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/configure Sun Dec 25 21:33:15 2005 +0000 +++ b/configure Mon Dec 26 03:16:48 2005 +0000 @@ -3304,6 +3304,21 @@ echores "$_glob" +echocheck "setenv()" +cat > $TMPC << EOF +#include <stdlib.h> +int main (void){ setenv("","",0); return 0; } +EOF +_setenv=no +cc_check && _setenv=yes +if test "$_setenv" = yes ; then + _def_setenv='#define HAVE_SETENV 1' +else + _def_setenv='#undef HAVE_SETENV' +fi +echores "$_setenv" + + echocheck "sys/sysinfo.h" cat > $TMPC << EOF #include <sys/sysinfo.h> @@ -7480,6 +7495,12 @@ /* Define this if your system has glob */ $_def_glob +/* Define this if your system has setenv */ +$_def_setenv +#ifndef HAVE_SETENV +int setenv(const char *name, const char *val, int overwrite); +#endif + /* Define this if your system has pthreads */ $_def_pthreads
--- a/libao2/ao_sdl.c Sun Dec 25 21:33:15 2005 +0000 +++ b/libao2/ao_sdl.c Mon Dec 26 03:16:48 2005 +0000 @@ -122,22 +122,6 @@ // end ring buffer stuff -#if defined(__MINGW32__) || defined(HPUX) || defined(sgi) || (defined(sun) && defined(__svr4__)) -/* setenv is missing on win32, solaris, IRIX and HPUX */ -static void setenv(const char *name, const char *val, int _xx) -{ - int len = strlen(name) + strlen(val) + 2; - char *env = malloc(len); - - if (env != NULL) { - strcpy(env, name); - strcat(env, "="); - strcat(env, val); - putenv(env); - } -} -#endif - // to set/get/query special features/parameters static int control(int cmd,void *arg){
--- a/libvo/vo_sdl.c Sun Dec 25 21:33:15 2005 +0000 +++ b/libvo/vo_sdl.c Mon Dec 26 03:16:48 2005 +0000 @@ -138,22 +138,6 @@ #include <SDL.h> //#include <SDL/SDL_syswm.h> -#if defined(__MINGW32__) || defined(HPUX) || defined(sgi) || (defined(sun) && defined(__svr4__)) -/* setenv is missing on win32, solaris, IRIX and HPUX */ -static void setenv(const char *name, const char *val, int _xx) -{ - int len = strlen(name) + strlen(val) + 2; - char *env = malloc(len); - - if (env != NULL) { - strcpy(env, name); - strcat(env, "="); - strcat(env, val); - putenv(env); - } -} -#endif - #ifdef SDL_ENABLE_LOCKS #define SDL_OVR_LOCK(x) if (SDL_LockYUVOverlay (priv->overlay)) { \
--- a/osdep/Makefile Sun Dec 25 21:33:15 2005 +0000 +++ b/osdep/Makefile Mon Dec 26 03:16:48 2005 +0000 @@ -4,7 +4,7 @@ LIBNAME = libosdep.a SRCS= shmem.c strsep.c strl.c vsscanf.c scandir.c gettimeofday.c fseeko.c \ - swab.c + swab.c setenv.c # timer.c getch = getch2.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osdep/setenv.c Mon Dec 26 03:16:48 2005 +0000 @@ -0,0 +1,29 @@ +/* setenv implementation for systems lacking it. */ + +#include "../config.h" + +#ifndef HAVE_SETENV + +#include <stdlib.h> +#include <string.h> +#ifndef MP_DEBUG + #define NDEBUG +#endif +#include <assert.h> + +int setenv(const char *name, const char *val, int overwrite) +{ + int len = strlen(name) + strlen(val) + 2; + char *env = malloc(len); + if (!env) { return -1; } + + assert(overwrite != 0); + + strcpy(env, name); + strcat(env, "="); + strcat(env, val); + putenv(env); + + return 0; +} +#endif