[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-25 285ed41 1/4: * lisp/character-fold.el (character-
From: |
Artur Malabarba |
Subject: |
[Emacs-diffs] emacs-25 285ed41 1/4: * lisp/character-fold.el (character-fold-to-regexp): Be careful |
Date: |
Sun, 29 Nov 2015 21:27:42 +0000 |
branch: emacs-25
commit 285ed41605ca44794dd7fd16abf63eb3f8808238
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
* lisp/character-fold.el (character-fold-to-regexp): Be careful
not to return huge regexps.
---
lisp/character-fold.el | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/lisp/character-fold.el b/lisp/character-fold.el
index c2b9a07..88622b3 100644
--- a/lisp/character-fold.el
+++ b/lisp/character-fold.el
@@ -150,9 +150,8 @@ Any character in STRING that has an entry in
`character-fold-table' is replaced with that entry (which is a
regexp) and other characters are `regexp-quote'd.
-Note that this function can potentially return regexps too long
-for Emacs to handle. If STRING is longer than 30 characters,
-consider not using this function.
+If the resulting regexp would be too long for Emacs to handle,
+just return the result of calling `regexp-quote' on STRING.
FROM is for internal use. It specifies an index in the STRING
from which to start."
@@ -222,7 +221,11 @@ from which to start."
(setq i (1+ i)))
(when (> spaces 0)
(push (character-fold--make-space-string spaces) out))
- (apply #'concat (nreverse out))))
+ (let ((regexp (apply #'concat (nreverse out))))
+ ;; Limited by `MAX_BUF_SIZE' in `regex.c'.
+ (if (> (length regexp) 32000)
+ (regexp-quote string)
+ regexp))))
;;; Commands provided for completeness.