[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gettext] [PATCH] xgettext: Wrap location comments to 79 charact
From: |
Daiki Ueno |
Subject: |
Re: [bug-gettext] [PATCH] xgettext: Wrap location comments to 79 characters |
Date: |
Thu, 05 Feb 2015 22:22:07 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
> - if (column > 2 && column + len >= page_width)
> + if (column > 2 && column + len > page_width)
Thanks, good catch. I've pushed it after minimizing the test case as
attached.
Regards,
--
Daiki Ueno
>From ea070a750206e6ffde1439afe7738ad4faed1bf4 Mon Sep 17 00:00:00 2001
From: Alex Henrie <address@hidden>
Date: Wed, 4 Feb 2015 22:59:14 -0700
Subject: [PATCH] xgettext: Wrap location comments to 79 characters
Previously, messages wre wrapped to 79 characters, but location
comments were wrapped to 78 characters.
* gettext-tools/src/write-po.c (message_print_comment_filepos): Fix
off-by-one in calculating line-wrapping width of location comment.
* gettext-tools/tests/xgettext-13: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add new test.
* gettext-tools/tests/mm-viet.out: Adjust to the recent line-wrapping
behavior change.
---
gettext-tools/src/ChangeLog | 9 +++++++
gettext-tools/src/write-po.c | 2 +-
gettext-tools/tests/ChangeLog | 6 +++++
gettext-tools/tests/Makefile.am | 1 +
gettext-tools/tests/mm-viet.out | 26 +++++++++---------
gettext-tools/tests/xgettext-13 | 59 +++++++++++++++++++++++++++++++++++++++++
6 files changed, 88 insertions(+), 15 deletions(-)
create mode 100755 gettext-tools/tests/xgettext-13
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 633ec9e..93a7dd0 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,12 @@
+2015-02-05 Alex Henrie <address@hidden> (tiny change)
+
+ xgettext: Wrap location comments to 79 characters
+
+ Previously, messages were wrapped to 79 characters, but location
+ comments were wrapped to 78 characters.
+ * write-po.c (message_print_comment_filepos): Fix off-by-one in
+ calculating line-wrapping width of location comment.
+
2015-02-03 Daiki Ueno <address@hidden>
msgfilter: Factor out quoted string handling
diff --git a/gettext-tools/src/write-po.c b/gettext-tools/src/write-po.c
index d49a95f..701decf 100644
--- a/gettext-tools/src/write-po.c
+++ b/gettext-tools/src/write-po.c
@@ -400,7 +400,7 @@ message_print_comment_filepos (const message_ty *mp,
ostream_t stream,
else
sprintf (buffer, ":%ld", (long) pp->line_number);
len = strlen (cp) + strlen (buffer) + 1;
- if (column > 2 && column + len >= page_width)
+ if (column > 2 && column + len > page_width)
{
ostream_write_str (stream, "\n#:");
column = 2;
diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog
index eec1586..bc82cca 100644
--- a/gettext-tools/tests/ChangeLog
+++ b/gettext-tools/tests/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-05 Alex Henrie <address@hidden> (tiny change)
+
+ * xgettext-13: New file.
+ * Makefile.am (TESTS): Add new test.
+ * mm-viet.out: Adjust to the recent line-wrapping behavior change.
+
2015-01-29 Daiki Ueno <address@hidden>
* msgexec-6: New file.
diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am
index ee34655..32bc192 100644
--- a/gettext-tools/tests/Makefile.am
+++ b/gettext-tools/tests/Makefile.am
@@ -72,6 +72,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5
gettext-6 gettext-7 \
recode-sr-latin-1 recode-sr-latin-2 \
xgettext-2 xgettext-3 xgettext-4 xgettext-5 xgettext-6 \
xgettext-7 xgettext-8 xgettext-9 xgettext-10 xgettext-11 xgettext-12 \
+ xgettext-13 \
xgettext-awk-1 xgettext-awk-2 \
xgettext-c-2 xgettext-c-3 xgettext-c-4 xgettext-c-5 \
xgettext-c-6 xgettext-c-7 xgettext-c-8 xgettext-c-9 xgettext-c-10 \
diff --git a/gettext-tools/tests/mm-viet.out b/gettext-tools/tests/mm-viet.out
index f57688b..9e510df 100644
--- a/gettext-tools/tests/mm-viet.out
+++ b/gettext-tools/tests/mm-viet.out
@@ -3034,8 +3034,8 @@ msgstr "_Ngôn ngữ"
#. i18n: file data/abc.xml line 5
#: rc.cpp:46 rc.cpp:58 rc.cpp:106 rc.cpp:118 rc.cpp:146 rc.cpp:154 rc.cpp:158
-#: rc.cpp:166 rc.cpp:182 rc.cpp:286 rc.cpp:306 rc.cpp:314 rc.cpp:338
-#: rc.cpp:382 rc.cpp:410 rc.cpp:414
+#: rc.cpp:166 rc.cpp:182 rc.cpp:286 rc.cpp:306 rc.cpp:314 rc.cpp:338 rc.cpp:382
+#: rc.cpp:410 rc.cpp:414
msgid ""
"_: Language Section\n"
"Other"
@@ -3051,11 +3051,11 @@ msgstr "_Ngôn ngữ"
#. i18n: file data/ada.xml line 3
#: rc.cpp:50 rc.cpp:62 rc.cpp:94 rc.cpp:98 rc.cpp:102 rc.cpp:114 rc.cpp:130
-#: rc.cpp:134 rc.cpp:138 rc.cpp:150 rc.cpp:174 rc.cpp:178 rc.cpp:202
-#: rc.cpp:218 rc.cpp:226 rc.cpp:238 rc.cpp:242 rc.cpp:246 rc.cpp:254
-#: rc.cpp:270 rc.cpp:282 rc.cpp:290 rc.cpp:294 rc.cpp:298 rc.cpp:334
-#: rc.cpp:346 rc.cpp:350 rc.cpp:358 rc.cpp:390 rc.cpp:394 rc.cpp:418
-#: rc.cpp:426 rc.cpp:446 rc.cpp:466 rc.cpp:506 rc.cpp:522 rc.cpp:526
+#: rc.cpp:134 rc.cpp:138 rc.cpp:150 rc.cpp:174 rc.cpp:178 rc.cpp:202 rc.cpp:218
+#: rc.cpp:226 rc.cpp:238 rc.cpp:242 rc.cpp:246 rc.cpp:254 rc.cpp:270 rc.cpp:282
+#: rc.cpp:290 rc.cpp:294 rc.cpp:298 rc.cpp:334 rc.cpp:346 rc.cpp:350 rc.cpp:358
+#: rc.cpp:390 rc.cpp:394 rc.cpp:418 rc.cpp:426 rc.cpp:446 rc.cpp:466 rc.cpp:506
+#: rc.cpp:522 rc.cpp:526
msgid ""
"_: Language Section\n"
"Sources"
@@ -3141,8 +3141,8 @@ msgstr "_Ngôn ngữ"
#. i18n: file data/asp.xml line 3
#: rc.cpp:78 rc.cpp:90 rc.cpp:122 rc.cpp:142 rc.cpp:170 rc.cpp:214 rc.cpp:230
-#: rc.cpp:258 rc.cpp:266 rc.cpp:274 rc.cpp:310 rc.cpp:326 rc.cpp:378
-#: rc.cpp:438 rc.cpp:478 rc.cpp:498 rc.cpp:510 rc.cpp:514 rc.cpp:518
+#: rc.cpp:258 rc.cpp:266 rc.cpp:274 rc.cpp:310 rc.cpp:326 rc.cpp:378 rc.cpp:438
+#: rc.cpp:478 rc.cpp:498 rc.cpp:510 rc.cpp:514 rc.cpp:518
msgid ""
"_: Language Section\n"
"Markup"
@@ -3158,9 +3158,8 @@ msgstr "_Ngôn ngữ"
#. i18n: file data/awk.xml line 3
#: rc.cpp:82 rc.cpp:86 rc.cpp:126 rc.cpp:186 rc.cpp:190 rc.cpp:234 rc.cpp:262
-#: rc.cpp:302 rc.cpp:318 rc.cpp:362 rc.cpp:366 rc.cpp:374 rc.cpp:398
-#: rc.cpp:402 rc.cpp:406 rc.cpp:422 rc.cpp:430 rc.cpp:442 rc.cpp:470
-#: rc.cpp:482 rc.cpp:486
+#: rc.cpp:302 rc.cpp:318 rc.cpp:362 rc.cpp:366 rc.cpp:374 rc.cpp:398 rc.cpp:402
+#: rc.cpp:406 rc.cpp:422 rc.cpp:430 rc.cpp:442 rc.cpp:470 rc.cpp:482 rc.cpp:486
msgid ""
"_: Language Section\n"
"Scripts"
@@ -3385,8 +3384,7 @@ msgid ""
msgstr "_Ngôn ngữ"
#. i18n: file data/fgl-4gl.xml line 3
-#: rc.cpp:194 rc.cpp:198 rc.cpp:278 rc.cpp:386 rc.cpp:454 rc.cpp:458
-#: rc.cpp:462
+#: rc.cpp:194 rc.cpp:198 rc.cpp:278 rc.cpp:386 rc.cpp:454 rc.cpp:458 rc.cpp:462
msgid ""
"_: Language Section\n"
"Database"
diff --git a/gettext-tools/tests/xgettext-13 b/gettext-tools/tests/xgettext-13
new file mode 100755
index 0000000..c463dd9
--- /dev/null
+++ b/gettext-tools/tests/xgettext-13
@@ -0,0 +1,59 @@
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test wrapping long lines.
+# Both msgid and location comments should wrap to at most 79 characters.
+
+cat <<\EOF > xg-test13.c
+/* With --width=30, the following 10 gettext calls will produce:
+
+ #: x:1 x:2 x:3 x:4 x:5 x:6 x:7
+ #: x:8 x:9 x:10
+ msgid "a"
+
+ because strlen("#:") + strlen(" x:N") * 7 = 30 */
+#line 1 "x"
+gettext ("a");
+gettext ("a");
+gettext ("a");
+gettext ("a");
+gettext ("a");
+gettext ("a");
+gettext ("a");
+gettext ("a");
+gettext ("a");
+gettext ("a");
+
+/* The following gettext call will produce:
+
+ msgid ""
+ "x:1 x:2 x:3 x:4 x:5 x:6 x:7 "
+ "x:8 x:9 x:10"
+
+ because strlen("\"") + strlen("x:N ") * 7 + strlen("\"") = 30 */
+gettext ("x:1 x:2 x:3 x:4 x:5 x:6 x:7 x:8 x:9 x:10");
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header --add-location --width=30 -d xg-test13.tmp \
+ xg-test13.c || exit 1
+LC_ALL=C tr -d '\r' < xg-test13.tmp.po > xg-test13.po || exit 1
+
+cat <<\EOF > xg-test13.ok
+#: x:1 x:2 x:3 x:4 x:5 x:6 x:7
+#: x:8 x:9 x:10
+msgid "a"
+msgstr ""
+
+#: x:19
+msgid ""
+"x:1 x:2 x:3 x:4 x:5 x:6 x:7 "
+"x:8 x:9 x:10"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-test13.ok xg-test13.po
+result=$?
+
+exit $result
--
2.1.3