Unverified Commit 2183fed1 authored by Javier Costa's avatar Javier Costa Committed by GitHub
Browse files

Merge pull request #5 from jacosro/4-escape-stmts

Escape quotations in statements (fixes #4)
parents 51bba5db 465b6c8c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ public class CFGGraph extends Graph {

        String nodes = getNodes().stream()
                .sorted(Comparator.comparingInt(GraphNode::getId))
                .map(node -> String.format("%s [label=\"%s: %s\"]", node.getId(), node.getId(), node.getData()))
                .map(GraphNode::toGraphvizRepresentation)
                .collect(Collectors.joining(lineSep));

        String arrows =
+3 −1
Original line number Diff line number Diff line
@@ -145,7 +145,9 @@ public class GraphNode<N extends Node> extends Vertex<String, ArcData> {
    }

    public String toGraphvizRepresentation() {
        return String.format("%s[label=\"%s: %s\"];", getId(), getId(), getData());
        String text = getData().replace("\\", "\\\\")
                .replace("\"", "\\\"");
        return String.format("%s[label=\"%s: %s\"];", getId(), getId(), text);
    }

    public Set<String> getDeclaredVariables() {