From 8913f9213dd060d0a4f2897895f703157dbfe4d1 Mon Sep 17 00:00:00 2001 From: Tim Zimmermann Date: Wed, 14 Jun 2017 22:46:43 +0200 Subject: [PATCH] Fix: use correct format specifiers for int64 (#45) * Fix: use correct format specifiers for int64 * Use iostream instead of stdio --- example/example.cpp | 2 +- src/util/sqlhelper.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/example/example.cpp b/example/example.cpp index 7cf0817..4cceb60 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) { printf("Parsed successfully!\n"); printf("Number of statements: %lu\n", result.size()); - for (uint i = 0; i < result.size(); ++i) { + for (auto i = 0u; i < result.size(); ++i) { // Print a statement summary. hsql::printStatementInfo(result.getStatement(i)); } diff --git a/src/util/sqlhelper.cpp b/src/util/sqlhelper.cpp index b6ad14b..459c0ba 100644 --- a/src/util/sqlhelper.cpp +++ b/src/util/sqlhelper.cpp @@ -1,6 +1,6 @@ #include "sqlhelper.h" -#include +#include #include namespace hsql { @@ -11,22 +11,22 @@ namespace hsql { return std::string(numIndent, '\t'); } void inprint(int64_t val, uintmax_t numIndent) { - printf("%s%ld \n", indent(numIndent).c_str(), val); + std::cout << indent(numIndent).c_str() << val << " " << std::endl; } void inprint(float val, uintmax_t numIndent) { - printf("%s%f\n", indent(numIndent).c_str(), val); + std::cout << indent(numIndent).c_str() << val << std::endl; } void inprint(const char* val, uintmax_t numIndent) { - printf("%s%s\n", indent(numIndent).c_str(), val); + std::cout << indent(numIndent).c_str() << val << std::endl; } void inprint(const char* val, const char* val2, uintmax_t numIndent) { - printf("%s%s->%s\n", indent(numIndent).c_str(), val, val2); + std::cout << indent(numIndent).c_str() << val << "->" << val2 << std::endl; } void inprintC(char val, uintmax_t numIndent) { - printf("%s%c\n", indent(numIndent).c_str(), val); + std::cout << indent(numIndent).c_str() << val << std::endl; } void inprintU(uint64_t val, uintmax_t numIndent) { - printf("%s%lu\n", indent(numIndent).c_str(), val); + std::cout << indent(numIndent).c_str() << val << std::endl; } void printTableRefInfo(TableRef* table, uintmax_t numIndent) { @@ -109,7 +109,7 @@ namespace hsql { printOperatorExpression(expr, numIndent); break; default: - fprintf(stderr, "Unrecognized expression type %d\n", expr->type); + std::cerr << "Unrecognized expression type " << expr->type << std::endl; return; } if (expr->alias != nullptr) { @@ -205,4 +205,4 @@ namespace hsql { } } -} // namespace hsql \ No newline at end of file +} // namespace hsql