]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Vala: Improve parsing of escape sequences.
authorBruno Haible <bruno@clisp.org>
Sun, 4 Nov 2018 19:19:49 +0000 (20:19 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 4 Nov 2018 23:25:33 +0000 (00:25 +0100)
* 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.

NEWS
gettext-tools/src/x-vala.c
gettext-tools/tests/xgettext-vala-1

diff --git a/NEWS b/NEWS
index 05c0ed2415655d635bb96e172023e1abef5cdc8d..219bc280dc9dc9d9c5b6e9d2bd00838ddc3a4244 100644 (file)
--- 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.
index 073448f71e41673cf82a790d6b8a06bc95a76488..7b9ae761f2add5b1618de29b2d6e67febf6c9873 100644 (file)
@@ -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 ();
 
index 8d3e8e3b4e4494daa68c30020b4beb3287729a35..3e16c76501041f4f509825a6728352031d35d85c 100755 (executable)
@@ -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 ""