]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
lisp-format: Fix a crash in format string that contains "~@?" before "~V".
authorBruno Haible <bruno@clisp.org>
Tue, 14 Mar 2023 00:38:13 +0000 (01:38 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 14 Mar 2023 01:57:28 +0000 (02:57 +0100)
* 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.

gettext-tools/src/format-lisp.c
gettext-tools/tests/Makefile.am
gettext-tools/tests/xgettext-lisp-5 [new file with mode: 0755]

index 57e23210d708ad49c030b81f1fafce7b3c4f13d3..d89746b76b8292add0b2e16e0997d95dc9d39b04 100644 (file)
@@ -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;
index 5349c7624c683f5625a7deba33b152a5241ef4a7..2edb31138743ba729318d39c25a9bd33de580802 100644 (file)
@@ -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 (executable)
index 0000000..0818128
--- /dev/null
@@ -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