summaryrefslogtreecommitdiff
path: root/embed.pl
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2005-05-09 17:45:00 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-05-09 20:07:14 +0000
commitf54cb97a39f1a5849851e77a33524dfca2644cf5 (patch)
tree63ac7dcf435b959ee157bc3bd9c11eb775192034 /embed.pl
parenta0981a788197c6d427ceaf558d0dc8713c7737b3 (diff)
downloadperl-f54cb97a39f1a5849851e77a33524dfca2644cf5.tar.gz
attributes-two.patch, the next batch
Message-ID: <20050509154518.GA18273@petdance.com> p4raw-id: //depot/perl@24431
Diffstat (limited to 'embed.pl')
-rwxr-xr-xembed.pl28
1 files changed, 21 insertions, 7 deletions
diff --git a/embed.pl b/embed.pl
index 50ec17faf3..9cdef0782a 100755
--- a/embed.pl
+++ b/embed.pl
@@ -201,23 +201,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 ) {
my @pos = map { $has_context ? "pTHX_$_" : $_ } @nonnull;
- $ret .= sprintf( "\n\t\t\t__attribute__((nonnull(%s)))", join( ",", @pos ) );
+ push @attrs, sprintf( "__attribute__((nonnull(%s)))", join( ",", @pos ) );
+ }
+ if ( @attrs ) {
+ $ret .= "\n";
+ $ret .= join( "\n", map { "\t\t\t$_" } @attrs );
}
$ret .= ";";
$ret .= ' */' if $flags =~ /m/;
- $ret .= "\n";
+ $ret .= @attrs ? "\n\n" : "\n";
}
$ret;
}