3 #@ Strip *! style documents from C/C++ code.
4 #@ Assumes that such lines are exclusive, and that /*!< */ lines
5 #@ are followed by no other such comment.
6 #@ Synopsis: su-doc-strip.pl :FILE:
11 use diagnostics
-verbose
;
16 die 'False usage' if @ARGV == 0;
19 my ($f, $i, $fd, @lines) = (shift @ARGV, 0);
21 # Read it, stripping the comments
22 die "Cannot open $f for reading: $^E"
23 unless open $fd, '<:raw', $f;
27 if($_ =~ /^(.*?)\*\/[[:space
:]]*(.*)$/){
29 push @lines, $2 if length $2
31 }elsif($_ =~ /^(.*?)[[:space:]]*\/\
*!(.*)$/){
32 my ($m1, $m2) = ($1, $2);
33 if($m2 =~ /^(.*?)\*\/[[:space
:]]*(.*)$/){
35 push @lines, $l if length($l)
38 push @lines, $m1 if length $m1
41 push @lines, $_ if length $_
44 die "Cannot close $f after reading: $^E"
47 die "Cannot open $f for writing: $^E"
48 unless open $fd, '>:raw', $f;
51 die "Cannot write to $f: $^E"
52 unless print $fd $i, "\n"
54 die "Cannot close $f after writing: $^E"
60 {package main
; main_fun
()}