From 5df355415e0ccc440a312f45ceb1e4220e1deb01 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 27 Jan 2022 23:35:42 -0500 Subject: [PATCH] Improve check for packing quad values - Check if quad values can be packed by using `eval`. This is because the condition for whether `pack` can use quad values is a bit more complicated. See: * , * , * - Add unsigned quad value (Q) to the condition. --- Basic/Core/Core.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Basic/Core/Core.pm b/Basic/Core/Core.pm index ca954190d..3189592b4 100644 --- a/Basic/Core/Core.pm +++ b/Basic/Core/Core.pm @@ -16,6 +16,8 @@ use Config; use List::Util qw(max); use Scalar::Util 'blessed'; +our $CAN_PACK_QUAD = !! eval { my $packed = pack "Q", 0; 1 }; + # If "D" is available for pack(). # See commit # and PR . @@ -1204,7 +1206,7 @@ sub PDL::new { # new was passed a string argument that doesn't look like a number # so we can process as a Matlab-style data entry format. return PDL::Core::new_pdl_from_string($new,$value,$this,$type); - } elsif ($Config{ivsize} < 8 && $pack[$new->get_datatype] eq 'q*') { + } elsif (! $CAN_PACK_QUAD && $pack[$new->get_datatype] =~ /^[qQ]\*$/ ) { # special case when running on a perl without 64bit int support # we have to avoid pack("q", ...) in this case # because it dies with error: "Invalid type 'q' in pack"