SPDX-FileCopyrightText: 2013 Nicholas Clark SPDX-License-Identifier: Artistic-1.0 Again, we need this for 5.22. From 87c2fdd468989b9450aa393c4c715594cbba5711 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 8 Jul 2013 11:08:12 +0200 Subject: [PATCH] Tweak ExtUtils::Embed's generated C code to be closer to ExtUtils::Miniperl. Use #include "..." instead of #include <...> in xsi_header(), and don't add a trailing newline (and add a newline in xsinit() to compensate). Use four spaces instead of a tab for indenting. If there are no extensions and hence no calls to newXS() don't declare file[] and don't add a trailing newline. --- lib/ExtUtils/Embed.pm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git perl-5.18.4/lib/ExtUtils/Embed.pm perl-5.18.4/lib/ExtUtils/Embed.pm index 9710630e51..52221cba53 100644 --- perl-5.18.4/lib/ExtUtils/Embed.pm +++ perl-5.18.4/lib/ExtUtils/Embed.pm @@ -72,7 +72,7 @@ sub xsinit { @mods = grep(!$seen{$_}++, @mods); print $fh &xsi_header(); - print $fh "EXTERN_C void xs_init ($xsinit_proto);\n\n"; + print $fh "\nEXTERN_C void xs_init ($xsinit_proto);\n\n"; print $fh &xsi_protos(@mods); print $fh "\nEXTERN_C void\nxs_init($xsinit_proto)\n{\n"; @@ -83,9 +83,9 @@ sub xsinit { sub xsi_header { return < -#include - +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" EOF } @@ -109,9 +109,12 @@ sub xsi_body { my(@exts) = @_; my($pname,@retval,%seen); my($dl) = canon('/','DynaLoader'); - push(@retval, "\tchar *file = __FILE__;\n"); - push(@retval, "\tdXSUB_SYS;\n") if $] > 5.002; - push(@retval, "\n"); + push(@retval, " static const char file[] = __FILE__;\n") + if @exts; + push(@retval, " dXSUB_SYS;\n"); + push(@retval, " PERL_UNUSED_CONTEXT;\n"); + push(@retval, "\n") + if @exts; foreach $_ (@exts){ my($pname) = canon('/', $_); @@ -121,10 +124,10 @@ sub xsi_body { if ($pname eq $dl){ # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'! # boot_DynaLoader is called directly in DynaLoader.pm - $ccode = "\t/* DynaLoader is a special case */\n\tnewXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n"; + $ccode = " /* DynaLoader is a special case */\n newXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n"; push(@retval, $ccode) unless $seen{$ccode}++; } else { - $ccode = "\tnewXS(\"${mname}::bootstrap\", boot_${cname}, file);\n"; + $ccode = " newXS(\"${mname}::bootstrap\", boot_${cname}, file);\n"; push(@retval, $ccode) unless $seen{$ccode}++; } } -- 2.49.1