summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Mueller <smueller@cpan.org>2011-08-21 13:35:14 +0200
committerSteffen Mueller <smueller@cpan.org>2011-08-21 15:03:50 +0200
commit4fdacf635adc3ab81af6714f5f4ac3692f11f378 (patch)
tree451a3eb1f15b068e7456cd13dba9d58adf4cd0a8
parent45fef53488278d882a5b00bace266de60a7993e9 (diff)
downloadperl-4fdacf635adc3ab81af6714f5f4ac3692f11f378.tar.gz
Make sure to strip trailing semicolons from inputmap
If we don't get that right, there may be additional semicolons in the output C code. Those will be interpreted as empty statements which is a problem for strict/old compilers which require strict separation of declarations and other code. Reported by Torsten Schoenfeld, diagnosed by Thorsten and Jan Dubois.
-rw-r--r--dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm2
-rw-r--r--dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm2
-rw-r--r--dist/ExtUtils-ParseXS/t/002-more.t2
-rw-r--r--dist/ExtUtils-ParseXS/t/XSMore.xs15
4 files changed, 17 insertions, 4 deletions
diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm
index 7ecc7777cd..a338b23018 100644
--- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm
+++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm
@@ -2,7 +2,7 @@ package ExtUtils::Typemaps;
use 5.006001;
use strict;
use warnings;
-our $VERSION = '1.01';
+our $VERSION = '1.02';
#use Carp qw(croak);
require ExtUtils::ParseXS;
diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm
index 163353eca9..b8adbe69c0 100644
--- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm
+++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm
@@ -85,7 +85,7 @@ sub cleaned_code {
my $self = shift;
my $code = $self->code;
- $code =~ s/;*\s+\z//;
+ $code =~ s/(?:;+\s*|;*\s+)\z//s;
# Move C pre-processor instructions to column 1 to be strictly ANSI
# conformant. Some pre-processors are fussy about this.
diff --git a/dist/ExtUtils-ParseXS/t/002-more.t b/dist/ExtUtils-ParseXS/t/002-more.t
index 04bd296fc9..7973dced63 100644
--- a/dist/ExtUtils-ParseXS/t/002-more.t
+++ b/dist/ExtUtils-ParseXS/t/002-more.t
@@ -94,7 +94,7 @@ SKIP: {
# Tests for embedded typemaps
is XSMore::typemaptest1(), 42, 'Simple embedded typemap works';
is XSMore::typemaptest2(), 42, 'Simple embedded typemap works with funny end marker';
- is XSMore::typemaptest3(12), 12, 'Simple embedded typemap works for input, too';
+ is XSMore::typemaptest3(12, 13, 14), 12, 'Simple embedded typemap works for input, too';
# Win32 needs to close the DLL before it can unlink it, but unfortunately
# dl_unload_file was missing on Win32 prior to perl change #24679!
diff --git a/dist/ExtUtils-ParseXS/t/XSMore.xs b/dist/ExtUtils-ParseXS/t/XSMore.xs
index df40186538..2a0a87a7ec 100644
--- a/dist/ExtUtils-ParseXS/t/XSMore.xs
+++ b/dist/ExtUtils-ParseXS/t/XSMore.xs
@@ -6,6 +6,7 @@ typedef IV MyType;
typedef IV MyType2;
typedef IV MyType3;
typedef IV MyType4;
+typedef IV MyType5;
=for testing
@@ -89,6 +90,15 @@ T_BAAR
$var = ($type)SvIV($arg)
END
+TYPEMAP: <<END
+MyType5 T_WITHSEMICOLON
+
+INPUT
+
+T_WITHSEMICOLON
+ $var = ($type)SvIV($arg);
+END
+
MyType
typemaptest1()
@@ -105,7 +115,10 @@ typemaptest2()
RETVAL
MyType3
-typemaptest3(MyType4 foo)
+typemaptest3(foo, bar, baz)
+ MyType4 foo
+ MyType5 bar
+ MyType5 baz
CODE:
RETVAL = foo;
OUTPUT: