File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -379,8 +379,17 @@ void ErrorMessage::deserialize(const std::string &data)
379379 }
380380}
381381
382- std::string ErrorMessage::getXMLHeader (const std::string& productName)
383- {
382+ std::string ErrorMessage::getXMLHeader (std::string productName)
383+ {
384+ std::string version = CppCheck::version ();
385+ if (!productName.empty () && std::isdigit (productName.back ())) {
386+ const std::string::size_type pos = productName.find_last_not_of (" .0123456789" );
387+ if (pos > 1 && pos != std::string::npos && productName[pos] == ' ' ) {
388+ version = productName.substr (pos+1 );
389+ productName.erase (pos);
390+ }
391+ }
392+
384393 tinyxml2::XMLPrinter printer;
385394
386395 // standard xml header
@@ -393,7 +402,7 @@ std::string ErrorMessage::getXMLHeader(const std::string& productName)
393402 printer.OpenElement (" cppcheck" , false );
394403 if (!productName.empty ())
395404 printer.PushAttribute (" product-name" , productName.c_str ());
396- printer.PushAttribute (" version" , CppCheck:: version ());
405+ printer.PushAttribute (" version" , version. c_str ());
397406 printer.CloseElement (false );
398407 printer.OpenElement (" errors" , false );
399408
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ class CPPCHECKLIB ErrorMessage {
148148 */
149149 std::string toXML () const ;
150150
151- static std::string getXMLHeader (const std::string& productName);
151+ static std::string getXMLHeader (std::string productName);
152152 static std::string getXMLFooter ();
153153
154154 /* *
You can’t perform that action at this time.
0 commit comments