diff options
author | Nicholas Clark <nick@ccl4.org> | 2013-07-08 11:08:12 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-07-09 07:54:26 +0200 |
commit | 5ec3aaed3924eb916d899592d7ddce99dd92959b (patch) | |
tree | 040ae91f0456d46ea7aeeb9cd51758c5b08767e1 /lib/ExtUtils | |
parent | a76b6481754efe93c8fd83bfbf53f4409c2e6e8d (diff) | |
download | perl-5ec3aaed3924eb916d899592d7ddce99dd92959b.tar.gz |
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.
Diffstat (limited to 'lib/ExtUtils')
-rw-r--r-- | lib/ExtUtils/Embed.pm | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/ExtUtils/Embed.pm b/lib/ExtUtils/Embed.pm index 8953ce7db3..69f2822111 100644 --- a/lib/ExtUtils/Embed.pm +++ b/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,10 +83,9 @@ sub xsinit { sub xsi_header { return <<EOF; -#include <EXTERN.h> -#include <perl.h> -#include <XSUB.h> - +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" EOF } @@ -110,10 +109,12 @@ sub xsi_body { my(@exts) = @_; my($pname,@retval,%seen); my($dl) = canon('/','DynaLoader'); - push(@retval, "\tstatic const char file[] = __FILE__;\n"); - push(@retval, "\tdXSUB_SYS;\n"); - push(@retval, "\tPERL_UNUSED_CONTEXT;\n"); - 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('/', $_); @@ -123,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}++; } } |