mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 01:07:52 +00:00
gdbsupport: change xml_escape_text_append's parameter from pointer to reference
The passed in string can't be nullptr, it makes more sense to pass in a reference. Change-Id: Idc8bd38abe1d6d9b44aa227d7856956848c233b3
This commit is contained in:
@@ -40,7 +40,7 @@ static void test_xml_escape_text_append ()
|
||||
const char *input = "<this isn't=\"xml\"> &";
|
||||
const char *expected_output
|
||||
= "foo<xml><this isn't="xml"> &";
|
||||
xml_escape_text_append (&actual_output, input);
|
||||
xml_escape_text_append (actual_output, input);
|
||||
|
||||
SELF_CHECK (actual_output == expected_output);
|
||||
}
|
||||
|
||||
@@ -6520,7 +6520,7 @@ read_link_map (std::string &document, CORE_ADDR lmid, CORE_ADDR lm_addr,
|
||||
if (libname[0] != '\0')
|
||||
{
|
||||
string_appendf (document, "<library name=\"");
|
||||
xml_escape_text_append (&document, (char *) libname);
|
||||
xml_escape_text_append (document, (char *) libname);
|
||||
string_appendf (document, "\" lm=\"0x%s\" l_addr=\"0x%s\" "
|
||||
"l_ld=\"0x%s\" lmid=\"0x%s\"/>",
|
||||
paddress (lm_addr), paddress (l_addr),
|
||||
|
||||
@@ -1086,7 +1086,7 @@ netbsd_qxfer_libraries_svr4 (const pid_t pid, const char *annex,
|
||||
}
|
||||
|
||||
string_appendf (document, "<library name=\"");
|
||||
xml_escape_text_append (&document, (char *) libname);
|
||||
xml_escape_text_append (document, (char *) libname);
|
||||
string_appendf (document, "\" lm=\"0x%lx\" "
|
||||
"l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
|
||||
(unsigned long) lm_addr, (unsigned long) l_addr,
|
||||
|
||||
@@ -27,7 +27,7 @@ xml_escape_text (const char *text)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
xml_escape_text_append (&result, text);
|
||||
xml_escape_text_append (result, text);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -35,29 +35,29 @@ xml_escape_text (const char *text)
|
||||
/* See xml-utils.h. */
|
||||
|
||||
void
|
||||
xml_escape_text_append (std::string *result, const char *text)
|
||||
xml_escape_text_append (std::string &result, const char *text)
|
||||
{
|
||||
/* Expand the result. */
|
||||
for (int i = 0; text[i] != '\0'; i++)
|
||||
switch (text[i])
|
||||
{
|
||||
case '\'':
|
||||
*result += "'";
|
||||
result += "'";
|
||||
break;
|
||||
case '\"':
|
||||
*result += """;
|
||||
result += """;
|
||||
break;
|
||||
case '&':
|
||||
*result += "&";
|
||||
result += "&";
|
||||
break;
|
||||
case '<':
|
||||
*result += "<";
|
||||
result += "<";
|
||||
break;
|
||||
case '>':
|
||||
*result += ">";
|
||||
result += ">";
|
||||
break;
|
||||
default:
|
||||
*result += text[i];
|
||||
result += text[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@ extern std::string xml_escape_text (const char *text);
|
||||
/* Append TEXT to RESULT, with special characters replaced by entity
|
||||
references. */
|
||||
|
||||
extern void xml_escape_text_append (std::string *result, const char *text);
|
||||
extern void xml_escape_text_append (std::string &result, const char *text);
|
||||
|
||||
#endif /* COMMON_XML_UTILS_H */
|
||||
|
||||
Reference in New Issue
Block a user