+ -
当前位置:首页 → 问答吧 → C语言函数中 格式符 * 的用法

C语言函数中 格式符 * 的用法

时间:2010-10-18

来源:互联网

代码:
● dog cflow2dot.pl
$_=join " ",@ARGV;
my @in=`/usr/bin/cflow $_`;
my @index;
my @commet;
my $l=0;
print "digraph G {\n";
print "node [peripheries=2 style=filled color=\"#eecc80\" fontname=\"Vera Sans YuanTi Mono\"];\nrankdir=LR;\nmain[shape=box];\nedge [color=\"sienna\" fontcolor=\"green\"];\n";
foreach (@in){
chomp;
/^ */;my $n=length($&)/4;
s/^ *//; s/\(\)\s*//;
if(/>:$/){
s/(<.*>).*$//; push @commet,$1;
push @index,$_;
if($n ne 0){
print "$index[$n-1]->$_;\n";
}
}
else{
print "$index[$n-1]->$_;\n";
}
}
print "}\n";


代码:
● cflow2dot.pl habak.c xcore.c | dot -Tpng -o x.png
附件:

x.png [ 1.3 MiB | 被浏览 22 次 ]

作者: eexpress   发布时间: 2010-10-18

出来一堆错误,生成的图根本不准确。

作者: xihe   发布时间: 2010-10-18

引用:
my @color=qw(#eecc80 #ccee80 #80ccee #eecc80 #80eecc);
print "digraph G {\n";
print "node [peripheries=2 style=filled color=\"#eecc80\" fontname=\"Vera Sans YuanTi Mono\"];\nrankdir=LR;\nmain[shape=box];\nedge [color=\"sienna\" fontcolor=\"green\"];\n";
foreach (@in){
chomp;
/^ */;my $n=length($&)/4;
s/^ *//; s/\(\)\s*//;
print "node [color=\"$color[$n-1]\"];\n";
print "edge [color=\"$color[$n-1]\"];\n";
if(/>:$/){


加了3句。分支带不同颜色。

嘛错误?
☛ cflow2dot.pl habak.c xcore.c |dot -Tpng -o ~/x.png
附件:

Screenshot-3.png [ 142.74 KiB | 被浏览 11 次 ]

作者: eexpress   发布时间: 2010-10-18

代码:
☛ dog cflow2dot.pl
if(! -x "/usr/bin/cflow"){print "\'cflow\' not installed.\n"; exit;}
$_=join " ",@ARGV;
my @in=`/usr/bin/cflow $_`;
my @index;
my @commet;
my @color=qw(#eecc80 #ccee80 #80ccee #eecc80 #80eecc);
my $tmpdot="/tmp/cflow.dot";
my $tmppng="/tmp/cflow.png";
open FILE,'>',$tmpdot;  select FILE;
print "digraph G {\n";
print "node [peripheries=2 style=filled color=\"#eecc80\" fontname=\"Vera Sans YuanTi Mono\"];\nrankdir=LR;\nmain[shape=box];\nedge [color=\"sienna\" fontcolor=\"green\"];\n";
foreach (@in){
chomp;
/^ */;my $n=length($&)/4;
s/^ *//; s/\(\)\s*//;
print "node [color=\"$color[$n-1]\"];\nedge [color=\"$color[$n-1]\"];\n";
if(/>:$/){
s/(<.*>).*$//; push @commet,$1;
push @index,$_;
if($n ne 0){
print "$index[$n-1]->$_;\n";
}
}
else{
print "$index[$n-1]->$_;\n";
}
}
print "}\n";
select STDOUT; print "dot output to $tmpdot.\n";
if(-x "/usr/bin/dot"){
`dot -Tpng $tmpdot -o $tmppng`;
print "png output to $tmppng";
if(-x "/usr/bin/eog"){`eog $tmppng`;}
}
else{print "\'dot\' not installed.\n"}

作者: eexpress   发布时间: 2010-10-18