From 727a2a7943dbc043ff3a2f3fede0b9bff38dbe40 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Thu, 15 Apr 1999 12:17:24 +0000 Subject: [PATCH] handle __attribute__ git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5948 ec53bebd-3082-4978-b11e-865c3cabbd6b --- cf/make-proto.pl | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/cf/make-proto.pl b/cf/make-proto.pl index 5f39a04f0..2aad3353a 100644 --- a/cf/make-proto.pl +++ b/cf/make-proto.pl @@ -31,14 +31,14 @@ while(<>) { next; } if(/\{/){ + $_ = $line; + while(s/\*\//\ca/){ + s/\/\*(.|\n)*\ca//; + } + s/^\s*//; + s/\s$//; + s/\s+/ /g; if($line =~ /\)\s$/){ - $_ = $line; - while(s/\*\//\ca/){ - s/\/\*(.|\n)*\ca//; - } - s/^\s*//; - s/\s$//; - s/\s+/ /g; if(!/^static/ && !/^PRIVATE/){ # remove outer () s/\s*\(/@/; @@ -52,15 +52,19 @@ while(<>) { /([a-zA-Z0-9_]+)\s*@/; $f = $1; # only add newline if more than one parameter + $LP = "(("; # XXX workaround for indentation bug in emacs + $RP = "))"; + $P = "__P(("; if(/,/){ - s/@/ __P((\n\t/; + s/@/ __P$LP\n\t/; }else{ - s/@/ __P((/; + s/@/ __P$LP/; } - s/@/))/; + s/@/$RP/; $_ = $_ . ";"; # insert newline before function name s/(.*)\s([a-zA-Z0-9_]+ __P)/$1\n$2/; + s/(.*)\s(__attribute__.*)/$1\n\t$2/; $funcs{$f} = $_; } } @@ -141,11 +145,33 @@ foreach(sort keys %funcs){ if(/^(main)$/) { next } if(/^_/) { $private_h .= $funcs{$_} . "\n\n"; + if($funcs{$_} =~ /__attribute__/) { + $private_attribute_seen = 1; + } } else { $public_h .= $funcs{$_} . "\n\n"; + if($funcs{$_} =~ /__attribute__/) { + $public_attribute_seen = 1; + } } } +if ($public_attribute_seen) { + $public_h_header .= "#if !defined(__GNUC__) && !defined(__attribute__) +#define __attribute__(x) +#endif + +"; +} + +if ($private_attribute_seen) { + $private_h_header .= "#if !defined(__GNUC__) && !defined(__attribute__) +#define __attribute__(x) +#endif + +"; +} + if ($public_h ne "") { $public_h = $public_h_header . $public_h . "#endif /* $block */\n";