Skip to content

Commit

Permalink
Merge pull request #14 from SimonCahill/fix/comments-in-translations
Browse files Browse the repository at this point in the history
Fix/comments in translations
  • Loading branch information
SimonCahill authored Feb 12, 2023
2 parents 7d41bc4 + 4f18f63 commit a677ec7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)

project(borr VERSION 1.0.0 LANGUAGES CXX DESCRIPTION "Borr; A simple cross-platform C++ language file parser" HOMEPAGE_URL "https://github.com/SimonCahill")
project(borr VERSION 1.0.1 LANGUAGES CXX DESCRIPTION "Borr; A simple cross-platform C++ language file parser" HOMEPAGE_URL "https://github.com/SimonCahill")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down
16 changes: 8 additions & 8 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
INTERNAL_DOCS = YES
CASE_SENSE_NAMES = SYSTEM
HIDE_SCOPE_NAMES = NO
HIDE_COMPOUND_REFERENCE= NO
Expand Down Expand Up @@ -122,13 +122,13 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = src/language.cpp \
include/borr/extensions.hpp \
include/borr/langversion.hpp \
include/borr/language.hpp \
include/borr/string_splitter.hpp \
README.md \
reference/src/Main.cpp
INPUT = include/borr/language.hpp \
#include/borr/langversion.hpp \
#include/borr/extensions.hpp \
#include/borr/string_splitter.hpp \
#README.md \
#src/language.cpp \
#reference/src/Main.cpp
INPUT_ENCODING = UTF-8
INPUT_FILE_ENCODING =
FILE_PATTERNS = *.c \
Expand Down
7 changes: 4 additions & 3 deletions src/language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ namespace borr {
/**
* @brief Determines whether a line is empty or is commented out.
*
* @example
*
*
* @code
* # this would count as an empty line
* [section] # this does not
* @endcode
*
* @param line The line to check.
*
Expand Down Expand Up @@ -294,7 +295,7 @@ namespace borr {
*/
string language::removeInlineComments(const string& line) const {
namespace rc = std::regex_constants;
static const regex COMMENT_REGEX = regex(R"(#[^\n]+$)", rc::optimize);
static const regex COMMENT_REGEX = regex(R"(#[^\n]+[^"]$)", rc::optimize);

string copy = line;
smatch matches;
Expand Down
2 changes: 2 additions & 0 deletions test/src/LanguageClassTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ TEST_F(LanguageClassTests, testRemoveInlineComments) {
const static string SECTION_WITH_COMMENT_2 = R"([section]#comment)";
const static string TRANSLATION_WITH_COMMENT = R"(translation = "" # comment)";
const static string TRANSLATION_WITH_COMMENT_2 = R"(translation[] = ""#COMMENTS ARE WEIRD)";
const static string TRANSLATION_WITH_INTERNAL_COMMENT = R"(translation = "this # shouldn't match")";

ASSERT_EQ(removeInlineComments(SECTION_WITH_COMMENT), R"([section])");
ASSERT_EQ(removeInlineComments(SECTION_WITH_COMMENT_2), R"([section])");
ASSERT_EQ(removeInlineComments(TRANSLATION_WITH_COMMENT), R"(translation = "")");
ASSERT_EQ(removeInlineComments(TRANSLATION_WITH_COMMENT_2), R"(translation[] = "")");
ASSERT_EQ(removeInlineComments(TRANSLATION_WITH_INTERNAL_COMMENT), TRANSLATION_WITH_INTERNAL_COMMENT);
}

TEST_F(LanguageClassTests, testIsMultilineField) {
Expand Down

0 comments on commit a677ec7

Please sign in to comment.