summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1999-07-05 07:28:59 +0000
committerJarkko Hietaniemi <jhi@iki.fi>1999-07-05 07:28:59 +0000
commit8ba9dee36046939ca96a462c19c93dee3e0d9d52 (patch)
treec7fa86ab6faeb14a87ce6da74ed5bb78320f73b5 /util.c
parent86959918b69bd7566746d776574341f410f68755 (diff)
parent59c10aa22854831f97f41f8f8237b4d9b2426b0f (diff)
downloadperl-8ba9dee36046939ca96a462c19c93dee3e0d9d52.tar.gz
Integrate with mainperl.
p4raw-id: //depot/cfgperl@3585
Diffstat (limited to 'util.c')
-rw-r--r--util.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/util.c b/util.c
index 1f6fa1e0dd..28776ab8dd 100644
--- a/util.c
+++ b/util.c
@@ -66,6 +66,10 @@ long lastxycount[MAXXCOUNT][MAXYCOUNT];
#endif
+#if defined(HAS_FCNTL) && defined(F_SETFD) && !defined(FD_CLOEXEC)
+# define FD_CLOEXEC 1 /* NeXT needs this */
+#endif
+
/* paranoid version of system's malloc() */
/* NOTE: Do not call the next three routines directly. Use the macros
@@ -80,8 +84,9 @@ Perl_safesysmalloc(MEM_SIZE size)
Malloc_t ptr;
#ifdef HAS_64K_LIMIT
if (size > 0xffff) {
- PerlIO_printf(PerlIO_stderr(), "Allocation too large: %lx\n", size) FLUSH;
- WITH_THX(my_exit(1));
+ PerlIO_printf(PerlIO_stderr(),
+ "Allocation too large: %lx\n", size) FLUSH;
+ WITH_THX(my_exit(1));
}
#endif /* HAS_64K_LIMIT */
#ifdef DEBUGGING
@@ -1813,6 +1818,41 @@ Perl_my_setenv(pTHX_ char *nam, char *val)
#endif /* PERL_USE_SAFE_PUTENV */
}
+#else /* WIN32 || CYGWIN32 */
+#if defined(CYGWIN32)
+/*
+ * Save environ of perl.exe, currently Cygwin links in separate environ's
+ * for each exe/dll. Probably should be a member of impure_ptr.
+ */
+static char ***Perl_main_environ;
+
+EXTERN_C void
+Perl_my_setenv_init(char ***penviron)
+{
+ Perl_main_environ = penviron;
+}
+
+void
+my_setenv(char *nam, char *val)
+{
+ /* You can not directly manipulate the environ[] array because
+ * the routines do some additional work that syncs the Cygwin
+ * environment with the Windows environment.
+ */
+ char *oldstr = environ[setenv_getix(nam)];
+
+ if (!val) {
+ if (!oldstr)
+ return;
+ unsetenv(nam);
+ Safefree(oldstr);
+ return;
+ }
+ setenv(nam, val, 1);
+ environ = *Perl_main_environ; /* environ realloc can occur in setenv */
+ if(oldstr && environ[setenv_getix(nam)] != oldstr)
+ Safefree(oldstr);
+}
#else /* if WIN32 */
void
@@ -1874,6 +1914,7 @@ Perl_my_setenv(pTHX_ char *nam,char *val)
}
#endif /* WIN32 */
+#endif
I32
Perl_setenv_getix(pTHX_ char *nam)