From ff5b07b97aad006883ea073c69ddb42655918f0f Mon Sep 17 00:00:00 2001 From: Martin Willemoes Hansen Date: Wed, 25 Jun 2003 21:22:28 +0000 Subject: [PATCH] * parser/gapi_pp.pl: Added striping of C comments svn path=/trunk/gtk-sharp/; revision=15639 --- ChangeLog | 4 ++++ parser/gapi_pp.pl | 31 +++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8e3b102d..874c17a85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-06-25 Martin Willemoes Hansen + + * parser/gapi_pp.pl: Added striping of C comments + 2003-06-23 Martin Willemoes Hansen * glib/Type.cs: Added ToString diff --git a/parser/gapi_pp.pl b/parser/gapi_pp.pl index 0f8c5cf92..86c239d55 100755 --- a/parser/gapi_pp.pl +++ b/parser/gapi_pp.pl @@ -3,9 +3,11 @@ # gapi_pp.pl : A source preprocessor for the extraction of API info from a # C library source directory. # -# Author: Mike Kestner +# Authors: Mike Kestner +# Martin Willemoes Hansen # # 2001 Mike Kestner +# 2003 Martin Willemoes Hansen $eatit_regex = "^#if.*(__cplusplus|DEBUG|DISABLE_(DEPRECATED|COMPAT)|ENABLE_BROKEN|COMPILATION)"; $ignoreit_regex = '^\s+\*|#\s*include|#\s*else|#\s*endif|#\s*undef|G_(BEGIN|END)_DECLS|extern|GDKVAR|GTKVAR|GTKMAIN_C_VAR|GTKTYPEUTILS_VAR|VARIABLE|GTKTYPEBUILTIN'; @@ -130,8 +132,33 @@ foreach $fname (`ls $ARGV[0]/*.c`, @privhdrs) { print "private"; } + $comment = 0; + $begin = 0; + $end = 0; do { - print $line; + # Following ifs strips out // and /* */ C comments + if ($line =~ /\/\*/) { + $comment = 1; + $begin = 1; + } + + if ($comment != 1) { + $line =~ s/\/\/.*//; + print $line; + } + + if ($line =~ /\*\//) { + $comment = 0; + $end = 1; + } + + if ($begin == 1 && $end == 1) { + $line =~ s/\/\*.*\*\///; + print $line; + } + + $begin = 0; + $end = 0; } until (($line = ) =~ /^}/); print $line; }