Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jima155341 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"IO::File" : "1.14",
"Image::Size" : "0",
"LWP::Simple" : "0",
"match::simple" : "0.012",
"Time::Local" : "1.07",
"XML::Twig" : "3.34",
"experimental" : "0",
Expand Down
1 change: 1 addition & 0 deletions META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ requires:
IO::File: 1.14
Image::Size: 0
LWP::Simple: 0
match::simple: 0.012
Time::Local: 1.07
XML::Twig: 3.34
experimental: 0
Expand Down
46 changes: 6 additions & 40 deletions lib/ODF/lpOD/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -900,48 +900,14 @@ sub not_implemented
# supposedly remove them entirely. To preserve existing semantics of
# existing code including user-visible functions, I'm emulating (a subset of)
# the ~~ operator here. -Jim Avera 6/10/2024
#
# 2/9/2025[jima]: Using CPAN's match::simple instead (my code was buggy...)
use match::simple 0.012;
sub fake_smartmatch
{
my ($L, $R) = @_;
my $err;
if (@_ != 2) {
$err = "expects two args";
}
elsif (! defined($L)) {
return ! defined($R);
}
elsif (ref($L) ne "") {
$err = "only handles a simple left operand";
}
elsif (! defined($R)) {
return ! defined($L);
}
elsif ((my $rtype = ref($R)) ne "") {
if ($rtype eq "ARRAY") {
return any { __SUB__->($L,$_) } @$R;
}
elsif ($rtype eq "HASH") {
return exists($R->{$L});
}
elsif ($rtype eq "CODE") {
return $R->($L);
}
elsif ($rtype eq "RegExp") {
return $L =~ /$R/;
}
else {
$err = "does not handle operand of type $rtype"
}
}
else {
if (Scalar::Util::looks_like_number($R) ||
Scalar::Util::looks_like_number($L)) {
return $L == $R;
} else {
return $L eq $R;
}
}
confess "fake_smartmatch $err";
confess "Expecting two arguments" unless @_ == 2;
confess "Left side must be simple" if ref($_[0]);
match::simple::match($_[0],$_[1])
}

#=============================================================================
Expand Down