diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/files.el | 17 | ||||
| -rw-r--r-- | lisp/info.el | 4 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 6 | ||||
| -rw-r--r-- | lisp/subr.el | 10 |
5 files changed, 24 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 80cdb66425c..c3951a08c0a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2014-06-25 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * files.el (dir-locals-find-file, file-relative-name): | ||
| 4 | * info.el (Info-complete-menu-item): | ||
| 5 | * minibuffer.el (completion-table-subvert): Prefer string-prefix-p | ||
| 6 | to compare-strings to avoid out-of-range errors. | ||
| 7 | * subr.el (string-prefix-p): Adjust to match strict range | ||
| 8 | checking in compare-strings. | ||
| 9 | |||
| 1 | 2014-06-24 Leonard Randall <leonard.a.randall@gmail.com> (tiny change) | 10 | 2014-06-24 Leonard Randall <leonard.a.randall@gmail.com> (tiny change) |
| 2 | 11 | ||
| 3 | * textmodes/reftex-parse.el (reftex-using-biblatex-p): Make search | 12 | * textmodes/reftex-parse.el (reftex-using-biblatex-p): Make search |
diff --git a/lisp/files.el b/lisp/files.el index 9017cc96703..65f2009c7ce 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -3659,10 +3659,9 @@ of no valid cache entry." | |||
| 3659 | ;;; (setq locals-file nil)) | 3659 | ;;; (setq locals-file nil)) |
| 3660 | ;; Find the best cached value in `dir-locals-directory-cache'. | 3660 | ;; Find the best cached value in `dir-locals-directory-cache'. |
| 3661 | (dolist (elt dir-locals-directory-cache) | 3661 | (dolist (elt dir-locals-directory-cache) |
| 3662 | (when (and (eq t (compare-strings file nil (length (car elt)) | 3662 | (when (and (string-prefix-p (car elt) file |
| 3663 | (car elt) nil nil | 3663 | (memq system-type |
| 3664 | (memq system-type | 3664 | '(windows-nt cygwin ms-dos))) |
| 3665 | '(windows-nt cygwin ms-dos)))) | ||
| 3666 | (> (length (car elt)) (length (car dir-elt)))) | 3665 | (> (length (car elt)) (length (car dir-elt)))) |
| 3667 | (setq dir-elt elt))) | 3666 | (setq dir-elt elt))) |
| 3668 | (if (and dir-elt | 3667 | (if (and dir-elt |
| @@ -4507,18 +4506,14 @@ on a DOS/Windows machine, it returns FILENAME in expanded form." | |||
| 4507 | (let ((ancestor ".") | 4506 | (let ((ancestor ".") |
| 4508 | (filename-dir (file-name-as-directory filename))) | 4507 | (filename-dir (file-name-as-directory filename))) |
| 4509 | (while (not | 4508 | (while (not |
| 4510 | (or | 4509 | (or (string-prefix-p directory filename-dir fold-case) |
| 4511 | (eq t (compare-strings filename-dir nil (length directory) | 4510 | (string-prefix-p directory filename fold-case))) |
| 4512 | directory nil nil fold-case)) | ||
| 4513 | (eq t (compare-strings filename nil (length directory) | ||
| 4514 | directory nil nil fold-case)))) | ||
| 4515 | (setq directory (file-name-directory (substring directory 0 -1)) | 4511 | (setq directory (file-name-directory (substring directory 0 -1)) |
| 4516 | ancestor (if (equal ancestor ".") | 4512 | ancestor (if (equal ancestor ".") |
| 4517 | ".." | 4513 | ".." |
| 4518 | (concat "../" ancestor)))) | 4514 | (concat "../" ancestor)))) |
| 4519 | ;; Now ancestor is empty, or .., or ../.., etc. | 4515 | ;; Now ancestor is empty, or .., or ../.., etc. |
| 4520 | (if (eq t (compare-strings filename nil (length directory) | 4516 | (if (string-prefix-p directory filename fold-case) |
| 4521 | directory nil nil fold-case)) | ||
| 4522 | ;; We matched within FILENAME's directory part. | 4517 | ;; We matched within FILENAME's directory part. |
| 4523 | ;; Add the rest of FILENAME onto ANCESTOR. | 4518 | ;; Add the rest of FILENAME onto ANCESTOR. |
| 4524 | (let ((rest (substring filename (length directory)))) | 4519 | (let ((rest (substring filename (length directory)))) |
diff --git a/lisp/info.el b/lisp/info.el index 89ca8bdbe33..405d6a22449 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -2691,9 +2691,7 @@ Because of ambiguities, this should be concatenated with something like | |||
| 2691 | (equal (nth 1 Info-complete-cache) Info-current-node) | 2691 | (equal (nth 1 Info-complete-cache) Info-current-node) |
| 2692 | (equal (nth 2 Info-complete-cache) Info-complete-next-re) | 2692 | (equal (nth 2 Info-complete-cache) Info-complete-next-re) |
| 2693 | (equal (nth 5 Info-complete-cache) Info-complete-nodes) | 2693 | (equal (nth 5 Info-complete-cache) Info-complete-nodes) |
| 2694 | (let ((prev (nth 3 Info-complete-cache))) | 2694 | (string-prefix-p (nth 3 Info-complete-cache) string) t) |
| 2695 | (eq t (compare-strings string 0 (length prev) | ||
| 2696 | prev 0 nil t)))) | ||
| 2697 | ;; We can reuse the previous list. | 2695 | ;; We can reuse the previous list. |
| 2698 | (setq completions (nth 4 Info-complete-cache)) | 2696 | (setq completions (nth 4 Info-complete-cache)) |
| 2699 | ;; The cache can't be used. | 2697 | ;; The cache can't be used. |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7b252b4d46d..e7e08342b47 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -244,8 +244,7 @@ The result is a completion table which completes strings of the | |||
| 244 | form (concat S1 S) in the same way as TABLE completes strings of | 244 | form (concat S1 S) in the same way as TABLE completes strings of |
| 245 | the form (concat S2 S)." | 245 | the form (concat S2 S)." |
| 246 | (lambda (string pred action) | 246 | (lambda (string pred action) |
| 247 | (let* ((str (if (eq t (compare-strings string 0 (length s1) s1 nil nil | 247 | (let* ((str (if (string-prefix-p s1 string completion-ignore-case) |
| 248 | completion-ignore-case)) | ||
| 249 | (concat s2 (substring string (length s1))))) | 248 | (concat s2 (substring string (length s1))))) |
| 250 | (res (if str (complete-with-action action table str pred)))) | 249 | (res (if str (complete-with-action action table str pred)))) |
| 251 | (when res | 250 | (when res |
| @@ -257,8 +256,7 @@ the form (concat S2 S)." | |||
| 257 | (+ beg (- (length s1) (length s2)))) | 256 | (+ beg (- (length s1) (length s2)))) |
| 258 | . ,(and (eq (car-safe res) 'boundaries) (cddr res))))) | 257 | . ,(and (eq (car-safe res) 'boundaries) (cddr res))))) |
| 259 | ((stringp res) | 258 | ((stringp res) |
| 260 | (if (eq t (compare-strings res 0 (length s2) s2 nil nil | 259 | (if (string-prefix-p s2 string completion-ignore-case) |
| 261 | completion-ignore-case)) | ||
| 262 | (concat s1 (substring res (length s2))))) | 260 | (concat s1 (substring res (length s2))))) |
| 263 | ((eq action t) | 261 | ((eq action t) |
| 264 | (let ((bounds (completion-boundaries str table pred ""))) | 262 | (let ((bounds (completion-boundaries str table pred ""))) |
diff --git a/lisp/subr.el b/lisp/subr.el index 524b7954b7e..09a085288a5 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3677,12 +3677,14 @@ and replace a sub-expression, e.g. | |||
| 3677 | (setq matches (cons (substring string start l) matches)) ; leftover | 3677 | (setq matches (cons (substring string start l) matches)) ; leftover |
| 3678 | (apply #'concat (nreverse matches))))) | 3678 | (apply #'concat (nreverse matches))))) |
| 3679 | 3679 | ||
| 3680 | (defun string-prefix-p (str1 str2 &optional ignore-case) | 3680 | (defun string-prefix-p (prefix string &optional ignore-case) |
| 3681 | "Return non-nil if STR1 is a prefix of STR2. | 3681 | "Return non-nil if PREFIX is a prefix of STRING. |
| 3682 | If IGNORE-CASE is non-nil, the comparison is done without paying attention | 3682 | If IGNORE-CASE is non-nil, the comparison is done without paying attention |
| 3683 | to case differences." | 3683 | to case differences." |
| 3684 | (eq t (compare-strings str1 nil nil | 3684 | (let ((prefix-length (length prefix))) |
| 3685 | str2 0 (length str1) ignore-case))) | 3685 | (if (> prefix-length (length string)) nil |
| 3686 | (eq t (compare-strings prefix 0 prefix-length string | ||
| 3687 | 0 prefix-length ignore-case))))) | ||
| 3686 | 3688 | ||
| 3687 | (defun string-suffix-p (suffix string &optional ignore-case) | 3689 | (defun string-suffix-p (suffix string &optional ignore-case) |
| 3688 | "Return non-nil if SUFFIX is a suffix of STRING. | 3690 | "Return non-nil if SUFFIX is a suffix of STRING. |