summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2019-02-21 18:27:58 +0100
committerMatteo Casalin <matteo.casalin@yahoo.com>2019-03-05 22:37:14 +0100
commit78404432ed784b3570cb4c223e6311c3e9859b60 (patch)
tree4b2d03006e224879de18461dfcdd933d70ffbd2c
parent070ea7faa821a01b6a077e24724e37962173cb23 (diff)
Group some more common code
Change-Id: I2bf3e8afd9f330e8d7377300163a3224ed4db05c Reviewed-on: https://gerrit.libreoffice.org/68179 Tested-by: Jenkins Reviewed-by: Matteo Casalin <matteo.casalin@yahoo.com>
-rw-r--r--l10ntools/source/lngmerge.cxx35
1 files changed, 12 insertions, 23 deletions
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index f6939458c588..fdb0cf90b176 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -30,8 +30,14 @@
namespace {
-OString getBracketedContent(const OString& text) {
- return text.getToken(1, '[').getToken(0, ']');
+bool lcl_isNextGroup(OString &sGroup_out, const OString &sLineTrim)
+{
+ if (sLineTrim.startsWith("[") && sLineTrim.endsWith("]"))
+ {
+ sGroup_out = sLineTrim.getToken(1, '[').getToken(0, ']').trim();
+ return true;
+ }
+ return false;
}
void lcl_RemoveUTF8ByteOrderMarker( OString &rString )
@@ -122,13 +128,7 @@ void LngParser::WritePO(PoOfstream &aPOStream,
bool LngParser::isNextGroup(OString &sGroup_out, const OString &sLine_in)
{
- const OString sLineTrim = sLine_in.trim();
- if (sLineTrim.startsWith("[") && sLineTrim.endsWith("]"))
- {
- sGroup_out = getBracketedContent(sLineTrim).trim();
- return true;
- }
- return false;
+ return lcl_isNextGroup(sGroup_out, sLine_in.trim());
}
void LngParser::ReadLine(const OString &rLine_in,
@@ -162,16 +162,7 @@ void LngParser::Merge(
// seek to next group
while ( nPos < mvLines.size() && !bGroup )
- {
- OString sLine( mvLines[ nPos ] );
- sLine = sLine.trim();
- if ( sLine.startsWith("[") && sLine.endsWith("]") )
- {
- sGroup = getBracketedContent(sLine).trim();
- bGroup = true;
- }
- nPos ++;
- }
+ bGroup = lcl_isNextGroup(sGroup, mvLines[nPos++].trim());
while ( nPos < mvLines.size()) {
OStringHashMap Text;
@@ -188,11 +179,9 @@ void LngParser::Merge(
while ( nPos < mvLines.size() && !bGroup )
{
- OString sLine( mvLines[ nPos ] );
- sLine = sLine.trim();
- if ( sLine.startsWith("[") && sLine.endsWith("]") )
+ const OString sLine{ mvLines[nPos].trim() };
+ if ( lcl_isNextGroup(sGroup, sLine) )
{
- sGroup = getBracketedContent(sLine).trim();
bGroup = true;
nPos ++;
sLanguagesDone = "";