summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2013-11-24 10:49:44 +0200
committerBozhidar Batsov <bozhidar@batsov.com>2013-11-24 10:49:44 +0200
commit41ce6f702730d95ef62e770a1b8160e3aac9d0a8 (patch)
tree0dcbafeb865b63463ae26353aa92ad4b4954a73c /lisp/subr.el
parent0b09f7c0d338d8c527212a5397ddf52b58c2cbe2 (diff)
downloademacs-41ce6f702730d95ef62e770a1b8160e3aac9d0a8.tar.gz
* lisp/subr.el (string-suffix-p): New function.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 31798b44849..b22c719f010 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3635,6 +3635,15 @@ to case differences."
(eq t (compare-strings str1 nil nil
str2 0 (length str1) ignore-case)))
+(defun string-suffix-p (suffix string &optional ignore-case)
+ "Return non-nil if SUFFIX is a suffix of STRING.
+If IGNORE-CASE is non-nil, the comparison is done without paying
+attention to case differences."
+ (let ((start-pos (- (length string) (length suffix))))
+ (and (>= start-pos 0)
+ (eq t (compare-strings suffix nil nil
+ string start-pos nil ignore-case)))))
+
(defun bidi-string-mark-left-to-right (str)
"Return a string that can be safely inserted in left-to-right text.