[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19634: counting MANY function args more reliably
From: |
Paul Eggert |
Subject: |
bug#19634: counting MANY function args more reliably |
Date: |
Tue, 20 Jan 2015 01:26:25 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
Commit ef5a526f1b51b76b0f753e0936c80743a7f4463d fixed a bug in Emacs where the C
code passed 10 arguments to a function using the MANY calling convention, but
the caller mistakenly passed 8 as the argument count, and this mistakenly
discarded the last two arguments; see <http://bugs.gnu.org/3228#63>.
To help prevent this sort of mistake in the future, I would like to install
something like the attached patch, which uses a new C macro CALLN to count these
arguments automatically. The key lines in the patch are the following additions
to lisp.h:
#define CALLMANY(f, array) (f) (ARRAYELTS (array), array)
#define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
This lets code use 'return CALLN (foo, a, b, c, d);' instead of the current
error-prone usages which are like '{ Lisp_Object args[4]; args[0] = a; args[1] =
b; args[2] = c; args[3] = d; return foo (3, args); }'. (Oops, that last '3'
should have been a '4'....)
This patch still needs a ChangeLog entry and some more testing on my part, but I
thought I'd get it out for review now.
calln.diff
Description: Text Data
- bug#19634: counting MANY function args more reliably,
Paul Eggert <=