mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2812 from ethereum/removeEscape
Remove escape function.
This commit is contained in:
commit
7b6b12ca78
@ -28,34 +28,6 @@
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
|
||||
std::string dev::escaped(std::string const& _s, bool _all)
|
||||
{
|
||||
static const map<char, char> prettyEscapes{{'\r', 'r'}, {'\n', 'n'}, {'\t', 't'}, {'\v', 'v'}};
|
||||
std::string ret;
|
||||
ret.reserve(_s.size() + 2);
|
||||
ret.push_back('"');
|
||||
for (auto i: _s)
|
||||
if (i == '"' && !_all)
|
||||
ret += "\\\"";
|
||||
else if (i == '\\' && !_all)
|
||||
ret += "\\\\";
|
||||
else if (prettyEscapes.count(i) && !_all)
|
||||
{
|
||||
ret += '\\';
|
||||
ret += prettyEscapes.find(i)->second;
|
||||
}
|
||||
else if (i < ' ' || _all)
|
||||
{
|
||||
ret += "\\x";
|
||||
ret.push_back("0123456789abcdef"[(uint8_t)i / 16]);
|
||||
ret.push_back("0123456789abcdef"[(uint8_t)i % 16]);
|
||||
}
|
||||
else
|
||||
ret.push_back(i);
|
||||
ret.push_back('"');
|
||||
return ret;
|
||||
}
|
||||
|
||||
int dev::fromHex(char _i, WhenError _throw)
|
||||
{
|
||||
if (_i >= '0' && _i <= '9')
|
||||
|
@ -21,9 +21,12 @@
|
||||
*/
|
||||
|
||||
#include <libsolidity/ast/ASTPrinter.h>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <libsolidity/ast/AST.h>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace dev
|
||||
@ -579,8 +582,11 @@ void ASTPrinter::printSourcePart(ASTNode const& _node)
|
||||
if (!m_source.empty())
|
||||
{
|
||||
SourceLocation const& location(_node.location());
|
||||
*m_ostream << indentation() << " Source: "
|
||||
<< escaped(m_source.substr(location.start, location.end - location.start), false) << endl;
|
||||
*m_ostream <<
|
||||
indentation() <<
|
||||
" Source: " <<
|
||||
Json::valueToQuotedString(m_source.substr(location.start, location.end - location.start).c_str()) <<
|
||||
endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user