aboutsummaryrefslogtreecommitdiffstats
path: root/src/character.c
diff options
context:
space:
mode:
authorPaul Eggert2011-06-14 11:57:19 -0700
committerPaul Eggert2011-06-14 11:57:19 -0700
commitf66c7cf8f794d6f7fd9ccb8794ffc519e4e89795 (patch)
tree0de26b21c827049c7fa2485204ecf0e2d632b849 /src/character.c
parenta1759b76246a21c7c07dc2ee00b8db792715104c (diff)
downloademacs-f66c7cf8f794d6f7fd9ccb8794ffc519e4e89795.tar.gz
emacs-f66c7cf8f794d6f7fd9ccb8794ffc519e4e89795.zip
Variadic C functions now count arguments with ptrdiff_t.
This partly undoes my 2011-03-30 change, which replaced int with size_t. Back then I didn't know that the Emacs coding style prefers signed int. Also, in the meantime I found a few more instances where arguments were being counted with int, which may truncate counts on 64-bit machines, or EMACS_INT, which may be unnecessarily wide. * lisp.h (struct Lisp_Subr.function.aMANY) (DEFUN_ARGS_MANY, internal_condition_case_n, safe_call): Arg counts are now ptrdiff_t, not size_t. All variadic functions and their callers changed accordingly. (struct gcpro.nvars): Now size_t, not size_t. All uses changed. * bytecode.c (exec_byte_code): Check maxdepth for overflow, to avoid potential buffer overrun. Don't assume arg counts fit in 'int'. * callint.c (Fcall_interactively): Check arg count for overflow, to avoid potential buffer overrun. Use signed char, not 'int', for 'varies' array, so that we needn't bother to check its size calculation for overflow. * editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args. * eval.c (apply_lambda): * fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length. (struct textprop_rec.argnum): Now ptrdiff_t, not int. All uses changed. (mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args.
Diffstat (limited to 'src/character.c')
-rw-r--r--src/character.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/character.c b/src/character.c
index 70c0637804b..7fc5d647ff5 100644
--- a/src/character.c
+++ b/src/character.c
@@ -893,9 +893,9 @@ DEFUN ("string", Fstring, Sstring, 0, MANY, 0,
893 doc: /* 893 doc: /*
894Concatenate all the argument characters and make the result a string. 894Concatenate all the argument characters and make the result a string.
895usage: (string &rest CHARACTERS) */) 895usage: (string &rest CHARACTERS) */)
896 (size_t n, Lisp_Object *args) 896 (ptrdiff_t n, Lisp_Object *args)
897{ 897{
898 size_t i; 898 ptrdiff_t i;
899 int c; 899 int c;
900 unsigned char *buf, *p; 900 unsigned char *buf, *p;
901 Lisp_Object str; 901 Lisp_Object str;
@@ -919,9 +919,9 @@ usage: (string &rest CHARACTERS) */)
919DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0, 919DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0,
920 doc: /* Concatenate all the argument bytes and make the result a unibyte string. 920 doc: /* Concatenate all the argument bytes and make the result a unibyte string.
921usage: (unibyte-string &rest BYTES) */) 921usage: (unibyte-string &rest BYTES) */)
922 (size_t n, Lisp_Object *args) 922 (ptrdiff_t n, Lisp_Object *args)
923{ 923{
924 size_t i; 924 ptrdiff_t i;
925 int c; 925 int c;
926 unsigned char *buf, *p; 926 unsigned char *buf, *p;
927 Lisp_Object str; 927 Lisp_Object str;