diff --git a/README.md b/README.md index 944eb4b..607eb35 100644 --- a/README.md +++ b/README.md @@ -315,8 +315,8 @@ render("Hello{# Todo #}!", data); // "Hello!" Inja uses `string_view` from C++17, but includes the [polyfill](https://github.com/martinmoene/string-view-lite) from martinmoene. This way, the minimum version is C++11. Currently, the following compilers are tested: - - GCC 4.8 - 9 (and possibly later) - - Clang 3.5 - 9 (and possibly later) - - Microsoft Visual C++ 2016 - 2019 (and possibly later) +- GCC 4.8 - 9 (and possibly later) +- Clang 3.5 - 9 (and possibly later) +- Microsoft Visual C++ 2016 - 2019 (and possibly later) The unit tests fail to compile with GCC 4.8 but should just work fine. A complete list of supported compiler / os versions can be found in the [CI definition](https://github.com/pantor/inja/blob/master/.github/workflows/ci.yml). diff --git a/include/inja/exceptions.hpp b/include/inja/exceptions.hpp index bcb8383..2cf89f6 100644 --- a/include/inja/exceptions.hpp +++ b/include/inja/exceptions.hpp @@ -20,7 +20,7 @@ struct InjaError : public std::runtime_error { SourceLocation location; explicit InjaError(const std::string &type, const std::string &message) - : std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message) {} + : std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message), location({0, 0}) {} explicit InjaError(const std::string &type, const std::string &message, SourceLocation location) : std::runtime_error("[inja.exception." + type + "] (at " + std::to_string(location.line) + ":" + diff --git a/include/inja/lexer.hpp b/include/inja/lexer.hpp index 2d3145c..0d51e42 100644 --- a/include/inja/lexer.hpp +++ b/include/inja/lexer.hpp @@ -37,8 +37,8 @@ class Lexer { const LexerConfig &config; - State state {State::Text}; - MinusState minus_state {MinusState::Number}; + State state; + MinusState minus_state; nonstd::string_view m_in; size_t tok_start; size_t pos; @@ -268,7 +268,7 @@ class Lexer { } public: - explicit Lexer(const LexerConfig &config) : config(config) {} + explicit Lexer(const LexerConfig &config) : config(config), state(State::Text), minus_state(MinusState::Number) {} SourceLocation current_position() const { return get_source_location(m_in, tok_start); diff --git a/include/inja/utils.hpp b/include/inja/utils.hpp index eee804e..ee58ccc 100644 --- a/include/inja/utils.hpp +++ b/include/inja/utils.hpp @@ -56,7 +56,7 @@ inline SourceLocation get_source_location(nonstd::string_view content, size_t po size_t search_start = 0; while (search_start <= sliced.size()) { search_start = sliced.find("\n", search_start) + 1; - if (search_start <= 0) { + if (search_start == 0) { break; } count_lines += 1; diff --git a/single_include/inja/inja.hpp b/single_include/inja/inja.hpp index dbf1d99..d7aec6d 100644 --- a/single_include/inja/inja.hpp +++ b/single_include/inja/inja.hpp @@ -1687,7 +1687,7 @@ struct InjaError : public std::runtime_error { SourceLocation location; explicit InjaError(const std::string &type, const std::string &message) - : std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message) {} + : std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message), location({0, 0}) {} explicit InjaError(const std::string &type, const std::string &message, SourceLocation location) : std::runtime_error("[inja.exception." + type + "] (at " + std::to_string(location.line) + ":" + @@ -1869,7 +1869,7 @@ inline SourceLocation get_source_location(nonstd::string_view content, size_t po size_t search_start = 0; while (search_start <= sliced.size()) { search_start = sliced.find("\n", search_start) + 1; - if (search_start <= 0) { + if (search_start == 0) { break; } count_lines += 1; @@ -1910,8 +1910,8 @@ class Lexer { const LexerConfig &config; - State state {State::Text}; - MinusState minus_state {MinusState::Number}; + State state; + MinusState minus_state; nonstd::string_view m_in; size_t tok_start; size_t pos; @@ -2141,7 +2141,7 @@ class Lexer { } public: - explicit Lexer(const LexerConfig &config) : config(config) {} + explicit Lexer(const LexerConfig &config) : config(config), state(State::Text), minus_state(MinusState::Number) {} SourceLocation current_position() const { return get_source_location(m_in, tok_start);