From e6a77a185a35fd52dd80db71b120f6538a346e44 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Fri, 16 Jan 2015 19:01:34 +0900 Subject: [PATCH] desktop: Avoid useless warning for group header MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reported by Marek Černocký at: * gettext-tools/src/read-desktop.c (desktop_lex): Fix "invalid non-blank character" check after reading a group header. * gettext-tools/tests/xgettext-desktop-1: Check "invalid non-blank character" warning. --- gettext-tools/src/ChangeLog | 8 ++++++++ gettext-tools/src/read-desktop.c | 15 ++++++--------- gettext-tools/tests/ChangeLog | 4 ++++ gettext-tools/tests/xgettext-desktop-1 | 13 +++++++++++++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 0a4dbdbea..7a96c1858 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,11 @@ +2015-01-16 Daiki Ueno + + desktop: Avoid useless warning for group header + Reported by Marek Černocký at: + + * read-desktop.c (desktop_lex): Fix "invalid non-blank + character" check after reading a group header. + 2015-01-13 Daiki Ueno * x-c.c (phase5_get): Reset raw_expected at the beginning of the diff --git a/gettext-tools/src/read-desktop.c b/gettext-tools/src/read-desktop.c index 8f9243b35..be574cec5 100644 --- a/gettext-tools/src/read-desktop.c +++ b/gettext-tools/src/read-desktop.c @@ -271,16 +271,13 @@ desktop_lex (token_ty *tp) break; } /* Skip until newline. */ - if (c != '\n') + while (c != '\n' && c != EOF) { - for (;;) - { - if (c == '\n' || c == EOF) - break; - if (!c_isspace (c)) - non_blank = true; - c = phase2_getc (); - } + c = phase2_getc (); + if (c == EOF) + break; + if (!c_isspace (c)) + non_blank = true; } if (non_blank) po_xerror (PO_SEVERITY_WARNING, NULL, diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index f8cb454b3..a08f91d78 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,7 @@ +2015-01-16 Daiki Ueno + + * xgettext-desktop-1: Check "invalid non-blank character" warning. + 2015-01-13 Daiki Ueno * xgettext-c-20: Improve test coverage of raw string tests. diff --git a/gettext-tools/tests/xgettext-desktop-1 b/gettext-tools/tests/xgettext-desktop-1 index ae908795c..c6f9df1cf 100755 --- a/gettext-tools/tests/xgettext-desktop-1 +++ b/gettext-tools/tests/xgettext-desktop-1 @@ -26,6 +26,19 @@ EOF (LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err3.desktop 2>&1; exit) | grep "invalid non-blank line" || exit 1 +cat <<\EOF >err4.desktop +[Desktop Entry]a +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - err4.desktop 2>&1; exit) | grep "invalid non-blank character" || exit 1 + +# gettext 0.19.4 issued an baseless warning of this. +cat <<\EOF >ok4.desktop +[Desktop Entry] +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --add-comments -o - ok4.desktop 2>&1; exit) | grep "invalid non-blank character" && exit 1 + cat <<\EOF > xg.desktop [Desktop Entry] Type=Application -- 2.47.2