]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Wrap location comments to 79 characters
authorAlex Henrie <alexhenrie24@gmail.com>
Thu, 5 Feb 2015 05:59:14 +0000 (22:59 -0700)
committerDaiki Ueno <ueno@gnu.org>
Thu, 5 Feb 2015 13:19:01 +0000 (22:19 +0900)
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
gettext-tools/src/write-po.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/Makefile.am
gettext-tools/tests/mm-viet.out
gettext-tools/tests/xgettext-13 [new file with mode: 0755]

index 633ec9e237d139c0f5483f7aa17634a80805115d..93a7dd02afab3d37e1f451b90e8612277cea2488 100644 (file)
@@ -1,3 +1,12 @@
+2015-02-05  Alex Henrie  <alexhenrie24@gmail.com>  (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  <ueno@gnu.org>
 
        msgfilter: Factor out quoted string handling
index d49a95fabcce73e9883c0687dbd82972e5b9ff74..701decfcce198488f68335f37f4db7cff98bedfa 100644 (file)
@@ -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;
index eec158698b59f6a4352344c887863438764eac63..bc82ccaa66e3fb543abc7d0f08dec6433e09a5e1 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-05  Alex Henrie  <alexhenrie24@gmail.com>  (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  <ueno@gnu.org>
 
        * msgexec-6: New file.
index ee346552dceae848320f4ee8f44eab74e545e2b6..32bc1924e50f6bacf17952d18699db9cfbc3a657 100644 (file)
@@ -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 \
index f57688b1fc97dbbd1bbc7c4b9366a3e38e2a2bd2..9e510dfd795a11357cdaae66e6ba8c3ea9feddc8 100644 (file)
@@ -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 (executable)
index 0000000..c463dd9
--- /dev/null
@@ -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