diff options
| author | YAMAMOTO Mitsuharu | 2019-04-27 18:33:39 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2019-04-27 18:33:39 +0900 |
| commit | 886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28 (patch) | |
| tree | b5770d9fc10a704ad8aeb3474c6940121252c770 /src/data.c | |
| parent | 015a6e1df2772bd43680df5cbeaffccf98a881da (diff) | |
| parent | 8dc00b2f1e6523c634df3e24379afbe712a32b27 (diff) | |
| download | emacs-886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28.tar.gz emacs-886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28.zip | |
Merge branch 'master' into harfbuzz
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 189 |
1 files changed, 92 insertions, 97 deletions
diff --git a/src/data.c b/src/data.c index 0980cf99886..7928a1dc41d 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter. | 1 | /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter. |
| 2 | Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2018 Free Software | 2 | Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2019 Free Software |
| 3 | Foundation, Inc. | 3 | Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -42,49 +42,49 @@ static void swap_in_symval_forwarding (struct Lisp_Symbol *, | |||
| 42 | struct Lisp_Buffer_Local_Value *); | 42 | struct Lisp_Buffer_Local_Value *); |
| 43 | 43 | ||
| 44 | static bool | 44 | static bool |
| 45 | BOOLFWDP (union Lisp_Fwd *a) | 45 | BOOLFWDP (lispfwd a) |
| 46 | { | 46 | { |
| 47 | return XFWDTYPE (a) == Lisp_Fwd_Bool; | 47 | return XFWDTYPE (a) == Lisp_Fwd_Bool; |
| 48 | } | 48 | } |
| 49 | static bool | 49 | static bool |
| 50 | INTFWDP (union Lisp_Fwd *a) | 50 | INTFWDP (lispfwd a) |
| 51 | { | 51 | { |
| 52 | return XFWDTYPE (a) == Lisp_Fwd_Int; | 52 | return XFWDTYPE (a) == Lisp_Fwd_Int; |
| 53 | } | 53 | } |
| 54 | static bool | 54 | static bool |
| 55 | KBOARD_OBJFWDP (union Lisp_Fwd *a) | 55 | KBOARD_OBJFWDP (lispfwd a) |
| 56 | { | 56 | { |
| 57 | return XFWDTYPE (a) == Lisp_Fwd_Kboard_Obj; | 57 | return XFWDTYPE (a) == Lisp_Fwd_Kboard_Obj; |
| 58 | } | 58 | } |
| 59 | static bool | 59 | static bool |
| 60 | OBJFWDP (union Lisp_Fwd *a) | 60 | OBJFWDP (lispfwd a) |
| 61 | { | 61 | { |
| 62 | return XFWDTYPE (a) == Lisp_Fwd_Obj; | 62 | return XFWDTYPE (a) == Lisp_Fwd_Obj; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | static struct Lisp_Boolfwd * | 65 | static struct Lisp_Boolfwd const * |
| 66 | XBOOLFWD (union Lisp_Fwd *a) | 66 | XBOOLFWD (lispfwd a) |
| 67 | { | 67 | { |
| 68 | eassert (BOOLFWDP (a)); | 68 | eassert (BOOLFWDP (a)); |
| 69 | return &a->u_boolfwd; | 69 | return a.fwdptr; |
| 70 | } | 70 | } |
| 71 | static struct Lisp_Kboard_Objfwd * | 71 | static struct Lisp_Kboard_Objfwd const * |
| 72 | XKBOARD_OBJFWD (union Lisp_Fwd *a) | 72 | XKBOARD_OBJFWD (lispfwd a) |
| 73 | { | 73 | { |
| 74 | eassert (KBOARD_OBJFWDP (a)); | 74 | eassert (KBOARD_OBJFWDP (a)); |
| 75 | return &a->u_kboard_objfwd; | 75 | return a.fwdptr; |
| 76 | } | 76 | } |
| 77 | static struct Lisp_Intfwd * | 77 | static struct Lisp_Intfwd const * |
| 78 | XFIXNUMFWD (union Lisp_Fwd *a) | 78 | XFIXNUMFWD (lispfwd a) |
| 79 | { | 79 | { |
| 80 | eassert (INTFWDP (a)); | 80 | eassert (INTFWDP (a)); |
| 81 | return &a->u_intfwd; | 81 | return a.fwdptr; |
| 82 | } | 82 | } |
| 83 | static struct Lisp_Objfwd * | 83 | static struct Lisp_Objfwd const * |
| 84 | XOBJFWD (union Lisp_Fwd *a) | 84 | XOBJFWD (lispfwd a) |
| 85 | { | 85 | { |
| 86 | eassert (OBJFWDP (a)); | 86 | eassert (OBJFWDP (a)); |
| 87 | return &a->u_objfwd; | 87 | return a.fwdptr; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | static void | 90 | static void |
| @@ -130,7 +130,7 @@ set_blv_valcell (struct Lisp_Buffer_Local_Value *blv, Lisp_Object val) | |||
| 130 | blv->valcell = val; | 130 | blv->valcell = val; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static _Noreturn void | 133 | static AVOID |
| 134 | wrong_length_argument (Lisp_Object a1, Lisp_Object a2, Lisp_Object a3) | 134 | wrong_length_argument (Lisp_Object a1, Lisp_Object a2, Lisp_Object a3) |
| 135 | { | 135 | { |
| 136 | Lisp_Object size1 = make_fixnum (bool_vector_size (a1)); | 136 | Lisp_Object size1 = make_fixnum (bool_vector_size (a1)); |
| @@ -142,7 +142,7 @@ wrong_length_argument (Lisp_Object a1, Lisp_Object a2, Lisp_Object a3) | |||
| 142 | make_fixnum (bool_vector_size (a3))); | 142 | make_fixnum (bool_vector_size (a3))); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | _Noreturn void | 145 | AVOID |
| 146 | wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value) | 146 | wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value) |
| 147 | { | 147 | { |
| 148 | /* If VALUE is not even a valid Lisp object, we'd want to abort here | 148 | /* If VALUE is not even a valid Lisp object, we'd want to abort here |
| @@ -230,9 +230,7 @@ for example, (type-of 1) returns `integer'. */) | |||
| 230 | case PVEC_MARKER: return Qmarker; | 230 | case PVEC_MARKER: return Qmarker; |
| 231 | case PVEC_OVERLAY: return Qoverlay; | 231 | case PVEC_OVERLAY: return Qoverlay; |
| 232 | case PVEC_FINALIZER: return Qfinalizer; | 232 | case PVEC_FINALIZER: return Qfinalizer; |
| 233 | #ifdef HAVE_MODULES | ||
| 234 | case PVEC_USER_PTR: return Quser_ptr; | 233 | case PVEC_USER_PTR: return Quser_ptr; |
| 235 | #endif | ||
| 236 | case PVEC_WINDOW_CONFIGURATION: return Qwindow_configuration; | 234 | case PVEC_WINDOW_CONFIGURATION: return Qwindow_configuration; |
| 237 | case PVEC_PROCESS: return Qprocess; | 235 | case PVEC_PROCESS: return Qprocess; |
| 238 | case PVEC_WINDOW: return Qwindow; | 236 | case PVEC_WINDOW: return Qwindow; |
| @@ -669,7 +667,7 @@ global value outside of any lexical scope. */) | |||
| 669 | case SYMBOL_LOCALIZED: | 667 | case SYMBOL_LOCALIZED: |
| 670 | { | 668 | { |
| 671 | struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); | 669 | struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); |
| 672 | if (blv->fwd) | 670 | if (blv->fwd.fwdptr) |
| 673 | /* In set_internal, we un-forward vars when their value is | 671 | /* In set_internal, we un-forward vars when their value is |
| 674 | set to Qunbound. */ | 672 | set to Qunbound. */ |
| 675 | return Qt; | 673 | return Qt; |
| @@ -804,7 +802,7 @@ The return value is undefined. */) | |||
| 804 | 802 | ||
| 805 | { | 803 | { |
| 806 | bool autoload = AUTOLOADP (definition); | 804 | bool autoload = AUTOLOADP (definition); |
| 807 | if (NILP (Vpurify_flag) || !autoload) | 805 | if (!will_dump_p () || !autoload) |
| 808 | { /* Only add autoload entries after dumping, because the ones before are | 806 | { /* Only add autoload entries after dumping, because the ones before are |
| 809 | not useful and else we get loads of them from the loaddefs.el. */ | 807 | not useful and else we get loads of them from the loaddefs.el. */ |
| 810 | 808 | ||
| @@ -980,14 +978,12 @@ chain of aliases, signal a `cyclic-variable-indirection' error. */) | |||
| 980 | swap_in_symval_forwarding for that. */ | 978 | swap_in_symval_forwarding for that. */ |
| 981 | 979 | ||
| 982 | Lisp_Object | 980 | Lisp_Object |
| 983 | do_symval_forwarding (register union Lisp_Fwd *valcontents) | 981 | do_symval_forwarding (lispfwd valcontents) |
| 984 | { | 982 | { |
| 985 | register Lisp_Object val; | ||
| 986 | switch (XFWDTYPE (valcontents)) | 983 | switch (XFWDTYPE (valcontents)) |
| 987 | { | 984 | { |
| 988 | case Lisp_Fwd_Int: | 985 | case Lisp_Fwd_Int: |
| 989 | XSETINT (val, *XFIXNUMFWD (valcontents)->intvar); | 986 | return make_int (*XFIXNUMFWD (valcontents)->intvar); |
| 990 | return val; | ||
| 991 | 987 | ||
| 992 | case Lisp_Fwd_Bool: | 988 | case Lisp_Fwd_Bool: |
| 993 | return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); | 989 | return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); |
| @@ -1023,7 +1019,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents) | |||
| 1023 | void | 1019 | void |
| 1024 | wrong_choice (Lisp_Object choice, Lisp_Object wrong) | 1020 | wrong_choice (Lisp_Object choice, Lisp_Object wrong) |
| 1025 | { | 1021 | { |
| 1026 | ptrdiff_t i = 0, len = XFIXNUM (Flength (choice)); | 1022 | ptrdiff_t i = 0, len = list_length (choice); |
| 1027 | Lisp_Object obj, *args; | 1023 | Lisp_Object obj, *args; |
| 1028 | AUTO_STRING (one_of, "One of "); | 1024 | AUTO_STRING (one_of, "One of "); |
| 1029 | AUTO_STRING (comma, ", "); | 1025 | AUTO_STRING (comma, ", "); |
| @@ -1073,13 +1069,19 @@ wrong_range (Lisp_Object min, Lisp_Object max, Lisp_Object wrong) | |||
| 1073 | current buffer. This only plays a role for per-buffer variables. */ | 1069 | current buffer. This only plays a role for per-buffer variables. */ |
| 1074 | 1070 | ||
| 1075 | static void | 1071 | static void |
| 1076 | store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newval, struct buffer *buf) | 1072 | store_symval_forwarding (lispfwd valcontents, Lisp_Object newval, |
| 1073 | struct buffer *buf) | ||
| 1077 | { | 1074 | { |
| 1078 | switch (XFWDTYPE (valcontents)) | 1075 | switch (XFWDTYPE (valcontents)) |
| 1079 | { | 1076 | { |
| 1080 | case Lisp_Fwd_Int: | 1077 | case Lisp_Fwd_Int: |
| 1081 | CHECK_FIXNUM (newval); | 1078 | { |
| 1082 | *XFIXNUMFWD (valcontents)->intvar = XFIXNUM (newval); | 1079 | intmax_t i; |
| 1080 | CHECK_INTEGER (newval); | ||
| 1081 | if (! integer_to_intmax (newval, &i)) | ||
| 1082 | xsignal1 (Qoverflow_error, newval); | ||
| 1083 | *XFIXNUMFWD (valcontents)->intvar = i; | ||
| 1084 | } | ||
| 1083 | break; | 1085 | break; |
| 1084 | 1086 | ||
| 1085 | case Lisp_Fwd_Bool: | 1087 | case Lisp_Fwd_Bool: |
| @@ -1175,12 +1177,12 @@ swap_in_global_binding (struct Lisp_Symbol *symbol) | |||
| 1175 | struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (symbol); | 1177 | struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (symbol); |
| 1176 | 1178 | ||
| 1177 | /* Unload the previously loaded binding. */ | 1179 | /* Unload the previously loaded binding. */ |
| 1178 | if (blv->fwd) | 1180 | if (blv->fwd.fwdptr) |
| 1179 | set_blv_value (blv, do_symval_forwarding (blv->fwd)); | 1181 | set_blv_value (blv, do_symval_forwarding (blv->fwd)); |
| 1180 | 1182 | ||
| 1181 | /* Select the global binding in the symbol. */ | 1183 | /* Select the global binding in the symbol. */ |
| 1182 | set_blv_valcell (blv, blv->defcell); | 1184 | set_blv_valcell (blv, blv->defcell); |
| 1183 | if (blv->fwd) | 1185 | if (blv->fwd.fwdptr) |
| 1184 | store_symval_forwarding (blv->fwd, XCDR (blv->defcell), NULL); | 1186 | store_symval_forwarding (blv->fwd, XCDR (blv->defcell), NULL); |
| 1185 | 1187 | ||
| 1186 | /* Indicate that the global binding is set up now. */ | 1188 | /* Indicate that the global binding is set up now. */ |
| @@ -1210,7 +1212,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_ | |||
| 1210 | 1212 | ||
| 1211 | /* Unload the previously loaded binding. */ | 1213 | /* Unload the previously loaded binding. */ |
| 1212 | tem1 = blv->valcell; | 1214 | tem1 = blv->valcell; |
| 1213 | if (blv->fwd) | 1215 | if (blv->fwd.fwdptr) |
| 1214 | set_blv_value (blv, do_symval_forwarding (blv->fwd)); | 1216 | set_blv_value (blv, do_symval_forwarding (blv->fwd)); |
| 1215 | /* Choose the new binding. */ | 1217 | /* Choose the new binding. */ |
| 1216 | { | 1218 | { |
| @@ -1224,7 +1226,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_ | |||
| 1224 | 1226 | ||
| 1225 | /* Load the new binding. */ | 1227 | /* Load the new binding. */ |
| 1226 | set_blv_valcell (blv, tem1); | 1228 | set_blv_valcell (blv, tem1); |
| 1227 | if (blv->fwd) | 1229 | if (blv->fwd.fwdptr) |
| 1228 | store_symval_forwarding (blv->fwd, blv_value (blv), NULL); | 1230 | store_symval_forwarding (blv->fwd, blv_value (blv), NULL); |
| 1229 | } | 1231 | } |
| 1230 | } | 1232 | } |
| @@ -1252,7 +1254,9 @@ find_symbol_value (Lisp_Object symbol) | |||
| 1252 | { | 1254 | { |
| 1253 | struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); | 1255 | struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); |
| 1254 | swap_in_symval_forwarding (sym, blv); | 1256 | swap_in_symval_forwarding (sym, blv); |
| 1255 | return blv->fwd ? do_symval_forwarding (blv->fwd) : blv_value (blv); | 1257 | return (blv->fwd.fwdptr |
| 1258 | ? do_symval_forwarding (blv->fwd) | ||
| 1259 | : blv_value (blv)); | ||
| 1256 | } | 1260 | } |
| 1257 | case SYMBOL_FORWARDED: | 1261 | case SYMBOL_FORWARDED: |
| 1258 | return do_symval_forwarding (SYMBOL_FWD (sym)); | 1262 | return do_symval_forwarding (SYMBOL_FWD (sym)); |
| @@ -1354,7 +1358,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, | |||
| 1354 | We need to unload it, and choose a new binding. */ | 1358 | We need to unload it, and choose a new binding. */ |
| 1355 | 1359 | ||
| 1356 | /* Write out `realvalue' to the old loaded binding. */ | 1360 | /* Write out `realvalue' to the old loaded binding. */ |
| 1357 | if (blv->fwd) | 1361 | if (blv->fwd.fwdptr) |
| 1358 | set_blv_value (blv, do_symval_forwarding (blv->fwd)); | 1362 | set_blv_value (blv, do_symval_forwarding (blv->fwd)); |
| 1359 | 1363 | ||
| 1360 | /* Find the new binding. */ | 1364 | /* Find the new binding. */ |
| @@ -1401,12 +1405,12 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, | |||
| 1401 | /* Store the new value in the cons cell. */ | 1405 | /* Store the new value in the cons cell. */ |
| 1402 | set_blv_value (blv, newval); | 1406 | set_blv_value (blv, newval); |
| 1403 | 1407 | ||
| 1404 | if (blv->fwd) | 1408 | if (blv->fwd.fwdptr) |
| 1405 | { | 1409 | { |
| 1406 | if (voide) | 1410 | if (voide) |
| 1407 | /* If storing void (making the symbol void), forward only through | 1411 | /* If storing void (making the symbol void), forward only through |
| 1408 | buffer-local indicator, not through Lisp_Objfwd, etc. */ | 1412 | buffer-local indicator, not through Lisp_Objfwd, etc. */ |
| 1409 | blv->fwd = NULL; | 1413 | blv->fwd.fwdptr = NULL; |
| 1410 | else | 1414 | else |
| 1411 | store_symval_forwarding (blv->fwd, newval, | 1415 | store_symval_forwarding (blv->fwd, newval, |
| 1412 | BUFFERP (where) | 1416 | BUFFERP (where) |
| @@ -1418,7 +1422,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, | |||
| 1418 | { | 1422 | { |
| 1419 | struct buffer *buf | 1423 | struct buffer *buf |
| 1420 | = BUFFERP (where) ? XBUFFER (where) : current_buffer; | 1424 | = BUFFERP (where) ? XBUFFER (where) : current_buffer; |
| 1421 | union Lisp_Fwd *innercontents = SYMBOL_FWD (sym); | 1425 | lispfwd innercontents = SYMBOL_FWD (sym); |
| 1422 | if (BUFFER_OBJFWDP (innercontents)) | 1426 | if (BUFFER_OBJFWDP (innercontents)) |
| 1423 | { | 1427 | { |
| 1424 | int offset = XBUFFER_OBJFWD (innercontents)->offset; | 1428 | int offset = XBUFFER_OBJFWD (innercontents)->offset; |
| @@ -1590,14 +1594,14 @@ default_value (Lisp_Object symbol) | |||
| 1590 | But the `realvalue' slot may be more up to date, since | 1594 | But the `realvalue' slot may be more up to date, since |
| 1591 | ordinary setq stores just that slot. So use that. */ | 1595 | ordinary setq stores just that slot. So use that. */ |
| 1592 | struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); | 1596 | struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); |
| 1593 | if (blv->fwd && EQ (blv->valcell, blv->defcell)) | 1597 | if (blv->fwd.fwdptr && EQ (blv->valcell, blv->defcell)) |
| 1594 | return do_symval_forwarding (blv->fwd); | 1598 | return do_symval_forwarding (blv->fwd); |
| 1595 | else | 1599 | else |
| 1596 | return XCDR (blv->defcell); | 1600 | return XCDR (blv->defcell); |
| 1597 | } | 1601 | } |
| 1598 | case SYMBOL_FORWARDED: | 1602 | case SYMBOL_FORWARDED: |
| 1599 | { | 1603 | { |
| 1600 | union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); | 1604 | lispfwd valcontents = SYMBOL_FWD (sym); |
| 1601 | 1605 | ||
| 1602 | /* For a built-in buffer-local variable, get the default value | 1606 | /* For a built-in buffer-local variable, get the default value |
| 1603 | rather than letting do_symval_forwarding get the current value. */ | 1607 | rather than letting do_symval_forwarding get the current value. */ |
| @@ -1685,13 +1689,13 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value, | |||
| 1685 | XSETCDR (blv->defcell, value); | 1689 | XSETCDR (blv->defcell, value); |
| 1686 | 1690 | ||
| 1687 | /* If the default binding is now loaded, set the REALVALUE slot too. */ | 1691 | /* If the default binding is now loaded, set the REALVALUE slot too. */ |
| 1688 | if (blv->fwd && EQ (blv->defcell, blv->valcell)) | 1692 | if (blv->fwd.fwdptr && EQ (blv->defcell, blv->valcell)) |
| 1689 | store_symval_forwarding (blv->fwd, value, NULL); | 1693 | store_symval_forwarding (blv->fwd, value, NULL); |
| 1690 | return; | 1694 | return; |
| 1691 | } | 1695 | } |
| 1692 | case SYMBOL_FORWARDED: | 1696 | case SYMBOL_FORWARDED: |
| 1693 | { | 1697 | { |
| 1694 | union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); | 1698 | lispfwd valcontents = SYMBOL_FWD (sym); |
| 1695 | 1699 | ||
| 1696 | /* Handle variables like case-fold-search that have special slots | 1700 | /* Handle variables like case-fold-search that have special slots |
| 1697 | in the buffer. | 1701 | in the buffer. |
| @@ -1741,43 +1745,13 @@ for this variable. */) | |||
| 1741 | set_default_internal (symbol, value, SET_INTERNAL_SET); | 1745 | set_default_internal (symbol, value, SET_INTERNAL_SET); |
| 1742 | return value; | 1746 | return value; |
| 1743 | } | 1747 | } |
| 1744 | |||
| 1745 | DEFUN ("setq-default", Fsetq_default, Ssetq_default, 0, UNEVALLED, 0, | ||
| 1746 | doc: /* Set the default value of variable VAR to VALUE. | ||
| 1747 | VAR, the variable name, is literal (not evaluated); | ||
| 1748 | VALUE is an expression: it is evaluated and its value returned. | ||
| 1749 | The default value of a variable is seen in buffers | ||
| 1750 | that do not have their own values for the variable. | ||
| 1751 | |||
| 1752 | More generally, you can use multiple variables and values, as in | ||
| 1753 | (setq-default VAR VALUE VAR VALUE...) | ||
| 1754 | This sets each VAR's default value to the corresponding VALUE. | ||
| 1755 | The VALUE for the Nth VAR can refer to the new default values | ||
| 1756 | of previous VARs. | ||
| 1757 | usage: (setq-default [VAR VALUE]...) */) | ||
| 1758 | (Lisp_Object args) | ||
| 1759 | { | ||
| 1760 | Lisp_Object args_left, symbol, val; | ||
| 1761 | |||
| 1762 | args_left = val = args; | ||
| 1763 | |||
| 1764 | while (CONSP (args_left)) | ||
| 1765 | { | ||
| 1766 | val = eval_sub (Fcar (XCDR (args_left))); | ||
| 1767 | symbol = XCAR (args_left); | ||
| 1768 | Fset_default (symbol, val); | ||
| 1769 | args_left = Fcdr (XCDR (args_left)); | ||
| 1770 | } | ||
| 1771 | |||
| 1772 | return val; | ||
| 1773 | } | ||
| 1774 | 1748 | ||
| 1775 | /* Lisp functions for creating and removing buffer-local variables. */ | 1749 | /* Lisp functions for creating and removing buffer-local variables. */ |
| 1776 | 1750 | ||
| 1777 | union Lisp_Val_Fwd | 1751 | union Lisp_Val_Fwd |
| 1778 | { | 1752 | { |
| 1779 | Lisp_Object value; | 1753 | Lisp_Object value; |
| 1780 | union Lisp_Fwd *fwd; | 1754 | lispfwd fwd; |
| 1781 | }; | 1755 | }; |
| 1782 | 1756 | ||
| 1783 | static struct Lisp_Buffer_Local_Value * | 1757 | static struct Lisp_Buffer_Local_Value * |
| @@ -1797,7 +1771,10 @@ make_blv (struct Lisp_Symbol *sym, bool forwarded, | |||
| 1797 | or keyboard-local forwarding. */ | 1771 | or keyboard-local forwarding. */ |
| 1798 | eassert (!(forwarded && BUFFER_OBJFWDP (valcontents.fwd))); | 1772 | eassert (!(forwarded && BUFFER_OBJFWDP (valcontents.fwd))); |
| 1799 | eassert (!(forwarded && KBOARD_OBJFWDP (valcontents.fwd))); | 1773 | eassert (!(forwarded && KBOARD_OBJFWDP (valcontents.fwd))); |
| 1800 | blv->fwd = forwarded ? valcontents.fwd : NULL; | 1774 | if (forwarded) |
| 1775 | blv->fwd = valcontents.fwd; | ||
| 1776 | else | ||
| 1777 | blv->fwd.fwdptr = NULL; | ||
| 1801 | set_blv_where (blv, Qnil); | 1778 | set_blv_where (blv, Qnil); |
| 1802 | blv->local_if_set = 0; | 1779 | blv->local_if_set = 0; |
| 1803 | set_blv_defcell (blv, tem); | 1780 | set_blv_defcell (blv, tem); |
| @@ -1828,7 +1805,7 @@ The function `default-value' gets the default value and `set-default' sets it. | |||
| 1828 | { | 1805 | { |
| 1829 | struct Lisp_Symbol *sym; | 1806 | struct Lisp_Symbol *sym; |
| 1830 | struct Lisp_Buffer_Local_Value *blv = NULL; | 1807 | struct Lisp_Buffer_Local_Value *blv = NULL; |
| 1831 | union Lisp_Val_Fwd valcontents; | 1808 | union Lisp_Val_Fwd valcontents UNINIT; |
| 1832 | bool forwarded UNINIT; | 1809 | bool forwarded UNINIT; |
| 1833 | 1810 | ||
| 1834 | CHECK_SYMBOL (variable); | 1811 | CHECK_SYMBOL (variable); |
| @@ -1895,7 +1872,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) | |||
| 1895 | { | 1872 | { |
| 1896 | Lisp_Object tem; | 1873 | Lisp_Object tem; |
| 1897 | bool forwarded UNINIT; | 1874 | bool forwarded UNINIT; |
| 1898 | union Lisp_Val_Fwd valcontents; | 1875 | union Lisp_Val_Fwd valcontents UNINIT; |
| 1899 | struct Lisp_Symbol *sym; | 1876 | struct Lisp_Symbol *sym; |
| 1900 | struct Lisp_Buffer_Local_Value *blv = NULL; | 1877 | struct Lisp_Buffer_Local_Value *blv = NULL; |
| 1901 | 1878 | ||
| @@ -1960,6 +1937,16 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) | |||
| 1960 | (current_buffer, | 1937 | (current_buffer, |
| 1961 | Fcons (Fcons (variable, XCDR (blv->defcell)), | 1938 | Fcons (Fcons (variable, XCDR (blv->defcell)), |
| 1962 | BVAR (current_buffer, local_var_alist))); | 1939 | BVAR (current_buffer, local_var_alist))); |
| 1940 | |||
| 1941 | /* If the symbol forwards into a C variable, then load the binding | ||
| 1942 | for this buffer now, to preserve the invariant that forwarded | ||
| 1943 | variables must always hold the value corresponding to the | ||
| 1944 | current buffer (they are swapped eagerly). | ||
| 1945 | Otherwise, if C code modifies the variable before we load the | ||
| 1946 | binding in, then that new value would clobber the default binding | ||
| 1947 | the next time we unload it. See bug#34318. */ | ||
| 1948 | if (blv->fwd.fwdptr) | ||
| 1949 | swap_in_symval_forwarding (sym, blv); | ||
| 1963 | } | 1950 | } |
| 1964 | 1951 | ||
| 1965 | return variable; | 1952 | return variable; |
| @@ -1985,7 +1972,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) | |||
| 1985 | case SYMBOL_PLAINVAL: return variable; | 1972 | case SYMBOL_PLAINVAL: return variable; |
| 1986 | case SYMBOL_FORWARDED: | 1973 | case SYMBOL_FORWARDED: |
| 1987 | { | 1974 | { |
| 1988 | union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); | 1975 | lispfwd valcontents = SYMBOL_FWD (sym); |
| 1989 | if (BUFFER_OBJFWDP (valcontents)) | 1976 | if (BUFFER_OBJFWDP (valcontents)) |
| 1990 | { | 1977 | { |
| 1991 | int offset = XBUFFER_OBJFWD (valcontents)->offset; | 1978 | int offset = XBUFFER_OBJFWD (valcontents)->offset; |
| @@ -2068,7 +2055,7 @@ BUFFER defaults to the current buffer. */) | |||
| 2068 | } | 2055 | } |
| 2069 | case SYMBOL_FORWARDED: | 2056 | case SYMBOL_FORWARDED: |
| 2070 | { | 2057 | { |
| 2071 | union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); | 2058 | lispfwd valcontents = SYMBOL_FWD (sym); |
| 2072 | if (BUFFER_OBJFWDP (valcontents)) | 2059 | if (BUFFER_OBJFWDP (valcontents)) |
| 2073 | { | 2060 | { |
| 2074 | int offset = XBUFFER_OBJFWD (valcontents)->offset; | 2061 | int offset = XBUFFER_OBJFWD (valcontents)->offset; |
| @@ -2139,7 +2126,7 @@ If the current binding is global (the default), the value is nil. */) | |||
| 2139 | case SYMBOL_PLAINVAL: return Qnil; | 2126 | case SYMBOL_PLAINVAL: return Qnil; |
| 2140 | case SYMBOL_FORWARDED: | 2127 | case SYMBOL_FORWARDED: |
| 2141 | { | 2128 | { |
| 2142 | union Lisp_Fwd *valcontents = SYMBOL_FWD (sym); | 2129 | lispfwd valcontents = SYMBOL_FWD (sym); |
| 2143 | if (KBOARD_OBJFWDP (valcontents)) | 2130 | if (KBOARD_OBJFWDP (valcontents)) |
| 2144 | return Fframe_terminal (selected_frame); | 2131 | return Fframe_terminal (selected_frame); |
| 2145 | else if (!BUFFER_OBJFWDP (valcontents)) | 2132 | else if (!BUFFER_OBJFWDP (valcontents)) |
| @@ -2414,14 +2401,14 @@ emacs_mpz_mul (mpz_t rop, mpz_t const op1, mpz_t const op2) | |||
| 2414 | } | 2401 | } |
| 2415 | 2402 | ||
| 2416 | static void | 2403 | static void |
| 2417 | emacs_mpz_mul_2exp (mpz_t rop, mpz_t const op1, mp_bitcnt_t op2) | 2404 | emacs_mpz_mul_2exp (mpz_t rop, mpz_t const op1, EMACS_INT op2) |
| 2418 | { | 2405 | { |
| 2419 | /* Fudge factor derived from GMP 6.1.2, to avoid an abort in | 2406 | /* Fudge factor derived from GMP 6.1.2, to avoid an abort in |
| 2420 | mpz_mul_2exp (look for the '+ 1' in its source code). */ | 2407 | mpz_mul_2exp (look for the '+ 1' in its source code). */ |
| 2421 | enum { mul_2exp_extra_limbs = 1 }; | 2408 | enum { mul_2exp_extra_limbs = 1 }; |
| 2422 | enum { lim = min (NLIMBS_LIMIT, GMP_NLIMBS_MAX - mul_2exp_extra_limbs) }; | 2409 | enum { lim = min (NLIMBS_LIMIT, GMP_NLIMBS_MAX - mul_2exp_extra_limbs) }; |
| 2423 | 2410 | ||
| 2424 | mp_bitcnt_t op2limbs = op2 / GMP_NUMB_BITS; | 2411 | EMACS_INT op2limbs = op2 / GMP_NUMB_BITS; |
| 2425 | if (lim - emacs_mpz_size (op1) < op2limbs) | 2412 | if (lim - emacs_mpz_size (op1) < op2limbs) |
| 2426 | overflow_error (); | 2413 | overflow_error (); |
| 2427 | mpz_mul_2exp (rop, op1, op2); | 2414 | mpz_mul_2exp (rop, op1, op2); |
| @@ -2655,7 +2642,7 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max) | |||
| 2655 | else | 2642 | else |
| 2656 | { | 2643 | { |
| 2657 | Lisp_Object hi = CONSP (c) ? XCAR (c) : c; | 2644 | Lisp_Object hi = CONSP (c) ? XCAR (c) : c; |
| 2658 | valid = integer_to_uintmax (hi, &val); | 2645 | valid = INTEGERP (hi) && integer_to_uintmax (hi, &val); |
| 2659 | 2646 | ||
| 2660 | if (valid && CONSP (c)) | 2647 | if (valid && CONSP (c)) |
| 2661 | { | 2648 | { |
| @@ -2716,7 +2703,7 @@ cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max) | |||
| 2716 | else | 2703 | else |
| 2717 | { | 2704 | { |
| 2718 | Lisp_Object hi = CONSP (c) ? XCAR (c) : c; | 2705 | Lisp_Object hi = CONSP (c) ? XCAR (c) : c; |
| 2719 | valid = integer_to_intmax (hi, &val); | 2706 | valid = INTEGERP (hi) && integer_to_intmax (hi, &val); |
| 2720 | 2707 | ||
| 2721 | if (valid && CONSP (c)) | 2708 | if (valid && CONSP (c)) |
| 2722 | { | 2709 | { |
| @@ -2960,7 +2947,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args, | |||
| 2960 | /* Set ACCUM to the next operation's result if it fits, | 2947 | /* Set ACCUM to the next operation's result if it fits, |
| 2961 | else exit the loop. */ | 2948 | else exit the loop. */ |
| 2962 | bool overflow = false; | 2949 | bool overflow = false; |
| 2963 | intmax_t a; | 2950 | intmax_t a UNINIT; |
| 2964 | switch (code) | 2951 | switch (code) |
| 2965 | { | 2952 | { |
| 2966 | case Aadd : overflow = INT_ADD_WRAPV (accum, next, &a); break; | 2953 | case Aadd : overflow = INT_ADD_WRAPV (accum, next, &a); break; |
| @@ -3251,12 +3238,21 @@ If COUNT is negative, shifting is actually to the right. | |||
| 3251 | In this case, the sign bit is duplicated. */) | 3238 | In this case, the sign bit is duplicated. */) |
| 3252 | (Lisp_Object value, Lisp_Object count) | 3239 | (Lisp_Object value, Lisp_Object count) |
| 3253 | { | 3240 | { |
| 3254 | /* The negative of the minimum value of COUNT that fits into a fixnum, | ||
| 3255 | such that mpz_fdiv_q_exp supports -COUNT. */ | ||
| 3256 | EMACS_INT minus_count_min = min (-MOST_NEGATIVE_FIXNUM, | ||
| 3257 | TYPE_MAXIMUM (mp_bitcnt_t)); | ||
| 3258 | CHECK_INTEGER (value); | 3241 | CHECK_INTEGER (value); |
| 3259 | CHECK_RANGED_INTEGER (count, - minus_count_min, TYPE_MAXIMUM (mp_bitcnt_t)); | 3242 | CHECK_INTEGER (count); |
| 3243 | |||
| 3244 | if (! FIXNUMP (count)) | ||
| 3245 | { | ||
| 3246 | if (EQ (value, make_fixnum (0))) | ||
| 3247 | return value; | ||
| 3248 | if (mpz_sgn (XBIGNUM (count)->value) < 0) | ||
| 3249 | { | ||
| 3250 | EMACS_INT v = (FIXNUMP (value) ? XFIXNUM (value) | ||
| 3251 | : mpz_sgn (XBIGNUM (value)->value)); | ||
| 3252 | return make_fixnum (v < 0 ? -1 : 0); | ||
| 3253 | } | ||
| 3254 | overflow_error (); | ||
| 3255 | } | ||
| 3260 | 3256 | ||
| 3261 | if (XFIXNUM (count) <= 0) | 3257 | if (XFIXNUM (count) <= 0) |
| 3262 | { | 3258 | { |
| @@ -3275,7 +3271,11 @@ In this case, the sign bit is duplicated. */) | |||
| 3275 | 3271 | ||
| 3276 | mpz_t *zval = bignum_integer (&mpz[0], value); | 3272 | mpz_t *zval = bignum_integer (&mpz[0], value); |
| 3277 | if (XFIXNUM (count) < 0) | 3273 | if (XFIXNUM (count) < 0) |
| 3278 | mpz_fdiv_q_2exp (mpz[0], *zval, - XFIXNUM (count)); | 3274 | { |
| 3275 | if (TYPE_MAXIMUM (mp_bitcnt_t) < - XFIXNUM (count)) | ||
| 3276 | return make_fixnum (mpz_sgn (*zval) < 0 ? -1 : 0); | ||
| 3277 | mpz_fdiv_q_2exp (mpz[0], *zval, - XFIXNUM (count)); | ||
| 3278 | } | ||
| 3279 | else | 3279 | else |
| 3280 | emacs_mpz_mul_2exp (mpz[0], *zval, XFIXNUM (count)); | 3280 | emacs_mpz_mul_2exp (mpz[0], *zval, XFIXNUM (count)); |
| 3281 | return make_integer_mpz (); | 3281 | return make_integer_mpz (); |
| @@ -3836,9 +3836,7 @@ syms_of_data (void) | |||
| 3836 | DEFSYM (Qbool_vector_p, "bool-vector-p"); | 3836 | DEFSYM (Qbool_vector_p, "bool-vector-p"); |
| 3837 | DEFSYM (Qchar_or_string_p, "char-or-string-p"); | 3837 | DEFSYM (Qchar_or_string_p, "char-or-string-p"); |
| 3838 | DEFSYM (Qmarkerp, "markerp"); | 3838 | DEFSYM (Qmarkerp, "markerp"); |
| 3839 | #ifdef HAVE_MODULES | ||
| 3840 | DEFSYM (Quser_ptrp, "user-ptrp"); | 3839 | DEFSYM (Quser_ptrp, "user-ptrp"); |
| 3841 | #endif | ||
| 3842 | DEFSYM (Qbuffer_or_string_p, "buffer-or-string-p"); | 3840 | DEFSYM (Qbuffer_or_string_p, "buffer-or-string-p"); |
| 3843 | DEFSYM (Qinteger_or_marker_p, "integer-or-marker-p"); | 3841 | DEFSYM (Qinteger_or_marker_p, "integer-or-marker-p"); |
| 3844 | DEFSYM (Qfboundp, "fboundp"); | 3842 | DEFSYM (Qfboundp, "fboundp"); |
| @@ -3933,9 +3931,7 @@ syms_of_data (void) | |||
| 3933 | DEFSYM (Qoverlay, "overlay"); | 3931 | DEFSYM (Qoverlay, "overlay"); |
| 3934 | DEFSYM (Qfinalizer, "finalizer"); | 3932 | DEFSYM (Qfinalizer, "finalizer"); |
| 3935 | DEFSYM (Qmodule_function, "module-function"); | 3933 | DEFSYM (Qmodule_function, "module-function"); |
| 3936 | #ifdef HAVE_MODULES | ||
| 3937 | DEFSYM (Quser_ptr, "user-ptr"); | 3934 | DEFSYM (Quser_ptr, "user-ptr"); |
| 3938 | #endif | ||
| 3939 | DEFSYM (Qfloat, "float"); | 3935 | DEFSYM (Qfloat, "float"); |
| 3940 | DEFSYM (Qwindow_configuration, "window-configuration"); | 3936 | DEFSYM (Qwindow_configuration, "window-configuration"); |
| 3941 | DEFSYM (Qprocess, "process"); | 3937 | DEFSYM (Qprocess, "process"); |
| @@ -4021,7 +4017,6 @@ syms_of_data (void) | |||
| 4021 | defsubr (&Sdefault_boundp); | 4017 | defsubr (&Sdefault_boundp); |
| 4022 | defsubr (&Sdefault_value); | 4018 | defsubr (&Sdefault_value); |
| 4023 | defsubr (&Sset_default); | 4019 | defsubr (&Sset_default); |
| 4024 | defsubr (&Ssetq_default); | ||
| 4025 | defsubr (&Smake_variable_buffer_local); | 4020 | defsubr (&Smake_variable_buffer_local); |
| 4026 | defsubr (&Smake_local_variable); | 4021 | defsubr (&Smake_local_variable); |
| 4027 | defsubr (&Skill_local_variable); | 4022 | defsubr (&Skill_local_variable); |