[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-devel] Possible infinite loop in TeX-delete-dups-by-car and TeX-
[AUCTeX-devel] Possible infinite loop in TeX-delete-dups-by-car and TeX-delete-duplicate-strings
Fri, 01 Sep 2017 17:21:27 +0900
I found that the two functions `TeX-delete-dups-by-car' and
`TeX-delete-duplicate-strings' can fall into infinite loop under certain
I'm proposing a fix, so please tell me if someone finds any problems in
[How to confirm]
1. Activate AUCTeX.
2. Evaluate (TeX-delete-duplicate-strings '("nil")) or
(TeX-delete-dups-by-car '(("nil" . 1))) . Both examples fall into
Since (string= "nil" nil) returns t, the loop
(while (string= elt (cadr new))
(setcdr new (cddr new)))
in `TeX-delete-duplicate-strings' never finishes when the list given as
the argument to the function ends with a string "nil" after sort.
Essentially the same reason applies for `TeX-delete-dups-by-car', too.
I estimate that it is quite uncommon that this bug causes a problem in
practical cases considering the ways that these functions are used, but
I still think it should be fixed.
The attached patch fixes the problem. Although it may seem complicated,
the essential part is just the two occurence of
- (while new
+ (while (cdr new)
only. The rest are just plain rewrite using utility functions to reduce
code duplication. (The reason that I moved the position of defun of
`TeX-car-string-lessp' is that the defcustom of `TeX-engine' requires
`TeX-delete-dups-by-car' at load time. Thus all the functions used in
`TeX-delete-dups-by-car' must be defined before the defcustom.)
Any comments and suggestions are welcome.
Description: fix infinite loop
- [AUCTeX-devel] Possible infinite loop in TeX-delete-dups-by-car and TeX-delete-duplicate-strings,
Ikumi Keita <=