diff options
| author | Paul Eggert | 2011-09-03 16:03:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-09-03 16:03:38 -0700 |
| commit | b49e353d9d01adbe60bc5d0b1658b4ef978b0b06 (patch) | |
| tree | 9f2ffa6f7a6562abf661a4951012b488ad8b1ae7 /src/eval.c | |
| parent | 74b880cbc18bd0194c7b1fc44c4a983ee05adae2 (diff) | |
| parent | bc3200871917d5c54c8c4299a06bf8f8ba2ea02d (diff) | |
| download | emacs-b49e353d9d01adbe60bc5d0b1658b4ef978b0b06.tar.gz emacs-b49e353d9d01adbe60bc5d0b1658b4ef978b0b06.zip | |
Merge from trunk.
Diffstat (limited to 'src/eval.c')
| -rw-r--r-- | src/eval.c | 65 |
1 files changed, 25 insertions, 40 deletions
diff --git a/src/eval.c b/src/eval.c index ef169e80e27..e722b53fb72 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -133,8 +133,9 @@ static Lisp_Object Ffetch_bytecode (Lisp_Object); | |||
| 133 | void | 133 | void |
| 134 | init_eval_once (void) | 134 | init_eval_once (void) |
| 135 | { | 135 | { |
| 136 | specpdl_size = 50; | 136 | enum { size = 50 }; |
| 137 | specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); | 137 | specpdl = (struct specbinding *) xmalloc (size * sizeof (struct specbinding)); |
| 138 | specpdl_size = size; | ||
| 138 | specpdl_ptr = specpdl; | 139 | specpdl_ptr = specpdl; |
| 139 | /* Don't forget to update docs (lispref node "Local Variables"). */ | 140 | /* Don't forget to update docs (lispref node "Local Variables"). */ |
| 140 | max_specpdl_size = 1300; /* 1000 is not enough for CEDET's c-by.el. */ | 141 | max_specpdl_size = 1300; /* 1000 is not enough for CEDET's c-by.el. */ |
| @@ -192,7 +193,7 @@ call_debugger (Lisp_Object arg) | |||
| 192 | if (lisp_eval_depth + 40 > max_lisp_eval_depth) | 193 | if (lisp_eval_depth + 40 > max_lisp_eval_depth) |
| 193 | max_lisp_eval_depth = lisp_eval_depth + 40; | 194 | max_lisp_eval_depth = lisp_eval_depth + 40; |
| 194 | 195 | ||
| 195 | if (SPECPDL_INDEX () + 100 > max_specpdl_size) | 196 | if (max_specpdl_size - 100 < SPECPDL_INDEX ()) |
| 196 | max_specpdl_size = SPECPDL_INDEX () + 100; | 197 | max_specpdl_size = SPECPDL_INDEX () + 100; |
| 197 | 198 | ||
| 198 | #ifdef HAVE_WINDOW_SYSTEM | 199 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -1357,8 +1358,12 @@ A handler is applicable to an error | |||
| 1357 | if CONDITION-NAME is one of the error's condition names. | 1358 | if CONDITION-NAME is one of the error's condition names. |
| 1358 | If an error happens, the first applicable handler is run. | 1359 | If an error happens, the first applicable handler is run. |
| 1359 | 1360 | ||
| 1360 | The car of a handler may be a list of condition names | 1361 | The car of a handler may be a list of condition names instead of a |
| 1361 | instead of a single condition name. Then it handles all of them. | 1362 | single condition name; then it handles all of them. If the special |
| 1363 | condition name `debug' is present in this list, it allows another | ||
| 1364 | condition in the list to run the debugger if `debug-on-error' and the | ||
| 1365 | other usual mechanisms says it should (otherwise, `condition-case' | ||
| 1366 | suppresses the debugger). | ||
| 1362 | 1367 | ||
| 1363 | When a handler handles an error, control returns to the `condition-case' | 1368 | When a handler handles an error, control returns to the `condition-case' |
| 1364 | and it executes the handler's BODY... | 1369 | and it executes the handler's BODY... |
| @@ -1461,13 +1466,6 @@ internal_condition_case (Lisp_Object (*bfun) (void), Lisp_Object handlers, | |||
| 1461 | struct catchtag c; | 1466 | struct catchtag c; |
| 1462 | struct handler h; | 1467 | struct handler h; |
| 1463 | 1468 | ||
| 1464 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1465 | we will get the wrong results if some are not closed now. */ | ||
| 1466 | #if HAVE_X_WINDOWS | ||
| 1467 | if (x_catching_errors ()) | ||
| 1468 | abort (); | ||
| 1469 | #endif | ||
| 1470 | |||
| 1471 | c.tag = Qnil; | 1469 | c.tag = Qnil; |
| 1472 | c.val = Qnil; | 1470 | c.val = Qnil; |
| 1473 | c.backlist = backtrace_list; | 1471 | c.backlist = backtrace_list; |
| @@ -1506,13 +1504,6 @@ internal_condition_case_1 (Lisp_Object (*bfun) (Lisp_Object), Lisp_Object arg, | |||
| 1506 | struct catchtag c; | 1504 | struct catchtag c; |
| 1507 | struct handler h; | 1505 | struct handler h; |
| 1508 | 1506 | ||
| 1509 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1510 | we will get the wrong results if some are not closed now. */ | ||
| 1511 | #if HAVE_X_WINDOWS | ||
| 1512 | if (x_catching_errors ()) | ||
| 1513 | abort (); | ||
| 1514 | #endif | ||
| 1515 | |||
| 1516 | c.tag = Qnil; | 1507 | c.tag = Qnil; |
| 1517 | c.val = Qnil; | 1508 | c.val = Qnil; |
| 1518 | c.backlist = backtrace_list; | 1509 | c.backlist = backtrace_list; |
| @@ -1555,13 +1546,6 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object), | |||
| 1555 | struct catchtag c; | 1546 | struct catchtag c; |
| 1556 | struct handler h; | 1547 | struct handler h; |
| 1557 | 1548 | ||
| 1558 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1559 | we will get the wrong results if some are not closed now. */ | ||
| 1560 | #if HAVE_X_WINDOWS | ||
| 1561 | if (x_catching_errors ()) | ||
| 1562 | abort (); | ||
| 1563 | #endif | ||
| 1564 | |||
| 1565 | c.tag = Qnil; | 1549 | c.tag = Qnil; |
| 1566 | c.val = Qnil; | 1550 | c.val = Qnil; |
| 1567 | c.backlist = backtrace_list; | 1551 | c.backlist = backtrace_list; |
| @@ -1604,13 +1588,6 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), | |||
| 1604 | struct catchtag c; | 1588 | struct catchtag c; |
| 1605 | struct handler h; | 1589 | struct handler h; |
| 1606 | 1590 | ||
| 1607 | /* Since Fsignal will close off all calls to x_catch_errors, | ||
| 1608 | we will get the wrong results if some are not closed now. */ | ||
| 1609 | #if HAVE_X_WINDOWS | ||
| 1610 | if (x_catching_errors ()) | ||
| 1611 | abort (); | ||
| 1612 | #endif | ||
| 1613 | |||
| 1614 | c.tag = Qnil; | 1591 | c.tag = Qnil; |
| 1615 | c.val = Qnil; | 1592 | c.val = Qnil; |
| 1616 | c.backlist = backtrace_list; | 1593 | c.backlist = backtrace_list; |
| @@ -1727,6 +1704,10 @@ See also the function `condition-case'. */) | |||
| 1727 | && (!NILP (Vdebug_on_signal) | 1704 | && (!NILP (Vdebug_on_signal) |
| 1728 | /* If no handler is present now, try to run the debugger. */ | 1705 | /* If no handler is present now, try to run the debugger. */ |
| 1729 | || NILP (clause) | 1706 | || NILP (clause) |
| 1707 | /* A `debug' symbol in the handler list disables the normal | ||
| 1708 | suppression of the debugger. */ | ||
| 1709 | || (CONSP (clause) && CONSP (XCAR (clause)) | ||
| 1710 | && !NILP (Fmemq (Qdebug, XCAR (clause)))) | ||
| 1730 | /* Special handler that means "print a message and run debugger | 1711 | /* Special handler that means "print a message and run debugger |
| 1731 | if requested". */ | 1712 | if requested". */ |
| 1732 | || EQ (h->handler, Qerror))) | 1713 | || EQ (h->handler, Qerror))) |
| @@ -3274,17 +3255,21 @@ static void | |||
| 3274 | grow_specpdl (void) | 3255 | grow_specpdl (void) |
| 3275 | { | 3256 | { |
| 3276 | register int count = SPECPDL_INDEX (); | 3257 | register int count = SPECPDL_INDEX (); |
| 3277 | if (specpdl_size >= max_specpdl_size) | 3258 | int max_size = |
| 3259 | min (max_specpdl_size, | ||
| 3260 | min (max (PTRDIFF_MAX, SIZE_MAX) / sizeof (struct specbinding), | ||
| 3261 | INT_MAX)); | ||
| 3262 | int size; | ||
| 3263 | if (max_size <= specpdl_size) | ||
| 3278 | { | 3264 | { |
| 3279 | if (max_specpdl_size < 400) | 3265 | if (max_specpdl_size < 400) |
| 3280 | max_specpdl_size = 400; | 3266 | max_size = max_specpdl_size = 400; |
| 3281 | if (specpdl_size >= max_specpdl_size) | 3267 | if (max_size <= specpdl_size) |
| 3282 | signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); | 3268 | signal_error ("Variable binding depth exceeds max-specpdl-size", Qnil); |
| 3283 | } | 3269 | } |
| 3284 | specpdl_size *= 2; | 3270 | size = specpdl_size < max_size / 2 ? 2 * specpdl_size : max_size; |
| 3285 | if (specpdl_size > max_specpdl_size) | 3271 | specpdl = xnrealloc (specpdl, size, sizeof *specpdl); |
| 3286 | specpdl_size = max_specpdl_size; | 3272 | specpdl_size = size; |
| 3287 | specpdl = (struct specbinding *) xrealloc (specpdl, specpdl_size * sizeof (struct specbinding)); | ||
| 3288 | specpdl_ptr = specpdl + count; | 3273 | specpdl_ptr = specpdl + count; |
| 3289 | } | 3274 | } |
| 3290 | 3275 | ||