From: Jarkko Hietaniemi Date: Fri, 23 Feb 2001 20:02:25 +0000 (+0000) Subject: Abolish USE_WIN32_RTL_ENV. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2d7c14ee4980d18d982b4709ee152c49510a6872;p=p5sagit%2Fp5-mst-13.2.git Abolish USE_WIN32_RTL_ENV. p4raw-id: //depot/perl@8916 --- diff --git a/perl.c b/perl.c index 23b1a4d..b1d70b1 100644 --- a/perl.c +++ b/perl.c @@ -3382,15 +3382,6 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register sv = newSVpv(s--,0); (void)hv_store(hv, *env, s - *env, sv, 0); *s = '='; -#if defined(__BORLANDC__) && defined(USE_WIN32_RTL_ENV) - /* Sins of the RTL. See note in my_setenv(). */ - { - STRLEN len = strlen(*env); - char *e = safesysmalloc(len+1); - (void)strcpy(e, *env); - (void)PerlEnv_putenv(e); - } -#endif } #ifdef NEED_ENVIRON_DUP_FOR_MODIFY if (dup_env_base) { diff --git a/util.c b/util.c index 409307f..e24a81d 100644 --- a/util.c +++ b/util.c @@ -2039,47 +2039,6 @@ Perl_my_setenv(pTHX_ char *nam, char *val) void Perl_my_setenv(pTHX_ char *nam,char *val) { - -#ifdef USE_WIN32_RTL_ENV - - register char *envstr; - STRLEN namlen = strlen(nam); - STRLEN vallen; - char *oldstr = environ[setenv_getix(nam)]; - - /* putenv() has totally broken semantics in both the Borland - * and Microsoft CRTLs. They either store the passed pointer in - * the environment without making a copy, or make a copy and don't - * free it. And on top of that, they dont free() old entries that - * are being replaced/deleted. This means the caller must - * free any old entries somehow, or we end up with a memory - * leak every time my_setenv() is called. One might think - * one could directly manipulate environ[], like the UNIX code - * above, but direct changes to environ are not allowed when - * calling putenv(), since the RTLs maintain an internal - * *copy* of environ[]. Bad, bad, *bad* stink. - * GSAR 97-06-07 - */ - - if (!val) { - if (!oldstr) - return; - val = ""; - vallen = 0; - } - else - vallen = strlen(val); - envstr = (char*)safesysmalloc((namlen + vallen + 3) * sizeof(char)); - (void)sprintf(envstr,"%s=%s",nam,val); - (void)PerlEnv_putenv(envstr); - if (oldstr) - safesysfree(oldstr); -#ifdef _MSC_VER - safesysfree(envstr); /* MSVCRT leaks without this */ -#endif - -#else /* !USE_WIN32_RTL_ENV */ - register char *envstr; STRLEN len = strlen(nam) + 3; if (!val) { @@ -2090,8 +2049,6 @@ Perl_my_setenv(pTHX_ char *nam,char *val) (void)sprintf(envstr,"%s=%s",nam,val); (void)PerlEnv_putenv(envstr); Safefree(envstr); - -#endif } #endif /* WIN32 */ diff --git a/win32/win32.c b/win32/win32.c index ba445a4..226ef9b 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1322,8 +1322,6 @@ win32_longpath(char *path) return path; } -#ifndef USE_WIN32_RTL_ENV - DllExport char * win32_getenv(const char *name) { @@ -1425,8 +1423,6 @@ win32_putenv(const char *name) return relval; } -#endif - static long filetime_to_clock(PFILETIME ft) { diff --git a/win32/win32.h b/win32/win32.h index 1040ef1..232542c 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -122,11 +122,6 @@ struct utsname { #define PERL_NO_FORCE_LINK /* no need for PL_force_link_funcs */ -/* if USE_WIN32_RTL_ENV is not defined, Perl uses direct Win32 calls - * to read the environment, bypassing the runtime's (usually broken) - * facilities for accessing the same. See note in util.c/my_setenv(). */ -/*#define USE_WIN32_RTL_ENV */ - /* Define USE_FIXED_OSFHANDLE to fix MSVCRT's _open_osfhandle() on W95. It now uses some black magic to work seamlessly with the DLL CRT and works with MSVC++ 4.0+ or GCC/Mingw32 diff --git a/win32/win32iop.h b/win32/win32iop.h index 5629bab..5412f5e 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -120,10 +120,8 @@ DllExport void win32_seekdir(DIR *dirp, long loc); DllExport void win32_rewinddir(DIR *dirp); DllExport int win32_closedir(DIR *dirp); -#ifndef USE_WIN32_RTL_ENV DllExport char* win32_getenv(const char *name); DllExport int win32_putenv(const char *name); -#endif DllExport unsigned win32_sleep(unsigned int); DllExport int win32_times(struct tms *timebuf); @@ -300,12 +298,10 @@ END_EXTERN_C #undef crypt #define crypt(t,s) win32_crypt(t,s) -#ifndef USE_WIN32_RTL_ENV #undef getenv #define getenv win32_getenv #undef putenv #define putenv win32_putenv -#endif #endif /* WIN32IO_IS_STDIO */ #endif /* WIN32IOP_H */