bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gettext] gettext 0.19.8.1 mangles empty .desktop lines


From: Daiki Ueno
Subject: Re: [bug-gettext] gettext 0.19.8.1 mangles empty .desktop lines
Date: Mon, 01 Apr 2019 07:30:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Hello Bastien,

Bastien Nocera <address@hidden> writes:

> When applying a translation to a .desktop file with an empty value,
> gettext will strip the line feed causing 2 lines to be merged
> together. 
>
> For example:
> Categories=
> NoDisplay=true
>
> Would become, removing the "NoDisplay":
> Categories=NoDisplay=true
>
> Attached is a test case, unpack, and run "make". The resulting gnome-
> user-share-webdav.desktop file should have 2 lines for Categories and
> NoDisplay, but only has one.

Thank you for the report with the test case.  That should be fixed with
the attached patch (already merged in master).

Regards,
-- 
Daiki Ueno
>From 78ffc7480aa3c0a435961fb94d4e184c4e027c13 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <address@hidden>
Date: Mon, 1 Apr 2019 07:17:19 +0200
Subject: [PATCH] desktop: Fix whitespace handling around '='

While the spec only allows spaces before and after '=',
xgettext/msgfmt previously accepted all whitespaces including '\n'.
That was causing unwanted concatenation of desktop lines.

Reported by Bastien Nocera in:
https://lists.gnu.org/archive/html/bug-gettext/2019-03/msg00017.html

* gettext-tools/src/read-desktop.c (desktop_lex): Properly handle
space characters before and after '='.
* gettext-tools/tests/msgfmt-desktop-1: Add a test case.
---
 gettext-tools/src/read-desktop.c     | 10 +++++-----
 gettext-tools/tests/msgfmt-desktop-1 |  4 ++++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/gettext-tools/src/read-desktop.c b/gettext-tools/src/read-desktop.c
index 4d5c3db19..41bde41e1 100644
--- a/gettext-tools/src/read-desktop.c
+++ b/gettext-tools/src/read-desktop.c
@@ -380,14 +380,14 @@ desktop_lex (token_ty *tp)
               }
             APPEND (0);
 
-            /* Skip any whitespace before '='.  */
+            /* Skip any space before '='.  */
             for (;;)
               {
                 c = phase2_getc ();
                 switch (c)
                   {
                   default:
-                    if (c_isspace (c))
+                    if (c == ' ')
                       continue;
                     phase2_ungetc (c);
                     break;
@@ -413,18 +413,18 @@ desktop_lex (token_ty *tp)
                 return;
               }
 
-            /* Skip any whitespace after '='.  */
+            /* Skip any space after '='.  */
             for (;;)
               {
                 c = phase2_getc ();
                 switch (c)
                   {
                   default:
-                    if (c_isspace (c))
+                    if (c == ' ')
                       continue;
                     phase2_ungetc (c);
                     break;
-                  case EOF: case '\n':
+                  case EOF:
                     break;
                   }
                 break;
diff --git a/gettext-tools/tests/msgfmt-desktop-1 
b/gettext-tools/tests/msgfmt-desktop-1
index d410c0101..a1c71fb18 100755
--- a/gettext-tools/tests/msgfmt-desktop-1
+++ b/gettext-tools/tests/msgfmt-desktop-1
@@ -10,6 +10,8 @@ Name =Foo
 Comment[foo]=Already translated comment
 Comment= \sThis is a \nmultiline comment; for testing
 Keywords=Keyword1;Keyword2;Key\;word3;
+Categories=
+NoDisplay=true
 EOF
 
 cat <<\EOF > fr.po
@@ -61,6 +63,8 @@ Comment[fr]=French \ncomment
 Comment=\sThis is a \nmultiline comment; for testing
 Keywords[fr]=one;two;thr\;ee;
 Keywords=Keyword1;Keyword2;Key\;word3;
+Categories=
+NoDisplay=true
 EOF
 
 # Sanity checks for contradicting options.
-- 
2.20.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]