[Gtk-sharp-list] gapi__pp.pl patch for striping out c comments
Martin Willemoes Hansen
mwh@sysrq.dk
21 Jun 2003 13:17:35 +0200
--=-7z3Q9C0rTol3bsSR7ZRu
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi!
I added stripping of // too.
Can I commit?
--
Martin Willemoes Hansen
--------------------------------------------------------
E-Mail mwh@sysrq.dk Website mwh.sysrq.dk
IRC MWH, freenode.net
--------------------------------------------------------
--=-7z3Q9C0rTol3bsSR7ZRu
Content-Disposition: attachment; filename=gapi_pp.pl.diff
Content-Type: text/plain; name=gapi_pp.pl.diff; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
--- /mnt/gnu/cvs/mono/gtk-sharp/parser/gapi_pp.pl 2002-08-12 21:14:43.000000000 +0200
+++ gapi_pp.pl 2003-06-21 12:13:49.000000000 +0200
@@ -130,8 +130,33 @@
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 = <INFILE>) =~ /^}/);
print $line;
}
--=-7z3Q9C0rTol3bsSR7ZRu--