Skip Menu |

This queue is for tickets about the Graph-ReadWrite CPAN distribution.

Report information
The Basics
Id: 51022
Status: new
Priority: 0/
Queue: Graph-ReadWrite

People
Owner: Nobody in particular
Requestors: bwagner [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Graph::Reader::Dot::read_graph fails on digraphs with comments //, #, /**/
Graph::Reader::Dot::read_graph fails on digraphs with comments <pre><tt>//, #, /**/</tt></pre> These ought to be allowed according to: http://www.graphviz.org/doc/info/lang.html Workaround: Use the module in the attachment to have your digraph patched on the fly to keep <pre><tt>Graph::Reader::Dot::read_graph</tt></pre> happy. Thanks Bernhard
Subject: FixDotFormat.pm
package FixDotFormat; use strict; use warnings; use IO::Handle::Util qw(io_from_any); # Quick and dirty fix for features missing from Graph::Reader::Dot. # Plugging in this filter between the source and Graph::Reader::Dot # will allow to read graphs: # - without an ID (between keyword "graph" and "{". # - with c-preprocessor-style comments ("#"). # - with c++-one-line-style comments ("//"). # Note: c-style-comments /* */ are NOT supported. # use like this: # # use FixDotFormat; # # my $graph = Graph::Reader::Dot->new->read_graph(FixDotFormat::fix(new IO::File($ARGV[0]))); # sub fix { my ($handle) = @_; my $dot = join("", <$handle>); $dot =~ s/(.*)#(.*)/$1/g; $dot =~ s+(.*)//(.*)+$1+g; $dot =~ tr/\n//s; # must be done after one-line style comments ("//", "#") $dot =~ s/graph\s+{/graph dummy {/s; # must be done after comment removal! io_from_any $dot; } 1;