From: Bruno Haible Date: Sun, 4 Nov 2018 19:19:49 +0000 (+0100) Subject: xgettext: Vala: Improve parsing of escape sequences. X-Git-Tag: v0.20~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0debf509e2ca3e992bb1875b2b79b2613bc2496;p=thirdparty%2Fgettext.git xgettext: Vala: Improve parsing of escape sequences. * gettext-tools/src/x-vala.c (phase7_getc): Don't recognize \?, \a, \1...\7, \U. Do recognize \$. * gettext-tools/tests/xgettext-vala-1: Test \t in verbatim strings literals. * NEWS: Mention the change. --- diff --git a/NEWS b/NEWS index 05c0ed241..219bc280d 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,8 @@ - Pascal: xgettext can now extract strings from .rsj files, produced by the Free Pascal compiler version 3.0.0 or newer. + - Vala: + xgettext now parses escape sequences in strings more accurately. * Runtime behaviour: - The interpretation of the language preferences on macOS has been fixed. diff --git a/gettext-tools/src/x-vala.c b/gettext-tools/src/x-vala.c index 073448f71..7b9ae761f 100644 --- a/gettext-tools/src/x-vala.c +++ b/gettext-tools/src/x-vala.c @@ -448,19 +448,13 @@ phase7_getc () case '"': case '\'': - case '?': case '\\': + case '$': return c; - case 'a': - return '\a'; case 'b': return '\b'; - /* The \e escape is preculiar to gcc, and assumes an ASCII - character set (or superset). We don't provide support for it - here. */ - case 'f': return '\f'; case 'n': @@ -513,8 +507,7 @@ phase7_getc () } return n; - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': + case '0': n = 0; for (j = 0; j < 3; ++j) { @@ -534,12 +527,12 @@ phase7_getc () phase1_ungetc (c); return n; - case 'U': case 'u': + case 'u': { unsigned char buf[8]; n = 0; - for (j = 0; j < (c == 'u' ? 4 : 8); j++) + for (j = 0; j < 4; j++) { int c1 = phase1_getc (); diff --git a/gettext-tools/tests/xgettext-vala-1 b/gettext-tools/tests/xgettext-vala-1 index 8d3e8e3b4..3e16c7650 100755 --- a/gettext-tools/tests/xgettext-vala-1 +++ b/gettext-tools/tests/xgettext-vala-1 @@ -27,7 +27,7 @@ int main (string[] args) { } var s4 = _("""Extract this - ""\a + ""\t\a fourth string"""); var s5 = _("Extract this \u2464th string"); @@ -128,7 +128,7 @@ msgstr "" msgid "" "Extract this\n" -" \"\"\\a\n" +" \"\"\\t\\a\n" " fourth string" msgstr "" @@ -193,7 +193,7 @@ msgstr "" msgid "" "Extract this\n" -" \"\"\\a\n" +" \"\"\\t\\a\n" " fourth string" msgstr ""