summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Henrie <alexhenrie24@gmail.com>2015-02-06 11:43:56 -0700
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-02-09 11:17:54 +0000
commitdc4ed9e1cb4b2ea4b02793a24eb276dec1758ccd (patch)
treec87280343eec4bc3dbc7c00aece4c023b75b7cd4
parent104241306b844bdc8608cba7022aba0898f16ce4 (diff)
linguist: Consistently wrap PO file lines to 79 characters
If the space character is not taken into account, some lines are given one extra character. This makes Qt Linguist wrap them differently from gettext and produce unnecessarily large diffs when editing files generated by gettext. Change-Id: I310d747a8f455d8ca47e882af04b081e9db25f69 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
-rw-r--r--src/linguist/shared/po.cpp2
-rw-r--r--tests/auto/linguist/lconvert/data/wrapping.po9
2 files changed, 10 insertions, 1 deletions
diff --git a/src/linguist/shared/po.cpp b/src/linguist/shared/po.cpp
index f4354246c..86fb6a1d1 100644
--- a/src/linguist/shared/po.cpp
+++ b/src/linguist/shared/po.cpp
@@ -162,7 +162,7 @@ static QString poEscapedLines(const QString &prefix, bool addSpace, const QStrin
static QString poWrappedEscapedLines(const QString &prefix, bool addSpace, const QString &line)
{
- const int maxlen = MAX_LEN - prefix.length();
+ const int maxlen = MAX_LEN - prefix.length() - addSpace;
QStringList lines;
int off = 0;
while (off + maxlen < line.length()) {
diff --git a/tests/auto/linguist/lconvert/data/wrapping.po b/tests/auto/linguist/lconvert/data/wrapping.po
index 9feb4a0ac..4ec8c7fe4 100644
--- a/tests/auto/linguist/lconvert/data/wrapping.po
+++ b/tests/auto/linguist/lconvert/data/wrapping.po
@@ -55,3 +55,12 @@ msgstr ""
#: gettxt.c:8
msgid "one two three four five six\n"
msgstr ""
+
+#: gettxt.c:10 gettxt.c:100 gettxt.c:101 gettxt.c:102 gettxt.c:103 gettxt.c:104
+msgid "foo"
+msgstr ""
+
+#: gettxt.c:100 gettxt.c:101 gettxt.c:102 gettxt.c:103 gettxt.c:104
+#: gettxt.c:105
+msgid "bar"
+msgstr ""