Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67613 - trunk/tools/inspect
From: dnljms_at_[hidden]
Date: 2011-01-03 07:45:26


Author: danieljames
Date: 2011-01-03 07:45:15 EST (Mon, 03 Jan 2011)
New Revision: 67613
URL: http://svn.boost.org/trac/boost/changeset/67613

Log:
Html encode error messages.
Text files modified:
   trunk/tools/inspect/inspect.cpp | 30 ++++++++++++++++++++++++++++--
   1 files changed, 28 insertions(+), 2 deletions(-)

Modified: trunk/tools/inspect/inspect.cpp
==============================================================================
--- trunk/tools/inspect/inspect.cpp (original)
+++ trunk/tools/inspect/inspect.cpp 2011-01-03 07:45:15 EST (Mon, 03 Jan 2011)
@@ -348,6 +348,32 @@
       std::cout << "</blockquote>\n";
   }
 
+// html_encode -------------------------------------------------------------//
+
+ std::string html_encode(std::string const& text)
+ {
+ std::string result;
+
+ for(std::string::const_iterator it = text.begin(),
+ end = text.end(); it != end; ++it)
+ {
+ switch(*it) {
+ case '<':
+ result += "&lt;";
+ break;
+ case '>':
+ result += "&gt;";
+ break;
+ case '&':
+ result += "&amp;";
+ break;
+ default:
+ result += *it;
+ }
+ }
+
+ return result;
+ }
 
 // display_details ---------------------------------------------------------//
 
@@ -442,8 +468,8 @@
 
           // print the message
           if (itr->line_number)
- std::cout << sep << "(line " << itr->line_number << ") " << itr->msg;
- else std::cout << sep << itr->msg;
+ std::cout << sep << "(line " << itr->line_number << ") " << html_encode(itr->msg);
+ else std::cout << sep << html_encode(itr->msg);
 
           first_sep = false;
         }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk