Skip to content

Commit fa053c0

Browse files
author
MarcoFalke
committed
style: Fix whitespace in Parse* functions
1 parent fa03dec commit fa053c0

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

src/core_read.cpp

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ opcodetype ParseOpCode(const std::string& s)
2626
{
2727
static std::map<std::string, opcodetype> mapOpNames;
2828

29-
if (mapOpNames.empty())
30-
{
31-
for (unsigned int op = 0; op <= MAX_OPCODE; op++)
32-
{
29+
if (mapOpNames.empty()) {
30+
for (unsigned int op = 0; op <= MAX_OPCODE; op++) {
3331
// Allow OP_RESERVED to get into mapOpNames
34-
if (op < OP_NOP && op != OP_RESERVED)
32+
if (op < OP_NOP && op != OP_RESERVED) {
3533
continue;
34+
}
3635

3736
std::string strName = GetOpName(static_cast<opcodetype>(op));
38-
if (strName == "OP_UNKNOWN")
37+
if (strName == "OP_UNKNOWN") {
3938
continue;
39+
}
4040
mapOpNames[strName] = static_cast<opcodetype>(op);
4141
// Convenience: OP_ADD and just ADD are both recognized:
42-
if (strName.compare(0, 3, "OP_") == 0) { // strName starts with "OP_"
42+
if (strName.compare(0, 3, "OP_") == 0) { // strName starts with "OP_"
4343
mapOpNames[strName.substr(3)] = static_cast<opcodetype>(op);
4444
}
4545
}
@@ -59,42 +59,33 @@ CScript ParseScript(const std::string& s)
5959
std::vector<std::string> words;
6060
boost::algorithm::split(words, s, boost::algorithm::is_any_of(" \t\n"), boost::algorithm::token_compress_on);
6161

62-
for (const std::string& w : words)
63-
{
64-
if (w.empty())
65-
{
62+
for (const std::string& w : words) {
63+
if (w.empty()) {
6664
// Empty string, ignore. (boost::split given '' will return one word)
67-
}
68-
else if (std::all_of(w.begin(), w.end(), ::IsDigit) ||
69-
(w.front() == '-' && w.size() > 1 && std::all_of(w.begin()+1, w.end(), ::IsDigit)))
65+
} else if (std::all_of(w.begin(), w.end(), ::IsDigit) ||
66+
(w.front() == '-' && w.size() > 1 && std::all_of(w.begin() + 1, w.end(), ::IsDigit)))
7067
{
7168
// Number
7269
int64_t n = LocaleIndependentAtoi<int64_t>(w);
7370

74-
//limit the range of numbers ParseScript accepts in decimal
75-
//since numbers outside -0xFFFFFFFF...0xFFFFFFFF are illegal in scripts
71+
// limit the range of numbers ParseScript accepts in decimal
72+
// since numbers outside -0xFFFFFFFF...0xFFFFFFFF are illegal in scripts
7673
if (n > int64_t{0xffffffff} || n < -1 * int64_t{0xffffffff}) {
7774
throw std::runtime_error("script parse error: decimal numeric value only allowed in the "
7875
"range -0xFFFFFFFF...0xFFFFFFFF");
7976
}
8077

8178
result << n;
82-
}
83-
else if (w.substr(0,2) == "0x" && w.size() > 2 && IsHex(std::string(w.begin()+2, w.end())))
84-
{
79+
} else if (w.substr(0, 2) == "0x" && w.size() > 2 && IsHex(std::string(w.begin() + 2, w.end()))) {
8580
// Raw hex data, inserted NOT pushed onto stack:
86-
std::vector<unsigned char> raw = ParseHex(std::string(w.begin()+2, w.end()));
81+
std::vector<unsigned char> raw = ParseHex(std::string(w.begin() + 2, w.end()));
8782
result.insert(result.end(), raw.begin(), raw.end());
88-
}
89-
else if (w.size() >= 2 && w.front() == '\'' && w.back() == '\'')
90-
{
83+
} else if (w.size() >= 2 && w.front() == '\'' && w.back() == '\'') {
9184
// Single-quoted string, pushed as data. NOTE: this is poor-man's
9285
// parsing, spaces/tabs/newlines in single-quoted strings won't work.
93-
std::vector<unsigned char> value(w.begin()+1, w.end()-1);
86+
std::vector<unsigned char> value(w.begin() + 1, w.end() - 1);
9487
result << value;
95-
}
96-
else
97-
{
88+
} else {
9889
// opcode, e.g. OP_ADD or ADD:
9990
result << ParseOpCode(w);
10091
}

0 commit comments

Comments
 (0)