Signal list cycles in ‘length’ etc.
commit14dd9101ec4838f75addf25bf6b06ef33f8a7e97
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 5 Feb 2017 21:25:37 +0000 (5 13:25 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 5 Feb 2017 21:30:29 +0000 (5 13:30 -0800)
tree500eb382ab23735af5b722b5ad7882c05bdfa965
parentb7fa6b1f1cee9d1b71553fa665843774d2e5cf3d
Signal list cycles in ‘length’ etc.

Use macros like FOR_EACH_TAIL instead of maybe_quit to
catch list cycles automatically instead of relying on the
user becoming impatient and typing C-g (Bug#25606).
* src/fns.c (Flength, Fmember, Fmemq, Fmemql, Fassq, Fassoc, Frassq)
(Frassoc, Fdelete, Freverse):
Use FOR_EACH_TAIL instead of maybe_quit.
(Fnreverse): Use simple EQ to check for circular list instead
of rarely_quit, as this suffices in this unusual case.
(Fplist_put, Flax_plist_put, Flax_plist_put):
Use FOR_EACH_TAIL_CONS instead of maybe_quit.
(internal_equal): Use FOR_EACH_TAIL_CONS to check lists, instead
of by-hand tail recursion that did not catch cycles.
* src/fns.c (Fsafe_length, Fplist_get):
* src/xdisp.c (display_mode_element):
Use FOR_EACH_TAIL_SAFE instead of by-hand Floyd’s algorithm.
* src/lisp.h (QUIT_COUNT_HEURISTIC): Remove; no longer needed.
(rarely_quit): Simply count toward USHRT_MAX + 1, since the
fancier versions are no longer needed.
(FOR_EACH_TAIL_CONS, FOR_EACH_TAIL_SAFE)
(FOR_EACH_TAIL_INTERNAL): New macros, the last with definiens
mostly taken from FOR_EACH_TAIL.
(FOR_EACH_TAIL): Rewrite in terms of FOR_EACH_TAIL_INTERNAL.
etc/NEWS
src/fns.c
src/lisp.h
src/xdisp.c