aboutsummaryrefslogtreecommitdiffstats
path: root/src/fns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fns.c')
-rw-r--r--src/fns.c63
1 files changed, 30 insertions, 33 deletions
diff --git a/src/fns.c b/src/fns.c
index 9a009c8ab44..bce922859d1 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -348,7 +348,7 @@ Symbols are also allowed; their print names are used instead. */)
348 return i1 < SCHARS (s2) ? Qt : Qnil; 348 return i1 < SCHARS (s2) ? Qt : Qnil;
349} 349}
350 350
351static Lisp_Object concat (int nargs, Lisp_Object *args, 351static Lisp_Object concat (size_t nargs, Lisp_Object *args,
352 enum Lisp_Type target_type, int last_special); 352 enum Lisp_Type target_type, int last_special);
353 353
354/* ARGSUSED */ 354/* ARGSUSED */
@@ -378,7 +378,7 @@ The result is a list whose elements are the elements of all the arguments.
378Each argument may be a list, vector or string. 378Each argument may be a list, vector or string.
379The last argument is not copied, just used as the tail of the new list. 379The last argument is not copied, just used as the tail of the new list.
380usage: (append &rest SEQUENCES) */) 380usage: (append &rest SEQUENCES) */)
381 (int nargs, Lisp_Object *args) 381 (size_t nargs, Lisp_Object *args)
382{ 382{
383 return concat (nargs, args, Lisp_Cons, 1); 383 return concat (nargs, args, Lisp_Cons, 1);
384} 384}
@@ -388,7 +388,7 @@ DEFUN ("concat", Fconcat, Sconcat, 0, MANY, 0,
388The result is a string whose elements are the elements of all the arguments. 388The result is a string whose elements are the elements of all the arguments.
389Each argument may be a string or a list or vector of characters (integers). 389Each argument may be a string or a list or vector of characters (integers).
390usage: (concat &rest SEQUENCES) */) 390usage: (concat &rest SEQUENCES) */)
391 (int nargs, Lisp_Object *args) 391 (size_t nargs, Lisp_Object *args)
392{ 392{
393 return concat (nargs, args, Lisp_String, 0); 393 return concat (nargs, args, Lisp_String, 0);
394} 394}
@@ -398,7 +398,7 @@ DEFUN ("vconcat", Fvconcat, Svconcat, 0, MANY, 0,
398The result is a vector whose elements are the elements of all the arguments. 398The result is a vector whose elements are the elements of all the arguments.
399Each argument may be a list, vector or string. 399Each argument may be a list, vector or string.
400usage: (vconcat &rest SEQUENCES) */) 400usage: (vconcat &rest SEQUENCES) */)
401 (int nargs, Lisp_Object *args) 401 (size_t nargs, Lisp_Object *args)
402{ 402{
403 return concat (nargs, args, Lisp_Vectorlike, 0); 403 return concat (nargs, args, Lisp_Vectorlike, 0);
404} 404}
@@ -446,7 +446,8 @@ struct textprop_rec
446}; 446};
447 447
448static Lisp_Object 448static Lisp_Object
449concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special) 449concat (size_t nargs, Lisp_Object *args,
450 enum Lisp_Type target_type, int last_special)
450{ 451{
451 Lisp_Object val; 452 Lisp_Object val;
452 register Lisp_Object tail; 453 register Lisp_Object tail;
@@ -455,7 +456,7 @@ concat (int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_speci
455 EMACS_INT toindex_byte = 0; 456 EMACS_INT toindex_byte = 0;
456 register EMACS_INT result_len; 457 register EMACS_INT result_len;
457 register EMACS_INT result_len_byte; 458 register EMACS_INT result_len_byte;
458 register int argnum; 459 register size_t argnum;
459 Lisp_Object last_tail; 460 Lisp_Object last_tail;
460 Lisp_Object prev; 461 Lisp_Object prev;
461 int some_multibyte; 462 int some_multibyte;
@@ -2232,9 +2233,9 @@ DEFUN ("nconc", Fnconc, Snconc, 0, MANY, 0,
2232 doc: /* Concatenate any number of lists by altering them. 2233 doc: /* Concatenate any number of lists by altering them.
2233Only the last argument is not altered, and need not be a list. 2234Only the last argument is not altered, and need not be a list.
2234usage: (nconc &rest LISTS) */) 2235usage: (nconc &rest LISTS) */)
2235 (int nargs, Lisp_Object *args) 2236 (size_t nargs, Lisp_Object *args)
2236{ 2237{
2237 register int argnum; 2238 register size_t argnum;
2238 register Lisp_Object tail, tem, val; 2239 register Lisp_Object tail, tem, val;
2239 2240
2240 val = tail = Qnil; 2241 val = tail = Qnil;
@@ -2763,7 +2764,7 @@ DEFUN ("widget-apply", Fwidget_apply, Swidget_apply, 2, MANY, 0,
2763 doc: /* Apply the value of WIDGET's PROPERTY to the widget itself. 2764 doc: /* Apply the value of WIDGET's PROPERTY to the widget itself.
2764ARGS are passed as extra arguments to the function. 2765ARGS are passed as extra arguments to the function.
2765usage: (widget-apply WIDGET PROPERTY &rest ARGS) */) 2766usage: (widget-apply WIDGET PROPERTY &rest ARGS) */)
2766 (int nargs, Lisp_Object *args) 2767 (size_t nargs, Lisp_Object *args)
2767{ 2768{
2768 /* This function can GC. */ 2769 /* This function can GC. */
2769 Lisp_Object newargs[3]; 2770 Lisp_Object newargs[3];
@@ -3367,7 +3368,7 @@ Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value;
3367/* Function prototypes. */ 3368/* Function prototypes. */
3368 3369
3369static struct Lisp_Hash_Table *check_hash_table (Lisp_Object); 3370static struct Lisp_Hash_Table *check_hash_table (Lisp_Object);
3370static int get_key_arg (Lisp_Object, int, Lisp_Object *, char *); 3371static size_t get_key_arg (Lisp_Object, size_t, Lisp_Object *, char *);
3371static void maybe_resize_hash_table (struct Lisp_Hash_Table *); 3372static void maybe_resize_hash_table (struct Lisp_Hash_Table *);
3372static int cmpfn_eql (struct Lisp_Hash_Table *, Lisp_Object, unsigned, 3373static int cmpfn_eql (struct Lisp_Hash_Table *, Lisp_Object, unsigned,
3373 Lisp_Object, unsigned); 3374 Lisp_Object, unsigned);
@@ -3422,27 +3423,23 @@ next_almost_prime (int n)
3422/* Find KEY in ARGS which has size NARGS. Don't consider indices for 3423/* Find KEY in ARGS which has size NARGS. Don't consider indices for
3423 which USED[I] is non-zero. If found at index I in ARGS, set 3424 which USED[I] is non-zero. If found at index I in ARGS, set
3424 USED[I] and USED[I + 1] to 1, and return I + 1. Otherwise return 3425 USED[I] and USED[I + 1] to 1, and return I + 1. Otherwise return
3425 -1. This function is used to extract a keyword/argument pair from 3426 0. This function is used to extract a keyword/argument pair from
3426 a DEFUN parameter list. */ 3427 a DEFUN parameter list. */
3427 3428
3428static int 3429static size_t
3429get_key_arg (Lisp_Object key, int nargs, Lisp_Object *args, char *used) 3430get_key_arg (Lisp_Object key, size_t nargs, Lisp_Object *args, char *used)
3430{ 3431{
3431 int i; 3432 size_t i;
3432
3433 for (i = 0; i < nargs - 1; ++i)
3434 if (!used[i] && EQ (args[i], key))
3435 break;
3436 3433
3437 if (i >= nargs - 1) 3434 for (i = 1; i < nargs; i++)
3438 i = -1; 3435 if (!used[i - 1] && EQ (args[i - 1], key))
3439 else 3436 {
3440 { 3437 used[i - 1] = 1;
3441 used[i++] = 1; 3438 used[i] = 1;
3442 used[i] = 1; 3439 return i;
3443 } 3440 }
3444 3441
3445 return i; 3442 return 0;
3446} 3443}
3447 3444
3448 3445
@@ -4290,12 +4287,12 @@ WEAK. WEAK t is equivalent to `key-and-value'. Default value of WEAK
4290is nil. 4287is nil.
4291 4288
4292usage: (make-hash-table &rest KEYWORD-ARGS) */) 4289usage: (make-hash-table &rest KEYWORD-ARGS) */)
4293 (int nargs, Lisp_Object *args) 4290 (size_t nargs, Lisp_Object *args)
4294{ 4291{
4295 Lisp_Object test, size, rehash_size, rehash_threshold, weak; 4292 Lisp_Object test, size, rehash_size, rehash_threshold, weak;
4296 Lisp_Object user_test, user_hash; 4293 Lisp_Object user_test, user_hash;
4297 char *used; 4294 char *used;
4298 int i; 4295 size_t i;
4299 4296
4300 /* The vector `used' is used to keep track of arguments that 4297 /* The vector `used' is used to keep track of arguments that
4301 have been consumed. */ 4298 have been consumed. */
@@ -4304,7 +4301,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4304 4301
4305 /* See if there's a `:test TEST' among the arguments. */ 4302 /* See if there's a `:test TEST' among the arguments. */
4306 i = get_key_arg (QCtest, nargs, args, used); 4303 i = get_key_arg (QCtest, nargs, args, used);
4307 test = i < 0 ? Qeql : args[i]; 4304 test = i ? args[i] : Qeql;
4308 if (!EQ (test, Qeq) && !EQ (test, Qeql) && !EQ (test, Qequal)) 4305 if (!EQ (test, Qeq) && !EQ (test, Qeql) && !EQ (test, Qequal))
4309 { 4306 {
4310 /* See if it is a user-defined test. */ 4307 /* See if it is a user-defined test. */
@@ -4321,7 +4318,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4321 4318
4322 /* See if there's a `:size SIZE' argument. */ 4319 /* See if there's a `:size SIZE' argument. */
4323 i = get_key_arg (QCsize, nargs, args, used); 4320 i = get_key_arg (QCsize, nargs, args, used);
4324 size = i < 0 ? Qnil : args[i]; 4321 size = i ? args[i] : Qnil;
4325 if (NILP (size)) 4322 if (NILP (size))
4326 size = make_number (DEFAULT_HASH_SIZE); 4323 size = make_number (DEFAULT_HASH_SIZE);
4327 else if (!INTEGERP (size) || XINT (size) < 0) 4324 else if (!INTEGERP (size) || XINT (size) < 0)
@@ -4329,7 +4326,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4329 4326
4330 /* Look for `:rehash-size SIZE'. */ 4327 /* Look for `:rehash-size SIZE'. */
4331 i = get_key_arg (QCrehash_size, nargs, args, used); 4328 i = get_key_arg (QCrehash_size, nargs, args, used);
4332 rehash_size = i < 0 ? make_float (DEFAULT_REHASH_SIZE) : args[i]; 4329 rehash_size = i ? args[i] : make_float (DEFAULT_REHASH_SIZE);
4333 if (!NUMBERP (rehash_size) 4330 if (!NUMBERP (rehash_size)
4334 || (INTEGERP (rehash_size) && XINT (rehash_size) <= 0) 4331 || (INTEGERP (rehash_size) && XINT (rehash_size) <= 0)
4335 || XFLOATINT (rehash_size) <= 1.0) 4332 || XFLOATINT (rehash_size) <= 1.0)
@@ -4337,7 +4334,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4337 4334
4338 /* Look for `:rehash-threshold THRESHOLD'. */ 4335 /* Look for `:rehash-threshold THRESHOLD'. */
4339 i = get_key_arg (QCrehash_threshold, nargs, args, used); 4336 i = get_key_arg (QCrehash_threshold, nargs, args, used);
4340 rehash_threshold = i < 0 ? make_float (DEFAULT_REHASH_THRESHOLD) : args[i]; 4337 rehash_threshold = i ? args[i] : make_float (DEFAULT_REHASH_THRESHOLD);
4341 if (!FLOATP (rehash_threshold) 4338 if (!FLOATP (rehash_threshold)
4342 || XFLOATINT (rehash_threshold) <= 0.0 4339 || XFLOATINT (rehash_threshold) <= 0.0
4343 || XFLOATINT (rehash_threshold) > 1.0) 4340 || XFLOATINT (rehash_threshold) > 1.0)
@@ -4345,7 +4342,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4345 4342
4346 /* Look for `:weakness WEAK'. */ 4343 /* Look for `:weakness WEAK'. */
4347 i = get_key_arg (QCweakness, nargs, args, used); 4344 i = get_key_arg (QCweakness, nargs, args, used);
4348 weak = i < 0 ? Qnil : args[i]; 4345 weak = i ? args[i] : Qnil;
4349 if (EQ (weak, Qt)) 4346 if (EQ (weak, Qt))
4350 weak = Qkey_and_value; 4347 weak = Qkey_and_value;
4351 if (!NILP (weak) 4348 if (!NILP (weak)