aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c77
1 files changed, 25 insertions, 52 deletions
diff --git a/src/data.c b/src/data.c
index d2f4d40d7bc..9d7e7effdcd 100644
--- a/src/data.c
+++ b/src/data.c
@@ -683,7 +683,7 @@ global value outside of any lexical scope. */)
683 switch (sym->u.s.redirect) 683 switch (sym->u.s.redirect)
684 { 684 {
685 case SYMBOL_PLAINVAL: valcontents = SYMBOL_VAL (sym); break; 685 case SYMBOL_PLAINVAL: valcontents = SYMBOL_VAL (sym); break;
686 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 686 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
687 case SYMBOL_LOCALIZED: 687 case SYMBOL_LOCALIZED:
688 { 688 {
689 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); 689 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
@@ -773,7 +773,10 @@ DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0,
773} 773}
774 774
775DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0, 775DEFUN ("symbol-name", Fsymbol_name, Ssymbol_name, 1, 1, 0,
776 doc: /* Return SYMBOL's name, a string. */) 776 doc: /* Return SYMBOL's name, a string.
777
778Warning: never alter the string returned by `symbol-name'.
779Doing that might make Emacs dysfunctional, and might even crash Emacs. */)
777 (register Lisp_Object symbol) 780 (register Lisp_Object symbol)
778{ 781{
779 register Lisp_Object name; 782 register Lisp_Object name;
@@ -1246,51 +1249,20 @@ The value, if non-nil, is a list of mode name symbols. */)
1246 Getting and Setting Values of Symbols 1249 Getting and Setting Values of Symbols
1247 ***********************************************************************/ 1250 ***********************************************************************/
1248 1251
1249/* Return the symbol holding SYMBOL's value. Signal
1250 `cyclic-variable-indirection' if SYMBOL's chain of variable
1251 indirections contains a loop. */
1252
1253struct Lisp_Symbol *
1254indirect_variable (struct Lisp_Symbol *symbol)
1255{
1256 struct Lisp_Symbol *tortoise, *hare;
1257
1258 hare = tortoise = symbol;
1259
1260 while (hare->u.s.redirect == SYMBOL_VARALIAS)
1261 {
1262 hare = SYMBOL_ALIAS (hare);
1263 if (hare->u.s.redirect != SYMBOL_VARALIAS)
1264 break;
1265
1266 hare = SYMBOL_ALIAS (hare);
1267 tortoise = SYMBOL_ALIAS (tortoise);
1268
1269 if (hare == tortoise)
1270 {
1271 Lisp_Object tem;
1272 XSETSYMBOL (tem, symbol);
1273 xsignal1 (Qcyclic_variable_indirection, tem);
1274 }
1275 }
1276
1277 return hare;
1278}
1279
1280
1281DEFUN ("indirect-variable", Findirect_variable, Sindirect_variable, 1, 1, 0, 1252DEFUN ("indirect-variable", Findirect_variable, Sindirect_variable, 1, 1, 0,
1282 doc: /* Return the variable at the end of OBJECT's variable chain. 1253 doc: /* Return the variable at the end of OBJECT's variable chain.
1283If OBJECT is a symbol, follow its variable indirections (if any), and 1254If OBJECT is a symbol, follow its variable indirections (if any), and
1284return the variable at the end of the chain of aliases. See Info node 1255return the variable at the end of the chain of aliases. See Info node
1285`(elisp)Variable Aliases'. 1256`(elisp)Variable Aliases'.
1286 1257
1287If OBJECT is not a symbol, just return it. If there is a loop in the 1258If OBJECT is not a symbol, just return it. */)
1288chain of aliases, signal a `cyclic-variable-indirection' error. */)
1289 (Lisp_Object object) 1259 (Lisp_Object object)
1290{ 1260{
1291 if (SYMBOLP (object)) 1261 if (SYMBOLP (object))
1292 { 1262 {
1293 struct Lisp_Symbol *sym = indirect_variable (XSYMBOL (object)); 1263 struct Lisp_Symbol *sym = XSYMBOL (object);
1264 while (sym->u.s.redirect == SYMBOL_VARALIAS)
1265 sym = SYMBOL_ALIAS (sym);
1294 XSETSYMBOL (object, sym); 1266 XSETSYMBOL (object, sym);
1295 } 1267 }
1296 return object; 1268 return object;
@@ -1579,7 +1551,7 @@ find_symbol_value (Lisp_Object symbol)
1579 start: 1551 start:
1580 switch (sym->u.s.redirect) 1552 switch (sym->u.s.redirect)
1581 { 1553 {
1582 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 1554 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
1583 case SYMBOL_PLAINVAL: return SYMBOL_VAL (sym); 1555 case SYMBOL_PLAINVAL: return SYMBOL_VAL (sym);
1584 case SYMBOL_LOCALIZED: 1556 case SYMBOL_LOCALIZED:
1585 { 1557 {
@@ -1668,7 +1640,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1668 start: 1640 start:
1669 switch (sym->u.s.redirect) 1641 switch (sym->u.s.redirect)
1670 { 1642 {
1671 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 1643 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
1672 case SYMBOL_PLAINVAL: SET_SYMBOL_VAL (sym , newval); return; 1644 case SYMBOL_PLAINVAL: SET_SYMBOL_VAL (sym , newval); return;
1673 case SYMBOL_LOCALIZED: 1645 case SYMBOL_LOCALIZED:
1674 { 1646 {
@@ -1922,7 +1894,7 @@ default_value (Lisp_Object symbol)
1922 start: 1894 start:
1923 switch (sym->u.s.redirect) 1895 switch (sym->u.s.redirect)
1924 { 1896 {
1925 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 1897 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
1926 case SYMBOL_PLAINVAL: return SYMBOL_VAL (sym); 1898 case SYMBOL_PLAINVAL: return SYMBOL_VAL (sym);
1927 case SYMBOL_LOCALIZED: 1899 case SYMBOL_LOCALIZED:
1928 { 1900 {
@@ -2016,7 +1988,7 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
2016 start: 1988 start:
2017 switch (sym->u.s.redirect) 1989 switch (sym->u.s.redirect)
2018 { 1990 {
2019 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 1991 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
2020 case SYMBOL_PLAINVAL: set_internal (symbol, value, Qnil, bindflag); return; 1992 case SYMBOL_PLAINVAL: set_internal (symbol, value, Qnil, bindflag); return;
2021 case SYMBOL_LOCALIZED: 1993 case SYMBOL_LOCALIZED:
2022 { 1994 {
@@ -2154,7 +2126,7 @@ See also `defvar-local'. */)
2154 start: 2126 start:
2155 switch (sym->u.s.redirect) 2127 switch (sym->u.s.redirect)
2156 { 2128 {
2157 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 2129 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
2158 case SYMBOL_PLAINVAL: 2130 case SYMBOL_PLAINVAL:
2159 forwarded = 0; valcontents.value = SYMBOL_VAL (sym); 2131 forwarded = 0; valcontents.value = SYMBOL_VAL (sym);
2160 if (BASE_EQ (valcontents.value, Qunbound)) 2132 if (BASE_EQ (valcontents.value, Qunbound))
@@ -2222,7 +2194,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
2222 start: 2194 start:
2223 switch (sym->u.s.redirect) 2195 switch (sym->u.s.redirect)
2224 { 2196 {
2225 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 2197 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
2226 case SYMBOL_PLAINVAL: 2198 case SYMBOL_PLAINVAL:
2227 forwarded = 0; valcontents.value = SYMBOL_VAL (sym); break; 2199 forwarded = 0; valcontents.value = SYMBOL_VAL (sym); break;
2228 case SYMBOL_LOCALIZED: 2200 case SYMBOL_LOCALIZED:
@@ -2308,7 +2280,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
2308 start: 2280 start:
2309 switch (sym->u.s.redirect) 2281 switch (sym->u.s.redirect)
2310 { 2282 {
2311 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 2283 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
2312 case SYMBOL_PLAINVAL: return variable; 2284 case SYMBOL_PLAINVAL: return variable;
2313 case SYMBOL_FORWARDED: 2285 case SYMBOL_FORWARDED:
2314 { 2286 {
@@ -2375,7 +2347,7 @@ Also see `buffer-local-boundp'.*/)
2375 start: 2347 start:
2376 switch (sym->u.s.redirect) 2348 switch (sym->u.s.redirect)
2377 { 2349 {
2378 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 2350 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
2379 case SYMBOL_PLAINVAL: return Qnil; 2351 case SYMBOL_PLAINVAL: return Qnil;
2380 case SYMBOL_LOCALIZED: 2352 case SYMBOL_LOCALIZED:
2381 { 2353 {
@@ -2425,7 +2397,7 @@ value in BUFFER, or if VARIABLE is automatically buffer-local (see
2425 start: 2397 start:
2426 switch (sym->u.s.redirect) 2398 switch (sym->u.s.redirect)
2427 { 2399 {
2428 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 2400 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
2429 case SYMBOL_PLAINVAL: return Qnil; 2401 case SYMBOL_PLAINVAL: return Qnil;
2430 case SYMBOL_LOCALIZED: 2402 case SYMBOL_LOCALIZED:
2431 { 2403 {
@@ -2460,7 +2432,7 @@ If the current binding is global (the default), the value is nil. */)
2460 start: 2432 start:
2461 switch (sym->u.s.redirect) 2433 switch (sym->u.s.redirect)
2462 { 2434 {
2463 case SYMBOL_VARALIAS: sym = indirect_variable (sym); goto start; 2435 case SYMBOL_VARALIAS: sym = SYMBOL_ALIAS (sym); goto start;
2464 case SYMBOL_PLAINVAL: return Qnil; 2436 case SYMBOL_PLAINVAL: return Qnil;
2465 case SYMBOL_FORWARDED: 2437 case SYMBOL_FORWARDED:
2466 { 2438 {
@@ -3218,9 +3190,9 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args,
3218 intmax_t a; 3190 intmax_t a;
3219 switch (code) 3191 switch (code)
3220 { 3192 {
3221 case Aadd : overflow = INT_ADD_WRAPV (accum, next, &a); break; 3193 case Aadd : overflow = ckd_add (&a, accum, next); break;
3222 case Amult: overflow = INT_MULTIPLY_WRAPV (accum, next, &a); break; 3194 case Amult: overflow = ckd_mul (&a, accum, next); break;
3223 case Asub : overflow = INT_SUBTRACT_WRAPV (accum, next, &a); break; 3195 case Asub : overflow = ckd_sub (&a, accum, next); break;
3224 case Adiv: 3196 case Adiv:
3225 if (next == 0) 3197 if (next == 0)
3226 xsignal0 (Qarith_error); 3198 xsignal0 (Qarith_error);
@@ -4214,10 +4186,11 @@ syms_of_data (void)
4214 Fput (Qrecursion_error, Qerror_message, build_pure_c_string 4186 Fput (Qrecursion_error, Qerror_message, build_pure_c_string
4215 ("Excessive recursive calling error")); 4187 ("Excessive recursive calling error"));
4216 4188
4217 PUT_ERROR (Qexcessive_variable_binding, recursion_tail,
4218 "Variable binding depth exceeds max-specpdl-size");
4219 PUT_ERROR (Qexcessive_lisp_nesting, recursion_tail, 4189 PUT_ERROR (Qexcessive_lisp_nesting, recursion_tail,
4220 "Lisp nesting exceeds `max-lisp-eval-depth'"); 4190 "Lisp nesting exceeds `max-lisp-eval-depth'");
4191 /* Error obsolete (from 29.1), kept for compatibility. */
4192 PUT_ERROR (Qexcessive_variable_binding, recursion_tail,
4193 "Variable binding depth exceeds max-specpdl-size");
4221 4194
4222 /* Types that type-of returns. */ 4195 /* Types that type-of returns. */
4223 DEFSYM (Qinteger, "integer"); 4196 DEFSYM (Qinteger, "integer");