Skip to content

Commit e4140d1

Browse files
nwc10tonycoz
authored andcommitted
Only expose Internals::getcwd() in miniperl
It's only used during bootstrapping for miniperl when the XS version of Cwd is not yet available, and only needed on platforms that don't already provide their own builtin for getcwd(). It was added in v5.30.0 with the clear warning that [it] may be removed or changed without notice and is not used by any code on CPAN. (Cwd references it, but won't use it once installed as it will have already found an XS implementation (platform specific or generic).
1 parent 2e910a6 commit e4140d1

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

Makefile.SH

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ shextract = $shextract
498498
!GROK!THIS!
499499

500500
# Source files where we build a variant for miniperl:
501-
mini_special='op perl'
501+
mini_special='op perl universal'
502502
for file in $mini_special; do
503503
mini_special_c="$mini_special_c ${file}mini.c"
504504
mini_only_objs="$mini_only_objs ${file}mini\$(OBJ_EXT)"
@@ -548,7 +548,7 @@ c = $(c1) $(c2) $(c3) $(c4) $(c5) miniperlmain.c $(mini_only_src)
548548
549549
obj1 = $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) pad$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) reentr$(OBJ_EXT) mro_core$(OBJ_EXT) keywords$(OBJ_EXT)
550550
obj2 = hv$(OBJ_EXT) av$(OBJ_EXT) run$(OBJ_EXT) pp_hot$(OBJ_EXT) sv$(OBJ_EXT) pp$(OBJ_EXT) scope$(OBJ_EXT) pp_ctl$(OBJ_EXT) pp_sys$(OBJ_EXT)
551-
obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) numeric$(OBJ_EXT) mathoms$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT) caretx$(OBJ_EXT) dquote$(OBJ_EXT) time64$(OBJ_EXT)
551+
obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) numeric$(OBJ_EXT) mathoms$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT) caretx$(OBJ_EXT) dquote$(OBJ_EXT) time64$(OBJ_EXT)
552552
553553
# split the objects into 3 exclusive sets: those used by both miniperl and
554554
# perl, and those used by just one or the other. Doesn't include the

t/io/getcwd.t

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ BEGIN {
66
set_up_inc('../lib');
77
}
88

9-
use Config;
10-
11-
$Config{d_getcwd}
12-
or plan skip_all => "no getcwd";
9+
defined &Internals::getcwd
10+
or plan skip_all => "no Internals::getcwd";
1311

1412
my $cwd = Internals::getcwd();
15-
ok(!defined $cwd || $cwd ne "",
16-
"Internals::getcwd() returned a reasonable result");
1713

18-
if (defined $cwd) {
19-
ok(-d $cwd, "check a success result is a directory");
14+
if (ok(defined $cwd, "Internals::getcwd() returned a defined result")) {
15+
isnt($cwd, "", "Internals::getcwd() returned a non-empty result");
16+
ok(-d $cwd, "Internals::getcwd() result is a directory");
2017
}
2118

2219
done_testing();

universal.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#line 2 "universal.c"
12
/* universal.c
23
*
34
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -1065,7 +1066,7 @@ XS(XS_re_regexp_pattern)
10651066
NOT_REACHED; /* NOTREACHED */
10661067
}
10671068

1068-
#ifdef HAS_GETCWD
1069+
#if defined(HAS_GETCWD) && defined(PERL_IS_MINIPERL)
10691070

10701071
XS(XS_Internals_getcwd)
10711072
{
@@ -1273,7 +1274,7 @@ static const struct xsub_details these_details[] = {
12731274
{"re::regnames", XS_re_regnames, ";$", 0 },
12741275
{"re::regnames_count", XS_re_regnames_count, "", 0 },
12751276
{"re::regexp_pattern", XS_re_regexp_pattern, "$", 0 },
1276-
#ifdef HAS_GETCWD
1277+
#if defined(HAS_GETCWD) && defined(PERL_IS_MINIPERL)
12771278
{"Internals::getcwd", XS_Internals_getcwd, "", 0 },
12781279
#endif
12791280
{"Tie::Hash::NamedCapture::_tie_it", XS_NamedCapture_tie_it, NULL, 0 },

0 commit comments

Comments
 (0)