Skip to content

Commit

Permalink
Only expose Internals::getcwd() in miniperl
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
nwc10 authored and tonycoz committed Oct 4, 2021
1 parent 2e910a6 commit e4140d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile.SH
Expand Up @@ -498,7 +498,7 @@ shextract = $shextract
!GROK!THIS!

# Source files where we build a variant for miniperl:
mini_special='op perl'
mini_special='op perl universal'
for file in $mini_special; do
mini_special_c="$mini_special_c ${file}mini.c"
mini_only_objs="$mini_only_objs ${file}mini\$(OBJ_EXT)"
Expand Down Expand Up @@ -548,7 +548,7 @@ c = $(c1) $(c2) $(c3) $(c4) $(c5) miniperlmain.c $(mini_only_src)
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)
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)
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)
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)
# split the objects into 3 exclusive sets: those used by both miniperl and
# perl, and those used by just one or the other. Doesn't include the
Expand Down
13 changes: 5 additions & 8 deletions t/io/getcwd.t
Expand Up @@ -6,17 +6,14 @@ BEGIN {
set_up_inc('../lib');
}

use Config;

$Config{d_getcwd}
or plan skip_all => "no getcwd";
defined &Internals::getcwd
or plan skip_all => "no Internals::getcwd";

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

if (defined $cwd) {
ok(-d $cwd, "check a success result is a directory");
if (ok(defined $cwd, "Internals::getcwd() returned a defined result")) {
isnt($cwd, "", "Internals::getcwd() returned a non-empty result");
ok(-d $cwd, "Internals::getcwd() result is a directory");
}

done_testing();
5 changes: 3 additions & 2 deletions universal.c
@@ -1,3 +1,4 @@
#line 2 "universal.c"
/* universal.c
*
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
Expand Down Expand Up @@ -1065,7 +1066,7 @@ XS(XS_re_regexp_pattern)
NOT_REACHED; /* NOTREACHED */
}

#ifdef HAS_GETCWD
#if defined(HAS_GETCWD) && defined(PERL_IS_MINIPERL)

XS(XS_Internals_getcwd)
{
Expand Down Expand Up @@ -1273,7 +1274,7 @@ static const struct xsub_details these_details[] = {
{"re::regnames", XS_re_regnames, ";$", 0 },
{"re::regnames_count", XS_re_regnames_count, "", 0 },
{"re::regexp_pattern", XS_re_regexp_pattern, "$", 0 },
#ifdef HAS_GETCWD
#if defined(HAS_GETCWD) && defined(PERL_IS_MINIPERL)
{"Internals::getcwd", XS_Internals_getcwd, "", 0 },
#endif
{"Tie::Hash::NamedCapture::_tie_it", XS_NamedCapture_tie_it, NULL, 0 },
Expand Down

0 comments on commit e4140d1

Please sign in to comment.