diff options
Diffstat (limited to 'src/fns.c')
-rw-r--r-- | src/fns.c | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/src/fns.c b/src/fns.c index 360501db80a..aee268f3067 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1451,7 +1451,7 @@ The value is actually the tail of LIST whose car is ELT. */) Lisp_Object list; { register Lisp_Object tail; - for (tail = list; !NILP (tail); tail = XCDR (tail)) + for (tail = list; CONSP (tail); tail = XCDR (tail)) { register Lisp_Object tem; CHECK_LIST_CONS (tail, list); @@ -1502,7 +1502,7 @@ The value is actually the tail of LIST whose car is ELT. */) if (!FLOATP (elt)) return Fmemq (elt, list); - for (tail = list; !NILP (tail); tail = XCDR (tail)) + for (tail = list; CONSP (tail); tail = XCDR (tail)) { register Lisp_Object tem; CHECK_LIST_CONS (tail, list); @@ -1806,7 +1806,7 @@ to be sure of changing the value of `foo'. */) { Lisp_Object tail, prev; - for (tail = seq, prev = Qnil; !NILP (tail); tail = XCDR (tail)) + for (tail = seq, prev = Qnil; CONSP (tail); tail = XCDR (tail)) { CHECK_LIST_CONS (tail, seq); @@ -2440,7 +2440,8 @@ Return PARENT. PARENT must be either nil or another char-table. */) { CHECK_CHAR_TABLE (parent); - for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent) + for (temp = parent; CHAR_TABLE_P (temp); + temp = XCHAR_TABLE (temp)->parent) if (EQ (temp, char_table)) error ("Attempt to make a chartable be its own parent"); } @@ -2825,8 +2826,8 @@ DEFUN ("optimize-char-table", Foptimize_char_table, Soptimize_char_table, void map_char_table (c_function, function, table, subtable, arg, depth, indices) void (*c_function) P_ ((Lisp_Object, Lisp_Object, Lisp_Object)); - Lisp_Object function, table, subtable, arg, *indices; - int depth; + Lisp_Object function, table, subtable, arg; + int depth, *indices; { int i, to; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; @@ -2860,7 +2861,7 @@ map_char_table (c_function, function, table, subtable, arg, depth, indices) } else { - int charset = XFASTINT (indices[0]) - 128; + int charset = indices[0] - 128; i = 32; to = SUB_CHAR_TABLE_ORDINARY_SLOTS; @@ -2874,8 +2875,8 @@ map_char_table (c_function, function, table, subtable, arg, depth, indices) int charset; elt = XCHAR_TABLE (subtable)->contents[i]; - XSETFASTINT (indices[depth], i); - charset = XFASTINT (indices[0]) - 128; + indices[depth] = i; + charset = indices[0] - 128; if (depth == 0 && (!CHARSET_DEFINED_P (charset) || charset == CHARSET_8_BIT_CONTROL @@ -2892,8 +2893,8 @@ map_char_table (c_function, function, table, subtable, arg, depth, indices) { int c1, c2, c; - c1 = depth >= 1 ? XFASTINT (indices[1]) : 0; - c2 = depth >= 2 ? XFASTINT (indices[2]) : 0; + c1 = depth >= 1 ? indices[1] : 0; + c2 = depth >= 2 ? indices[2] : 0; c = MAKE_CHAR (charset, c1, c2); if (NILP (elt)) @@ -2927,14 +2928,14 @@ The key is always a possible IDX argument to `aref'. */) Lisp_Object function, char_table; { /* The depth of char table is at most 3. */ - Lisp_Object indices[3]; + int indices[3]; CHECK_CHAR_TABLE (char_table); /* When Lisp_Object is represented as a union, `call2' cannot directly be passed to map_char_table because it returns a Lisp_Object rather than returning nothing. - Casting leads to crashes on some architectures. -stef */ + Casting leads to crashes on some architectures. --Stef */ map_char_table (void_call2, Qnil, char_table, char_table, function, 0, indices); return Qnil; } @@ -3134,7 +3135,7 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */) len = Flength (sequence); leni = XINT (len); nargs = leni + leni - 1; - if (nargs < 0) return build_string (""); + if (nargs < 0) return empty_unibyte_string; SAFE_ALLOCA_LISP (args, nargs); @@ -3236,7 +3237,8 @@ is nil and `use-dialog-box' is non-nil. */) { #ifdef HAVE_MENUS - if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) + if (FRAME_WINDOW_P (SELECTED_FRAME ()) + && (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) && use_dialog_box && have_menus_p ()) { @@ -3275,6 +3277,7 @@ is nil and `use-dialog-box' is non-nil. */) Fraise_frame (mini_frame); } + temporarily_switch_to_single_kboard (SELECTED_FRAME ()); obj = read_filtered_event (1, 0, 0, 0, Qnil); cursor_in_echo_area = 0; /* If we need to quit, quit with cursor_in_echo_area = 0. */ @@ -3367,7 +3370,8 @@ is nil, and `use-dialog-box' is non-nil. */) CHECK_STRING (prompt); #ifdef HAVE_MENUS - if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) + if (FRAME_WINDOW_P (SELECTED_FRAME ()) + && (NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) && use_dialog_box && have_menus_p ()) { @@ -4268,7 +4272,7 @@ base64_decode_1 (from, to, length, multibyte, nchars_return) /* The list of all weak hash tables. Don't staticpro this one. */ -Lisp_Object Vweak_hash_tables; +struct Lisp_Hash_Table *weak_hash_tables; /* Various symbols. */ @@ -4595,7 +4599,7 @@ make_hash_table (test, size, rehash_size, rehash_threshold, weak, h->weak = weak; h->rehash_threshold = rehash_threshold; h->rehash_size = rehash_size; - h->count = make_number (0); + h->count = 0; h->key_and_value = Fmake_vector (make_number (2 * sz), Qnil); h->hash = Fmake_vector (size, Qnil); h->next = Fmake_vector (size, Qnil); @@ -4614,11 +4618,11 @@ make_hash_table (test, size, rehash_size, rehash_threshold, weak, /* Maybe add this hash table to the list of all weak hash tables. */ if (NILP (h->weak)) - h->next_weak = Qnil; + h->next_weak = NULL; else { - h->next_weak = Vweak_hash_tables; - Vweak_hash_tables = table; + h->next_weak = weak_hash_tables; + weak_hash_tables = h; } return table; @@ -4649,8 +4653,8 @@ copy_hash_table (h1) /* Maybe add this hash table to the list of all weak hash tables. */ if (!NILP (h2->weak)) { - h2->next_weak = Vweak_hash_tables; - Vweak_hash_tables = table; + h2->next_weak = weak_hash_tables; + weak_hash_tables = h2; } return table; @@ -4775,7 +4779,7 @@ hash_put (h, key, value, hash) /* Increment count after resizing because resizing may fail. */ maybe_resize_hash_table (h); - h->count = make_number (XFASTINT (h->count) + 1); + h->count++; /* Store key/value in the key_and_value vector. */ i = XFASTINT (h->next_free); @@ -4831,8 +4835,8 @@ hash_remove (h, key) HASH_KEY (h, i) = HASH_VALUE (h, i) = HASH_HASH (h, i) = Qnil; HASH_NEXT (h, i) = h->next_free; h->next_free = make_number (i); - h->count = make_number (XFASTINT (h->count) - 1); - xassert (XINT (h->count) >= 0); + h->count--; + xassert (h->count >= 0); break; } else @@ -4850,7 +4854,7 @@ void hash_clear (h) struct Lisp_Hash_Table *h; { - if (XFASTINT (h->count) > 0) + if (h->count > 0) { int i, size = HASH_TABLE_SIZE (h); @@ -4866,7 +4870,7 @@ hash_clear (h) AREF (h->index, i) = Qnil; h->next_free = make_number (0); - h->count = make_number (0); + h->count = 0; } } @@ -4936,7 +4940,7 @@ sweep_weak_table (h, remove_entries_p) HASH_KEY (h, i) = HASH_VALUE (h, i) = Qnil; HASH_HASH (h, i) = Qnil; - h->count = make_number (XFASTINT (h->count) - 1); + h->count--; } else { @@ -4969,13 +4973,12 @@ sweep_weak_table (h, remove_entries_p) /* Remove elements from weak hash tables that don't survive the current garbage collection. Remove weak tables that don't survive - from Vweak_hash_tables. Called from gc_sweep. */ + from weak_hash_tables. Called from gc_sweep. */ void sweep_weak_hash_tables () { - Lisp_Object table, used, next; - struct Lisp_Hash_Table *h; + struct Lisp_Hash_Table *h, *used, *next; int marked; /* Mark all keys and values that are in use. Keep on marking until @@ -4987,9 +4990,8 @@ sweep_weak_hash_tables () do { marked = 0; - for (table = Vweak_hash_tables; !GC_NILP (table); table = h->next_weak) + for (h = weak_hash_tables; h; h = h->next_weak) { - h = XHASH_TABLE (table); if (h->size & ARRAY_MARK_FLAG) marked |= sweep_weak_table (h, 0); } @@ -4997,24 +4999,23 @@ sweep_weak_hash_tables () while (marked); /* Remove tables and entries that aren't used. */ - for (table = Vweak_hash_tables, used = Qnil; !GC_NILP (table); table = next) + for (h = weak_hash_tables, used = NULL; h; h = next) { - h = XHASH_TABLE (table); next = h->next_weak; if (h->size & ARRAY_MARK_FLAG) { /* TABLE is marked as used. Sweep its contents. */ - if (XFASTINT (h->count) > 0) + if (h->count > 0) sweep_weak_table (h, 1); /* Add table to the list of used weak hash tables. */ h->next_weak = used; - used = table; + used = h; } } - Vweak_hash_tables = used; + weak_hash_tables = used; } @@ -5340,7 +5341,7 @@ DEFUN ("hash-table-count", Fhash_table_count, Shash_table_count, 1, 1, 0, (table) Lisp_Object table; { - return check_hash_table (table)->count; + return make_number (check_hash_table (table)->count); } @@ -5558,7 +5559,7 @@ guesswork fails. Normally, an error is signaled in such case. */) if (STRING_MULTIBYTE (object)) /* use default, we can't guess correct value */ - coding_system = SYMBOL_VALUE (XCAR (Vcoding_category_list)); + coding_system = find_symbol_value (XCAR (Vcoding_category_list)); else coding_system = Qraw_text; } @@ -5915,7 +5916,7 @@ used if both `use-dialog-box' and this variable are non-nil. */); void init_fns () { - Vweak_hash_tables = Qnil; + weak_hash_tables = NULL; } /* arch-tag: 787f8219-5b74-46bd-8469-7e1cc475fa31 |