diff options
author | Bruno Haible <bruno@clisp.org> | 2023-03-14 01:38:13 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-03-14 02:57:28 +0100 |
commit | 85d4cb991e6a8c111d0739c343bba22143c094d6 (patch) | |
tree | 139f526519d9ade80e08f972c0b8f7a330b2641c | |
parent | c19208d3ffc49222d7725eb0777034e40d592bb7 (diff) | |
download | gettext-85d4cb991e6a8c111d0739c343bba22143c094d6.tar.gz |
lisp-format: Fix a crash in format string that contains "~@?" before "~V".
* gettext-tools/src/format-lisp.c (nocheck_params): Don't call
add_req_type_constraint if position < 0.
* gettext-tools/tests/xgettext-lisp-5: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
-rw-r--r-- | gettext-tools/src/format-lisp.c | 3 | ||||
-rw-r--r-- | gettext-tools/tests/Makefile.am | 1 | ||||
-rwxr-xr-x | gettext-tools/tests/xgettext-lisp-5 | 24 |
3 files changed, 27 insertions, 1 deletions
diff --git a/gettext-tools/src/format-lisp.c b/gettext-tools/src/format-lisp.c index 57e23210d..d89746b76 100644 --- a/gettext-tools/src/format-lisp.c +++ b/gettext-tools/src/format-lisp.c @@ -2426,7 +2426,8 @@ nocheck_params (struct format_arg_list **listp, if (params->type == PT_V) { int position = params->value; - add_req_type_constraint (listp, position, FAT_CHARACTER_INTEGER_NULL); + if (position >= 0) + add_req_type_constraint (listp, position, FAT_CHARACTER_INTEGER_NULL); } return true; diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 5349c7624..2edb31138 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -122,6 +122,7 @@ TESTS = gettext-1 gettext-2 \ xgettext-librep-1 xgettext-librep-2 xgettext-librep-3 \ xgettext-librep-stackovfl-1 xgettext-librep-stackovfl-2 \ xgettext-lisp-1 xgettext-lisp-2 xgettext-lisp-3 xgettext-lisp-4 \ + xgettext-lisp-5 \ xgettext-lisp-stackovfl-1 xgettext-lisp-stackovfl-2 \ xgettext-lua-1 xgettext-lua-2 xgettext-lua-3 \ xgettext-lua-stackovfl-1 xgettext-lua-stackovfl-2 \ diff --git a/gettext-tools/tests/xgettext-lisp-5 b/gettext-tools/tests/xgettext-lisp-5 new file mode 100755 index 000000000..0818128d4 --- /dev/null +++ b/gettext-tools/tests/xgettext-lisp-5 @@ -0,0 +1,24 @@ +#! /bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test Lisp support: lisp-format string with a ~V at an unknown position. + +cat <<EOF > xg-ls-5.lisp +(gettext "~@?~v!") +EOF + +: ${XGETTEXT=xgettext} +${XGETTEXT} --omit-header --no-location -d xg-ls-5.tmp xg-ls-5.lisp || Exit 1 +LC_ALL=C tr -d '\r' < xg-ls-5.tmp.po > xg-ls-5.po || Exit 1 + +cat <<EOF > xg-ls-5.ok +#, lisp-format +msgid "~@?~v!" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-ls-5.ok xg-ls-5.po +result=$? + +exit $result |