branch: externals/auctex
commit 7863f42363d0ac53663cfb6759537ee221158060
Author: Ikumi Keita <[email protected]>
Commit: Ikumi Keita <[email protected]>
Prevent possible infinite loop
* tex.el (TeX-delete-duplicate-strings): Make sure that comparison is
done with valid list elements.
(TeX-delete-dups-by-car): Ditto.
Use `TeX-sort-strings' and `TeX-car-string-lessp'.
(TeX-car-string-lessp): Move the position of defun before the
defcustom of `TeX-engine'. Since the defcustom requires
`TeX-delete-dups-by-car' at load time, all the functions used in
`TeX-delete-dups-by-car' must be defined before the defcustom.
---
tex.el | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/tex.el b/tex.el
index 79b59b8..e4012b0 100644
--- a/tex.el
+++ b/tex.el
@@ -914,12 +914,11 @@ overlays."
"Return a list of all elements in ALIST, but each car only once.
Elements of KEEP-LIST are not removed even if duplicate."
;; Copy of `reftex-uniquify-by-car' (written by David Kastrup).
- (setq keep-list (sort (copy-sequence keep-list) #'string<))
+ (setq keep-list (TeX-sort-strings keep-list))
(setq alist (sort (copy-sequence alist)
- (lambda (a b)
- (string< (car a) (car b)))))
+ #'TeX-car-string-lessp))
(let ((new alist) elt)
- (while new
+ (while (cdr new)
(setq elt (caar new))
(while (and keep-list (string< (car keep-list) elt))
(setq keep-list (cdr keep-list)))
@@ -933,7 +932,7 @@ Elements of KEEP-LIST are not removed even if duplicate."
"Return a list of all strings in LIST, but each only once."
(setq list (TeX-sort-strings list))
(let ((new list) elt)
- (while new
+ (while (cdr new)
(setq elt (car new))
(while (string= elt (cadr new))
(setcdr new (cddr new)))
@@ -944,6 +943,11 @@ Elements of KEEP-LIST are not removed even if duplicate."
"Return sorted list of all strings in LIST."
(sort (copy-sequence list) #'string<))
+(defun TeX-car-string-lessp (s1 s2)
+ "Compare the cars of S1 and S2 in lexicographic order.
+Return t if first is less than second in lexicographic order."
+ (string-lessp (car s1) (car s2)))
+
;;; Buffer
(defgroup TeX-output nil
@@ -4737,11 +4741,6 @@ If optional argument STRIP is non-nil, remove file
extension."
;; Some of these functions has little to do with TeX, but nonetheless we
;; should use the "TeX-" prefix to avoid name clashes.
-(defun TeX-car-string-lessp (s1 s2)
- "Compare the cars of S1 and S2 in lexicographic order.
-Return t if first is less than second in lexicographic order."
- (string-lessp (car s1) (car s2)))
-
(defun TeX-listify (elt)
"Return a newly created list with element ELT.
If ELT already is a list, return ELT."