branch: externals/greader
commit 697e77b5a61b61437add19381afd6d58b292751d
Author: Michelangelo Rodriguez <michelangelo.rodrig...@gmail.com>
Commit: Michelangelo Rodriguez <michelangelo.rodrig...@gmail.com>

    greader-dict-add: fixed.
    
    Now the function `greader-dict-add' returns an error if WORD and
    REPLACEMENT are `equal-ignore-case'.
    This is to prevent an infinite-loop in
    `greader-dict-check-and-replace''s infrastructure.
---
 greader-dict.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/greader-dict.el b/greader-dict.el
index fefb3a467d..0b0eaf6d8a 100644
--- a/greader-dict.el
+++ b/greader-dict.el
@@ -177,6 +177,10 @@ A value of 0 indicates saving immediately."
   "Add the WORD REPLACEMent pair to `greader-dictionary'.
 If you want to add a partial replacement, you should
 add `\*'to the end of the WORD string parameter."
+  ;; We prevent an infinite loop if disallowing that key and values
+  ;; are the same.
+  (when (string-equal-ignore-case word replacement)
+    (user-error "key and value are the same, aborting"))
   (puthash word replacement greader-dictionary)
   (setq greader-dict--saved-flag nil)
   (cond

Reply via email to