]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
desktop: Fix whitespace handling around '='
authorDaiki Ueno <ueno@gnu.org>
Mon, 1 Apr 2019 05:17:19 +0000 (07:17 +0200)
committerDaiki Ueno <ueno@gnu.org>
Mon, 1 Apr 2019 05:27:19 +0000 (07:27 +0200)
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
gettext-tools/tests/msgfmt-desktop-1

index 4d5c3db192c94666d907bb498c0ad963bbca9246..41bde41e1d593e8b72553d4b577b68eb91b1b20e 100644 (file)
@@ -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;
index d410c0101df4321d4afa80b5af74a532f5f00f06..a1c71fb18c1b21c953ee8fb363ad32e645985041 100755 (executable)
@@ -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.