diff options
| author | Mattias EngdegÄrd | 2022-09-19 10:55:09 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-09-19 19:30:03 +0200 |
| commit | 60102016e416e5c19fa5945aeb80693dac7ff2e6 (patch) | |
| tree | 69979ff773d7031634e7bc4f4388abc4ae104717 /lisp/net/shr.el | |
| parent | a7c65fc6660878e244432a5b25fb3a4ff20e8604 (diff) | |
| download | emacs-60102016e416e5c19fa5945aeb80693dac7ff2e6.tar.gz emacs-60102016e416e5c19fa5945aeb80693dac7ff2e6.zip | |
Abolish max-specpdl-size (bug#57911)
The max-lisp-eval-depth limit is sufficient to prevent unbounded stack
growth including the specbind stack; simplify matters for the user by
not having them to worry about two different limits. This change
turns max-specpdl-size into a harmless variable with no effects,
to keep existing code happy.
* lisp/subr.el (max-specpdl-size):
Define as an ordinary (but obsolete) dynamic variable.
* admin/grammars/Makefile.in:
* doc/lispintro/emacs-lisp-intro.texi (Loops & Recursion):
* doc/lispref/control.texi (Cleanups):
* doc/lispref/edebug.texi (Checking Whether to Stop):
* doc/lispref/eval.texi (Eval):
* doc/lispref/variables.texi (Local Variables):
* doc/misc/calc.texi (Recursion Depth):
Update documentation.
* etc/NEWS: Announce.
* src/eval.c
(FletX): Use safe iteration to guard against circular bindings list.
(syms_of_eval): Remove old max-specpdl-size definition.
(init_eval_once, restore_stack_limits, call_debugger)
(signal_or_quit, grow_specpdl_allocation):
* leim/Makefile.in:
* lisp/Makefile.in:
* lisp/calc/calc-stuff.el (calc-more-recursion-depth)
(calc-less-recursion-depth):
* lisp/calc/calc.el (calc-do):
* lisp/cedet/semantic/ede-grammar.el (ede-proj-makefile-insert-rules):
* lisp/cedet/semantic/grammar.el (semantic-grammar-batch-build-one-package):
* lisp/cus-start.el (standard):
* lisp/emacs-lisp/comp.el (comp--native-compile):
* lisp/emacs-lisp/edebug.el (edebug-max-depth):
(edebug-read-and-maybe-wrap-form, edebug-default-enter):
* lisp/emacs-lisp/regexp-opt.el (regexp-opt):
* lisp/eshell/esh-mode.el (eshell-mode):
* lisp/loadup.el (max-specpdl-size):
* lisp/mh-e/mh-e.el (mh-invisible-headers):
* lisp/net/shr.el (shr-insert-document, shr-descend):
* lisp/play/hanoi.el (hanoi-internal):
* lisp/progmodes/cperl-mode.el:
* src/fileio.c (Fdo_auto_save):
Remove references to and modifications of max-specpdl-size.
Diffstat (limited to 'lisp/net/shr.el')
| -rw-r--r-- | lisp/net/shr.el | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 54ce9b1a41c..d56420eb02e 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el | |||
| @@ -373,7 +373,6 @@ DOM should be a parse tree as generated by | |||
| 373 | shr-width | 373 | shr-width |
| 374 | (* shr-width (frame-char-width))) | 374 | (* shr-width (frame-char-width))) |
| 375 | (shr--window-width))) | 375 | (shr--window-width))) |
| 376 | (max-specpdl-size max-specpdl-size) | ||
| 377 | (shr--link-targets nil) | 376 | (shr--link-targets nil) |
| 378 | (hscroll (window-hscroll)) | 377 | (hscroll (window-hscroll)) |
| 379 | ;; `bidi-display-reordering' is supposed to be only used for | 378 | ;; `bidi-display-reordering' is supposed to be only used for |
| @@ -625,41 +624,34 @@ size, and full-buffer size." | |||
| 625 | (shr-stylesheet shr-stylesheet) | 624 | (shr-stylesheet shr-stylesheet) |
| 626 | (shr-depth (1+ shr-depth)) | 625 | (shr-depth (1+ shr-depth)) |
| 627 | (start (point))) | 626 | (start (point))) |
| 628 | ;; shr uses many frames per nested node. | 627 | (when style |
| 629 | (if (and (> shr-depth (/ max-specpdl-size 15)) | 628 | (if (string-match-p "color\\|display\\|border-collapse" style) |
| 630 | (not (and shr-offer-extend-specpdl | 629 | (setq shr-stylesheet (nconc (shr-parse-style style) |
| 631 | (y-or-n-p "Too deeply nested to render properly; increase `max-specpdl-size'?") | 630 | shr-stylesheet)) |
| 632 | (setq max-specpdl-size (* max-specpdl-size 2))))) | 631 | (setq style nil))) |
| 633 | (setq shr-warning | 632 | ;; If we have a display:none, then just ignore this part of the DOM. |
| 634 | "Not rendering the complete page because of too-deep nesting") | 633 | (unless (or (equal (cdr (assq 'display shr-stylesheet)) "none") |
| 634 | (and shr-discard-aria-hidden | ||
| 635 | (equal (dom-attr dom 'aria-hidden) "true"))) | ||
| 636 | ;; We don't use shr-indirect-call here, since shr-descend is | ||
| 637 | ;; the central bit of shr.el, and should be as fast as | ||
| 638 | ;; possible. Having one more level of indirection with its | ||
| 639 | ;; negative effect on performance is deemed unjustified in | ||
| 640 | ;; this case. | ||
| 641 | (cond (external | ||
| 642 | (funcall external dom)) | ||
| 643 | ((fboundp function) | ||
| 644 | (funcall function dom)) | ||
| 645 | (t | ||
| 646 | (shr-generic dom))) | ||
| 647 | (when-let ((id (dom-attr dom 'id))) | ||
| 648 | (push (cons id (set-marker (make-marker) start)) shr--link-targets)) | ||
| 649 | ;; If style is set, then this node has set the color. | ||
| 635 | (when style | 650 | (when style |
| 636 | (if (string-match-p "color\\|display\\|border-collapse" style) | 651 | (shr-colorize-region |
| 637 | (setq shr-stylesheet (nconc (shr-parse-style style) | 652 | start (point) |
| 638 | shr-stylesheet)) | 653 | (cdr (assq 'color shr-stylesheet)) |
| 639 | (setq style nil))) | 654 | (cdr (assq 'background-color shr-stylesheet))))))) |
| 640 | ;; If we have a display:none, then just ignore this part of the DOM. | ||
| 641 | (unless (or (equal (cdr (assq 'display shr-stylesheet)) "none") | ||
| 642 | (and shr-discard-aria-hidden | ||
| 643 | (equal (dom-attr dom 'aria-hidden) "true"))) | ||
| 644 | ;; We don't use shr-indirect-call here, since shr-descend is | ||
| 645 | ;; the central bit of shr.el, and should be as fast as | ||
| 646 | ;; possible. Having one more level of indirection with its | ||
| 647 | ;; negative effect on performance is deemed unjustified in | ||
| 648 | ;; this case. | ||
| 649 | (cond (external | ||
| 650 | (funcall external dom)) | ||
| 651 | ((fboundp function) | ||
| 652 | (funcall function dom)) | ||
| 653 | (t | ||
| 654 | (shr-generic dom))) | ||
| 655 | (when-let ((id (dom-attr dom 'id))) | ||
| 656 | (push (cons id (set-marker (make-marker) start)) shr--link-targets)) | ||
| 657 | ;; If style is set, then this node has set the color. | ||
| 658 | (when style | ||
| 659 | (shr-colorize-region | ||
| 660 | start (point) | ||
| 661 | (cdr (assq 'color shr-stylesheet)) | ||
| 662 | (cdr (assq 'background-color shr-stylesheet)))))))) | ||
| 663 | 655 | ||
| 664 | (defun shr-fill-text (text) | 656 | (defun shr-fill-text (text) |
| 665 | (if (zerop (length text)) | 657 | (if (zerop (length text)) |