From b25a249eaa9598b93be64cb9553a847fdf078c04 Mon Sep 17 00:00:00 2001 From: Edgar Date: Fri, 15 Jan 2021 10:30:56 +0100 Subject: [PATCH] :bug: Fixed GetNumStrings not counting strings with context --- include/moFileReader.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/moFileReader.hpp b/include/moFileReader.hpp index 97d56f8..bf08829 100644 --- a/include/moFileReader.hpp +++ b/include/moFileReader.hpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include //------------------------------------------------------------- // Path-Seperators are different on other OS. @@ -289,10 +289,10 @@ class moFileReader { protected: /// \brief Type for the map which holds the translation-pairs later. - typedef std::unordered_map moLookupList; + typedef std::map moLookupList; /// \brief Type for the 2D map which holds the translation-pairs later. - typedef std::unordered_map moContextLookupList; + typedef std::map moContextLookupList; public: /// \brief The Magic Number describes the endianess of bytes on the system. @@ -490,11 +490,13 @@ class moFileReader // Store it in the map. if(x == std::string::npos){ m_lookup[original_str] = translation_str; + numStrings++; } else{ // try-catch for handling out_of_range exceptions try { m_lookup_context[original_str.substr(0, x)][original_str.substr(x + 1, original_str.length())] = translation_str; + numStrings++; } catch (...) { m_error = "Stream bad during reading. The .mo-file seems to be invalid or has bad descriptions!"; @@ -550,6 +552,8 @@ class moFileReader void ClearTable() { m_lookup.clear(); + m_lookup_context.clear(); + numStrings = 0; } /** \brief Returns the Number of Entries in our Lookup-Table. @@ -558,7 +562,7 @@ class moFileReader */ unsigned int GetNumStrings() const { - return m_lookup.size(); + return numStrings; } /** \brief Exports the whole content of the .mo-File as .html @@ -684,6 +688,8 @@ class moFileReader moLookupList m_lookup; moContextLookupList m_lookup_context; + int numStrings = 0; + // Replaces < with ( to satisfy html-rules. static void MakeHtmlConform(std::string &_inout) {