aboutsummaryrefslogtreecommitdiffstats
path: root/src/fns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fns.c')
-rw-r--r--src/fns.c115
1 files changed, 62 insertions, 53 deletions
diff --git a/src/fns.c b/src/fns.c
index 4d82e4e6e1d..95450c5e911 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -51,7 +51,7 @@ static Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper;
51 51
52static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512; 52static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512;
53 53
54static int internal_equal (Lisp_Object , Lisp_Object, int, int); 54static bool internal_equal (Lisp_Object, Lisp_Object, int, bool);
55 55
56DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, 56DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
57 doc: /* Return the argument unchanged. */) 57 doc: /* Return the argument unchanged. */)
@@ -352,7 +352,7 @@ Symbols are also allowed; their print names are used instead. */)
352} 352}
353 353
354static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args, 354static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args,
355 enum Lisp_Type target_type, int last_special); 355 enum Lisp_Type target_type, bool last_special);
356 356
357/* ARGSUSED */ 357/* ARGSUSED */
358Lisp_Object 358Lisp_Object
@@ -450,19 +450,19 @@ struct textprop_rec
450 450
451static Lisp_Object 451static Lisp_Object
452concat (ptrdiff_t nargs, Lisp_Object *args, 452concat (ptrdiff_t nargs, Lisp_Object *args,
453 enum Lisp_Type target_type, int last_special) 453 enum Lisp_Type target_type, bool last_special)
454{ 454{
455 Lisp_Object val; 455 Lisp_Object val;
456 register Lisp_Object tail; 456 Lisp_Object tail;
457 register Lisp_Object this; 457 Lisp_Object this;
458 ptrdiff_t toindex; 458 ptrdiff_t toindex;
459 ptrdiff_t toindex_byte = 0; 459 ptrdiff_t toindex_byte = 0;
460 register EMACS_INT result_len; 460 EMACS_INT result_len;
461 register EMACS_INT result_len_byte; 461 EMACS_INT result_len_byte;
462 ptrdiff_t argnum; 462 ptrdiff_t argnum;
463 Lisp_Object last_tail; 463 Lisp_Object last_tail;
464 Lisp_Object prev; 464 Lisp_Object prev;
465 int some_multibyte; 465 bool some_multibyte;
466 /* When we make a multibyte string, we can't copy text properties 466 /* When we make a multibyte string, we can't copy text properties
467 while concatenating each string because the length of resulting 467 while concatenating each string because the length of resulting
468 string can't be decided until we finish the whole concatenation. 468 string can't be decided until we finish the whole concatenation.
@@ -1527,11 +1527,14 @@ The value is actually the first element of LIST whose cdr equals KEY. */)
1527} 1527}
1528 1528
1529DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0, 1529DEFUN ("delq", Fdelq, Sdelq, 2, 2, 0,
1530 doc: /* Delete by side effect any occurrences of ELT as a member of LIST. 1530 doc: /* Delete members of LIST which are `eq' to ELT, and return the result.
1531The modified LIST is returned. Comparison is done with `eq'. 1531More precisely, this function skips any members `eq' to ELT at the
1532If the first member of LIST is ELT, there is no way to remove it by side effect; 1532front of LIST, then removes members `eq' to ELT from the remaining
1533therefore, write `(setq foo (delq element foo))' 1533sublist by modifying its list structure, then returns the resulting
1534to be sure of changing the value of `foo'. */) 1534list.
1535
1536Write `(setq foo (delq element foo))' to be sure of correctly changing
1537the value of a list `foo'. */)
1535 (register Lisp_Object elt, Lisp_Object list) 1538 (register Lisp_Object elt, Lisp_Object list)
1536{ 1539{
1537 register Lisp_Object tail, prev; 1540 register Lisp_Object tail, prev;
@@ -1559,13 +1562,19 @@ to be sure of changing the value of `foo'. */)
1559} 1562}
1560 1563
1561DEFUN ("delete", Fdelete, Sdelete, 2, 2, 0, 1564DEFUN ("delete", Fdelete, Sdelete, 2, 2, 0,
1562 doc: /* Delete by side effect any occurrences of ELT as a member of SEQ. 1565 doc: /* Delete members of SEQ which are `equal' to ELT, and return the result.
1563SEQ must be a list, a vector, or a string. 1566SEQ must be a sequence (i.e. a list, a vector, or a string).
1564The modified SEQ is returned. Comparison is done with `equal'. 1567The return value is a sequence of the same type.
1565If SEQ is not a list, or the first member of SEQ is ELT, deleting it 1568
1566is not a side effect; it is simply using a different sequence. 1569If SEQ is a list, this behaves like `delq', except that it compares
1567Therefore, write `(setq foo (delete element foo))' 1570with `equal' instead of `eq'. In particular, it may remove elements
1568to be sure of changing the value of `foo'. */) 1571by altering the list structure.
1572
1573If SEQ is not a list, deletion is never performed destructively;
1574instead this function creates and returns a new vector or string.
1575
1576Write `(setq foo (delete element foo))' to be sure of correctly
1577changing the value of a sequence `foo'. */)
1569 (Lisp_Object elt, Lisp_Object seq) 1578 (Lisp_Object elt, Lisp_Object seq)
1570{ 1579{
1571 if (VECTORP (seq)) 1580 if (VECTORP (seq))
@@ -1988,10 +1997,10 @@ of strings. (`equal' ignores text properties.) */)
1988 1997
1989/* DEPTH is current depth of recursion. Signal an error if it 1998/* DEPTH is current depth of recursion. Signal an error if it
1990 gets too deep. 1999 gets too deep.
1991 PROPS, if non-nil, means compare string text properties too. */ 2000 PROPS means compare string text properties too. */
1992 2001
1993static int 2002static bool
1994internal_equal (register Lisp_Object o1, register Lisp_Object o2, int depth, int props) 2003internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props)
1995{ 2004{
1996 if (depth > 200) 2005 if (depth > 200)
1997 error ("Stack overflow in equal"); 2006 error ("Stack overflow in equal");
@@ -2589,9 +2598,9 @@ Normally the return value is FEATURE.
2589The normal messages at start and end of loading FILENAME are suppressed. */) 2598The normal messages at start and end of loading FILENAME are suppressed. */)
2590 (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror) 2599 (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror)
2591{ 2600{
2592 register Lisp_Object tem; 2601 Lisp_Object tem;
2593 struct gcpro gcpro1, gcpro2; 2602 struct gcpro gcpro1, gcpro2;
2594 int from_file = load_in_progress; 2603 bool from_file = load_in_progress;
2595 2604
2596 CHECK_SYMBOL (feature); 2605 CHECK_SYMBOL (feature);
2597 2606
@@ -2917,8 +2926,8 @@ static const short base64_char_to_value[128] =
2917 base64 characters. */ 2926 base64 characters. */
2918 2927
2919 2928
2920static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, int, int); 2929static ptrdiff_t base64_encode_1 (const char *, char *, ptrdiff_t, bool, bool);
2921static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, int, 2930static ptrdiff_t base64_decode_1 (const char *, char *, ptrdiff_t, bool,
2922 ptrdiff_t *); 2931 ptrdiff_t *);
2923 2932
2924DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region, 2933DEFUN ("base64-encode-region", Fbase64_encode_region, Sbase64_encode_region,
@@ -2953,7 +2962,7 @@ into shorter lines. */)
2953 encoded, length, NILP (no_line_break), 2962 encoded, length, NILP (no_line_break),
2954 !NILP (BVAR (current_buffer, enable_multibyte_characters))); 2963 !NILP (BVAR (current_buffer, enable_multibyte_characters)));
2955 if (encoded_length > allength) 2964 if (encoded_length > allength)
2956 abort (); 2965 emacs_abort ();
2957 2966
2958 if (encoded_length < 0) 2967 if (encoded_length < 0)
2959 { 2968 {
@@ -3009,7 +3018,7 @@ into shorter lines. */)
3009 encoded, length, NILP (no_line_break), 3018 encoded, length, NILP (no_line_break),
3010 STRING_MULTIBYTE (string)); 3019 STRING_MULTIBYTE (string));
3011 if (encoded_length > allength) 3020 if (encoded_length > allength)
3012 abort (); 3021 emacs_abort ();
3013 3022
3014 if (encoded_length < 0) 3023 if (encoded_length < 0)
3015 { 3024 {
@@ -3026,7 +3035,7 @@ into shorter lines. */)
3026 3035
3027static ptrdiff_t 3036static ptrdiff_t
3028base64_encode_1 (const char *from, char *to, ptrdiff_t length, 3037base64_encode_1 (const char *from, char *to, ptrdiff_t length,
3029 int line_break, int multibyte) 3038 bool line_break, bool multibyte)
3030{ 3039{
3031 int counter = 0; 3040 int counter = 0;
3032 ptrdiff_t i = 0; 3041 ptrdiff_t i = 0;
@@ -3133,7 +3142,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3133 ptrdiff_t old_pos = PT; 3142 ptrdiff_t old_pos = PT;
3134 ptrdiff_t decoded_length; 3143 ptrdiff_t decoded_length;
3135 ptrdiff_t inserted_chars; 3144 ptrdiff_t inserted_chars;
3136 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 3145 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
3137 USE_SAFE_ALLOCA; 3146 USE_SAFE_ALLOCA;
3138 3147
3139 validate_region (&beg, &end); 3148 validate_region (&beg, &end);
@@ -3154,7 +3163,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */
3154 decoded, length, 3163 decoded, length,
3155 multibyte, &inserted_chars); 3164 multibyte, &inserted_chars);
3156 if (decoded_length > allength) 3165 if (decoded_length > allength)
3157 abort (); 3166 emacs_abort ();
3158 3167
3159 if (decoded_length < 0) 3168 if (decoded_length < 0)
3160 { 3169 {
@@ -3204,7 +3213,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3204 decoded_length = base64_decode_1 (SSDATA (string), decoded, length, 3213 decoded_length = base64_decode_1 (SSDATA (string), decoded, length,
3205 0, NULL); 3214 0, NULL);
3206 if (decoded_length > length) 3215 if (decoded_length > length)
3207 abort (); 3216 emacs_abort ();
3208 else if (decoded_length >= 0) 3217 else if (decoded_length >= 0)
3209 decoded_string = make_unibyte_string (decoded, decoded_length); 3218 decoded_string = make_unibyte_string (decoded, decoded_length);
3210 else 3219 else
@@ -3218,13 +3227,13 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string,
3218} 3227}
3219 3228
3220/* Base64-decode the data at FROM of LENGTH bytes into TO. If 3229/* Base64-decode the data at FROM of LENGTH bytes into TO. If
3221 MULTIBYTE is nonzero, the decoded result should be in multibyte 3230 MULTIBYTE, the decoded result should be in multibyte
3222 form. If NCHARS_RETURN is not NULL, store the number of produced 3231 form. If NCHARS_RETURN is not NULL, store the number of produced
3223 characters in *NCHARS_RETURN. */ 3232 characters in *NCHARS_RETURN. */
3224 3233
3225static ptrdiff_t 3234static ptrdiff_t
3226base64_decode_1 (const char *from, char *to, ptrdiff_t length, 3235base64_decode_1 (const char *from, char *to, ptrdiff_t length,
3227 int multibyte, ptrdiff_t *nchars_return) 3236 bool multibyte, ptrdiff_t *nchars_return)
3228{ 3237{
3229 ptrdiff_t i = 0; /* Used inside READ_QUADRUPLET_BYTE */ 3238 ptrdiff_t i = 0; /* Used inside READ_QUADRUPLET_BYTE */
3230 char *e = to; 3239 char *e = to;
@@ -3340,7 +3349,7 @@ static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value;
3340static struct Lisp_Hash_Table *check_hash_table (Lisp_Object); 3349static struct Lisp_Hash_Table *check_hash_table (Lisp_Object);
3341static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *); 3350static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *);
3342static void maybe_resize_hash_table (struct Lisp_Hash_Table *); 3351static void maybe_resize_hash_table (struct Lisp_Hash_Table *);
3343static int sweep_weak_table (struct Lisp_Hash_Table *, int); 3352static bool sweep_weak_table (struct Lisp_Hash_Table *, bool);
3344 3353
3345 3354
3346 3355
@@ -3432,10 +3441,10 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max)
3432 ***********************************************************************/ 3441 ***********************************************************************/
3433 3442
3434/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3443/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
3435 HASH2 in hash table H using `eql'. Value is non-zero if KEY1 and 3444 HASH2 in hash table H using `eql'. Value is true if KEY1 and
3436 KEY2 are the same. */ 3445 KEY2 are the same. */
3437 3446
3438static int 3447static bool
3439cmpfn_eql (struct Lisp_Hash_Table *h, 3448cmpfn_eql (struct Lisp_Hash_Table *h,
3440 Lisp_Object key1, EMACS_UINT hash1, 3449 Lisp_Object key1, EMACS_UINT hash1,
3441 Lisp_Object key2, EMACS_UINT hash2) 3450 Lisp_Object key2, EMACS_UINT hash2)
@@ -3447,10 +3456,10 @@ cmpfn_eql (struct Lisp_Hash_Table *h,
3447 3456
3448 3457
3449/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3458/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
3450 HASH2 in hash table H using `equal'. Value is non-zero if KEY1 and 3459 HASH2 in hash table H using `equal'. Value is true if KEY1 and
3451 KEY2 are the same. */ 3460 KEY2 are the same. */
3452 3461
3453static int 3462static bool
3454cmpfn_equal (struct Lisp_Hash_Table *h, 3463cmpfn_equal (struct Lisp_Hash_Table *h,
3455 Lisp_Object key1, EMACS_UINT hash1, 3464 Lisp_Object key1, EMACS_UINT hash1,
3456 Lisp_Object key2, EMACS_UINT hash2) 3465 Lisp_Object key2, EMACS_UINT hash2)
@@ -3460,10 +3469,10 @@ cmpfn_equal (struct Lisp_Hash_Table *h,
3460 3469
3461 3470
3462/* Compare KEY1 which has hash code HASH1, and KEY2 with hash code 3471/* Compare KEY1 which has hash code HASH1, and KEY2 with hash code
3463 HASH2 in hash table H using H->user_cmp_function. Value is non-zero 3472 HASH2 in hash table H using H->user_cmp_function. Value is true
3464 if KEY1 and KEY2 are the same. */ 3473 if KEY1 and KEY2 are the same. */
3465 3474
3466static int 3475static bool
3467cmpfn_user_defined (struct Lisp_Hash_Table *h, 3476cmpfn_user_defined (struct Lisp_Hash_Table *h,
3468 Lisp_Object key1, EMACS_UINT hash1, 3477 Lisp_Object key1, EMACS_UINT hash1,
3469 Lisp_Object key2, EMACS_UINT hash2) 3478 Lisp_Object key2, EMACS_UINT hash2)
@@ -3923,16 +3932,16 @@ hash_clear (struct Lisp_Hash_Table *h)
3923 Weak Hash Tables 3932 Weak Hash Tables
3924 ************************************************************************/ 3933 ************************************************************************/
3925 3934
3926/* Sweep weak hash table H. REMOVE_ENTRIES_P non-zero means remove 3935/* Sweep weak hash table H. REMOVE_ENTRIES_P means remove
3927 entries from the table that don't survive the current GC. 3936 entries from the table that don't survive the current GC.
3928 REMOVE_ENTRIES_P zero means mark entries that are in use. Value is 3937 !REMOVE_ENTRIES_P means mark entries that are in use. Value is
3929 non-zero if anything was marked. */ 3938 true if anything was marked. */
3930 3939
3931static int 3940static bool
3932sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p) 3941sweep_weak_table (struct Lisp_Hash_Table *h, bool remove_entries_p)
3933{ 3942{
3934 ptrdiff_t bucket, n; 3943 ptrdiff_t bucket, n;
3935 int marked; 3944 bool marked;
3936 3945
3937 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG; 3946 n = ASIZE (h->index) & ~ARRAY_MARK_FLAG;
3938 marked = 0; 3947 marked = 0;
@@ -3949,7 +3958,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3949 ptrdiff_t i = XFASTINT (idx); 3958 ptrdiff_t i = XFASTINT (idx);
3950 bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i)); 3959 bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i));
3951 bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i)); 3960 bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i));
3952 int remove_p; 3961 bool remove_p;
3953 3962
3954 if (EQ (h->weak, Qkey)) 3963 if (EQ (h->weak, Qkey))
3955 remove_p = !key_known_to_survive_p; 3964 remove_p = !key_known_to_survive_p;
@@ -3960,7 +3969,7 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3960 else if (EQ (h->weak, Qkey_and_value)) 3969 else if (EQ (h->weak, Qkey_and_value))
3961 remove_p = !(key_known_to_survive_p && value_known_to_survive_p); 3970 remove_p = !(key_known_to_survive_p && value_known_to_survive_p);
3962 else 3971 else
3963 abort (); 3972 emacs_abort ();
3964 3973
3965 next = HASH_NEXT (h, i); 3974 next = HASH_NEXT (h, i);
3966 3975
@@ -4022,7 +4031,7 @@ void
4022sweep_weak_hash_tables (void) 4031sweep_weak_hash_tables (void)
4023{ 4032{
4024 struct Lisp_Hash_Table *h, *used, *next; 4033 struct Lisp_Hash_Table *h, *used, *next;
4025 int marked; 4034 bool marked;
4026 4035
4027 /* Mark all keys and values that are in use. Keep on marking until 4036 /* Mark all keys and values that are in use. Keep on marking until
4028 there is no more change. This is necessary for cases like 4037 there is no more change. This is necessary for cases like
@@ -4256,7 +4265,7 @@ sxhash (Lisp_Object obj, int depth)
4256 break; 4265 break;
4257 4266
4258 default: 4267 default:
4259 abort (); 4268 emacs_abort ();
4260 } 4269 }
4261 4270
4262 return hash; 4271 return hash;
@@ -4674,7 +4683,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4674 coding_system = Vcoding_system_for_write; 4683 coding_system = Vcoding_system_for_write;
4675 else 4684 else
4676 { 4685 {
4677 int force_raw_text = 0; 4686 bool force_raw_text = 0;
4678 4687
4679 coding_system = BVAR (XBUFFER (object), buffer_file_coding_system); 4688 coding_system = BVAR (XBUFFER (object), buffer_file_coding_system);
4680 if (NILP (coding_system) 4689 if (NILP (coding_system)