summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-03 18:34:27 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-03 18:34:27 +0300
commit976b43426305bae21d0b29adf6f144772f29666a (patch)
tree1f066a34a0227ebee754a1c10969e1672118ef7e
parentcce2dab67a0f4ea6996587d8d57f679a5e0286e6 (diff)
downloadmplint-976b43426305bae21d0b29adf6f144772f29666a.tar.gz
mplint-976b43426305bae21d0b29adf6f144772f29666a.tar.bz2
mplint-976b43426305bae21d0b29adf6f144772f29666a.tar.xz
mplint-976b43426305bae21d0b29adf6f144772f29666a.zip
Add check for same number of spaces at start of line (po files).
-rw-r--r--src/rules/po.cpp27
-rw-r--r--tests/testreport.txt3
-rw-r--r--tests/testsrc/bad/uk.po5
3 files changed, 29 insertions, 6 deletions
diff --git a/src/rules/po.cpp b/src/rules/po.cpp
index d600d19..edfb787 100644
--- a/src/rules/po.cpp
+++ b/src/rules/po.cpp
@@ -28,6 +28,17 @@ bool skipOneCheck(false);
std::string msgId;
std::string msgStr;
+static int countStartSpaces(const std::string &str)
+{
+ const int sz = str.size();
+ for (int f = 0; f < sz; f ++)
+ {
+ if (str[f] != ' ')
+ return f;
+ }
+ return -1;
+}
+
static void processMessage(RuleBase *const rule)
{
// rule->print(std::string("pair: ").append(msgId).append(
@@ -73,6 +84,7 @@ static void processMessage(RuleBase *const rule)
if (name.find("po/unused/") != std::string::npos)
return;
+ bool isError(false);
if (eId == '.' ||
eId == ',' ||
eId == '!' ||
@@ -86,7 +98,10 @@ static void processMessage(RuleBase *const rule)
eId == ' ')
{
if (eId != eStr)
+ {
rule->print("Wrong character at end of translation line.");
+ isError = true;
+ }
}
if (sId == '.' ||
sId == ',' ||
@@ -101,13 +116,21 @@ static void processMessage(RuleBase *const rule)
sId == ' ')
{
if (sId != sStr)
+ {
rule->print("Wrong character at start of translation line.");
+ isError = true;
+ }
}
- if (msgId.find("###") != std::string::npos
- && msgStr.find("###") == std::string::npos)
+ if (msgId.find("###") != std::string::npos &&
+ msgStr.find("###") == std::string::npos)
{
rule->print("Missing ### in translation.");
}
+ if (isError == false)
+ {
+ if (countStartSpaces(msgId) != countStartSpaces(msgStr))
+ rule->print("Wrong number of spaces at start of translation line.");
+ }
/*
if (msgId.find("\\n") != std::string::npos)
{
diff --git a/tests/testreport.txt b/tests/testreport.txt
index 2a620a7..94223aa 100644
--- a/tests/testreport.txt
+++ b/tests/testreport.txt
@@ -44,7 +44,8 @@
[testsrc/bad/packet.cpp:25]: V012: Wrong output packet creation. Must be 'createOutPacket(CMSG...'
[testsrc/bad/uk.po:2257]: V010: Wrong character at end of translation line.
[testsrc/bad/uk.po:2269]: V010: Wrong character at start of translation line.
-[testsrc/bad/uk.po:3712]: V010: Wrong character at end of translation line.
+[testsrc/bad/uk.po:2535]: V010: Wrong number of spaces at start of translation line.
+[testsrc/bad/uk.po:3711]: V010: Wrong character at end of translation line.
[testsrc/bad/virtual1.cpp:33]: V013: Keywords virtual is useless if used with override or final
[testsrc/bad/virtual1.cpp:36]: V013: Keywords virtual is useless if used with override or final
[testsrc/bad/virtual1.h:31]: V013: Keywords virtual is useless if used with override or final
diff --git a/tests/testsrc/bad/uk.po b/tests/testsrc/bad/uk.po
index 1aef374..9f6c414 100644
--- a/tests/testsrc/bad/uk.po
+++ b/tests/testsrc/bad/uk.po
@@ -2530,9 +2530,8 @@ msgid "Options:"
msgstr "Параметри:"
#: src/main.cpp:45
-#, fuzzy
-msgid " -v --version : Display the version"
-msgstr " -h --help : показати ще раз цю довідку"
+msgid " -v --version : Display the version"
+msgstr " -v --version : показати ще раз цю довідку"
#: src/main.cpp:46
#, fuzzy