From df93e4533d1c25d707f8a135480f4e7ba54f85e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Fri, 11 Mar 2016 09:44:42 +0100 Subject: [PATCH] graphviz.dot: fix escaping logic It used escape the escape char \, but it shouldn't do that because it leads to double escaping. --- extra/graphviz/dot/dot-tests.factor | 21 +++++++++++++++++++++ extra/graphviz/dot/dot.factor | 10 +++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 extra/graphviz/dot/dot-tests.factor diff --git a/extra/graphviz/dot/dot-tests.factor b/extra/graphviz/dot/dot-tests.factor new file mode 100644 index 0000000000..190b9361a9 --- /dev/null +++ b/extra/graphviz/dot/dot-tests.factor @@ -0,0 +1,21 @@ +USING: graphviz.dot.private io.streams.string sequences tools.test ; +IN: graphviz.dot.tests + +! Making sure strings are escaped properly +{ + { + "\"BAH\" " + "\"LINE1\\nLINE2\" " + "\"\\lLINE1\\lLINE2\" " + "\"hum\\\"ho\\\"\" " + } +} [ + { + "BAH" + "LINE1\\nLINE2" + "\\lLINE1\\lLINE2" + "hum\"ho\"" + } [ + [ dot. ] with-string-writer + ] map +] unit-test diff --git a/extra/graphviz/dot/dot.factor b/extra/graphviz/dot/dot.factor index 82109cc87b..48677794b8 100644 --- a/extra/graphviz/dot/dot.factor +++ b/extra/graphviz/dot/dot.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2012 Alex Vondrak. ! See http://factorcode.org/license.txt for BSD license. USING: accessors classes classes.tuple combinators formatting graphviz -graphviz.attributes io io.files kernel namespaces prettyprint.backend -sequences splitting strings words ; +graphviz.attributes io io.files kernel namespaces sequences splitting +strings words ; IN: graphviz.dot