X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=embed.pl;h=27815ae9cd75804aa01c91e2eac0c9dc73c0022d;hb=dafda6d147bb18b3050b636ac1d31818028dd936;hp=6487ff4ae0dfc83b28ab98726e6d1fb6893706bb;hpb=f728784643460445f91833d46f0c8bf60beb6583;p=p5sagit%2Fp5-mst-13.2.git diff --git a/embed.pl b/embed.pl index 6487ff4..27815ae 100755 --- a/embed.pl +++ b/embed.pl @@ -24,6 +24,7 @@ sub do_not_edit ($) $years =~ s/1999,/1999,\n / if length $years > 40; my $warning = <$filename" or die "Can't open $filename: $!"; binmode F; $F = \*F; @@ -120,7 +121,7 @@ sub munge_c_files () { if (@_ > 1) { $functions->{$_[2]} = \@_ if $_[@_-1] =~ /\.\.\./; } - } '/dev/null', ''; + } '/dev/null', '', ''; local $^I = '.bak'; while (<>) { # if (/^#\s*include\s+"perl.h"/) { @@ -201,38 +202,37 @@ sub write_protos { $ret .= "void" if !$has_context; } $ret .= ")"; - $ret .= " __attribute__((noreturn))" if $flags =~ /r/; - $ret .= "\n\t\t\t__attribute__((malloc)) __attribute__((warn_unused_result))" if $flags =~ /a/; - $ret .= "\n\t\t\t__attribute__((pure))" if $flags =~ /P/; + my @attrs; + if ( $flags =~ /r/ ) { + push @attrs, "__attribute__noreturn__"; + } + if ( $flags =~ /a/ ) { + push @attrs, "__attribute__malloc__"; + $flags .= "R"; # All allocing must check return value + } + if ( $flags =~ /R/ ) { + push @attrs, "__attribute__warn_unused_result__"; + } + if ( $flags =~ /P/ ) { + push @attrs, "__attribute__pure__"; + } if( $flags =~ /f/ ) { my $prefix = $has_context ? 'pTHX_' : ''; my $args = scalar @args; - $ret .= sprintf "\n\t\t\t__attribute__format__(__printf__,%s%d,%s%d)", + push @attrs, sprintf "__attribute__format__(__printf__,%s%d,%s%d)", $prefix, $args - 1, $prefix, $args; } - $ret .= "\n\t\t\t__attribute__((nonnull))" if $flags =~ /N/; if ( @nonnull ) { - if ($has_context) { - my @pos = map { $has_context ? $_ + 1 : $_ } @nonnull; - $ret .= sprintf( <