Skip to content

Commit 77974f3

Browse files
authored
Merge pull request bitcoin#34 from paveljanik/20161116_Wshadow_codepoint
Do not shadow member variable codepoint
2 parents 28876d0 + a38fcd3 commit 77974f3

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

lib/univalue_utffilter.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,27 @@ class JSONUTF8StringFilter
4646
}
4747
}
4848
// Write codepoint directly, possibly collating surrogate pairs
49-
void push_back_u(unsigned int codepoint)
49+
void push_back_u(unsigned int codepoint_)
5050
{
5151
if (state) // Only accept full codepoints in open state
5252
is_valid = false;
53-
if (codepoint >= 0xD800 && codepoint < 0xDC00) { // First half of surrogate pair
53+
if (codepoint_ >= 0xD800 && codepoint_ < 0xDC00) { // First half of surrogate pair
5454
if (surpair) // Two subsequent surrogate pair openers - fail
5555
is_valid = false;
5656
else
57-
surpair = codepoint;
58-
} else if (codepoint >= 0xDC00 && codepoint < 0xE000) { // Second half of surrogate pair
57+
surpair = codepoint_;
58+
} else if (codepoint_ >= 0xDC00 && codepoint_ < 0xE000) { // Second half of surrogate pair
5959
if (surpair) { // Open surrogate pair, expect second half
6060
// Compute code point from UTF-16 surrogate pair
61-
append_codepoint(0x10000 | ((surpair - 0xD800)<<10) | (codepoint - 0xDC00));
61+
append_codepoint(0x10000 | ((surpair - 0xD800)<<10) | (codepoint_ - 0xDC00));
6262
surpair = 0;
6363
} else // Second half doesn't follow a first half - fail
6464
is_valid = false;
6565
} else {
6666
if (surpair) // First half of surrogate pair not followed by second - fail
6767
is_valid = false;
6868
else
69-
append_codepoint(codepoint);
69+
append_codepoint(codepoint_);
7070
}
7171
}
7272
// Check that we're in a state where the string can be ended
@@ -96,22 +96,22 @@ class JSONUTF8StringFilter
9696
// Two subsequent \u.... may have to be replaced with one actual codepoint.
9797
unsigned int surpair; // First half of open UTF-16 surrogate pair, or 0
9898

99-
void append_codepoint(unsigned int codepoint)
99+
void append_codepoint(unsigned int codepoint_)
100100
{
101-
if (codepoint <= 0x7f)
102-
str.push_back((char)codepoint);
103-
else if (codepoint <= 0x7FF) {
104-
str.push_back((char)(0xC0 | (codepoint >> 6)));
105-
str.push_back((char)(0x80 | (codepoint & 0x3F)));
106-
} else if (codepoint <= 0xFFFF) {
107-
str.push_back((char)(0xE0 | (codepoint >> 12)));
108-
str.push_back((char)(0x80 | ((codepoint >> 6) & 0x3F)));
109-
str.push_back((char)(0x80 | (codepoint & 0x3F)));
110-
} else if (codepoint <= 0x1FFFFF) {
111-
str.push_back((char)(0xF0 | (codepoint >> 18)));
112-
str.push_back((char)(0x80 | ((codepoint >> 12) & 0x3F)));
113-
str.push_back((char)(0x80 | ((codepoint >> 6) & 0x3F)));
114-
str.push_back((char)(0x80 | (codepoint & 0x3F)));
101+
if (codepoint_ <= 0x7f)
102+
str.push_back((char)codepoint_);
103+
else if (codepoint_ <= 0x7FF) {
104+
str.push_back((char)(0xC0 | (codepoint_ >> 6)));
105+
str.push_back((char)(0x80 | (codepoint_ & 0x3F)));
106+
} else if (codepoint_ <= 0xFFFF) {
107+
str.push_back((char)(0xE0 | (codepoint_ >> 12)));
108+
str.push_back((char)(0x80 | ((codepoint_ >> 6) & 0x3F)));
109+
str.push_back((char)(0x80 | (codepoint_ & 0x3F)));
110+
} else if (codepoint_ <= 0x1FFFFF) {
111+
str.push_back((char)(0xF0 | (codepoint_ >> 18)));
112+
str.push_back((char)(0x80 | ((codepoint_ >> 12) & 0x3F)));
113+
str.push_back((char)(0x80 | ((codepoint_ >> 6) & 0x3F)));
114+
str.push_back((char)(0x80 | (codepoint_ & 0x3F)));
115115
}
116116
}
117117
};

0 commit comments

Comments
 (0)