summaryrefslogtreecommitdiff
path: root/src
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 /src
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).
Diffstat (limited to 'src')
-rw-r--r--src/rules/po.cpp27
1 files changed, 25 insertions, 2 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)
{