SKIP: {
skip 'Can\'t find a UTF-8 locale', 4*256 unless defined $utf8_locale;
+ eval { require POSIX; import POSIX 'locale_h'; };
+ unless (defined &POSIX::LC_CTYPE) {
+ skip "no POSIX (maybe no Fcntl, or no dynamic loading)", 4*256;
+ }
+
use feature qw( unicode_strings );
no locale;
push @unicode_ucfirst, ucfirst(chr $i);
}
- use if $Config{d_setlocale}, qw(POSIX locale_h);
use locale;
setlocale(LC_CTYPE, $utf8_locale);
$where //= try_prog('NIS+', 'passwd.org_dir', '/bin/niscat');
# Try dscl
-if (!defined $where && $Config::Config{useperlio}) {
+DSCL: {
+my @dscl = qw(/usr/bin/dscl);
+if (!defined $where && $Config::Config{useperlio} && grep { -x } @dscl) {
+ eval { require PerlIO::scalar; }; # Beware miniperl.
+ if ($@) {
+ print "# No PerlIO::scalar, will not try dscl\n";
+ last DSCL;
+ }
# Map dscl items to passwd fields, and provide support for
# mucking with the dscl output if we need to (and we do).
my %want = do {
$want{UniqueID}{mung} = $want{PrimaryGroupID}{mung} = sub {
unpack 'L', pack 'l', $_[0]};
- foreach my $dscl (qw(/usr/bin/dscl)) {
+ foreach my $dscl (@dscl) {
next unless -x $dscl;
next unless open my $fh, '-|', "$dscl . -readall /Users @{[keys %want]} 2>/dev/null";
my @lines;
push @lines, join (':', @rec) . "\n";
}
my $data = join '', @lines;
- if (open PW, '<', \$data) {
+ if (open PW, '<', \$data) { # Needs PerlIO::scalar.
$where = "dscl . -readall /Users";
last;
}
}
}
+} # DSCL:
if (not defined $where) {
# Try local.
}
-{
+SKIP: {
use feature qw( fc unicode_strings );
- use if $Config{d_setlocale}, qw(POSIX locale_h);
+
+ eval { require POSIX; import POSIX 'locale_h'; };
+ unless (defined &POSIX::LC_ALL) {
+ skip "no POSIX (or no Fcntl, or no dynamic loading)", 256;
+ }
+
setlocale(&POSIX::LC_ALL, "C") if $Config{d_setlocale};
# This tests both code paths in pp_fc