Merge branch 'master' into topic/jsiwek/brofiler

Conflicts:
	src/main.cc
This commit is contained in:
Jon Siwek 2012-01-11 10:57:44 -06:00
commit 1181444f37
291 changed files with 17420 additions and 6314 deletions

View file

@ -41,6 +41,37 @@
#include "Net.h"
#include "Reporter.h"
/**
* Takes a string, escapes characters into equivalent hex codes (\x##), and
* returns a string containing all escaped values.
*
* @param str string to escape
* @param escape_all If true, all characters are escaped. If false, only
* characters are escaped that are either whitespace or not printable in
* ASCII.
* @return A std::string containing a list of escaped hex values of the form
* \x## */
std::string get_escaped_string(const std::string& str, bool escape_all)
{
char tbuf[16];
string esc = "";
for ( size_t i = 0; i < str.length(); ++i )
{
char c = str[i];
if ( escape_all || isspace(c) || ! isascii(c) || ! isprint(c) )
{
snprintf(tbuf, sizeof(tbuf), "\\x%02x", str[i]);
esc += tbuf;
}
else
esc += c;
}
return esc;
}
char* copy_string(const char* s)
{
char* c = new char[strlen(s)+1];