summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-11-25 12:11:40 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-11-25 12:11:40 +0800
commit884815b8df616d5c1a253f168f872a6ff04a699a (patch)
treec38a2726d8083b3298e5b4e53e1db84da17aed47
parentb8f469a1db8454ecbf81c2a28098aa3708ad6e42 (diff)
downloadpttbbs-884815b8df616d5c1a253f168f872a6ff04a699a.tar
pttbbs-884815b8df616d5c1a253f168f872a6ff04a699a.tar.gz
pttbbs-884815b8df616d5c1a253f168f872a6ff04a699a.tar.bz2
pttbbs-884815b8df616d5c1a253f168f872a6ff04a699a.tar.lz
pttbbs-884815b8df616d5c1a253f168f872a6ff04a699a.tar.xz
pttbbs-884815b8df616d5c1a253f168f872a6ff04a699a.tar.zst
pttbbs-884815b8df616d5c1a253f168f872a6ff04a699a.zip
speed up and fix some bug
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2353 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rwxr-xr-xdocs/proto/cdoc46
1 files changed, 35 insertions, 11 deletions
diff --git a/docs/proto/cdoc b/docs/proto/cdoc
index d21fa988..360bee3b 100755
--- a/docs/proto/cdoc
+++ b/docs/proto/cdoc
@@ -8,6 +8,12 @@ use strict;
=cut
這個程式可以從 C 的程式碼中,列出所有 statis/non-static 的 functions。
+如果有以下這種 pattern 出現,會原封不動丟出來。
+
+/**
+ * Something
+ **/
+
每個 function 前面可以有 javadoc-style 的註解。範例如下:
/**
@@ -31,8 +37,8 @@ foreach my $f (@ARGV) {
sub grep_desc
{
- my $name = '\w+';
- my $type = '\w+\s*\*?';
+ my $name = '\b\w+\b';
+ my $type = '\b\w+\s*\*?';
my $sentence = '.*';
my $one_desc = "$name\\s+$sentence";
@@ -44,15 +50,15 @@ sub grep_desc
my $seedesc = "\@see\\s+$sentence(?:\n$desc_line)*";
my $desc = "$desc_head(?:$desc_line)*$desc_tail";
- my $modifier = '(?:static|inline)\\s+';
+ my $modifier = '(?:static|inline)\s+';
my $one_param = "$type\\s*$name";
my $more_param = ",\\s*$one_param";
- my $param = "(?:$one_param(?:$more_param)*)?";
- my $func_proto = "(?:$modifier)?$type\\s+$name\\($param\\)";
+ my $param = "(?:$one_param(?:$more_param)*|void)?";
+ my $func_proto = "(?:$modifier)*$type\\s+$name\\($param\\)";
$content =~ s/($desc_head(?:$desc_line)*\s*\*\*\/)//mo and return "$1\n";
- $content =~ s/($desc_head(?:$desc_line)*$desc_tail)?($func_proto)\s*{//mo
+ $content =~ s/($desc_head(?:$desc_line)*$desc_tail)?($func_proto)\s*{(?:.|\n)*?\n}//mo
or return undef;
my $comment = $1;
my $function = $2;
@@ -67,19 +73,37 @@ sub grep_desc
# check comment style here
- return "$function;\n".($comment ? $comment : " no comment\n");
+ return ($function, $comment);
}
sub makedoc
{
- $_ = shift @_;
- open SRC, "<$_";
+ my $file = shift @_;
+ open SRC, "<$file";
$content = join "",<SRC>;
close SRC;
+ open STATIC, ">$file.tmp";
+
# just to break them up to avoid vim's misunderstanding
print "// vim".":ft=c\n\n";
- while ($_ = grep_desc()) {
- print "$_\n";
+
+ $content =~ s#/\*[^*](.|\n)*?\*/##gm;
+ while (my ($function, $comment) = grep_desc()) {
+ last unless $function;
+ my $FILE = ($function =~ /\bstatic\b/) ? *STATIC : *STDOUT;
+ print $FILE "$function;\n". ($comment ? $comment : " no comment\n")."\n";
}
+
+ close STATIC;
+
+ print <<XXX;
+/*
+ * static function
+ */
+
+XXX
+ open STATIC, "<$file.tmp";
+ print <STATIC>;
+ close STATIC;
}