give fmt-c a name for every parameter

fmt-c takes a parameter's name with `cadr', so an unnamed one handed
over bare lost its second word to it: `(* const char)' dropped its
star, and `(int)' had no second word at all.
This commit is contained in:
2026-09-30 13:22:07 +03:00
parent 2b73fcf1c4
commit 2da5b5005b
4 changed files with 66 additions and 14 deletions

View File

@@ -378,20 +378,21 @@ forms, and what remains."
(if (named-arg? arg)
(walk-type (maybe-unwrap-type (cdr arg)))
;; A lone type may arrive wrapped in parens of its own, and those
;; are not part of it: ((* const char))
;; Plain names e.g. (int) are left as is
(walk-type (if (and (pair? arg) (null? (cdr arg)) (pair? (car arg)))
(car arg)
arg))))
;; are not part of it: ((* const char)), (int)
(walk-type (maybe-unwrap-type arg))))
;;; A parameter reaches fmt-c as `(type name)' and nothing else: it
;;; reads the name out with `cadr', so a nameless one is the type and
;;; an explicit #f. Handing it the bare type instead made it read the
;;; type's own second word as the name -- `(* const char)' lost its
;;; star -- and a one-word type had no second word to read at all.
(define (walk-arglist form)
;; E.g.:
;; ((float) (int) (const char) (* const char) (¤ (* const struct res) 32))
;; ((f1 float) (f2 float) (f3 float) (res (¤ float 4)))
(map (lambda (arg)
(if (named-arg? arg)
(list (arg-type arg) (walk-type (car arg)))
(arg-type arg)))
(list (arg-type arg)
(and (named-arg? arg) (walk-type (car arg)))))
(remove comment-form? form)))
(define (walk-arg-types form)