summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-17 06:48:01 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-17 06:48:01 -0700
commitf0116cf8f27d74247fa791a816d7a51d5f6bf990 (patch)
tree99f357d00f51f204e3938db30d55364d3f3cf90b
parent4848e41950cfbde0522eae5c0adc2ab8cccae709 (diff)
downloadtxr-f0116cf8f27d74247fa791a816d7a51d5f6bf990.tar.gz
txr-f0116cf8f27d74247fa791a816d7a51d5f6bf990.tar.bz2
txr-f0116cf8f27d74247fa791a816d7a51d5f6bf990.zip
ffi: fix broken deffi support for variadic functions.
* stdlib/ffi.c (sys:analyze-argtypes): Add missing fallback case in filtering loop. This wouldn't have happened if we had a ecaseql macro, and used it. Or if we had coverage of this in tests. * tests/017/variadic.tl, tests/017/variadic.expected: New files.
-rw-r--r--stdlib/ffi.tl3
-rw-r--r--tests/017/variadic.expected1
-rw-r--r--tests/017/variadic.tl6
3 files changed, 9 insertions, 1 deletions
diff --git a/stdlib/ffi.tl b/stdlib/ffi.tl
index e6d8d049..bf1c6111 100644
--- a/stdlib/ffi.tl
+++ b/stdlib/ffi.tl
@@ -64,7 +64,8 @@
((float) 'double)
((be-float le-float)
(compile-error form "variadic argument cannot be of type ~s"
- vt))))))
+ vt))
+ (t vt)))))
(list* (+ (len ftypes) (len vtypes)) (len ftypes) (append ftypes vtypes))))
diff --git a/tests/017/variadic.expected b/tests/017/variadic.expected
new file mode 100644
index 00000000..8a918349
--- /dev/null
+++ b/tests/017/variadic.expected
@@ -0,0 +1 @@
+foo-123 = 4.560
diff --git a/tests/017/variadic.tl b/tests/017/variadic.tl
new file mode 100644
index 00000000..6fa464e0
--- /dev/null
+++ b/tests/017/variadic.tl
@@ -0,0 +1,6 @@
+(load "../common")
+
+(with-dyn-lib (libc)
+ (deffi printf-int-double "printf" int (str : int double)))
+
+(printf-int-double "foo-%d = %4.3f\n" 123 4.56)