Fix issues discovered while evaluating pvs-studio

This commit is contained in:
Jason Turner
2014-05-11 11:53:03 -06:00
parent bcb7172037
commit c35b35e4f8
3 changed files with 13 additions and 13 deletions

View File

@@ -404,7 +404,7 @@ namespace chaiscript
oss << text; oss << text;
for (unsigned int j = 0; j < this->children.size(); ++j) { for (size_t j = 0; j < this->children.size(); ++j) {
oss << this->children[j]->pretty_print(); oss << this->children[j]->pretty_print();
} }
@@ -413,13 +413,13 @@ namespace chaiscript
/// Prints the contents of an AST node, including its children, recursively /// Prints the contents of an AST node, including its children, recursively
std::string to_string(std::string t_prepend = "") { std::string to_string(const std::string &t_prepend = "") {
std::ostringstream oss; std::ostringstream oss;
oss << t_prepend << "(" << ast_node_type_to_string(this->identifier) << ") " oss << t_prepend << "(" << ast_node_type_to_string(this->identifier) << ") "
<< this->text << " : " << this->start.line << ", " << this->start.column << std::endl; << this->text << " : " << this->start.line << ", " << this->start.column << std::endl;
for (unsigned int j = 0; j < this->children.size(); ++j) { for (size_t j = 0; j < this->children.size(); ++j) {
oss << this->children[j]->to_string(t_prepend + " "); oss << this->children[j]->to_string(t_prepend + " ");
} }
return oss.str(); return oss.str();

View File

@@ -258,7 +258,7 @@ namespace chaiscript
{ {
std::ostringstream oss; std::ostringstream oss;
for (unsigned int j = 0; j < this->children.size(); ++j) { for (size_t j = 0; j < this->children.size(); ++j) {
oss << this->children[j]->pretty_print(); oss << this->children[j]->pretty_print();
if (j == 0) if (j == 0)
@@ -323,7 +323,7 @@ namespace chaiscript
virtual std::string pretty_print() const virtual std::string pretty_print() const
{ {
std::ostringstream oss; std::ostringstream oss;
for (unsigned int j = 0; j < this->children.size(); ++j) { for (size_t j = 0; j < this->children.size(); ++j) {
oss << this->children[j]->pretty_print(); oss << this->children[j]->pretty_print();
if (j == 0) if (j == 0)
@@ -1248,7 +1248,7 @@ namespace chaiscript
assert(end_point > 0); assert(end_point > 0);
end_point = this->children.size() - 1; end_point = this->children.size() - 1;
} }
for (unsigned int i = 1; i < end_point; ++i) { for (size_t i = 1; i < end_point; ++i) {
chaiscript::eval::detail::Scope_Push_Pop catchscope(t_ss); chaiscript::eval::detail::Scope_Push_Pop catchscope(t_ss);
AST_NodePtr catch_block = this->children[i]; AST_NodePtr catch_block = this->children[i];

View File

@@ -212,7 +212,7 @@ namespace chaiscript
* Shows the current stack of matched ast_nodes * Shows the current stack of matched ast_nodes
*/ */
void show_match_stack() { void show_match_stack() {
for (unsigned int i = 0; i < m_match_stack.size(); ++i) { for (size_t i = 0; i < m_match_stack.size(); ++i) {
//debug_print(match_stack[i]); //debug_print(match_stack[i]);
std::cout << m_match_stack[i]->to_string(); std::cout << m_match_stack[i]->to_string();
} }
@@ -1109,11 +1109,11 @@ namespace chaiscript
*/ */
bool Keyword_(const char *t_s) { bool Keyword_(const char *t_s) {
bool retval = false; bool retval = false;
int len = static_cast<int>(strlen(t_s)); size_t len = strlen(t_s);
if ((m_input_end - m_input_pos) >= len) { if ((m_input_end - m_input_pos) >= static_cast<std::make_signed<size_t>::type>(len)) {
std::string::const_iterator tmp = m_input_pos; std::string::const_iterator tmp = m_input_pos;
for (int i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
if (*tmp != t_s[i]) { if (*tmp != t_s[i]) {
return false; return false;
} }
@@ -1157,11 +1157,11 @@ namespace chaiscript
*/ */
bool Symbol_(const char *t_s) { bool Symbol_(const char *t_s) {
bool retval = false; bool retval = false;
int len = static_cast<int>(strlen(t_s)); size_t len = strlen(t_s);
if ((m_input_end - m_input_pos) >= len) { if ((m_input_end - m_input_pos) >= static_cast<std::make_signed<size_t>::type>(len)) {
std::string::const_iterator tmp = m_input_pos; std::string::const_iterator tmp = m_input_pos;
for (int i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
if (*tmp != t_s[i]) { if (*tmp != t_s[i]) {
return false; return false;
} }