Skip to content

Commit

Permalink
perl: Provide alternate definition of newSVpvn_utf8 for older Perl.
Browse files Browse the repository at this point in the history
Commit 40fff10 uses newSVpvn_utf8.
This macro did not exist in Perl < 5.12, but we can use newSVpvn
instead.

Also update the associated test script:

- Don't use 'done_testing'.  Not supported by ancient Perl.

- Skip the tests entirely on ancient Perl.
  • Loading branch information
rwmjones committed May 14, 2014
1 parent aca0a4d commit f1cce9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions generator/generator.ml
Expand Up @@ -2351,6 +2351,11 @@ and generate_perl_xs () =
#include <hivex.h>
#include <inttypes.h>
/* For Perl < 5.12 */
#ifndef newSVpvn_utf8
#define newSVpvn_utf8(a,b,u) newSVpvn((a),(b))
#endif
static SV *
my_newSVll(long long val) {
#ifdef USE_64_BIT_ALL
Expand Down
10 changes: 8 additions & 2 deletions perl/t/130-special.t
Expand Up @@ -7,8 +7,16 @@ BEGIN {
binmode STDOUT, ':encoding(UTF-8)';
binmode STDERR, ':encoding(UTF-8)';
}

use Test::More;

# Old Perl hivex bindings cannot handle Unicode properly.
if ($] < 5.012) {
plan skip_all => "Version of Perl is too old to handle Unicode";
} else {
plan tests => 8;
}

use Win::Hivex;

my $srcdir = $ENV{srcdir} || ".";
Expand All @@ -34,5 +42,3 @@ ok $value, 'value has been found';
ok $node, q<'weird™' (node) has been found>;
($value) = grep { $h->value_key($_) eq 'symbols $£₤₧€' } $h->node_values($node);
ok $value, q<'weird™\symbols $£₤₧€' (value) has been found>;

done_testing;

0 comments on commit f1cce9c

Please sign in to comment.