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) {
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) {
(void)sprintf(envstr,"%s=%s",nam,val);
(void)PerlEnv_putenv(envstr);
Safefree(envstr);
-
-#endif
}
#endif /* WIN32 */
return path;
}
-#ifndef USE_WIN32_RTL_ENV
-
DllExport char *
win32_getenv(const char *name)
{
return relval;
}
-#endif
-
static long
filetime_to_clock(PFILETIME ft)
{
#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
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);
#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 */