mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Fix sign/unsigned compiler warnings
This commit is contained in:
parent
5cac962f18
commit
2b2b171cbd
@ -301,7 +301,7 @@ inline void read_file(const std::string& path, std::string& out)
|
|||||||
fs.seekg(0, std::ios_base::end);
|
fs.seekg(0, std::ios_base::end);
|
||||||
auto size = fs.tellg();
|
auto size = fs.tellg();
|
||||||
fs.seekg(0);
|
fs.seekg(0);
|
||||||
out.resize(size);
|
out.resize(static_cast<size_t>(size));
|
||||||
fs.read(&out[0], size);
|
fs.read(&out[0], size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,11 +345,11 @@ inline const char* get_header_value(const MultiMap& map, const char* key, const
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get_header_value_int(const MultiMap& map, const char* key, int def)
|
inline size_t get_header_value_int(const MultiMap& map, const char* key, size_t def)
|
||||||
{
|
{
|
||||||
auto it = map.find(key);
|
auto it = map.find(key);
|
||||||
if (it != map.end()) {
|
if (it != map.end()) {
|
||||||
return std::stoi(it->second);
|
return static_cast<size_t>(std::stoul(it->second));
|
||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
@ -424,7 +424,7 @@ inline std::string encode_url(const std::string& s)
|
|||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
for (auto i = 0; s[i]; i++) {
|
for (size_t i = 0; s[i]; i++) {
|
||||||
switch (s[i]) {
|
switch (s[i]) {
|
||||||
case ' ': result += "+"; break;
|
case ' ': result += "+"; break;
|
||||||
case '\'': result += "%27"; break;
|
case '\'': result += "%27"; break;
|
||||||
@ -435,7 +435,7 @@ inline std::string encode_url(const std::string& s)
|
|||||||
if (s[i] < 0) {
|
if (s[i] < 0) {
|
||||||
result += '%';
|
result += '%';
|
||||||
char hex[4];
|
char hex[4];
|
||||||
size_t len = snprintf(hex, sizeof(hex), "%02X", (unsigned char)s[i]);
|
auto len = static_cast<size_t>(snprintf(hex, sizeof(hex), "%02X", static_cast<unsigned char>(s[i])));
|
||||||
assert(len == 2);
|
assert(len == 2);
|
||||||
result.append(hex, len);
|
result.append(hex, len);
|
||||||
} else {
|
} else {
|
||||||
@ -463,10 +463,10 @@ inline bool is_hex(char c, int& v)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int from_hex_to_i(const std::string& s, int i, int cnt, int& val)
|
inline size_t from_hex_to_i(const std::string& s, size_t i, int cnt, int& val)
|
||||||
{
|
{
|
||||||
val = 0;
|
val = 0;
|
||||||
for (; s[i] && cnt; i++, cnt--) {
|
for ( ; s[i] && cnt; i++, cnt--) {
|
||||||
int v = 0;
|
int v = 0;
|
||||||
if (is_hex(s[i], v)) {
|
if (is_hex(s[i], v)) {
|
||||||
val = val * 16 + v;
|
val = val * 16 + v;
|
||||||
@ -483,26 +483,26 @@ inline size_t to_utf8(int code, char* buff)
|
|||||||
buff[0] = (code & 0x7F);
|
buff[0] = (code & 0x7F);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (code < 0x0800) {
|
} else if (code < 0x0800) {
|
||||||
buff[0] = (0xC0 | ((code >> 6) & 0x1F));
|
buff[0] = static_cast<char>(0xC0 | ((code >> 6) & 0x1F));
|
||||||
buff[1] = (0x80 | (code & 0x3F));
|
buff[1] = static_cast<char>(0x80 | (code & 0x3F));
|
||||||
return 2;
|
return 2;
|
||||||
} else if (code < 0xD800) {
|
} else if (code < 0xD800) {
|
||||||
buff[0] = (0xE0 | ((code >> 12) & 0xF));
|
buff[0] = static_cast<char>(0xE0 | ((code >> 12) & 0xF));
|
||||||
buff[1] = (0x80 | ((code >> 6) & 0x3F));
|
buff[1] = static_cast<char>(0x80 | ((code >> 6) & 0x3F));
|
||||||
buff[2] = (0x80 | (code & 0x3F));
|
buff[2] = static_cast<char>(0x80 | (code & 0x3F));
|
||||||
return 3;
|
return 3;
|
||||||
} else if (code < 0xE000) { // D800 - DFFF is invalid...
|
} else if (code < 0xE000) { // D800 - DFFF is invalid...
|
||||||
return 0;
|
return 0;
|
||||||
} else if (code < 0x10000) {
|
} else if (code < 0x10000) {
|
||||||
buff[0] = (0xE0 | ((code >> 12) & 0xF));
|
buff[0] = static_cast<char>(0xE0 | ((code >> 12) & 0xF));
|
||||||
buff[1] = (0x80 | ((code >> 6) & 0x3F));
|
buff[1] = static_cast<char>(0x80 | ((code >> 6) & 0x3F));
|
||||||
buff[2] = (0x80 | (code & 0x3F));
|
buff[2] = static_cast<char>(0x80 | (code & 0x3F));
|
||||||
return 3;
|
return 3;
|
||||||
} else if (code < 0x110000) {
|
} else if (code < 0x110000) {
|
||||||
buff[0] = (0xF0 | ((code >> 18) & 0x7));
|
buff[0] = static_cast<char>(0xF0 | ((code >> 18) & 0x7));
|
||||||
buff[1] = (0x80 | ((code >> 12) & 0x3F));
|
buff[1] = static_cast<char>(0x80 | ((code >> 12) & 0x3F));
|
||||||
buff[2] = (0x80 | ((code >> 6) & 0x3F));
|
buff[2] = static_cast<char>(0x80 | ((code >> 6) & 0x3F));
|
||||||
buff[3] = (0x80 | (code & 0x3F));
|
buff[3] = static_cast<char>(0x80 | (code & 0x3F));
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,7 +514,7 @@ inline std::string decode_url(const std::string& s)
|
|||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
for (int i = 0; s[i]; i++) {
|
for (size_t i = 0; s[i]; i++) {
|
||||||
if (s[i] == '%') {
|
if (s[i] == '%') {
|
||||||
i++;
|
i++;
|
||||||
assert(s[i]);
|
assert(s[i]);
|
||||||
@ -539,7 +539,7 @@ inline std::string decode_url(const std::string& s)
|
|||||||
// HEX
|
// HEX
|
||||||
int val = 0;
|
int val = 0;
|
||||||
i = from_hex_to_i(s, i, 2, val);
|
i = from_hex_to_i(s, i, 2, val);
|
||||||
result += val;
|
result += static_cast<char>(val);
|
||||||
}
|
}
|
||||||
} else if (s[i] == '+') {
|
} else if (s[i] == '+') {
|
||||||
result += ' ';
|
result += ' ';
|
||||||
|
@ -123,7 +123,7 @@ int main(int argc, const char** argv)
|
|||||||
std::cout << "-------\t--------" << std::endl;
|
std::cout << "-------\t--------" << std::endl;
|
||||||
size_t prev_pos = 0;
|
size_t prev_pos = 0;
|
||||||
parser.enable_trace([&](auto name, auto s, auto /*n*/, auto& /*sv*/, auto& c, auto& /*dt*/) {
|
parser.enable_trace([&](auto name, auto s, auto /*n*/, auto& /*sv*/, auto& c, auto& /*dt*/) {
|
||||||
auto pos = s - c.s;
|
auto pos = static_cast<size_t>(s - c.s);
|
||||||
auto backtrack = (pos < prev_pos ? "*" : "");
|
auto backtrack = (pos < prev_pos ? "*" : "");
|
||||||
string indent;
|
string indent;
|
||||||
auto level = c.nest_level;
|
auto level = c.nest_level;
|
||||||
@ -133,7 +133,7 @@ int main(int argc, const char** argv)
|
|||||||
std::cout
|
std::cout
|
||||||
<< pos << ":" << c.nest_level << backtrack << "\t"
|
<< pos << ":" << c.nest_level << backtrack << "\t"
|
||||||
<< indent << name << std::endl;
|
<< indent << name << std::endl;
|
||||||
prev_pos = pos;
|
prev_pos = static_cast<size_t>(pos);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
70
peglib.h
70
peglib.h
@ -253,7 +253,7 @@ struct SemanticValues : protected std::vector<any>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto transform(size_t beg = 0, size_t end = -1) const -> vector<T> {
|
auto transform(size_t beg = 0, size_t end = static_cast<size_t>(-1)) const -> vector<T> {
|
||||||
return this->transform(beg, end, [](const any& v) { return v.get<T>(); });
|
return this->transform(beg, end, [](const any& v) { return v.get<T>(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,11 +432,11 @@ typedef std::function<void (const char* s, size_t n, size_t id, const std::strin
|
|||||||
* Result
|
* Result
|
||||||
*/
|
*/
|
||||||
inline bool success(size_t len) {
|
inline bool success(size_t len) {
|
||||||
return len != -1;
|
return len != static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool fail(size_t len) {
|
inline bool fail(size_t len) {
|
||||||
return len == -1;
|
return len == static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -512,21 +512,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto col = s - this->s;
|
auto col = s - this->s;
|
||||||
auto has_cache = cache_register[def_count * col + def_id];
|
auto has_cache = cache_register[def_count * static_cast<size_t>(col) + def_id];
|
||||||
|
|
||||||
if (has_cache) {
|
if (has_cache) {
|
||||||
if (cache_success[def_count * col + def_id]) {
|
if (cache_success[def_count * static_cast<size_t>(col) + def_id]) {
|
||||||
const auto& key = std::make_pair(s - this->s, def_id);
|
const auto& key = std::make_pair(s - this->s, def_id);
|
||||||
std::tie(len, val) = cache_result[key];
|
std::tie(len, val) = cache_result[key];
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
len = -1;
|
len = static_cast<size_t>(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fn(val);
|
fn(val);
|
||||||
cache_register[def_count * col + def_id] = true;
|
cache_register[def_count * static_cast<size_t>(col) + def_id] = true;
|
||||||
cache_success[def_count * col + def_id] = success(len);
|
cache_success[def_count * static_cast<size_t>(col) + def_id] = success(len);
|
||||||
if (success(len)) {
|
if (success(len)) {
|
||||||
const auto& key = std::make_pair(s - this->s, def_id);
|
const auto& key = std::make_pair(s - this->s, def_id);
|
||||||
cache_result[key] = std::make_pair(len, val);
|
cache_result[key] = std::make_pair(len, val);
|
||||||
@ -611,7 +611,7 @@ public:
|
|||||||
const auto& rule = *ope;
|
const auto& rule = *ope;
|
||||||
auto len = rule.parse(s + i, n - i, sv, c, dt);
|
auto len = rule.parse(s + i, n - i, sv, c, dt);
|
||||||
if (fail(len)) {
|
if (fail(len)) {
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
i += len;
|
i += len;
|
||||||
}
|
}
|
||||||
@ -669,7 +669,7 @@ public:
|
|||||||
}
|
}
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void accept(Visitor& v) override;
|
void accept(Visitor& v) override;
|
||||||
@ -697,10 +697,10 @@ public:
|
|||||||
auto len = rule.parse(s + i, n - i, sv, c, dt);
|
auto len = rule.parse(s + i, n - i, sv, c, dt);
|
||||||
if (fail(len)) {
|
if (fail(len)) {
|
||||||
if (sv.size() != save_sv_size) {
|
if (sv.size() != save_sv_size) {
|
||||||
sv.erase(sv.begin() + save_sv_size);
|
sv.erase(sv.begin() + static_cast<std::ptrdiff_t>(save_sv_size));
|
||||||
}
|
}
|
||||||
if (sv.tokens.size() != save_tok_size) {
|
if (sv.tokens.size() != save_tok_size) {
|
||||||
sv.tokens.erase(sv.tokens.begin() + save_tok_size);
|
sv.tokens.erase(sv.tokens.begin() + static_cast<std::ptrdiff_t>(save_tok_size));
|
||||||
}
|
}
|
||||||
c.error_pos = save_error_pos;
|
c.error_pos = save_error_pos;
|
||||||
break;
|
break;
|
||||||
@ -722,14 +722,14 @@ public:
|
|||||||
|
|
||||||
size_t parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const override {
|
size_t parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const override {
|
||||||
c.trace("OneOrMore", s, n, sv, dt);
|
c.trace("OneOrMore", s, n, sv, dt);
|
||||||
auto len = 0;
|
size_t len = 0;
|
||||||
{
|
{
|
||||||
c.nest_level++;
|
c.nest_level++;
|
||||||
auto se = make_scope_exit([&]() { c.nest_level--; });
|
auto se = make_scope_exit([&]() { c.nest_level--; });
|
||||||
const auto& rule = *ope_;
|
const auto& rule = *ope_;
|
||||||
len = rule.parse(s, n, sv, c, dt);
|
len = rule.parse(s, n, sv, c, dt);
|
||||||
if (fail(len)) {
|
if (fail(len)) {
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto save_error_pos = c.error_pos;
|
auto save_error_pos = c.error_pos;
|
||||||
@ -740,13 +740,13 @@ public:
|
|||||||
auto save_sv_size = sv.size();
|
auto save_sv_size = sv.size();
|
||||||
auto save_tok_size = sv.tokens.size();
|
auto save_tok_size = sv.tokens.size();
|
||||||
const auto& rule = *ope_;
|
const auto& rule = *ope_;
|
||||||
auto len = rule.parse(s + i, n - i, sv, c, dt);
|
len = rule.parse(s + i, n - i, sv, c, dt);
|
||||||
if (fail(len)) {
|
if (fail(len)) {
|
||||||
if (sv.size() != save_sv_size) {
|
if (sv.size() != save_sv_size) {
|
||||||
sv.erase(sv.begin() + save_sv_size);
|
sv.erase(sv.begin() + static_cast<std::ptrdiff_t>(save_sv_size));
|
||||||
}
|
}
|
||||||
if (sv.tokens.size() != save_tok_size) {
|
if (sv.tokens.size() != save_tok_size) {
|
||||||
sv.tokens.erase(sv.tokens.begin() + save_tok_size);
|
sv.tokens.erase(sv.tokens.begin() + static_cast<std::ptrdiff_t>(save_tok_size));
|
||||||
}
|
}
|
||||||
c.error_pos = save_error_pos;
|
c.error_pos = save_error_pos;
|
||||||
break;
|
break;
|
||||||
@ -779,10 +779,10 @@ public:
|
|||||||
return len;
|
return len;
|
||||||
} else {
|
} else {
|
||||||
if (sv.size() != save_sv_size) {
|
if (sv.size() != save_sv_size) {
|
||||||
sv.erase(sv.begin() + save_sv_size);
|
sv.erase(sv.begin() + static_cast<std::ptrdiff_t>(save_sv_size));
|
||||||
}
|
}
|
||||||
if (sv.tokens.size() != save_tok_size) {
|
if (sv.tokens.size() != save_tok_size) {
|
||||||
sv.tokens.erase(sv.tokens.begin() + save_tok_size);
|
sv.tokens.erase(sv.tokens.begin() + static_cast<std::ptrdiff_t>(save_tok_size));
|
||||||
}
|
}
|
||||||
c.error_pos = save_error_pos;
|
c.error_pos = save_error_pos;
|
||||||
return 0;
|
return 0;
|
||||||
@ -812,7 +812,7 @@ public:
|
|||||||
if (success(len)) {
|
if (success(len)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,7 +839,7 @@ public:
|
|||||||
auto len = rule.parse(s, n, chldsv, c, dt);
|
auto len = rule.parse(s, n, chldsv, c, dt);
|
||||||
if (success(len)) {
|
if (success(len)) {
|
||||||
c.set_error_pos(s);
|
c.set_error_pos(s);
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
} else {
|
} else {
|
||||||
c.error_pos = save_error_pos;
|
c.error_pos = save_error_pos;
|
||||||
return 0;
|
return 0;
|
||||||
@ -873,7 +873,7 @@ public:
|
|||||||
// TODO: UTF8 support
|
// TODO: UTF8 support
|
||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
c.set_error_pos(s);
|
c.set_error_pos(s);
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
auto ch = s[0];
|
auto ch = s[0];
|
||||||
auto i = 0u;
|
auto i = 0u;
|
||||||
@ -891,7 +891,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.set_error_pos(s);
|
c.set_error_pos(s);
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void accept(Visitor& v) override;
|
void accept(Visitor& v) override;
|
||||||
@ -909,7 +909,7 @@ public:
|
|||||||
// TODO: UTF8 support
|
// TODO: UTF8 support
|
||||||
if (n < 1 || s[0] != ch_) {
|
if (n < 1 || s[0] != ch_) {
|
||||||
c.set_error_pos(s);
|
c.set_error_pos(s);
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -927,7 +927,7 @@ public:
|
|||||||
// TODO: UTF8 support
|
// TODO: UTF8 support
|
||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
c.set_error_pos(s);
|
c.set_error_pos(s);
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1369,7 +1369,7 @@ inline size_t LiteralString::parse(const char* s, size_t n, SemanticValues& sv,
|
|||||||
for (; i < lit_.size(); i++) {
|
for (; i < lit_.size(); i++) {
|
||||||
if (i >= n || s[i] != lit_[i]) {
|
if (i >= n || s[i] != lit_[i]) {
|
||||||
c.set_error_pos(s);
|
c.set_error_pos(s);
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1378,7 +1378,7 @@ inline size_t LiteralString::parse(const char* s, size_t n, SemanticValues& sv,
|
|||||||
if (c.whitespaceOpe) {
|
if (c.whitespaceOpe) {
|
||||||
auto len = c.whitespaceOpe->parse(s + i, n - i, sv, c, dt);
|
auto len = c.whitespaceOpe->parse(s + i, n - i, sv, c, dt);
|
||||||
if (fail(len)) {
|
if (fail(len)) {
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
i += len;
|
i += len;
|
||||||
}
|
}
|
||||||
@ -1398,7 +1398,7 @@ inline size_t TokenBoundary::parse(const char* s, size_t n, SemanticValues& sv,
|
|||||||
if (c.whitespaceOpe) {
|
if (c.whitespaceOpe) {
|
||||||
auto l = c.whitespaceOpe->parse(s + len, n - len, sv, c, dt);
|
auto l = c.whitespaceOpe->parse(s + len, n - len, sv, c, dt);
|
||||||
if (fail(l)) {
|
if (fail(l)) {
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
len += l;
|
len += l;
|
||||||
}
|
}
|
||||||
@ -1450,7 +1450,7 @@ inline size_t Holder::parse(const char* s, size_t n, SemanticValues& sv, Context
|
|||||||
c.message = e.what();
|
c.message = e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len = -1;
|
len = static_cast<size_t>(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1582,7 +1582,7 @@ inline std::shared_ptr<Ope> cap(const std::shared_ptr<Ope>& ope, MatchAction ma,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<Ope> cap(const std::shared_ptr<Ope>& ope, MatchAction ma) {
|
inline std::shared_ptr<Ope> cap(const std::shared_ptr<Ope>& ope, MatchAction ma) {
|
||||||
return std::make_shared<Capture>(ope, ma, (size_t)-1, std::string());
|
return std::make_shared<Capture>(ope, ma, static_cast<size_t>(-1), std::string());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<Ope> tok(const std::shared_ptr<Ope>& ope) {
|
inline std::shared_ptr<Ope> tok(const std::shared_ptr<Ope>& ope) {
|
||||||
@ -1849,7 +1849,7 @@ private:
|
|||||||
Data& data = *dt.get<Data*>();
|
Data& data = *dt.get<Data*>();
|
||||||
|
|
||||||
auto ignore = (sv.size() == 4);
|
auto ignore = (sv.size() == 4);
|
||||||
auto baseId = ignore ? 1 : 0;
|
auto baseId = ignore ? 1u : 0u;
|
||||||
|
|
||||||
const auto& name = sv[baseId].get<std::string>();
|
const auto& name = sv[baseId].get<std::string>();
|
||||||
auto ope = sv[baseId + 2].get<std::shared_ptr<Ope>>();
|
auto ope = sv[baseId + 2].get<std::shared_ptr<Ope>>();
|
||||||
@ -1935,7 +1935,7 @@ private:
|
|||||||
switch (sv.choice()) {
|
switch (sv.choice()) {
|
||||||
case 0: { // Reference
|
case 0: { // Reference
|
||||||
auto ignore = (sv.size() == 2);
|
auto ignore = (sv.size() == 2);
|
||||||
auto baseId = ignore ? 1 : 0;
|
auto baseId = ignore ? 1u : 0u;
|
||||||
|
|
||||||
const auto& ident = sv[baseId].get<std::string>();
|
const auto& ident = sv[baseId].get<std::string>();
|
||||||
|
|
||||||
@ -2126,7 +2126,7 @@ private:
|
|||||||
char ret = 0;
|
char ret = 0;
|
||||||
int val;
|
int val;
|
||||||
while (i < n && is_hex(s[i], val)) {
|
while (i < n && is_hex(s[i], val)) {
|
||||||
ret = ret * 16 + val;
|
ret = static_cast<char>(ret * 16 + val);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return std::make_pair(ret, i);
|
return std::make_pair(ret, i);
|
||||||
@ -2136,7 +2136,7 @@ private:
|
|||||||
char ret = 0;
|
char ret = 0;
|
||||||
int val;
|
int val;
|
||||||
while (i < n && is_digit(s[i], val)) {
|
while (i < n && is_digit(s[i], val)) {
|
||||||
ret = ret * 8 + val;
|
ret = static_cast<char>(ret * 8 + val);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return std::make_pair(ret, i);
|
return std::make_pair(ret, i);
|
||||||
@ -2190,7 +2190,7 @@ const int AstDefaultTag = -1;
|
|||||||
|
|
||||||
#ifndef PEGLIB_NO_CONSTEXPR_SUPPORT
|
#ifndef PEGLIB_NO_CONSTEXPR_SUPPORT
|
||||||
inline constexpr unsigned int str2tag(const char* str, int h = 0) {
|
inline constexpr unsigned int str2tag(const char* str, int h = 0) {
|
||||||
return !str[h] ? 5381 : (str2tag(str, h + 1) * 33) ^ str[h];
|
return !str[h] ? 5381 : (str2tag(str, h + 1) * 33) ^ static_cast<unsigned char>(str[h]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr unsigned int operator "" _(const char* s, size_t) {
|
inline constexpr unsigned int operator "" _(const char* s, size_t) {
|
||||||
|
@ -786,7 +786,7 @@ TEST_CASE("User rule test", "[user rule]")
|
|||||||
return name.size();
|
return name.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return static_cast<size_t>(-1);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user