--- DirectedGraphPlugin.pm.orig 2005-04-26 14:59:31.000000000 +0200 +++ DirectedGraphPlugin.pm 2005-04-26 14:51:25.000000000 +0200 @@ -43,10 +43,9 @@ my $HASH_CODE_LENGTH=32; my %hashed_math_strings=(); -#my $cmd = '/home/mrjc/packages/graphviz/bin/dot'; -my $cmd = '/usr/bin/dot'; +my $cmd = '/usr/bin/dot -T%FORMAT|S% %INFILE|F% -o %OUTFILE|F%'; my $tmpFile = '/tmp/'.$pluginName."$$"; - + # ========================= sub initPlugin { @@ -110,15 +109,14 @@ } # create the png else { - $command=system($cmd." -Tpng $tmpFile -o $image"); - # If you've installed the netpbm package, you could alternatively - # use this command to smooth-scale the image - #$command=system($cmd." -Tpng $tmpFile | pngtopnm | pnmscale 0.7 | pnmtopng > $image"); - if($command) { + my ($output, $status) = &TWiki::readFromProcess($cmd, + FORMAT => 'png', INFILE => $tmpFile, OUTFILE => $image); + + if($status) { # errors existed so remove created files unlink "$image"; unlink $tmpFile; - return "DirectedGraph Error: syntax error - $command"; + return &showError($status, $output, $hashed_math_strings{"$hash_code"}); } } @@ -132,12 +130,13 @@ } # create the map else { - $command=system("$cmd -Tcmapx -o $cmapx $tmpFile"); - if($command) { + my ($output, $status) = &TWiki::readFromProcess($cmd, + FORMAT => 'cmapx', INFILE => $tmpFile, OUTFILE => $cmapx); + if($status) { # errors existed so remove created files unlink "$cmapx"; unlink $tmpFile; - return "DirectedGraph Error: syntax error"; + return &showError($status, $output, $hashed_math_strings{"$hash_code"}); } } } @@ -159,4 +158,14 @@ } } +# ========================= +sub showError { + my ($status, $output, $text) = @_; + + $output =~ s/^.*: (.*)/$1/; + my $line = 1; + $text =~ s/\n/sprintf("\n%02d: ", $line++)/ges; + $output .= "
$text\n
"; + return "DirectedGraph Error ($status): $output"; +} 1;