From: Matthew Fernandez Date: Tue, 6 Jul 2021 00:38:44 +0000 (-0700) Subject: gxl2gv: fix: recognize and handle HTML-like strings X-Git-Tag: 2.48.0~3^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38763516885bd90b5e1b6806a002e81aa2e75f3d;p=graphviz gxl2gv: fix: recognize and handle HTML-like strings When translating a Graphviz file through gv2gxl, HTML-like and non-HTML-like strings would be translated identically, resulting in a loss of information. This was fixed in the series merged in d44d19c86f0f469d1c76ce0d7630c8e0ac85e993. However, to take this through to completion and make round-tripping such strings possible, changes to gxl2gv were also required. The present commit updates gxl2gv to recognize the new ‘kind’ GXL attribute that gv2gxl uses to indicate a string originated as an HTML-like string. The output of gxl2gv now correctly translates this back to an HTML-like string. Fixes #517. Note that this fix is orthogonal to the behavior when using an HTML-like and non-HTML-like string with the same content. It is still not possible to do this without confusing the internal string interning dictionary (#2089). --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 0844b548e..49e7378f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - a Bashism removed from the Autotools build system - when Criterion is available, the `command_line` test binary is no longer built and installed by default, but rather during `make check` +- round-tripping a file through ``gv2gxl`` and then ``gxl2gv`` no longer causes + HTML-like labels to become non-HTML like labels #517 ## [2.47.3] - 2021-06-19 diff --git a/cmd/tools/gxl2gv.c b/cmd/tools/gxl2gv.c index 73bed1c8d..df5d8400a 100644 --- a/cmd/tools/gxl2gv.c +++ b/cmd/tools/gxl2gv.c @@ -40,6 +40,7 @@ typedef enum { TAG_GRAPH, TAG_NODE, TAG_EDGE, + TAG_HTML_LIKE_STRING, } attr_t; typedef struct slist slist; @@ -553,6 +554,8 @@ startElementHandler(void *userData, const char *name, const char **atts) ud->globalAttrType = TAG_EDGE; else if (strcmp("graph", atts[pos]) == 0) ud->globalAttrType = TAG_GRAPH; + else if (strcmp("HTML-like string", atts[pos]) == 0) + ud->globalAttrType = TAG_HTML_LIKE_STRING; } else { ud->globalAttrType = TAG_NONE; } @@ -654,6 +657,9 @@ static void endElementHandler(void *userData, const char *name) case TAG_GRAPH: setGraphAttr(G, name, value, ud); break; + case TAG_HTML_LIKE_STRING: + setAttr(name, value, ud, true); + break; } free(dynbuf); ud->globalAttrType = TAG_NONE; diff --git a/rtest/test_regression.py b/rtest/test_regression.py index 8380564e5..5306fcd3e 100644 --- a/rtest/test_regression.py +++ b/rtest/test_regression.py @@ -243,7 +243,6 @@ def test_167(): # Graphviz should not have caused a segfault assert ret != -signal.SIGSEGV, "Graphviz segfaulted" -@pytest.mark.xfail(strict=True) @pytest.mark.skipif(shutil.which("gv2gxl") is None or shutil.which("gxl2gv") is None, reason="GXL tools not available")