This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make PL_origenviron global
authorTomasz Konojacki <me@xenu.pl>
Tue, 19 Apr 2022 14:41:23 +0000 (16:41 +0200)
committerxenu <me@xenu.pl>
Sat, 28 May 2022 22:54:10 +0000 (00:54 +0200)
The purpose of PL_origenviron is to preserve the earliest known value
of environ, which is a global. All interpreters should share it.

embedvar.h
intrpvar.h
perl.c
perlvars.h
sv.c

index 11989eb..da874d4 100644 (file)
 #define PL_origalen            (vTHX->Iorigalen)
 #define PL_origargc            (vTHX->Iorigargc)
 #define PL_origargv            (vTHX->Iorigargv)
-#define PL_origenviron         (vTHX->Iorigenviron)
 #define PL_origfilename                (vTHX->Iorigfilename)
 #define PL_ors_sv              (vTHX->Iors_sv)
 #define PL_osname              (vTHX->Iosname)
index 94ddbf6..2ff67a8 100644 (file)
@@ -700,7 +700,6 @@ PERLVARI(I, cop_seqmax,     U32,    PERL_COP_SEQMAX) /* statement sequence number */
 
 PERLVARI(I, evalseq,   U32,    0)      /* eval sequence number */
 PERLVAR(I, origalen,   U32)
-PERLVAR(I, origenviron,        char **)
 #ifdef PERL_USES_PL_PIDSTATUS
 PERLVAR(I, pidstatus,  HV *)           /* pid-to-status mappings for waitpid */
 #endif
diff --git a/perl.c b/perl.c
index 9bd4b3e..b3e16c0 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -360,7 +360,8 @@ perl_construct(pTHXx)
 
 #ifndef PERL_MICRO
 #   ifdef  USE_ENVIRON_ARRAY
-    PL_origenviron = environ;
+    if (!PL_origenviron)
+        PL_origenviron = environ;
 #   endif
 #endif
 
index 9a2c94f..ae52cbe 100644 (file)
@@ -303,3 +303,4 @@ PERLVARI(G, strategy_pipe,       int, 0)    /* doio.c */
 PERLVARI(G, strategy_socketpair, int, 0)       /* doio.c */
 
 PERLVARI(G, my_environ, char **, NULL)
+PERLVARI(G, origenviron, char **, NULL)
diff --git a/sv.c b/sv.c
index bff92f6..faea851 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -15548,7 +15548,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
     PL_nomemok         = proto_perl->Inomemok;
     PL_an              = proto_perl->Ian;
     PL_evalseq         = proto_perl->Ievalseq;
-    PL_origenviron     = proto_perl->Iorigenviron;     /* XXX not quite right */
     PL_origalen                = proto_perl->Iorigalen;
 
     PL_sighandlerp     = proto_perl->Isighandlerp;