X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fformatter.cc;h=7cb3ea0ab8fb55ca8b7e0083b66638527128017a;hb=30f2a0f97e193f632c64205abe83abca7ed08ee7;hp=198b9e7df75d63b1afd92a64dc69ee71f4850760;hpb=bf2a0c2d70c613ab933de37b8aaa0702a15e2ccd;p=m6w6%2Flibmemcached diff --git a/libtest/formatter.cc b/libtest/formatter.cc index 198b9e7d..7cb3ea0a 100644 --- a/libtest/formatter.cc +++ b/libtest/formatter.cc @@ -52,39 +52,41 @@ std::string& escape4XML(std::string const& arg, std::string& escaped_string) for (std::string::const_iterator x= arg.begin(), end= arg.end(); x != end; ++x) { unsigned char c= *x; - if (' ' <= c and c <= '~' and c != '\\' and c != '"' and c != '>' and c != '<') + if (c == '&') { - escaped_string+= c; + escaped_string+= "&"; } else if (c == '>') { - escaped_string+= '&'; - escaped_string+= 'g'; - escaped_string+= 't'; - escaped_string+= ';'; + escaped_string+= ">"; } else if (c == '<') { - escaped_string+= '&'; - escaped_string+= 'l'; - escaped_string+= 't'; - escaped_string+= ';'; + escaped_string+= "<"; + } + else if (c == '\'') + { + escaped_string+= "'"; break; + } + else if (c == '"') + { + escaped_string+= """; + } + else if (c == ' ') + { + escaped_string+= ' '; + } + else if (isalnum(c)) + { + escaped_string+= c; } else { - escaped_string+= '\\'; - switch (c) { - case '"': escaped_string+= '"'; break; - case '\\': escaped_string+= '\\'; break; - case '\t': escaped_string+='t'; break; - case '\r': escaped_string+='r'; break; - case '\n': escaped_string+='n'; break; - default: - char const* const hexdig= "0123456789ABCDEF"; - escaped_string+= 'x'; - escaped_string+= hexdig[c >> 4]; - escaped_string+= hexdig[c & 0xF]; - } + char const* const hexdig= "0123456789ABCDEF"; + escaped_string+= "&#x"; + escaped_string+= hexdig[c >> 4]; + escaped_string+= hexdig[c & 0xF]; + escaped_string+= ';'; } } escaped_string+= '"'; @@ -219,8 +221,7 @@ void Formatter::xml(libtest::Framework& framework_, std::ofstream& output) << escape4XML((*case_iter)->name(), escaped_string) << " time=\"" << (*case_iter)->timer().elapsed_milliseconds() - << "\"" - << std::endl; + << "\""; switch ((*case_iter)->result()) {