[MPlayer-dev-eng] [PATCH] move setenv implementation to osdep/

Diego Biurrun diego at biurrun.de
Thu Oct 27 00:31:23 CEST 2005


On Thu, Oct 27, 2005 at 12:29:15AM +0200, Diego Biurrun wrote:
> Attached patch should fix bug #342 and generally make sense by removing
> code duplication.
> 
> Any glaring mistakes?  OK to commit?
  ^^^^^^^^^^^^^^^^^^^^^

Apart from forgetting to attach the patch i mean ... *sigh*

Here it is.

Diego
-------------- next part --------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.1096
diff -u -r1.1096 configure
--- configure	26 Oct 2005 20:40:19 -0000	1.1096
+++ configure	26 Oct 2005 22:26:31 -0000
@@ -3304,6 +3306,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>
@@ -7384,6 +7401,9 @@
 /* Define this if your system has glob */
 $_def_glob
 
+/* Define this if your system has setenv */
+$_def_setenv
+
 /* Define this if your system has pthreads */
 $_def_pthreads
 
Index: osdep/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/osdep/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- osdep/Makefile	18 Aug 2005 11:26:04 -0000	1.19
+++ osdep/Makefile	26 Oct 2005 22:26:31 -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
Index: libao2/ao_sdl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_sdl.c,v
retrieving revision 1.41
diff -u -r1.41 ao_sdl.c
--- libao2/ao_sdl.c	27 Feb 2005 23:06:32 -0000	1.41
+++ libao2/ao_sdl.c	26 Oct 2005 22:26:31 -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){
Index: libvo/vo_sdl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_sdl.c,v
retrieving revision 1.122
diff -u -r1.122 vo_sdl.c
--- libvo/vo_sdl.c	5 Aug 2005 01:24:36 -0000	1.122
+++ libvo/vo_sdl.c	26 Oct 2005 22:26:31 -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)) { \
--- /dev/null	2005-10-26 22:03:01.101616344 +0200
+++ osdep/setenv.c	2005-10-27 00:21:49.000000000 +0200
@@ -0,0 +1,20 @@
+/* setenv implementation for systems lacking setenv in stdlib.h. */
+
+#ifndef HAVE_SETENV
+
+#include <stdlib.h>
+#include <string.h>
+
+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


More information about the MPlayer-dev-eng mailing list