Skip to content

Commit

Permalink
Rename parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Sep 18, 2024
1 parent 4f9b4f9 commit f269ae8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
29 changes: 15 additions & 14 deletions src/i18n_review.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,9 +2061,9 @@ namespace i18n_check

//------------------------------------------------
std::tuple<bool, std::wstring, size_t, size_t>
i18n_review::read_po_msg(std::wstring_view& poFileText, const std::wstring_view msgTag)
i18n_review::read_po_msg(std::wstring_view& poCatalogEntry, const std::wstring_view msgTag)
{
const size_t idPos = poFileText.find(msgTag);
const size_t idPos = poCatalogEntry.find(msgTag);
if (idPos == std::wstring_view::npos)
{
return { false, std::wstring{}, std::wstring::npos, std::wstring::npos };
Expand All @@ -2072,27 +2072,27 @@ namespace i18n_check
// out translation (#~).
size_t lookBehindIndex{ idPos };
while (lookBehindIndex > 0 &&
string_util::is_neither(poFileText[lookBehindIndex], L'\r', L'\n'))
string_util::is_neither(poCatalogEntry[lookBehindIndex], L'\r', L'\n'))
{
--lookBehindIndex;
}
if (poFileText[++lookBehindIndex] == L'#')
if (poCatalogEntry[++lookBehindIndex] == L'#')
{
return { false, std::wstring{}, std::wstring::npos, std::wstring::npos };
}

poFileText.remove_prefix(idPos + msgTag.length());
poCatalogEntry.remove_prefix(idPos + msgTag.length());

size_t idEndPos{ 0 };
while (true)
{
idEndPos = poFileText.find(L'\"', idEndPos);
idEndPos = poCatalogEntry.find(L'\"', idEndPos);
if (idEndPos == std::wstring_view::npos)
{
return { false, std::wstring{}, std::wstring::npos, std::wstring::npos };
}
// skip escaped quotes
if (idEndPos > 0 && poFileText[idEndPos - 1] == L'\\')
if (idEndPos > 0 && poCatalogEntry[idEndPos - 1] == L'\\')
{
++idEndPos;
continue;
Expand All @@ -2101,29 +2101,30 @@ namespace i18n_check
{
size_t lookAheadIndex{ idEndPos + 1 };
// jump to next line
while (lookAheadIndex < poFileText.length() &&
string_util::is_either(poFileText[lookAheadIndex], L'\r', L'\n'))
while (lookAheadIndex < poCatalogEntry.length() &&
string_util::is_either(poCatalogEntry[lookAheadIndex], L'\r', L'\n'))
{
++lookAheadIndex;
}
// eat up leading spaces
while (lookAheadIndex < poFileText.length() &&
string_util::is_either(poFileText[lookAheadIndex], L'\t', L' '))
while (lookAheadIndex < poCatalogEntry.length() &&
string_util::is_either(poCatalogEntry[lookAheadIndex], L'\t', L' '))
{
++lookAheadIndex;
}
// if a quote, then this is still be part of the same string
if (lookAheadIndex < poFileText.length() && poFileText[lookAheadIndex] == L'"')
if (lookAheadIndex < poCatalogEntry.length() &&
poCatalogEntry[lookAheadIndex] == L'"')
{
idEndPos = lookAheadIndex + 1;
continue;
}
break;
}
}
const std::wstring msgId{ process_po_msg(poFileText.substr(0, idEndPos)) };
const std::wstring msgId{ process_po_msg(poCatalogEntry.substr(0, idEndPos)) };

poFileText.remove_prefix(idEndPos);
poCatalogEntry.remove_prefix(idEndPos);

return { true, msgId, idPos, idEndPos };
}
Expand Down
4 changes: 2 additions & 2 deletions src/i18n_review.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,12 +758,12 @@ namespace i18n_check
read_po_catalog_entry(std::wstring_view& poFileText);

/** @brief Finds and returns the message entry in a gettext catalog entry.
@param poFileText the po file content to parse.
@param poCatalogEntry the po file catalog entry to parse.
@returns If an entry is found, returns @c true, the message's value, its
starting position in the entry section, and the length of the message.*/
[[nodiscard]]
static std::tuple<bool, std::wstring, size_t, size_t>
read_po_msg(std::wstring_view& poFileText, const std::wstring_view msgTag);
read_po_msg(std::wstring_view& poCatalogEntry, const std::wstring_view msgTag);

protected:
// traditionally, 80 chars is the recommended line width,
Expand Down

0 comments on commit f269ae8

Please sign in to comment.