From: <enl...@li...> - 2005-04-14 09:09:28
|
Enlightenment CVS committal Author : raster Project : e17 Module : apps/e Dir : e17/apps/e/src/bin Modified Files: e_intl.c e_main.c e_remote_main.c e_utils.c e_utils.h Log Message: wrap putenv... (and for remote_main just strudup - if we leak it doesnt matter - it will not run for long :) ) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_intl.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- e_intl.c 14 Apr 2005 05:49:17 -0000 1.14 +++ e_intl.c 14 Apr 2005 09:09:21 -0000 1.15 @@ -66,8 +66,7 @@ if (!lang) lang = getenv("LANG"); if (!lang) lang = "en"; _e_intl_language = strdup(lang); - snprintf(buf, sizeof(buf), "LANG=%s", _e_intl_language); - putenv(buf); + e_util_env_set("LANG", _e_intl_language); setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALE_DIR); textdomain(PACKAGE); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_main.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -3 -r1.63 -r1.64 --- e_main.c 14 Apr 2005 02:10:32 -0000 1.63 +++ e_main.c 14 Apr 2005 09:09:21 -0000 1.64 @@ -80,7 +80,7 @@ printf("after restart!!!\n"); after_restart = 1; } - putenv("RESTART=1"); + e_util_env_set("RESTART", "1"); e_intl_init(); @@ -91,8 +91,7 @@ { i++; - snprintf(buf, sizeof(buf), "DISPLAY=%s", argv[i]); - putenv(buf); + e_util_env_set("DISPLAY", argv[i]); } else if ((!strcmp(argv[i], "-fake-xinerama-screen")) && (i < (argc - 1))) { @@ -132,16 +131,16 @@ p = strrchr(s, ':'); if (!p) { - snprintf(buf, sizeof(buf), "DISPLAY=%s:0.0", s); - putenv(buf); + snprintf(buf, sizeof(buf), "%s:0.0", s); + e_util_env_set("DISPLAY", buf); } else { p = strrchr(p, '.'); if (!p) { - snprintf(buf, sizeof(buf), "DISPLAY=%s.0", s); - putenv(buf); + snprintf(buf, sizeof(buf), "%s.0", s); + e_util_env_set("DISPLAY", buf); } } } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_remote_main.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- e_remote_main.c 9 Apr 2005 06:06:38 -0000 1.11 +++ e_remote_main.c 14 Apr 2005 09:09:22 -0000 1.12 @@ -86,7 +86,7 @@ if (!p) { snprintf(buf, sizeof(buf), "DISPLAY=%s:0.0", s); - putenv(buf); + putenv(strdup(buf)); } else { @@ -94,7 +94,7 @@ if (!p) { snprintf(buf, sizeof(buf), "DISPLAY=%s.0", s); - putenv(buf); + putenv(strdup(buf)); } } } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_utils.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e_utils.c 7 Feb 2005 13:51:09 -0000 1.3 +++ e_utils.c 14 Apr 2005 09:09:22 -0000 1.4 @@ -49,6 +49,35 @@ _e_util_dummy_timer = ecore_timer_add(0.0, _e_util_wakeup_cb, NULL); } +void +e_util_env_set(const char *var, const char *val) +{ + char buf[4096]; + + if (val) + { +#ifdef HAVE_SETENV + setenv(var, val, 1); +#else + char buf[8192]; + + snprintf(buf, sizeof(buf), "%s=%s", var, val); + if (getenv(var)) + putenv(buf); + else + putenv(strdup(buf)); +#endif + } + else + { +#ifdef HAVE_UNSETENV + unsetenv(var); +#else + if (getenv(var)) putenv(var); +#endif + } +} + /* local subsystem functions */ static void _e_util_container_fake_mouse_up_cb(void *data) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_utils.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e_utils.h 7 Feb 2005 13:51:09 -0000 1.4 +++ e_utils.h 14 Apr 2005 09:09:22 -0000 1.5 @@ -9,6 +9,7 @@ EAPI void e_util_container_fake_mouse_up_later(E_Container *con, int button); EAPI void e_util_container_fake_mouse_up_all_later(E_Container *con); EAPI void e_util_wakeup(void); - +EAPI void e_util_env_set(const char *var, const char *val); + #endif #endif |