[LyX/master] Get rid of xmlize, bringing no advantage over escapeString.

Thibaut Cuvelier tcuvelier at lyx.org
Sat Aug 1 01:26:18 UTC 2020


commit 0c0613327cad178d2546392d73cddab5feceaa19
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Aug 1 03:20:08 2020 +0200

    Get rid of xmlize, bringing no advantage over escapeString.
---
 src/Buffer.cpp                |    2 +-
 src/insets/InsetCitation.cpp  |    2 +-
 src/insets/InsetHyperlink.cpp |    2 +-
 src/xml.cpp                   |   17 +++++------------
 src/xml.h                     |    3 ---
 5 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 5059ceb..c8c18f2 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2230,7 +2230,7 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
 		os << "<title>"
 		   << (doctitle.empty() ?
 		         from_ascii("LyX Document") :
-		         xml::xmlize(doctitle, XMLStream::ESCAPE_ALL))
+		         xml::escapeString(doctitle, XMLStream::ESCAPE_ALL))
 		   << "</title>\n";
 
 		docstring styles = features.getTClassHTMLPreamble();
diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp
index a525316..760c1da 100644
--- a/src/insets/InsetCitation.cpp
+++ b/src/insets/InsetCitation.cpp
@@ -324,7 +324,7 @@ inline docstring wrapCitation(docstring const & key,
 	// we have to do the escaping here, because we will ultimately
 	// write this as a raw string, so as not to escape the tags.
 	return "<a href='#LyXCite-" + xml::cleanAttr(key) + "'>" +
-			xml::xmlize(content, XMLStream::ESCAPE_ALL) + "</a>";
+			xml::escapeString(content, XMLStream::ESCAPE_ALL) + "</a>";
 }
 
 } // anonymous namespace
diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp
index 0f039e3..26850cd 100644
--- a/src/insets/InsetHyperlink.cpp
+++ b/src/insets/InsetHyperlink.cpp
@@ -224,7 +224,7 @@ void InsetHyperlink::docbook(XMLStream & xs, OutputParams const &) const
 docstring InsetHyperlink::xhtml(XMLStream & xs, OutputParams const &) const
 {
 	docstring const & target =
-		xml::xmlize(getParam("target"), XMLStream::ESCAPE_AND);
+		xml::escapeString(getParam("target"), XMLStream::ESCAPE_AND);
 	docstring const & name   = getParam("name");
 	xs << xml::StartTag("a", to_utf8("href=\"" + target + "\""));
 	xs << (name.empty() ? target : name);
diff --git a/src/xml.cpp b/src/xml.cpp
index 06a9007..e16a784 100644
--- a/src/xml.cpp
+++ b/src/xml.cpp
@@ -91,13 +91,6 @@ docstring escapeString(docstring const & raw, XMLStream::EscapeSettings e)
 }
 
 
-// escape what needs escaping
-docstring xmlize(docstring const &str, XMLStream::EscapeSettings e)
-{
-	return xml::escapeString(str, e);
-}
-
-
 docstring cleanAttr(docstring const & str)
 {
 	docstring newname;
@@ -115,7 +108,7 @@ docstring StartTag::writeTag() const
 {
 	docstring output = '<' + tag_;
 	if (!attr_.empty()) {
-		docstring attributes = xml::xmlize(attr_, XMLStream::ESCAPE_NONE);
+		docstring attributes = xml::escapeString(attr_, XMLStream::ESCAPE_NONE);
 		attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(),
                                                           [](int c) {return !std::isspace(c);}));
 		if (!attributes.empty()) {
@@ -151,7 +144,7 @@ docstring CompTag::writeTag() const
 	if (!attr_.empty()) {
 		// Erase the beginning of the attributes if it contains space characters: this function deals with that
 		// automatically.
-		docstring attributes = xmlize(from_utf8(attr_), XMLStream::ESCAPE_NONE);
+		docstring attributes = escapeString(from_utf8(attr_), XMLStream::ESCAPE_NONE);
 		attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(),
                                                           [](int c) {return !std::isspace(c);}));
 		if (!attributes.empty()) {
@@ -298,7 +291,7 @@ void XMLStream::clearTagDeque()
 XMLStream &XMLStream::operator<<(docstring const &d)
 {
 	clearTagDeque();
-	os_ << xml::xmlize(d, escape_);
+	os_ << xml::escapeString(d, escape_);
 	escape_ = ESCAPE_ALL;
 	return *this;
 }
@@ -308,7 +301,7 @@ XMLStream &XMLStream::operator<<(const char *s)
 {
 	clearTagDeque();
 	docstring const d = from_ascii(s);
-	os_ << xml::xmlize(d, escape_);
+	os_ << xml::escapeString(d, escape_);
 	escape_ = ESCAPE_ALL;
 	return *this;
 }
@@ -483,7 +476,7 @@ XMLStream &XMLStream::operator<<(xml::EndTag const &etag)
 		string estr = "Closing tag `" + to_utf8(etag.tag_)
 					  + "' when other tags are pending. Discarded pending tags:\n";
 		for (dit = pending_tags_.begin(); dit != den; ++dit)
-			estr += to_utf8(xml::xmlize((*dit)->writeTag(), XMLStream::ESCAPE_ALL)) + "\n";
+			estr += to_utf8(xml::escapeString((*dit)->writeTag(), XMLStream::ESCAPE_ALL)) + "\n";
 		writeError(estr);
 		// clear the pending tags...
 		pending_tags_.clear();
diff --git a/src/xml.h b/src/xml.h
index 5afdcf5..12e7f25 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -139,9 +139,6 @@ docstring escapeChar(char c, XMLStream::EscapeSettings e);
 /// Escape a word instead of a single character
 docstring escapeString(docstring const & raw, XMLStream::EscapeSettings e=XMLStream::ESCAPE_ALL);
 
-/// Converts a string to a form safe for links, etc.
-docstring xmlize(docstring const &str, XMLStream::EscapeSettings e);
-
 /// cleans \param str for use as an attribute by replacing all non-altnum by "_"
 docstring cleanAttr(docstring const & str);
 


More information about the lyx-cvs mailing list