From: Bruno Haible Date: Mon, 15 Mar 2004 11:52:28 +0000 (+0000) Subject: Improved support for conditionals in Lisp format strings. X-Git-Tag: v0.14.2~276 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2768b96cc34072923d4f97aa686d46eaf5cb4aa;p=thirdparty%2Fgettext.git Improved support for conditionals in Lisp format strings. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 0984eb099..71a4850b7 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,8 @@ +2004-03-14 Bruno Haible + + * format-lisp.c (parse_upto): Add integer restriction for the dispatch + argument in ~[...~]. + 2004-03-02 Bruno Haible * read-csharp.c (msgdomain_read_csharp): Extend the lang -> frobbedlang diff --git a/gettext-tools/src/format-lisp.c b/gettext-tools/src/format-lisp.c index 4eda24c68..9ce33c74c 100644 --- a/gettext-tools/src/format-lisp.c +++ b/gettext-tools/src/format-lisp.c @@ -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) diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 4aa8d2195..9f6136ed1 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,7 @@ +2004-03-14 Bruno Haible + + * format-lisp-2: Add one more test for ~[...~]. + 2004-01-30 Bruno Haible * format-c-5-prg.c (main): Return with exit code 77 when the requested diff --git a/gettext-tools/tests/format-lisp-2 b/gettext-tools/tests/format-lisp-2 index 039a25958..6ad8ddd53 100755 --- a/gettext-tools/tests/format-lisp-2 +++ b/gettext-tools/tests/format-lisp-2 @@ -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"