From: Daiki Ueno Date: Mon, 1 Apr 2019 05:17:19 +0000 (+0200) Subject: desktop: Fix whitespace handling around '=' X-Git-Tag: v0.20~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78ffc7480aa3c0a435961fb94d4e184c4e027c13;p=thirdparty%2Fgettext.git 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. --- 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.