Skip to content

Commit 0d28783

Browse files
committed
* CopSTASH_set(..., NULL) does not work with older threaded perls
(5.16.x and older) Workaround by using the old code before commit 8eb3ec5 code in this case. Detect problem with a new C test file copstashset.c.
1 parent ec1649f commit 0d28783

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

config/copstashset.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <EXTERN.h>
2+
#include <perl.h>
3+
#include <XSUB.h>
4+
5+
int main() {
6+
CopSTASH_set(PL_curcop, NULL);
7+
}

myConfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ if (try_compile("config/svtrv.c", ["-I$Config{'archlibexp'}/CORE"], undef, ["-c
225225
$define{'HAS_REAL_SVT_RV'} = 1; # changed in perl 5.11.0, SVt_RV is since then defined as SVt_IV
226226
}
227227

228+
if (try_compile("config/copstashset.c", ["-I$Config{'archlibexp'}/CORE"], undef, ["-c"]))
229+
{
230+
$define{'CAN_COPSTASH_SET_NULL'} = 1; # this seems to work since 5.17.x, and fails with older threaded perls
231+
}
232+
228233
if (!$IsWin32)
229234
{
230235
if (!try_compile("config/tod.c"))

tkGlue.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4154,7 +4154,15 @@ int type;
41544154
SV *x = NULL;
41554155
int prefix = '?';
41564156
name = SvPV(sv,na);
4157+
#ifdef CAN_COPSTASH_SET_NULL
41574158
CopSTASH_set(PL_curcop, NULL);
4159+
#else
4160+
# ifdef USE_ITHREADS
4161+
CopSTASHPV(PL_curcop) = NULL;
4162+
# else
4163+
CopSTASH(PL_curcop) = NULL;
4164+
# endif
4165+
#endif
41584166
switch (type)
41594167
{
41604168
case TK_CONFIG_SCALARVAR:

0 commit comments

Comments
 (0)