unify XML string escaping implementations
The current code base (608aab7b) has four implementations (that I have found so far) of XML string escaping:
-
xml_stringand friends in cmd/tools/gv2gxl.c -
xml_stringand friends in cmd/smyrna/smyrna_utils.c -
xml_stringand friends in lib/common/labels.c -
html_stringand friends in plugin/core/gvrender_core_vml.c
The identical comments surrounding these implementations make it clear they were once copy-pasted from the same source. The lib/common one looks like the original and a comment in Smyrna even explains why this situation exists:
/* many of these functions are available in libcommon.
* We cannot use those because dependencies cause a great
* deal of libcommon to be brought in, which complicates
* and makes possible conflicts as some parts of libcommon
* rely on not using libcgraph.
*/
As far as I'm aware, this situation no longer exists. libcgraph is the only graph library supported and there is no sensible way to use libcommon without libcgraph. However, a naive attempt to undo the Smyrna code duplication fails because:
- A number of libcommon headers rely on something else being #included prior to them. lib/common/utils.h that contains the libcommon prototype for
xml_stringcannot be #included without other libcommon headers being #included prior to it. - A number of libcommon typedefs/prototypes conflict with other ones in Smyrna headers.
The situation is pretty messy and may require diagnosing and undoing the conflicting definitions one-by-one. But I think it's worth doing in service of paring back the number of XML string escaping variants we're maintaining to 1.