]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Improved support for conditionals in Lisp format strings.
authorBruno Haible <bruno@clisp.org>
Mon, 15 Mar 2004 11:52:28 +0000 (11:52 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:50 +0000 (12:11 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/format-lisp.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/format-lisp-2

index 0984eb0996444b73f3c71863b02d7758e210e11a..71a4850b7ad506d127c95cfe9d03270b18f74a4f 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-14  Bruno Haible  <bruno@clisp.org>
+
+       * format-lisp.c (parse_upto): Add integer restriction for the dispatch
+       argument in ~[...~].
+
 2004-03-02  Bruno Haible  <bruno@clisp.org>
 
        * read-csharp.c (msgdomain_read_csharp): Extend the lang -> frobbedlang
index 4eda24c68fa5a3614fc1a5c128b2d5767a85f2f1..9ce33c74c0c1142b5429e5601fd7f2504453da24 100644 (file)
@@ -2944,6 +2944,7 @@ parse_upto (const char **formatp,
              }
            else
              {
+               int arg_position;
                int union_position;
                struct format_arg_list *union_list;
                bool last_alternative;
@@ -2953,9 +2954,13 @@ parse_upto (const char **formatp,
                  return false;
 
                /* If there was no first parameter, an argument is consumed.  */
+               arg_position = -1;
                if (!(paramcount >= 1 && params[0].type != PT_NIL))
                  if (position >= 0)
-                   add_req_type_constraint (&list, position++, FAT_OBJECT);
+                   {
+                     arg_position = position;
+                     add_req_type_constraint (&list, position++, FAT_OBJECT);
+                   }
 
                *formatp = format;
                *escapep = escape;
@@ -2974,6 +2979,11 @@ parse_upto (const char **formatp,
                                     &sub_separator, spec, ']', !last_alternative,
                                     invalid_reason))
                      return false;
+                   /* If this alternative is chosen, the argument arg_position
+                      is an integer, namely the index of this alternative.  */
+                   if (!last_alternative && arg_position >= 0)
+                     add_req_type_constraint (&sub_list, arg_position,
+                                              FAT_INTEGER);
                    if (sub_list != NULL)
                      {
                        if (union_position == -2)
index 4aa8d2195767996c529551d078b3cf5ec465b945..9f6136ed1f3c9e6012614c09d311e117ecf6b7f2 100644 (file)
@@ -1,3 +1,7 @@
+2004-03-14  Bruno Haible  <bruno@clisp.org>
+
+       * format-lisp-2: Add one more test for ~[...~].
+
 2004-01-30  Bruno Haible  <bruno@clisp.org>
 
        * format-c-5-prg.c (main): Return with exit code 77 when the requested
index 039a259585c893ed191696d15a8d5313a4e9cac9..6ad8ddd5324b686cbe0e23b22c3e340e41b0dc09 100755 (executable)
@@ -106,9 +106,12 @@ msgstr "xyz~(~D ~D~)"
 # Valid: case conversion is optional, and it doesn't catch ~^
 msgid  "abc~(~D~^ ~D~)def~C"
 msgstr "xyz~D~^ ~Duvw~C"
-# Valid: synoymous conditionals
+# Valid: synonymous conditionals
 msgid  "abc~@[~D~]def~C"
 msgstr "xyz~:[~;~:*~D~]~C"
+# Valid: synonymous conditionals
+msgid  "abc~Ddef"
+msgstr "abc~[null~;eins~:;~:*~D~]def"
 # Valid: conditionals are optional and don't catch ~^
 msgid  "abc~:[~;~]~^~D~C"
 msgstr "xyz~:[uvw~^~R~;~:*~S~^~D~]~C"