diff options
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 749 |
1 files changed, 357 insertions, 392 deletions
diff --git a/src/data.c b/src/data.c index 927bc7c5a47..cf01d38036d 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -22,6 +22,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 22 | #include <signal.h> | 22 | #include <signal.h> |
| 23 | #include <stdio.h> | 23 | #include <stdio.h> |
| 24 | #include <setjmp.h> | 24 | #include <setjmp.h> |
| 25 | |||
| 26 | #include <intprops.h> | ||
| 27 | |||
| 25 | #include "lisp.h" | 28 | #include "lisp.h" |
| 26 | #include "puresize.h" | 29 | #include "puresize.h" |
| 27 | #include "character.h" | 30 | #include "character.h" |
| @@ -29,14 +32,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 29 | #include "keyboard.h" | 32 | #include "keyboard.h" |
| 30 | #include "frame.h" | 33 | #include "frame.h" |
| 31 | #include "syssignal.h" | 34 | #include "syssignal.h" |
| 32 | #include "termhooks.h" /* For FRAME_KBOARD reference in y-or-n-p. */ | 35 | #include "termhooks.h" /* For FRAME_KBOARD reference in y-or-n-p. */ |
| 33 | #include "font.h" | 36 | #include "font.h" |
| 34 | 37 | ||
| 35 | #ifdef STDC_HEADERS | 38 | #ifdef STDC_HEADERS |
| 36 | #include <float.h> | 39 | #include <float.h> |
| 37 | #endif | 40 | #endif |
| 38 | 41 | ||
| 39 | /* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */ | 42 | /* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */ |
| 40 | #ifndef IEEE_FLOATING_POINT | 43 | #ifndef IEEE_FLOATING_POINT |
| 41 | #if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ | 44 | #if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ |
| 42 | && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) | 45 | && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) |
| @@ -48,30 +51,33 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 48 | 51 | ||
| 49 | #include <math.h> | 52 | #include <math.h> |
| 50 | 53 | ||
| 51 | #if !defined (atof) | 54 | Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; |
| 52 | extern double atof (const char *); | 55 | static Lisp_Object Qsubr; |
| 53 | #endif /* !atof */ | ||
| 54 | |||
| 55 | Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound; | ||
| 56 | Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; | 56 | Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; |
| 57 | Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range; | 57 | Lisp_Object Qerror, Qquit, Qargs_out_of_range; |
| 58 | Lisp_Object Qvoid_variable, Qvoid_function, Qcyclic_function_indirection; | 58 | static Lisp_Object Qwrong_type_argument; |
| 59 | Lisp_Object Qcyclic_variable_indirection, Qcircular_list; | 59 | Lisp_Object Qvoid_variable, Qvoid_function; |
| 60 | Lisp_Object Qsetting_constant, Qinvalid_read_syntax; | 60 | static Lisp_Object Qcyclic_function_indirection; |
| 61 | static Lisp_Object Qcyclic_variable_indirection; | ||
| 62 | Lisp_Object Qcircular_list; | ||
| 63 | static Lisp_Object Qsetting_constant; | ||
| 64 | Lisp_Object Qinvalid_read_syntax; | ||
| 61 | Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch; | 65 | Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch; |
| 62 | Lisp_Object Qend_of_file, Qarith_error, Qmark_inactive; | 66 | Lisp_Object Qend_of_file, Qarith_error, Qmark_inactive; |
| 63 | Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only; | 67 | Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only; |
| 64 | Lisp_Object Qtext_read_only; | 68 | Lisp_Object Qtext_read_only; |
| 65 | 69 | ||
| 66 | Lisp_Object Qintegerp, Qnatnump, Qwholenump, Qsymbolp, Qlistp, Qconsp; | 70 | Lisp_Object Qintegerp, Qwholenump, Qsymbolp, Qlistp, Qconsp; |
| 71 | static Lisp_Object Qnatnump; | ||
| 67 | Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp; | 72 | Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp; |
| 68 | Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp; | 73 | Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp; |
| 69 | Lisp_Object Qbuffer_or_string_p, Qkeywordp; | 74 | Lisp_Object Qbuffer_or_string_p; |
| 70 | Lisp_Object Qboundp, Qfboundp; | 75 | static Lisp_Object Qkeywordp, Qboundp; |
| 76 | Lisp_Object Qfboundp; | ||
| 71 | Lisp_Object Qchar_table_p, Qvector_or_char_table_p; | 77 | Lisp_Object Qchar_table_p, Qvector_or_char_table_p; |
| 72 | 78 | ||
| 73 | Lisp_Object Qcdr; | 79 | Lisp_Object Qcdr; |
| 74 | Lisp_Object Qad_advice_info, Qad_activate_internal; | 80 | static Lisp_Object Qad_advice_info, Qad_activate_internal; |
| 75 | 81 | ||
| 76 | Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; | 82 | Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; |
| 77 | Lisp_Object Qoverflow_error, Qunderflow_error; | 83 | Lisp_Object Qoverflow_error, Qunderflow_error; |
| @@ -83,8 +89,9 @@ Lisp_Object Qinteger; | |||
| 83 | static Lisp_Object Qsymbol, Qstring, Qcons, Qmarker, Qoverlay; | 89 | static Lisp_Object Qsymbol, Qstring, Qcons, Qmarker, Qoverlay; |
| 84 | Lisp_Object Qwindow; | 90 | Lisp_Object Qwindow; |
| 85 | static Lisp_Object Qfloat, Qwindow_configuration; | 91 | static Lisp_Object Qfloat, Qwindow_configuration; |
| 86 | Lisp_Object Qprocess; | 92 | static Lisp_Object Qprocess; |
| 87 | static Lisp_Object Qcompiled_function, Qbuffer, Qframe, Qvector; | 93 | static Lisp_Object Qcompiled_function, Qframe, Qvector; |
| 94 | Lisp_Object Qbuffer; | ||
| 88 | static Lisp_Object Qchar_table, Qbool_vector, Qhash_table; | 95 | static Lisp_Object Qchar_table, Qbool_vector, Qhash_table; |
| 89 | static Lisp_Object Qsubrp, Qmany, Qunevalled; | 96 | static Lisp_Object Qsubrp, Qmany, Qunevalled; |
| 90 | Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; | 97 | Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; |
| @@ -94,13 +101,6 @@ Lisp_Object Qinteractive_form; | |||
| 94 | static void swap_in_symval_forwarding (struct Lisp_Symbol *, struct Lisp_Buffer_Local_Value *); | 101 | static void swap_in_symval_forwarding (struct Lisp_Symbol *, struct Lisp_Buffer_Local_Value *); |
| 95 | 102 | ||
| 96 | 103 | ||
| 97 | void | ||
| 98 | circular_list_error (Lisp_Object list) | ||
| 99 | { | ||
| 100 | xsignal (Qcircular_list, list); | ||
| 101 | } | ||
| 102 | |||
| 103 | |||
| 104 | Lisp_Object | 104 | Lisp_Object |
| 105 | wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value) | 105 | wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value) |
| 106 | { | 106 | { |
| @@ -745,7 +745,9 @@ Value, if non-nil, is a list \(interactive SPEC). */) | |||
| 745 | else if (CONSP (fun)) | 745 | else if (CONSP (fun)) |
| 746 | { | 746 | { |
| 747 | Lisp_Object funcar = XCAR (fun); | 747 | Lisp_Object funcar = XCAR (fun); |
| 748 | if (EQ (funcar, Qlambda)) | 748 | if (EQ (funcar, Qclosure)) |
| 749 | return Fassq (Qinteractive, Fcdr (Fcdr (XCDR (fun)))); | ||
| 750 | else if (EQ (funcar, Qlambda)) | ||
| 749 | return Fassq (Qinteractive, Fcdr (XCDR (fun))); | 751 | return Fassq (Qinteractive, Fcdr (XCDR (fun))); |
| 750 | else if (EQ (funcar, Qautoload)) | 752 | else if (EQ (funcar, Qautoload)) |
| 751 | { | 753 | { |
| @@ -805,7 +807,10 @@ variable chain of symbols. */) | |||
| 805 | (Lisp_Object object) | 807 | (Lisp_Object object) |
| 806 | { | 808 | { |
| 807 | if (SYMBOLP (object)) | 809 | if (SYMBOLP (object)) |
| 808 | XSETSYMBOL (object, indirect_variable (XSYMBOL (object))); | 810 | { |
| 811 | struct Lisp_Symbol *sym = indirect_variable (XSYMBOL (object)); | ||
| 812 | XSETSYMBOL (object, sym); | ||
| 813 | } | ||
| 809 | return object; | 814 | return object; |
| 810 | } | 815 | } |
| 811 | 816 | ||
| @@ -815,9 +820,6 @@ variable chain of symbols. */) | |||
| 815 | This does not handle buffer-local variables; use | 820 | This does not handle buffer-local variables; use |
| 816 | swap_in_symval_forwarding for that. */ | 821 | swap_in_symval_forwarding for that. */ |
| 817 | 822 | ||
| 818 | #define do_blv_forwarding(blv) \ | ||
| 819 | ((blv)->forwarded ? do_symval_forwarding (BLV_FWD (blv)) : BLV_VALUE (blv)) | ||
| 820 | |||
| 821 | Lisp_Object | 823 | Lisp_Object |
| 822 | do_symval_forwarding (register union Lisp_Fwd *valcontents) | 824 | do_symval_forwarding (register union Lisp_Fwd *valcontents) |
| 823 | { | 825 | { |
| @@ -864,14 +866,6 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents) | |||
| 864 | BUF non-zero means set the value in buffer BUF instead of the | 866 | BUF non-zero means set the value in buffer BUF instead of the |
| 865 | current buffer. This only plays a role for per-buffer variables. */ | 867 | current buffer. This only plays a role for per-buffer variables. */ |
| 866 | 868 | ||
| 867 | #define store_blv_forwarding(blv, newval, buf) \ | ||
| 868 | do { \ | ||
| 869 | if ((blv)->forwarded) \ | ||
| 870 | store_symval_forwarding (BLV_FWD (blv), (newval), (buf)); \ | ||
| 871 | else \ | ||
| 872 | SET_BLV_VALUE (blv, newval); \ | ||
| 873 | } while (0) | ||
| 874 | |||
| 875 | static void | 869 | static void |
| 876 | store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newval, struct buffer *buf) | 870 | store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newval, struct buffer *buf) |
| 877 | { | 871 | { |
| @@ -907,12 +901,12 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva | |||
| 907 | 901 | ||
| 908 | for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) | 902 | for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) |
| 909 | { | 903 | { |
| 910 | Lisp_Object buf; | 904 | Lisp_Object lbuf; |
| 911 | struct buffer *b; | 905 | struct buffer *b; |
| 912 | 906 | ||
| 913 | buf = Fcdr (XCAR (tail)); | 907 | lbuf = Fcdr (XCAR (tail)); |
| 914 | if (!BUFFERP (buf)) continue; | 908 | if (!BUFFERP (lbuf)) continue; |
| 915 | b = XBUFFER (buf); | 909 | b = XBUFFER (lbuf); |
| 916 | 910 | ||
| 917 | if (! PER_BUFFER_VALUE_P (b, idx)) | 911 | if (! PER_BUFFER_VALUE_P (b, idx)) |
| 918 | PER_BUFFER_VALUE (b, offset) = newval; | 912 | PER_BUFFER_VALUE (b, offset) = newval; |
| @@ -1009,7 +1003,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_ | |||
| 1009 | } | 1003 | } |
| 1010 | else | 1004 | else |
| 1011 | { | 1005 | { |
| 1012 | tem1 = assq_no_quit (var, current_buffer->local_var_alist); | 1006 | tem1 = assq_no_quit (var, BVAR (current_buffer, local_var_alist)); |
| 1013 | XSETBUFFER (blv->where, current_buffer); | 1007 | XSETBUFFER (blv->where, current_buffer); |
| 1014 | } | 1008 | } |
| 1015 | } | 1009 | } |
| @@ -1178,7 +1172,7 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register | |||
| 1178 | tem1 = Fassq (symbol, | 1172 | tem1 = Fassq (symbol, |
| 1179 | (blv->frame_local | 1173 | (blv->frame_local |
| 1180 | ? XFRAME (where)->param_alist | 1174 | ? XFRAME (where)->param_alist |
| 1181 | : XBUFFER (where)->local_var_alist)); | 1175 | : BVAR (XBUFFER (where), local_var_alist))); |
| 1182 | blv->where = where; | 1176 | blv->where = where; |
| 1183 | blv->found = 1; | 1177 | blv->found = 1; |
| 1184 | 1178 | ||
| @@ -1209,8 +1203,8 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register | |||
| 1209 | bindings, not for frame-local bindings. */ | 1203 | bindings, not for frame-local bindings. */ |
| 1210 | eassert (!blv->frame_local); | 1204 | eassert (!blv->frame_local); |
| 1211 | tem1 = Fcons (symbol, XCDR (blv->defcell)); | 1205 | tem1 = Fcons (symbol, XCDR (blv->defcell)); |
| 1212 | XBUFFER (where)->local_var_alist | 1206 | BVAR (XBUFFER (where), local_var_alist) |
| 1213 | = Fcons (tem1, XBUFFER (where)->local_var_alist); | 1207 | = Fcons (tem1, BVAR (XBUFFER (where), local_var_alist)); |
| 1214 | } | 1208 | } |
| 1215 | } | 1209 | } |
| 1216 | 1210 | ||
| @@ -1269,7 +1263,7 @@ set_internal (register Lisp_Object symbol, register Lisp_Object newval, register | |||
| 1269 | /* Return the default value of SYMBOL, but don't check for voidness. | 1263 | /* Return the default value of SYMBOL, but don't check for voidness. |
| 1270 | Return Qunbound if it is void. */ | 1264 | Return Qunbound if it is void. */ |
| 1271 | 1265 | ||
| 1272 | Lisp_Object | 1266 | static Lisp_Object |
| 1273 | default_value (Lisp_Object symbol) | 1267 | default_value (Lisp_Object symbol) |
| 1274 | { | 1268 | { |
| 1275 | struct Lisp_Symbol *sym; | 1269 | struct Lisp_Symbol *sym; |
| @@ -1399,7 +1393,7 @@ for this variable. */) | |||
| 1399 | { | 1393 | { |
| 1400 | struct buffer *b; | 1394 | struct buffer *b; |
| 1401 | 1395 | ||
| 1402 | for (b = all_buffers; b; b = b->next) | 1396 | for (b = all_buffers; b; b = b->header.next.buffer) |
| 1403 | if (!PER_BUFFER_VALUE_P (b, idx)) | 1397 | if (!PER_BUFFER_VALUE_P (b, idx)) |
| 1404 | PER_BUFFER_VALUE (b, offset) = value; | 1398 | PER_BUFFER_VALUE (b, offset) = value; |
| 1405 | } | 1399 | } |
| @@ -1439,7 +1433,7 @@ usage: (setq-default [VAR VALUE]...) */) | |||
| 1439 | 1433 | ||
| 1440 | do | 1434 | do |
| 1441 | { | 1435 | { |
| 1442 | val = Feval (Fcar (Fcdr (args_left))); | 1436 | val = eval_sub (Fcar (Fcdr (args_left))); |
| 1443 | symbol = XCAR (args_left); | 1437 | symbol = XCAR (args_left); |
| 1444 | Fset_default (symbol, val); | 1438 | Fset_default (symbol, val); |
| 1445 | args_left = Fcdr (XCDR (args_left)); | 1439 | args_left = Fcdr (XCDR (args_left)); |
| @@ -1485,8 +1479,8 @@ make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents | |||
| 1485 | return blv; | 1479 | return blv; |
| 1486 | } | 1480 | } |
| 1487 | 1481 | ||
| 1488 | DEFUN ("make-variable-buffer-local", Fmake_variable_buffer_local, Smake_variable_buffer_local, | 1482 | DEFUN ("make-variable-buffer-local", Fmake_variable_buffer_local, |
| 1489 | 1, 1, "vMake Variable Buffer Local: ", | 1483 | Smake_variable_buffer_local, 1, 1, "vMake Variable Buffer Local: ", |
| 1490 | doc: /* Make VARIABLE become buffer-local whenever it is set. | 1484 | doc: /* Make VARIABLE become buffer-local whenever it is set. |
| 1491 | At any time, the value for the current buffer is in effect, | 1485 | At any time, the value for the current buffer is in effect, |
| 1492 | unless the variable has never been set in this buffer, | 1486 | unless the variable has never been set in this buffer, |
| @@ -1503,8 +1497,8 @@ The function `default-value' gets the default value and `set-default' sets it. | |||
| 1503 | { | 1497 | { |
| 1504 | struct Lisp_Symbol *sym; | 1498 | struct Lisp_Symbol *sym; |
| 1505 | struct Lisp_Buffer_Local_Value *blv = NULL; | 1499 | struct Lisp_Buffer_Local_Value *blv = NULL; |
| 1506 | union Lisp_Val_Fwd valcontents; | 1500 | union Lisp_Val_Fwd valcontents IF_LINT (= {0}); |
| 1507 | int forwarded; | 1501 | int forwarded IF_LINT (= 0); |
| 1508 | 1502 | ||
| 1509 | CHECK_SYMBOL (variable); | 1503 | CHECK_SYMBOL (variable); |
| 1510 | sym = XSYMBOL (variable); | 1504 | sym = XSYMBOL (variable); |
| @@ -1579,8 +1573,8 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) | |||
| 1579 | (register Lisp_Object variable) | 1573 | (register Lisp_Object variable) |
| 1580 | { | 1574 | { |
| 1581 | register Lisp_Object tem; | 1575 | register Lisp_Object tem; |
| 1582 | int forwarded; | 1576 | int forwarded IF_LINT (= 0); |
| 1583 | union Lisp_Val_Fwd valcontents; | 1577 | union Lisp_Val_Fwd valcontents IF_LINT (= {0}); |
| 1584 | struct Lisp_Symbol *sym; | 1578 | struct Lisp_Symbol *sym; |
| 1585 | struct Lisp_Buffer_Local_Value *blv = NULL; | 1579 | struct Lisp_Buffer_Local_Value *blv = NULL; |
| 1586 | 1580 | ||
| @@ -1632,13 +1626,13 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) | |||
| 1632 | if (let_shadows_global_binding_p (symbol)) | 1626 | if (let_shadows_global_binding_p (symbol)) |
| 1633 | message ("Making %s local to %s while let-bound!", | 1627 | message ("Making %s local to %s while let-bound!", |
| 1634 | SDATA (SYMBOL_NAME (variable)), | 1628 | SDATA (SYMBOL_NAME (variable)), |
| 1635 | SDATA (current_buffer->name)); | 1629 | SDATA (BVAR (current_buffer, name))); |
| 1636 | } | 1630 | } |
| 1637 | } | 1631 | } |
| 1638 | 1632 | ||
| 1639 | /* Make sure this buffer has its own value of symbol. */ | 1633 | /* Make sure this buffer has its own value of symbol. */ |
| 1640 | XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ | 1634 | XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ |
| 1641 | tem = Fassq (variable, current_buffer->local_var_alist); | 1635 | tem = Fassq (variable, BVAR (current_buffer, local_var_alist)); |
| 1642 | if (NILP (tem)) | 1636 | if (NILP (tem)) |
| 1643 | { | 1637 | { |
| 1644 | if (let_shadows_buffer_binding_p (sym)) | 1638 | if (let_shadows_buffer_binding_p (sym)) |
| @@ -1650,9 +1644,9 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) | |||
| 1650 | default value. */ | 1644 | default value. */ |
| 1651 | find_symbol_value (variable); | 1645 | find_symbol_value (variable); |
| 1652 | 1646 | ||
| 1653 | current_buffer->local_var_alist | 1647 | BVAR (current_buffer, local_var_alist) |
| 1654 | = Fcons (Fcons (variable, XCDR (blv->defcell)), | 1648 | = Fcons (Fcons (variable, XCDR (blv->defcell)), |
| 1655 | current_buffer->local_var_alist); | 1649 | BVAR (current_buffer, local_var_alist)); |
| 1656 | 1650 | ||
| 1657 | /* Make sure symbol does not think it is set up for this buffer; | 1651 | /* Make sure symbol does not think it is set up for this buffer; |
| 1658 | force it to look once again for this buffer's value. */ | 1652 | force it to look once again for this buffer's value. */ |
| @@ -1718,10 +1712,10 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) | |||
| 1718 | 1712 | ||
| 1719 | /* Get rid of this buffer's alist element, if any. */ | 1713 | /* Get rid of this buffer's alist element, if any. */ |
| 1720 | XSETSYMBOL (variable, sym); /* Propagate variable indirection. */ | 1714 | XSETSYMBOL (variable, sym); /* Propagate variable indirection. */ |
| 1721 | tem = Fassq (variable, current_buffer->local_var_alist); | 1715 | tem = Fassq (variable, BVAR (current_buffer, local_var_alist)); |
| 1722 | if (!NILP (tem)) | 1716 | if (!NILP (tem)) |
| 1723 | current_buffer->local_var_alist | 1717 | BVAR (current_buffer, local_var_alist) |
| 1724 | = Fdelq (tem, current_buffer->local_var_alist); | 1718 | = Fdelq (tem, BVAR (current_buffer, local_var_alist)); |
| 1725 | 1719 | ||
| 1726 | /* If the symbol is set up with the current buffer's binding | 1720 | /* If the symbol is set up with the current buffer's binding |
| 1727 | loaded, recompute its value. We have to do it now, or else | 1721 | loaded, recompute its value. We have to do it now, or else |
| @@ -1848,7 +1842,7 @@ BUFFER defaults to the current buffer. */) | |||
| 1848 | XSETBUFFER (tmp, buf); | 1842 | XSETBUFFER (tmp, buf); |
| 1849 | XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ | 1843 | XSETSYMBOL (variable, sym); /* Update in case of aliasing. */ |
| 1850 | 1844 | ||
| 1851 | for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail)) | 1845 | for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail)) |
| 1852 | { | 1846 | { |
| 1853 | elt = XCAR (tail); | 1847 | elt = XCAR (tail); |
| 1854 | if (EQ (variable, XCAR (elt))) | 1848 | if (EQ (variable, XCAR (elt))) |
| @@ -1961,7 +1955,8 @@ If the current binding is global (the default), the value is nil. */) | |||
| 1961 | #if 0 | 1955 | #if 0 |
| 1962 | extern struct terminal *get_terminal (Lisp_Object display, int); | 1956 | extern struct terminal *get_terminal (Lisp_Object display, int); |
| 1963 | 1957 | ||
| 1964 | DEFUN ("terminal-local-value", Fterminal_local_value, Sterminal_local_value, 2, 2, 0, | 1958 | DEFUN ("terminal-local-value", Fterminal_local_value, |
| 1959 | Sterminal_local_value, 2, 2, 0, | ||
| 1965 | doc: /* Return the terminal-local value of SYMBOL on TERMINAL. | 1960 | doc: /* Return the terminal-local value of SYMBOL on TERMINAL. |
| 1966 | If SYMBOL is not a terminal-local variable, then return its normal | 1961 | If SYMBOL is not a terminal-local variable, then return its normal |
| 1967 | value, like `symbol-value'. | 1962 | value, like `symbol-value'. |
| @@ -1978,7 +1973,8 @@ selected frame's terminal device). */) | |||
| 1978 | return result; | 1973 | return result; |
| 1979 | } | 1974 | } |
| 1980 | 1975 | ||
| 1981 | DEFUN ("set-terminal-local-value", Fset_terminal_local_value, Sset_terminal_local_value, 3, 3, 0, | 1976 | DEFUN ("set-terminal-local-value", Fset_terminal_local_value, |
| 1977 | Sset_terminal_local_value, 3, 3, 0, | ||
| 1982 | doc: /* Set the terminal-local binding of SYMBOL on TERMINAL to VALUE. | 1978 | doc: /* Set the terminal-local binding of SYMBOL on TERMINAL to VALUE. |
| 1983 | If VARIABLE is not a terminal-local variable, then set its normal | 1979 | If VARIABLE is not a terminal-local variable, then set its normal |
| 1984 | binding, like `set'. | 1980 | binding, like `set'. |
| @@ -2101,15 +2097,15 @@ or a byte-code object. IDX starts at 0. */) | |||
| 2101 | { | 2097 | { |
| 2102 | int size = 0; | 2098 | int size = 0; |
| 2103 | if (VECTORP (array)) | 2099 | if (VECTORP (array)) |
| 2104 | size = XVECTOR (array)->size; | 2100 | size = ASIZE (array); |
| 2105 | else if (COMPILEDP (array)) | 2101 | else if (COMPILEDP (array)) |
| 2106 | size = XVECTOR (array)->size & PSEUDOVECTOR_SIZE_MASK; | 2102 | size = ASIZE (array) & PSEUDOVECTOR_SIZE_MASK; |
| 2107 | else | 2103 | else |
| 2108 | wrong_type_argument (Qarrayp, array); | 2104 | wrong_type_argument (Qarrayp, array); |
| 2109 | 2105 | ||
| 2110 | if (idxval < 0 || idxval >= size) | 2106 | if (idxval < 0 || idxval >= size) |
| 2111 | args_out_of_range (array, idx); | 2107 | args_out_of_range (array, idx); |
| 2112 | return XVECTOR (array)->contents[idxval]; | 2108 | return AREF (array, idxval); |
| 2113 | } | 2109 | } |
| 2114 | } | 2110 | } |
| 2115 | 2111 | ||
| @@ -2128,7 +2124,7 @@ bool-vector. IDX starts at 0. */) | |||
| 2128 | 2124 | ||
| 2129 | if (VECTORP (array)) | 2125 | if (VECTORP (array)) |
| 2130 | { | 2126 | { |
| 2131 | if (idxval < 0 || idxval >= XVECTOR (array)->size) | 2127 | if (idxval < 0 || idxval >= ASIZE (array)) |
| 2132 | args_out_of_range (array, idx); | 2128 | args_out_of_range (array, idx); |
| 2133 | XVECTOR (array)->contents[idxval] = newelt; | 2129 | XVECTOR (array)->contents[idxval] = newelt; |
| 2134 | } | 2130 | } |
| @@ -2152,61 +2148,62 @@ bool-vector. IDX starts at 0. */) | |||
| 2152 | CHECK_CHARACTER (idx); | 2148 | CHECK_CHARACTER (idx); |
| 2153 | CHAR_TABLE_SET (array, idxval, newelt); | 2149 | CHAR_TABLE_SET (array, idxval, newelt); |
| 2154 | } | 2150 | } |
| 2155 | else if (STRING_MULTIBYTE (array)) | 2151 | else |
| 2156 | { | 2152 | { |
| 2157 | EMACS_INT idxval_byte, prev_bytes, new_bytes, nbytes; | 2153 | int c; |
| 2158 | unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; | ||
| 2159 | 2154 | ||
| 2160 | if (idxval < 0 || idxval >= SCHARS (array)) | 2155 | if (idxval < 0 || idxval >= SCHARS (array)) |
| 2161 | args_out_of_range (array, idx); | 2156 | args_out_of_range (array, idx); |
| 2162 | CHECK_CHARACTER (newelt); | 2157 | CHECK_CHARACTER (newelt); |
| 2158 | c = XFASTINT (newelt); | ||
| 2163 | 2159 | ||
| 2164 | nbytes = SBYTES (array); | 2160 | if (STRING_MULTIBYTE (array)) |
| 2165 | |||
| 2166 | idxval_byte = string_char_to_byte (array, idxval); | ||
| 2167 | p1 = SDATA (array) + idxval_byte; | ||
| 2168 | prev_bytes = BYTES_BY_CHAR_HEAD (*p1); | ||
| 2169 | new_bytes = CHAR_STRING (XINT (newelt), p0); | ||
| 2170 | if (prev_bytes != new_bytes) | ||
| 2171 | { | 2161 | { |
| 2172 | /* We must relocate the string data. */ | 2162 | EMACS_INT idxval_byte, prev_bytes, new_bytes, nbytes; |
| 2173 | EMACS_INT nchars = SCHARS (array); | 2163 | unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; |
| 2174 | unsigned char *str; | 2164 | |
| 2175 | USE_SAFE_ALLOCA; | 2165 | nbytes = SBYTES (array); |
| 2176 | 2166 | idxval_byte = string_char_to_byte (array, idxval); | |
| 2177 | SAFE_ALLOCA (str, unsigned char *, nbytes); | ||
| 2178 | memcpy (str, SDATA (array), nbytes); | ||
| 2179 | allocate_string_data (XSTRING (array), nchars, | ||
| 2180 | nbytes + new_bytes - prev_bytes); | ||
| 2181 | memcpy (SDATA (array), str, idxval_byte); | ||
| 2182 | p1 = SDATA (array) + idxval_byte; | 2167 | p1 = SDATA (array) + idxval_byte; |
| 2183 | memcpy (p1 + new_bytes, str + idxval_byte + prev_bytes, | 2168 | prev_bytes = BYTES_BY_CHAR_HEAD (*p1); |
| 2184 | nbytes - (idxval_byte + prev_bytes)); | 2169 | new_bytes = CHAR_STRING (c, p0); |
| 2185 | SAFE_FREE (); | 2170 | if (prev_bytes != new_bytes) |
| 2186 | clear_string_char_byte_cache (); | 2171 | { |
| 2172 | /* We must relocate the string data. */ | ||
| 2173 | EMACS_INT nchars = SCHARS (array); | ||
| 2174 | unsigned char *str; | ||
| 2175 | USE_SAFE_ALLOCA; | ||
| 2176 | |||
| 2177 | SAFE_ALLOCA (str, unsigned char *, nbytes); | ||
| 2178 | memcpy (str, SDATA (array), nbytes); | ||
| 2179 | allocate_string_data (XSTRING (array), nchars, | ||
| 2180 | nbytes + new_bytes - prev_bytes); | ||
| 2181 | memcpy (SDATA (array), str, idxval_byte); | ||
| 2182 | p1 = SDATA (array) + idxval_byte; | ||
| 2183 | memcpy (p1 + new_bytes, str + idxval_byte + prev_bytes, | ||
| 2184 | nbytes - (idxval_byte + prev_bytes)); | ||
| 2185 | SAFE_FREE (); | ||
| 2186 | clear_string_char_byte_cache (); | ||
| 2187 | } | ||
| 2188 | while (new_bytes--) | ||
| 2189 | *p1++ = *p0++; | ||
| 2187 | } | 2190 | } |
| 2188 | while (new_bytes--) | 2191 | else |
| 2189 | *p1++ = *p0++; | ||
| 2190 | } | ||
| 2191 | else | ||
| 2192 | { | ||
| 2193 | if (idxval < 0 || idxval >= SCHARS (array)) | ||
| 2194 | args_out_of_range (array, idx); | ||
| 2195 | CHECK_NUMBER (newelt); | ||
| 2196 | |||
| 2197 | if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt))) | ||
| 2198 | { | 2192 | { |
| 2199 | int i; | 2193 | if (! SINGLE_BYTE_CHAR_P (c)) |
| 2200 | 2194 | { | |
| 2201 | for (i = SBYTES (array) - 1; i >= 0; i--) | 2195 | int i; |
| 2202 | if (SREF (array, i) >= 0x80) | 2196 | |
| 2203 | args_out_of_range (array, newelt); | 2197 | for (i = SBYTES (array) - 1; i >= 0; i--) |
| 2204 | /* ARRAY is an ASCII string. Convert it to a multibyte | 2198 | if (SREF (array, i) >= 0x80) |
| 2205 | string, and try `aset' again. */ | 2199 | args_out_of_range (array, newelt); |
| 2206 | STRING_SET_MULTIBYTE (array); | 2200 | /* ARRAY is an ASCII string. Convert it to a multibyte |
| 2207 | return Faset (array, idx, newelt); | 2201 | string, and try `aset' again. */ |
| 2202 | STRING_SET_MULTIBYTE (array); | ||
| 2203 | return Faset (array, idx, newelt); | ||
| 2204 | } | ||
| 2205 | SSET (array, idxval, c); | ||
| 2208 | } | 2206 | } |
| 2209 | SSET (array, idxval, XINT (newelt)); | ||
| 2210 | } | 2207 | } |
| 2211 | 2208 | ||
| 2212 | return newelt; | 2209 | return newelt; |
| @@ -2216,7 +2213,7 @@ bool-vector. IDX starts at 0. */) | |||
| 2216 | 2213 | ||
| 2217 | enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal }; | 2214 | enum comparison { equal, notequal, less, grtr, less_or_equal, grtr_or_equal }; |
| 2218 | 2215 | ||
| 2219 | Lisp_Object | 2216 | static Lisp_Object |
| 2220 | arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison) | 2217 | arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison) |
| 2221 | { | 2218 | { |
| 2222 | double f1 = 0, f2 = 0; | 2219 | double f1 = 0, f2 = 0; |
| @@ -2331,33 +2328,110 @@ DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0, | |||
| 2331 | return Qnil; | 2328 | return Qnil; |
| 2332 | } | 2329 | } |
| 2333 | 2330 | ||
| 2334 | /* Convert between long values and pairs of Lisp integers. | 2331 | /* Convert the cons-of-integers, integer, or float value C to an |
| 2335 | Note that long_to_cons returns a single Lisp integer | 2332 | unsigned value with maximum value MAX. Signal an error if C does not |
| 2336 | when the value fits in one. */ | 2333 | have a valid format or is out of range. */ |
| 2334 | uintmax_t | ||
| 2335 | cons_to_unsigned (Lisp_Object c, uintmax_t max) | ||
| 2336 | { | ||
| 2337 | int valid = 0; | ||
| 2338 | uintmax_t val IF_LINT (= 0); | ||
| 2339 | if (INTEGERP (c)) | ||
| 2340 | { | ||
| 2341 | valid = 0 <= XINT (c); | ||
| 2342 | val = XINT (c); | ||
| 2343 | } | ||
| 2344 | else if (FLOATP (c)) | ||
| 2345 | { | ||
| 2346 | double d = XFLOAT_DATA (c); | ||
| 2347 | if (0 <= d | ||
| 2348 | && d < (max == UINTMAX_MAX ? (double) UINTMAX_MAX + 1 : max + 1)) | ||
| 2349 | { | ||
| 2350 | val = d; | ||
| 2351 | valid = 1; | ||
| 2352 | } | ||
| 2353 | } | ||
| 2354 | else if (CONSP (c) && NATNUMP (XCAR (c))) | ||
| 2355 | { | ||
| 2356 | uintmax_t top = XFASTINT (XCAR (c)); | ||
| 2357 | Lisp_Object rest = XCDR (c); | ||
| 2358 | if (top <= UINTMAX_MAX >> 24 >> 16 | ||
| 2359 | && CONSP (rest) | ||
| 2360 | && NATNUMP (XCAR (rest)) && XFASTINT (XCAR (rest)) < 1 << 24 | ||
| 2361 | && NATNUMP (XCDR (rest)) && XFASTINT (XCDR (rest)) < 1 << 16) | ||
| 2362 | { | ||
| 2363 | uintmax_t mid = XFASTINT (XCAR (rest)); | ||
| 2364 | val = top << 24 << 16 | mid << 16 | XFASTINT (XCDR (rest)); | ||
| 2365 | valid = 1; | ||
| 2366 | } | ||
| 2367 | else if (top <= UINTMAX_MAX >> 16) | ||
| 2368 | { | ||
| 2369 | if (CONSP (rest)) | ||
| 2370 | rest = XCAR (rest); | ||
| 2371 | if (NATNUMP (rest) && XFASTINT (rest) < 1 << 16) | ||
| 2372 | { | ||
| 2373 | val = top << 16 | XFASTINT (rest); | ||
| 2374 | valid = 1; | ||
| 2375 | } | ||
| 2376 | } | ||
| 2377 | } | ||
| 2337 | 2378 | ||
| 2338 | Lisp_Object | 2379 | if (! (valid && val <= max)) |
| 2339 | long_to_cons (long unsigned int i) | 2380 | error ("Not an in-range integer, float, or cons of integers"); |
| 2340 | { | 2381 | return val; |
| 2341 | unsigned long top = i >> 16; | ||
| 2342 | unsigned int bot = i & 0xFFFF; | ||
| 2343 | if (top == 0) | ||
| 2344 | return make_number (bot); | ||
| 2345 | if (top == (unsigned long)-1 >> 16) | ||
| 2346 | return Fcons (make_number (-1), make_number (bot)); | ||
| 2347 | return Fcons (make_number (top), make_number (bot)); | ||
| 2348 | } | 2382 | } |
| 2349 | 2383 | ||
| 2350 | unsigned long | 2384 | /* Convert the cons-of-integers, integer, or float value C to a signed |
| 2351 | cons_to_long (Lisp_Object c) | 2385 | value with extrema MIN and MAX. Signal an error if C does not have |
| 2386 | a valid format or is out of range. */ | ||
| 2387 | intmax_t | ||
| 2388 | cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max) | ||
| 2352 | { | 2389 | { |
| 2353 | Lisp_Object top, bot; | 2390 | int valid = 0; |
| 2391 | intmax_t val IF_LINT (= 0); | ||
| 2354 | if (INTEGERP (c)) | 2392 | if (INTEGERP (c)) |
| 2355 | return XINT (c); | 2393 | { |
| 2356 | top = XCAR (c); | 2394 | val = XINT (c); |
| 2357 | bot = XCDR (c); | 2395 | valid = 1; |
| 2358 | if (CONSP (bot)) | 2396 | } |
| 2359 | bot = XCAR (bot); | 2397 | else if (FLOATP (c)) |
| 2360 | return ((XINT (top) << 16) | XINT (bot)); | 2398 | { |
| 2399 | double d = XFLOAT_DATA (c); | ||
| 2400 | if (min <= d | ||
| 2401 | && d < (max == INTMAX_MAX ? (double) INTMAX_MAX + 1 : max + 1)) | ||
| 2402 | { | ||
| 2403 | val = d; | ||
| 2404 | valid = 1; | ||
| 2405 | } | ||
| 2406 | } | ||
| 2407 | else if (CONSP (c) && INTEGERP (XCAR (c))) | ||
| 2408 | { | ||
| 2409 | intmax_t top = XINT (XCAR (c)); | ||
| 2410 | Lisp_Object rest = XCDR (c); | ||
| 2411 | if (INTMAX_MIN >> 24 >> 16 <= top && top <= INTMAX_MAX >> 24 >> 16 | ||
| 2412 | && CONSP (rest) | ||
| 2413 | && NATNUMP (XCAR (rest)) && XFASTINT (XCAR (rest)) < 1 << 24 | ||
| 2414 | && NATNUMP (XCDR (rest)) && XFASTINT (XCDR (rest)) < 1 << 16) | ||
| 2415 | { | ||
| 2416 | intmax_t mid = XFASTINT (XCAR (rest)); | ||
| 2417 | val = top << 24 << 16 | mid << 16 | XFASTINT (XCDR (rest)); | ||
| 2418 | valid = 1; | ||
| 2419 | } | ||
| 2420 | else if (INTMAX_MIN >> 16 <= top && top <= INTMAX_MAX >> 16) | ||
| 2421 | { | ||
| 2422 | if (CONSP (rest)) | ||
| 2423 | rest = XCAR (rest); | ||
| 2424 | if (NATNUMP (rest) && XFASTINT (rest) < 1 << 16) | ||
| 2425 | { | ||
| 2426 | val = top << 16 | XFASTINT (rest); | ||
| 2427 | valid = 1; | ||
| 2428 | } | ||
| 2429 | } | ||
| 2430 | } | ||
| 2431 | |||
| 2432 | if (! (valid && min <= val && val <= max)) | ||
| 2433 | error ("Not an in-range integer, float, or cons of integers"); | ||
| 2434 | return val; | ||
| 2361 | } | 2435 | } |
| 2362 | 2436 | ||
| 2363 | DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0, | 2437 | DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0, |
| @@ -2378,35 +2452,10 @@ NUMBER may be an integer or a floating point number. */) | |||
| 2378 | return build_string (pigbuf); | 2452 | return build_string (pigbuf); |
| 2379 | } | 2453 | } |
| 2380 | 2454 | ||
| 2381 | if (sizeof (int) == sizeof (EMACS_INT)) | 2455 | sprintf (buffer, "%"pI"d", XINT (number)); |
| 2382 | sprintf (buffer, "%d", (int) XINT (number)); | ||
| 2383 | else if (sizeof (long) == sizeof (EMACS_INT)) | ||
| 2384 | sprintf (buffer, "%ld", (long) XINT (number)); | ||
| 2385 | else | ||
| 2386 | abort (); | ||
| 2387 | return build_string (buffer); | 2456 | return build_string (buffer); |
| 2388 | } | 2457 | } |
| 2389 | 2458 | ||
| 2390 | INLINE static int | ||
| 2391 | digit_to_number (int character, int base) | ||
| 2392 | { | ||
| 2393 | int digit; | ||
| 2394 | |||
| 2395 | if (character >= '0' && character <= '9') | ||
| 2396 | digit = character - '0'; | ||
| 2397 | else if (character >= 'a' && character <= 'z') | ||
| 2398 | digit = character - 'a' + 10; | ||
| 2399 | else if (character >= 'A' && character <= 'Z') | ||
| 2400 | digit = character - 'A' + 10; | ||
| 2401 | else | ||
| 2402 | return -1; | ||
| 2403 | |||
| 2404 | if (digit >= base) | ||
| 2405 | return -1; | ||
| 2406 | else | ||
| 2407 | return digit; | ||
| 2408 | } | ||
| 2409 | |||
| 2410 | DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0, | 2459 | DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0, |
| 2411 | doc: /* Parse STRING as a decimal number and return the number. | 2460 | doc: /* Parse STRING as a decimal number and return the number. |
| 2412 | This parses both integers and floating point numbers. | 2461 | This parses both integers and floating point numbers. |
| @@ -2417,9 +2466,8 @@ present, base 10 is used. BASE must be between 2 and 16 (inclusive). | |||
| 2417 | If the base used is not 10, STRING is always parsed as integer. */) | 2466 | If the base used is not 10, STRING is always parsed as integer. */) |
| 2418 | (register Lisp_Object string, Lisp_Object base) | 2467 | (register Lisp_Object string, Lisp_Object base) |
| 2419 | { | 2468 | { |
| 2420 | register unsigned char *p; | 2469 | register char *p; |
| 2421 | register int b; | 2470 | register int b; |
| 2422 | int sign = 1; | ||
| 2423 | Lisp_Object val; | 2471 | Lisp_Object val; |
| 2424 | 2472 | ||
| 2425 | CHECK_STRING (string); | 2473 | CHECK_STRING (string); |
| @@ -2434,40 +2482,13 @@ If the base used is not 10, STRING is always parsed as integer. */) | |||
| 2434 | xsignal1 (Qargs_out_of_range, base); | 2482 | xsignal1 (Qargs_out_of_range, base); |
| 2435 | } | 2483 | } |
| 2436 | 2484 | ||
| 2437 | /* Skip any whitespace at the front of the number. Some versions of | 2485 | p = SSDATA (string); |
| 2438 | atoi do this anyway, so we might as well make Emacs lisp consistent. */ | ||
| 2439 | p = SDATA (string); | ||
| 2440 | while (*p == ' ' || *p == '\t') | 2486 | while (*p == ' ' || *p == '\t') |
| 2441 | p++; | 2487 | p++; |
| 2442 | 2488 | ||
| 2443 | if (*p == '-') | 2489 | val = string_to_number (p, b, 1); |
| 2444 | { | 2490 | return NILP (val) ? make_number (0) : val; |
| 2445 | sign = -1; | ||
| 2446 | p++; | ||
| 2447 | } | ||
| 2448 | else if (*p == '+') | ||
| 2449 | p++; | ||
| 2450 | |||
| 2451 | if (isfloat_string (p, 1) && b == 10) | ||
| 2452 | val = make_float (sign * atof (p)); | ||
| 2453 | else | ||
| 2454 | { | ||
| 2455 | double v = 0; | ||
| 2456 | |||
| 2457 | while (1) | ||
| 2458 | { | ||
| 2459 | int digit = digit_to_number (*p++, b); | ||
| 2460 | if (digit < 0) | ||
| 2461 | break; | ||
| 2462 | v = v * b + digit; | ||
| 2463 | } | ||
| 2464 | |||
| 2465 | val = make_fixnum_or_float (sign * v); | ||
| 2466 | } | ||
| 2467 | |||
| 2468 | return val; | ||
| 2469 | } | 2491 | } |
| 2470 | |||
| 2471 | 2492 | ||
| 2472 | enum arithop | 2493 | enum arithop |
| 2473 | { | 2494 | { |
| @@ -2482,16 +2503,20 @@ enum arithop | |||
| 2482 | Amin | 2503 | Amin |
| 2483 | }; | 2504 | }; |
| 2484 | 2505 | ||
| 2485 | static Lisp_Object float_arith_driver (double, int, enum arithop, | 2506 | static Lisp_Object float_arith_driver (double, ptrdiff_t, enum arithop, |
| 2486 | int, Lisp_Object *); | 2507 | ptrdiff_t, Lisp_Object *); |
| 2487 | Lisp_Object | 2508 | static Lisp_Object |
| 2488 | arith_driver (enum arithop code, int nargs, register Lisp_Object *args) | 2509 | arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) |
| 2489 | { | 2510 | { |
| 2490 | register Lisp_Object val; | 2511 | register Lisp_Object val; |
| 2491 | register int argnum; | 2512 | ptrdiff_t argnum; |
| 2492 | register EMACS_INT accum = 0; | 2513 | register EMACS_INT accum = 0; |
| 2493 | register EMACS_INT next; | 2514 | register EMACS_INT next; |
| 2494 | 2515 | ||
| 2516 | int overflow = 0; | ||
| 2517 | ptrdiff_t ok_args; | ||
| 2518 | EMACS_INT ok_accum; | ||
| 2519 | |||
| 2495 | switch (SWITCH_ENUM_CAST (code)) | 2520 | switch (SWITCH_ENUM_CAST (code)) |
| 2496 | { | 2521 | { |
| 2497 | case Alogior: | 2522 | case Alogior: |
| @@ -2512,25 +2537,48 @@ arith_driver (enum arithop code, int nargs, register Lisp_Object *args) | |||
| 2512 | 2537 | ||
| 2513 | for (argnum = 0; argnum < nargs; argnum++) | 2538 | for (argnum = 0; argnum < nargs; argnum++) |
| 2514 | { | 2539 | { |
| 2540 | if (! overflow) | ||
| 2541 | { | ||
| 2542 | ok_args = argnum; | ||
| 2543 | ok_accum = accum; | ||
| 2544 | } | ||
| 2545 | |||
| 2515 | /* Using args[argnum] as argument to CHECK_NUMBER_... */ | 2546 | /* Using args[argnum] as argument to CHECK_NUMBER_... */ |
| 2516 | val = args[argnum]; | 2547 | val = args[argnum]; |
| 2517 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val); | 2548 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val); |
| 2518 | 2549 | ||
| 2519 | if (FLOATP (val)) | 2550 | if (FLOATP (val)) |
| 2520 | return float_arith_driver ((double) accum, argnum, code, | 2551 | return float_arith_driver (ok_accum, ok_args, code, |
| 2521 | nargs, args); | 2552 | nargs, args); |
| 2522 | args[argnum] = val; | 2553 | args[argnum] = val; |
| 2523 | next = XINT (args[argnum]); | 2554 | next = XINT (args[argnum]); |
| 2524 | switch (SWITCH_ENUM_CAST (code)) | 2555 | switch (SWITCH_ENUM_CAST (code)) |
| 2525 | { | 2556 | { |
| 2526 | case Aadd: | 2557 | case Aadd: |
| 2558 | if (INT_ADD_OVERFLOW (accum, next)) | ||
| 2559 | { | ||
| 2560 | overflow = 1; | ||
| 2561 | accum &= INTMASK; | ||
| 2562 | } | ||
| 2527 | accum += next; | 2563 | accum += next; |
| 2528 | break; | 2564 | break; |
| 2529 | case Asub: | 2565 | case Asub: |
| 2566 | if (INT_SUBTRACT_OVERFLOW (accum, next)) | ||
| 2567 | { | ||
| 2568 | overflow = 1; | ||
| 2569 | accum &= INTMASK; | ||
| 2570 | } | ||
| 2530 | accum = argnum ? accum - next : nargs == 1 ? - next : next; | 2571 | accum = argnum ? accum - next : nargs == 1 ? - next : next; |
| 2531 | break; | 2572 | break; |
| 2532 | case Amult: | 2573 | case Amult: |
| 2533 | accum *= next; | 2574 | if (INT_MULTIPLY_OVERFLOW (accum, next)) |
| 2575 | { | ||
| 2576 | EMACS_UINT a = accum, b = next, ab = a * b; | ||
| 2577 | overflow = 1; | ||
| 2578 | accum = ab & INTMASK; | ||
| 2579 | } | ||
| 2580 | else | ||
| 2581 | accum *= next; | ||
| 2534 | break; | 2582 | break; |
| 2535 | case Adiv: | 2583 | case Adiv: |
| 2536 | if (!argnum) | 2584 | if (!argnum) |
| @@ -2570,7 +2618,8 @@ arith_driver (enum arithop code, int nargs, register Lisp_Object *args) | |||
| 2570 | #define isnan(x) ((x) != (x)) | 2618 | #define isnan(x) ((x) != (x)) |
| 2571 | 2619 | ||
| 2572 | static Lisp_Object | 2620 | static Lisp_Object |
| 2573 | float_arith_driver (double accum, register int argnum, enum arithop code, int nargs, register Lisp_Object *args) | 2621 | float_arith_driver (double accum, ptrdiff_t argnum, enum arithop code, |
| 2622 | ptrdiff_t nargs, Lisp_Object *args) | ||
| 2574 | { | 2623 | { |
| 2575 | register Lisp_Object val; | 2624 | register Lisp_Object val; |
| 2576 | double next; | 2625 | double next; |
| @@ -2632,7 +2681,7 @@ float_arith_driver (double accum, register int argnum, enum arithop code, int na | |||
| 2632 | DEFUN ("+", Fplus, Splus, 0, MANY, 0, | 2681 | DEFUN ("+", Fplus, Splus, 0, MANY, 0, |
| 2633 | doc: /* Return sum of any number of arguments, which are numbers or markers. | 2682 | doc: /* Return sum of any number of arguments, which are numbers or markers. |
| 2634 | usage: (+ &rest NUMBERS-OR-MARKERS) */) | 2683 | usage: (+ &rest NUMBERS-OR-MARKERS) */) |
| 2635 | (int nargs, Lisp_Object *args) | 2684 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2636 | { | 2685 | { |
| 2637 | return arith_driver (Aadd, nargs, args); | 2686 | return arith_driver (Aadd, nargs, args); |
| 2638 | } | 2687 | } |
| @@ -2642,7 +2691,7 @@ DEFUN ("-", Fminus, Sminus, 0, MANY, 0, | |||
| 2642 | With one arg, negates it. With more than one arg, | 2691 | With one arg, negates it. With more than one arg, |
| 2643 | subtracts all but the first from the first. | 2692 | subtracts all but the first from the first. |
| 2644 | usage: (- &optional NUMBER-OR-MARKER &rest MORE-NUMBERS-OR-MARKERS) */) | 2693 | usage: (- &optional NUMBER-OR-MARKER &rest MORE-NUMBERS-OR-MARKERS) */) |
| 2645 | (int nargs, Lisp_Object *args) | 2694 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2646 | { | 2695 | { |
| 2647 | return arith_driver (Asub, nargs, args); | 2696 | return arith_driver (Asub, nargs, args); |
| 2648 | } | 2697 | } |
| @@ -2650,7 +2699,7 @@ usage: (- &optional NUMBER-OR-MARKER &rest MORE-NUMBERS-OR-MARKERS) */) | |||
| 2650 | DEFUN ("*", Ftimes, Stimes, 0, MANY, 0, | 2699 | DEFUN ("*", Ftimes, Stimes, 0, MANY, 0, |
| 2651 | doc: /* Return product of any number of arguments, which are numbers or markers. | 2700 | doc: /* Return product of any number of arguments, which are numbers or markers. |
| 2652 | usage: (* &rest NUMBERS-OR-MARKERS) */) | 2701 | usage: (* &rest NUMBERS-OR-MARKERS) */) |
| 2653 | (int nargs, Lisp_Object *args) | 2702 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2654 | { | 2703 | { |
| 2655 | return arith_driver (Amult, nargs, args); | 2704 | return arith_driver (Amult, nargs, args); |
| 2656 | } | 2705 | } |
| @@ -2659,9 +2708,9 @@ DEFUN ("/", Fquo, Squo, 2, MANY, 0, | |||
| 2659 | doc: /* Return first argument divided by all the remaining arguments. | 2708 | doc: /* Return first argument divided by all the remaining arguments. |
| 2660 | The arguments must be numbers or markers. | 2709 | The arguments must be numbers or markers. |
| 2661 | usage: (/ DIVIDEND DIVISOR &rest DIVISORS) */) | 2710 | usage: (/ DIVIDEND DIVISOR &rest DIVISORS) */) |
| 2662 | (int nargs, Lisp_Object *args) | 2711 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2663 | { | 2712 | { |
| 2664 | int argnum; | 2713 | ptrdiff_t argnum; |
| 2665 | for (argnum = 2; argnum < nargs; argnum++) | 2714 | for (argnum = 2; argnum < nargs; argnum++) |
| 2666 | if (FLOATP (args[argnum])) | 2715 | if (FLOATP (args[argnum])) |
| 2667 | return float_arith_driver (0, 0, Adiv, nargs, args); | 2716 | return float_arith_driver (0, 0, Adiv, nargs, args); |
| @@ -2743,7 +2792,7 @@ DEFUN ("max", Fmax, Smax, 1, MANY, 0, | |||
| 2743 | doc: /* Return largest of all the arguments (which must be numbers or markers). | 2792 | doc: /* Return largest of all the arguments (which must be numbers or markers). |
| 2744 | The value is always a number; markers are converted to numbers. | 2793 | The value is always a number; markers are converted to numbers. |
| 2745 | usage: (max NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS) */) | 2794 | usage: (max NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS) */) |
| 2746 | (int nargs, Lisp_Object *args) | 2795 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2747 | { | 2796 | { |
| 2748 | return arith_driver (Amax, nargs, args); | 2797 | return arith_driver (Amax, nargs, args); |
| 2749 | } | 2798 | } |
| @@ -2752,7 +2801,7 @@ DEFUN ("min", Fmin, Smin, 1, MANY, 0, | |||
| 2752 | doc: /* Return smallest of all the arguments (which must be numbers or markers). | 2801 | doc: /* Return smallest of all the arguments (which must be numbers or markers). |
| 2753 | The value is always a number; markers are converted to numbers. | 2802 | The value is always a number; markers are converted to numbers. |
| 2754 | usage: (min NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS) */) | 2803 | usage: (min NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS) */) |
| 2755 | (int nargs, Lisp_Object *args) | 2804 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2756 | { | 2805 | { |
| 2757 | return arith_driver (Amin, nargs, args); | 2806 | return arith_driver (Amin, nargs, args); |
| 2758 | } | 2807 | } |
| @@ -2761,7 +2810,7 @@ DEFUN ("logand", Flogand, Slogand, 0, MANY, 0, | |||
| 2761 | doc: /* Return bitwise-and of all the arguments. | 2810 | doc: /* Return bitwise-and of all the arguments. |
| 2762 | Arguments may be integers, or markers converted to integers. | 2811 | Arguments may be integers, or markers converted to integers. |
| 2763 | usage: (logand &rest INTS-OR-MARKERS) */) | 2812 | usage: (logand &rest INTS-OR-MARKERS) */) |
| 2764 | (int nargs, Lisp_Object *args) | 2813 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2765 | { | 2814 | { |
| 2766 | return arith_driver (Alogand, nargs, args); | 2815 | return arith_driver (Alogand, nargs, args); |
| 2767 | } | 2816 | } |
| @@ -2770,7 +2819,7 @@ DEFUN ("logior", Flogior, Slogior, 0, MANY, 0, | |||
| 2770 | doc: /* Return bitwise-or of all the arguments. | 2819 | doc: /* Return bitwise-or of all the arguments. |
| 2771 | Arguments may be integers, or markers converted to integers. | 2820 | Arguments may be integers, or markers converted to integers. |
| 2772 | usage: (logior &rest INTS-OR-MARKERS) */) | 2821 | usage: (logior &rest INTS-OR-MARKERS) */) |
| 2773 | (int nargs, Lisp_Object *args) | 2822 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2774 | { | 2823 | { |
| 2775 | return arith_driver (Alogior, nargs, args); | 2824 | return arith_driver (Alogior, nargs, args); |
| 2776 | } | 2825 | } |
| @@ -2779,7 +2828,7 @@ DEFUN ("logxor", Flogxor, Slogxor, 0, MANY, 0, | |||
| 2779 | doc: /* Return bitwise-exclusive-or of all the arguments. | 2828 | doc: /* Return bitwise-exclusive-or of all the arguments. |
| 2780 | Arguments may be integers, or markers converted to integers. | 2829 | Arguments may be integers, or markers converted to integers. |
| 2781 | usage: (logxor &rest INTS-OR-MARKERS) */) | 2830 | usage: (logxor &rest INTS-OR-MARKERS) */) |
| 2782 | (int nargs, Lisp_Object *args) | 2831 | (ptrdiff_t nargs, Lisp_Object *args) |
| 2783 | { | 2832 | { |
| 2784 | return arith_driver (Alogxor, nargs, args); | 2833 | return arith_driver (Alogxor, nargs, args); |
| 2785 | } | 2834 | } |
| @@ -2820,11 +2869,11 @@ In this case, zeros are shifted in on the left. */) | |||
| 2820 | if (XINT (count) >= BITS_PER_EMACS_INT) | 2869 | if (XINT (count) >= BITS_PER_EMACS_INT) |
| 2821 | XSETINT (val, 0); | 2870 | XSETINT (val, 0); |
| 2822 | else if (XINT (count) > 0) | 2871 | else if (XINT (count) > 0) |
| 2823 | XSETINT (val, (EMACS_UINT) XUINT (value) << XFASTINT (count)); | 2872 | XSETINT (val, XUINT (value) << XFASTINT (count)); |
| 2824 | else if (XINT (count) <= -BITS_PER_EMACS_INT) | 2873 | else if (XINT (count) <= -BITS_PER_EMACS_INT) |
| 2825 | XSETINT (val, 0); | 2874 | XSETINT (val, 0); |
| 2826 | else | 2875 | else |
| 2827 | XSETINT (val, (EMACS_UINT) XUINT (value) >> -XINT (count)); | 2876 | XSETINT (val, XUINT (value) >> -XINT (count)); |
| 2828 | return val; | 2877 | return val; |
| 2829 | } | 2878 | } |
| 2830 | 2879 | ||
| @@ -2884,74 +2933,75 @@ syms_of_data (void) | |||
| 2884 | { | 2933 | { |
| 2885 | Lisp_Object error_tail, arith_tail; | 2934 | Lisp_Object error_tail, arith_tail; |
| 2886 | 2935 | ||
| 2887 | Qquote = intern_c_string ("quote"); | 2936 | DEFSYM (Qquote, "quote"); |
| 2888 | Qlambda = intern_c_string ("lambda"); | 2937 | DEFSYM (Qlambda, "lambda"); |
| 2889 | Qsubr = intern_c_string ("subr"); | 2938 | DEFSYM (Qsubr, "subr"); |
| 2890 | Qerror_conditions = intern_c_string ("error-conditions"); | 2939 | DEFSYM (Qerror_conditions, "error-conditions"); |
| 2891 | Qerror_message = intern_c_string ("error-message"); | 2940 | DEFSYM (Qerror_message, "error-message"); |
| 2892 | Qtop_level = intern_c_string ("top-level"); | 2941 | DEFSYM (Qtop_level, "top-level"); |
| 2893 | 2942 | ||
| 2894 | Qerror = intern_c_string ("error"); | 2943 | DEFSYM (Qerror, "error"); |
| 2895 | Qquit = intern_c_string ("quit"); | 2944 | DEFSYM (Qquit, "quit"); |
| 2896 | Qwrong_type_argument = intern_c_string ("wrong-type-argument"); | 2945 | DEFSYM (Qwrong_type_argument, "wrong-type-argument"); |
| 2897 | Qargs_out_of_range = intern_c_string ("args-out-of-range"); | 2946 | DEFSYM (Qargs_out_of_range, "args-out-of-range"); |
| 2898 | Qvoid_function = intern_c_string ("void-function"); | 2947 | DEFSYM (Qvoid_function, "void-function"); |
| 2899 | Qcyclic_function_indirection = intern_c_string ("cyclic-function-indirection"); | 2948 | DEFSYM (Qcyclic_function_indirection, "cyclic-function-indirection"); |
| 2900 | Qcyclic_variable_indirection = intern_c_string ("cyclic-variable-indirection"); | 2949 | DEFSYM (Qcyclic_variable_indirection, "cyclic-variable-indirection"); |
| 2901 | Qvoid_variable = intern_c_string ("void-variable"); | 2950 | DEFSYM (Qvoid_variable, "void-variable"); |
| 2902 | Qsetting_constant = intern_c_string ("setting-constant"); | 2951 | DEFSYM (Qsetting_constant, "setting-constant"); |
| 2903 | Qinvalid_read_syntax = intern_c_string ("invalid-read-syntax"); | 2952 | DEFSYM (Qinvalid_read_syntax, "invalid-read-syntax"); |
| 2904 | 2953 | ||
| 2905 | Qinvalid_function = intern_c_string ("invalid-function"); | 2954 | DEFSYM (Qinvalid_function, "invalid-function"); |
| 2906 | Qwrong_number_of_arguments = intern_c_string ("wrong-number-of-arguments"); | 2955 | DEFSYM (Qwrong_number_of_arguments, "wrong-number-of-arguments"); |
| 2907 | Qno_catch = intern_c_string ("no-catch"); | 2956 | DEFSYM (Qno_catch, "no-catch"); |
| 2908 | Qend_of_file = intern_c_string ("end-of-file"); | 2957 | DEFSYM (Qend_of_file, "end-of-file"); |
| 2909 | Qarith_error = intern_c_string ("arith-error"); | 2958 | DEFSYM (Qarith_error, "arith-error"); |
| 2910 | Qbeginning_of_buffer = intern_c_string ("beginning-of-buffer"); | 2959 | DEFSYM (Qbeginning_of_buffer, "beginning-of-buffer"); |
| 2911 | Qend_of_buffer = intern_c_string ("end-of-buffer"); | 2960 | DEFSYM (Qend_of_buffer, "end-of-buffer"); |
| 2912 | Qbuffer_read_only = intern_c_string ("buffer-read-only"); | 2961 | DEFSYM (Qbuffer_read_only, "buffer-read-only"); |
| 2913 | Qtext_read_only = intern_c_string ("text-read-only"); | 2962 | DEFSYM (Qtext_read_only, "text-read-only"); |
| 2914 | Qmark_inactive = intern_c_string ("mark-inactive"); | 2963 | DEFSYM (Qmark_inactive, "mark-inactive"); |
| 2915 | 2964 | ||
| 2916 | Qlistp = intern_c_string ("listp"); | 2965 | DEFSYM (Qlistp, "listp"); |
| 2917 | Qconsp = intern_c_string ("consp"); | 2966 | DEFSYM (Qconsp, "consp"); |
| 2918 | Qsymbolp = intern_c_string ("symbolp"); | 2967 | DEFSYM (Qsymbolp, "symbolp"); |
| 2919 | Qkeywordp = intern_c_string ("keywordp"); | 2968 | DEFSYM (Qkeywordp, "keywordp"); |
| 2920 | Qintegerp = intern_c_string ("integerp"); | 2969 | DEFSYM (Qintegerp, "integerp"); |
| 2921 | Qnatnump = intern_c_string ("natnump"); | 2970 | DEFSYM (Qnatnump, "natnump"); |
| 2922 | Qwholenump = intern_c_string ("wholenump"); | 2971 | DEFSYM (Qwholenump, "wholenump"); |
| 2923 | Qstringp = intern_c_string ("stringp"); | 2972 | DEFSYM (Qstringp, "stringp"); |
| 2924 | Qarrayp = intern_c_string ("arrayp"); | 2973 | DEFSYM (Qarrayp, "arrayp"); |
| 2925 | Qsequencep = intern_c_string ("sequencep"); | 2974 | DEFSYM (Qsequencep, "sequencep"); |
| 2926 | Qbufferp = intern_c_string ("bufferp"); | 2975 | DEFSYM (Qbufferp, "bufferp"); |
| 2927 | Qvectorp = intern_c_string ("vectorp"); | 2976 | DEFSYM (Qvectorp, "vectorp"); |
| 2928 | Qchar_or_string_p = intern_c_string ("char-or-string-p"); | 2977 | DEFSYM (Qchar_or_string_p, "char-or-string-p"); |
| 2929 | Qmarkerp = intern_c_string ("markerp"); | 2978 | DEFSYM (Qmarkerp, "markerp"); |
| 2930 | Qbuffer_or_string_p = intern_c_string ("buffer-or-string-p"); | 2979 | DEFSYM (Qbuffer_or_string_p, "buffer-or-string-p"); |
| 2931 | Qinteger_or_marker_p = intern_c_string ("integer-or-marker-p"); | 2980 | DEFSYM (Qinteger_or_marker_p, "integer-or-marker-p"); |
| 2932 | Qboundp = intern_c_string ("boundp"); | 2981 | DEFSYM (Qboundp, "boundp"); |
| 2933 | Qfboundp = intern_c_string ("fboundp"); | 2982 | DEFSYM (Qfboundp, "fboundp"); |
| 2934 | 2983 | ||
| 2935 | Qfloatp = intern_c_string ("floatp"); | 2984 | DEFSYM (Qfloatp, "floatp"); |
| 2936 | Qnumberp = intern_c_string ("numberp"); | 2985 | DEFSYM (Qnumberp, "numberp"); |
| 2937 | Qnumber_or_marker_p = intern_c_string ("number-or-marker-p"); | 2986 | DEFSYM (Qnumber_or_marker_p, "number-or-marker-p"); |
| 2938 | 2987 | ||
| 2939 | Qchar_table_p = intern_c_string ("char-table-p"); | 2988 | DEFSYM (Qchar_table_p, "char-table-p"); |
| 2940 | Qvector_or_char_table_p = intern_c_string ("vector-or-char-table-p"); | 2989 | DEFSYM (Qvector_or_char_table_p, "vector-or-char-table-p"); |
| 2941 | 2990 | ||
| 2942 | Qsubrp = intern_c_string ("subrp"); | 2991 | DEFSYM (Qsubrp, "subrp"); |
| 2943 | Qunevalled = intern_c_string ("unevalled"); | 2992 | DEFSYM (Qunevalled, "unevalled"); |
| 2944 | Qmany = intern_c_string ("many"); | 2993 | DEFSYM (Qmany, "many"); |
| 2945 | 2994 | ||
| 2946 | Qcdr = intern_c_string ("cdr"); | 2995 | DEFSYM (Qcdr, "cdr"); |
| 2947 | 2996 | ||
| 2948 | /* Handle automatic advice activation */ | 2997 | /* Handle automatic advice activation. */ |
| 2949 | Qad_advice_info = intern_c_string ("ad-advice-info"); | 2998 | DEFSYM (Qad_advice_info, "ad-advice-info"); |
| 2950 | Qad_activate_internal = intern_c_string ("ad-activate-internal"); | 2999 | DEFSYM (Qad_activate_internal, "ad-activate-internal"); |
| 2951 | 3000 | ||
| 2952 | error_tail = pure_cons (Qerror, Qnil); | 3001 | error_tail = pure_cons (Qerror, Qnil); |
| 2953 | 3002 | ||
| 2954 | /* ERROR is used as a signaler for random errors for which nothing else is right */ | 3003 | /* ERROR is used as a signaler for random errors for which nothing else is |
| 3004 | right. */ | ||
| 2955 | 3005 | ||
| 2956 | Fput (Qerror, Qerror_conditions, | 3006 | Fput (Qerror, Qerror_conditions, |
| 2957 | error_tail); | 3007 | error_tail); |
| @@ -2988,8 +3038,7 @@ syms_of_data (void) | |||
| 2988 | Fput (Qcyclic_variable_indirection, Qerror_message, | 3038 | Fput (Qcyclic_variable_indirection, Qerror_message, |
| 2989 | make_pure_c_string ("Symbol's chain of variable indirections contains a loop")); | 3039 | make_pure_c_string ("Symbol's chain of variable indirections contains a loop")); |
| 2990 | 3040 | ||
| 2991 | Qcircular_list = intern_c_string ("circular-list"); | 3041 | DEFSYM (Qcircular_list, "circular-list"); |
| 2992 | staticpro (&Qcircular_list); | ||
| 2993 | Fput (Qcircular_list, Qerror_conditions, | 3042 | Fput (Qcircular_list, Qerror_conditions, |
| 2994 | pure_cons (Qcircular_list, error_tail)); | 3043 | pure_cons (Qcircular_list, error_tail)); |
| 2995 | Fput (Qcircular_list, Qerror_message, | 3044 | Fput (Qcircular_list, Qerror_message, |
| @@ -3056,11 +3105,11 @@ syms_of_data (void) | |||
| 3056 | Fput (Qtext_read_only, Qerror_message, | 3105 | Fput (Qtext_read_only, Qerror_message, |
| 3057 | make_pure_c_string ("Text is read-only")); | 3106 | make_pure_c_string ("Text is read-only")); |
| 3058 | 3107 | ||
| 3059 | Qrange_error = intern_c_string ("range-error"); | 3108 | DEFSYM (Qrange_error, "range-error"); |
| 3060 | Qdomain_error = intern_c_string ("domain-error"); | 3109 | DEFSYM (Qdomain_error, "domain-error"); |
| 3061 | Qsingularity_error = intern_c_string ("singularity-error"); | 3110 | DEFSYM (Qsingularity_error, "singularity-error"); |
| 3062 | Qoverflow_error = intern_c_string ("overflow-error"); | 3111 | DEFSYM (Qoverflow_error, "overflow-error"); |
| 3063 | Qunderflow_error = intern_c_string ("underflow-error"); | 3112 | DEFSYM (Qunderflow_error, "underflow-error"); |
| 3064 | 3113 | ||
| 3065 | Fput (Qdomain_error, Qerror_conditions, | 3114 | Fput (Qdomain_error, Qerror_conditions, |
| 3066 | pure_cons (Qdomain_error, arith_tail)); | 3115 | pure_cons (Qdomain_error, arith_tail)); |
| @@ -3087,93 +3136,29 @@ syms_of_data (void) | |||
| 3087 | Fput (Qunderflow_error, Qerror_message, | 3136 | Fput (Qunderflow_error, Qerror_message, |
| 3088 | make_pure_c_string ("Arithmetic underflow error")); | 3137 | make_pure_c_string ("Arithmetic underflow error")); |
| 3089 | 3138 | ||
| 3090 | staticpro (&Qrange_error); | ||
| 3091 | staticpro (&Qdomain_error); | ||
| 3092 | staticpro (&Qsingularity_error); | ||
| 3093 | staticpro (&Qoverflow_error); | ||
| 3094 | staticpro (&Qunderflow_error); | ||
| 3095 | |||
| 3096 | staticpro (&Qnil); | 3139 | staticpro (&Qnil); |
| 3097 | staticpro (&Qt); | 3140 | staticpro (&Qt); |
| 3098 | staticpro (&Qquote); | ||
| 3099 | staticpro (&Qlambda); | ||
| 3100 | staticpro (&Qsubr); | ||
| 3101 | staticpro (&Qunbound); | 3141 | staticpro (&Qunbound); |
| 3102 | staticpro (&Qerror_conditions); | ||
| 3103 | staticpro (&Qerror_message); | ||
| 3104 | staticpro (&Qtop_level); | ||
| 3105 | |||
| 3106 | staticpro (&Qerror); | ||
| 3107 | staticpro (&Qquit); | ||
| 3108 | staticpro (&Qwrong_type_argument); | ||
| 3109 | staticpro (&Qargs_out_of_range); | ||
| 3110 | staticpro (&Qvoid_function); | ||
| 3111 | staticpro (&Qcyclic_function_indirection); | ||
| 3112 | staticpro (&Qcyclic_variable_indirection); | ||
| 3113 | staticpro (&Qvoid_variable); | ||
| 3114 | staticpro (&Qsetting_constant); | ||
| 3115 | staticpro (&Qinvalid_read_syntax); | ||
| 3116 | staticpro (&Qwrong_number_of_arguments); | ||
| 3117 | staticpro (&Qinvalid_function); | ||
| 3118 | staticpro (&Qno_catch); | ||
| 3119 | staticpro (&Qend_of_file); | ||
| 3120 | staticpro (&Qarith_error); | ||
| 3121 | staticpro (&Qbeginning_of_buffer); | ||
| 3122 | staticpro (&Qend_of_buffer); | ||
| 3123 | staticpro (&Qbuffer_read_only); | ||
| 3124 | staticpro (&Qtext_read_only); | ||
| 3125 | staticpro (&Qmark_inactive); | ||
| 3126 | |||
| 3127 | staticpro (&Qlistp); | ||
| 3128 | staticpro (&Qconsp); | ||
| 3129 | staticpro (&Qsymbolp); | ||
| 3130 | staticpro (&Qkeywordp); | ||
| 3131 | staticpro (&Qintegerp); | ||
| 3132 | staticpro (&Qnatnump); | ||
| 3133 | staticpro (&Qwholenump); | ||
| 3134 | staticpro (&Qstringp); | ||
| 3135 | staticpro (&Qarrayp); | ||
| 3136 | staticpro (&Qsequencep); | ||
| 3137 | staticpro (&Qbufferp); | ||
| 3138 | staticpro (&Qvectorp); | ||
| 3139 | staticpro (&Qchar_or_string_p); | ||
| 3140 | staticpro (&Qmarkerp); | ||
| 3141 | staticpro (&Qbuffer_or_string_p); | ||
| 3142 | staticpro (&Qinteger_or_marker_p); | ||
| 3143 | staticpro (&Qfloatp); | ||
| 3144 | staticpro (&Qnumberp); | ||
| 3145 | staticpro (&Qnumber_or_marker_p); | ||
| 3146 | staticpro (&Qchar_table_p); | ||
| 3147 | staticpro (&Qvector_or_char_table_p); | ||
| 3148 | staticpro (&Qsubrp); | ||
| 3149 | staticpro (&Qmany); | ||
| 3150 | staticpro (&Qunevalled); | ||
| 3151 | |||
| 3152 | staticpro (&Qboundp); | ||
| 3153 | staticpro (&Qfboundp); | ||
| 3154 | staticpro (&Qcdr); | ||
| 3155 | staticpro (&Qad_advice_info); | ||
| 3156 | staticpro (&Qad_activate_internal); | ||
| 3157 | 3142 | ||
| 3158 | /* Types that type-of returns. */ | 3143 | /* Types that type-of returns. */ |
| 3159 | Qinteger = intern_c_string ("integer"); | 3144 | DEFSYM (Qinteger, "integer"); |
| 3160 | Qsymbol = intern_c_string ("symbol"); | 3145 | DEFSYM (Qsymbol, "symbol"); |
| 3161 | Qstring = intern_c_string ("string"); | 3146 | DEFSYM (Qstring, "string"); |
| 3162 | Qcons = intern_c_string ("cons"); | 3147 | DEFSYM (Qcons, "cons"); |
| 3163 | Qmarker = intern_c_string ("marker"); | 3148 | DEFSYM (Qmarker, "marker"); |
| 3164 | Qoverlay = intern_c_string ("overlay"); | 3149 | DEFSYM (Qoverlay, "overlay"); |
| 3165 | Qfloat = intern_c_string ("float"); | 3150 | DEFSYM (Qfloat, "float"); |
| 3166 | Qwindow_configuration = intern_c_string ("window-configuration"); | 3151 | DEFSYM (Qwindow_configuration, "window-configuration"); |
| 3167 | Qprocess = intern_c_string ("process"); | 3152 | DEFSYM (Qprocess, "process"); |
| 3168 | Qwindow = intern_c_string ("window"); | 3153 | DEFSYM (Qwindow, "window"); |
| 3169 | /* Qsubr = intern_c_string ("subr"); */ | 3154 | /* DEFSYM (Qsubr, "subr"); */ |
| 3170 | Qcompiled_function = intern_c_string ("compiled-function"); | 3155 | DEFSYM (Qcompiled_function, "compiled-function"); |
| 3171 | Qbuffer = intern_c_string ("buffer"); | 3156 | DEFSYM (Qbuffer, "buffer"); |
| 3172 | Qframe = intern_c_string ("frame"); | 3157 | DEFSYM (Qframe, "frame"); |
| 3173 | Qvector = intern_c_string ("vector"); | 3158 | DEFSYM (Qvector, "vector"); |
| 3174 | Qchar_table = intern_c_string ("char-table"); | 3159 | DEFSYM (Qchar_table, "char-table"); |
| 3175 | Qbool_vector = intern_c_string ("bool-vector"); | 3160 | DEFSYM (Qbool_vector, "bool-vector"); |
| 3176 | Qhash_table = intern_c_string ("hash-table"); | 3161 | DEFSYM (Qhash_table, "hash-table"); |
| 3177 | 3162 | ||
| 3178 | DEFSYM (Qfont_spec, "font-spec"); | 3163 | DEFSYM (Qfont_spec, "font-spec"); |
| 3179 | DEFSYM (Qfont_entity, "font-entity"); | 3164 | DEFSYM (Qfont_entity, "font-entity"); |
| @@ -3181,25 +3166,6 @@ syms_of_data (void) | |||
| 3181 | 3166 | ||
| 3182 | DEFSYM (Qinteractive_form, "interactive-form"); | 3167 | DEFSYM (Qinteractive_form, "interactive-form"); |
| 3183 | 3168 | ||
| 3184 | staticpro (&Qinteger); | ||
| 3185 | staticpro (&Qsymbol); | ||
| 3186 | staticpro (&Qstring); | ||
| 3187 | staticpro (&Qcons); | ||
| 3188 | staticpro (&Qmarker); | ||
| 3189 | staticpro (&Qoverlay); | ||
| 3190 | staticpro (&Qfloat); | ||
| 3191 | staticpro (&Qwindow_configuration); | ||
| 3192 | staticpro (&Qprocess); | ||
| 3193 | staticpro (&Qwindow); | ||
| 3194 | /* staticpro (&Qsubr); */ | ||
| 3195 | staticpro (&Qcompiled_function); | ||
| 3196 | staticpro (&Qbuffer); | ||
| 3197 | staticpro (&Qframe); | ||
| 3198 | staticpro (&Qvector); | ||
| 3199 | staticpro (&Qchar_table); | ||
| 3200 | staticpro (&Qbool_vector); | ||
| 3201 | staticpro (&Qhash_table); | ||
| 3202 | |||
| 3203 | defsubr (&Sindirect_variable); | 3169 | defsubr (&Sindirect_variable); |
| 3204 | defsubr (&Sinteractive_form); | 3170 | defsubr (&Sinteractive_form); |
| 3205 | defsubr (&Seq); | 3171 | defsubr (&Seq); |
| @@ -3308,7 +3274,11 @@ syms_of_data (void) | |||
| 3308 | XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; | 3274 | XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; |
| 3309 | } | 3275 | } |
| 3310 | 3276 | ||
| 3311 | SIGTYPE | 3277 | #ifndef FORWARD_SIGNAL_TO_MAIN_THREAD |
| 3278 | static void arith_error (int) NO_RETURN; | ||
| 3279 | #endif | ||
| 3280 | |||
| 3281 | static void | ||
| 3312 | arith_error (int signo) | 3282 | arith_error (int signo) |
| 3313 | { | 3283 | { |
| 3314 | sigsetmask (SIGEMPTYMASK); | 3284 | sigsetmask (SIGEMPTYMASK); |
| @@ -3329,9 +3299,4 @@ init_data (void) | |||
| 3329 | return; | 3299 | return; |
| 3330 | #endif /* CANNOT_DUMP */ | 3300 | #endif /* CANNOT_DUMP */ |
| 3331 | signal (SIGFPE, arith_error); | 3301 | signal (SIGFPE, arith_error); |
| 3332 | |||
| 3333 | #ifdef uts | ||
| 3334 | signal (SIGEMT, arith_error); | ||
| 3335 | #endif /* uts */ | ||
| 3336 | } | 3302 | } |
| 3337 | |||