From d846dfa33cbbf7efc5965373665471b6a6ea5f66 Mon Sep 17 00:00:00 2001 From: Slaven Rezic Date: Sat, 12 Oct 2024 18:59:24 +0200 Subject: [PATCH] replace smartmatch by match::smart (without requires changes) (RT #156060) --- lib/Unix/Passwd/File.pm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Unix/Passwd/File.pm b/lib/Unix/Passwd/File.pm index 3c22e25..55a538e 100644 --- a/lib/Unix/Passwd/File.pm +++ b/lib/Unix/Passwd/File.pm @@ -10,7 +10,7 @@ our $VERSION = '0.251'; # VERSION use 5.010001; use strict; use warnings; -use experimental 'smartmatch'; +use match::smart; #use Log::ger; use File::Flock::Retry; @@ -934,7 +934,7 @@ sub get_user_groups { for (my $i=0; $i < @$group; $i++) { my @mm = split /,/, $group->[$i][3]; - next unless $user ~~ @mm || $group->[$i][0] eq $user; + next unless $user |M| \@mm || $group->[$i][0] eq $user; if (!$detail) { push @rows, $group->[$i][0]; } elsif ($wfn) { @@ -980,7 +980,7 @@ sub is_member { my $res = get_group(etc_dir=>$args{etc_dir}, group=>$group); return undef unless $res->[0] == 200; my @mm = split /,/, $res->[2]{members}; - return $user ~~ @mm ? 1:0; + return $user |M| \@mm ? 1:0; } $SPEC{get_max_uid} = { @@ -1137,7 +1137,7 @@ sub _add_group_or_user { my @gids = map { $_->[2] } @$group; if (!defined($gid)) { for ($min_gid .. $max_gid) { - do { $gid = $_; last } unless $_ ~~ @gids; + do { $gid = $_; last } unless $_ |M| \@gids; } return [412, "Can't find available GID"] unless defined($gid); @@ -1156,7 +1156,7 @@ sub _add_group_or_user { my @uids = map { $_->[2] } @$passwd; if (!defined($uid)) { for ($min_uid .. $max_uid) { - do { $uid = $_; last } unless $_ ~~ @uids; + do { $uid = $_; last } unless $_ |M| \@uids; } return [412, "Can't find available UID"] unless defined($uid); @@ -1171,7 +1171,7 @@ sub _add_group_or_user { for my $l (@$group) { next unless $l->[0] eq $gn; my @mm = split /,/, $l->[3]; - unless ($user ~~ @mm) { + unless ($user |M| \@mm) { $l->[3] = join(",", @mm, $user); $write_g++; last; @@ -1550,7 +1550,7 @@ sub add_user_to_group { my ($l, $f, $args) = @_; return unless $l->[0] eq $gn; my @mm = split /,/, $l->[3]; - return if $user ~~ @mm; + return if $user |M| \@mm; push @mm, $user; $args->{members} = join(",", @mm); }, @@ -1589,7 +1589,7 @@ sub delete_user_from_group { my ($l, $f, $args) = @_; return unless $l->[0] eq $gn; my @mm = split /,/, $l->[3]; - return unless $user ~~ @mm; + return unless $user |M| \@mm; @mm = grep {$_ ne $user} @mm; $args->{members} = join(",", @mm); }, @@ -1654,11 +1654,11 @@ sub add_delete_user_groups { for my $l (@$group) { my @mm = split /,/, $l->[-1]; - if ($l->[0] ~~ $add && !($user ~~ @mm)) { + if ($l->[0] |M| $add && !($user |M| \@mm)) { $changed++; push @mm, $user; } - if ($l->[0] ~~ $del && $user ~~ @mm) { + if ($l->[0] |M| $del && $user |M| \@mm) { $changed++; @mm = grep {$_ ne $user} @mm; } @@ -1717,11 +1717,11 @@ sub set_user_groups { for my $l (@$group) { my @mm = split /,/, $l->[-1]; - if ($l->[0] ~~ $gg && !($user ~~ @mm)) { + if ($l->[0] |M| $gg && !($user |M| \@mm)) { $changed++; push @mm, $user; } - if (!($l->[0] ~~ $gg) && $user ~~ @mm) { + if (!($l->[0] |M| $gg) && $user |M| \@mm) { $changed++; @mm = grep {$_ ne $user} @mm; } @@ -1791,7 +1791,7 @@ sub _delete_group_or_user { if ($which eq 'user') { # also delete all mention of the user in any group my @mm = split /,/, $group->[$i][3]; - if ($user ~~ @mm) { + if ($user |M| \@mm) { $changed++; $group->[$i][3] = join(",", grep {$_ ne $user} @mm); } @@ -1810,7 +1810,7 @@ sub _delete_group_or_user { if ($which eq 'user') { # also delete all mention of the user in any group my @mm = split /,/, $gshadow->[$i][3]; - if ($user ~~ @mm) { + if ($user |M| \@mm) { $changed++; $gshadow->[$i][3] = join(",", grep {$_ ne $user} @mm); } -- 2.11.0