changeset 174:ab02213f5683 dev

rindex: return nil, instead of -1, if no match found.
author yuuji@gentei.org
date Fri, 18 Feb 2011 15:33:21 +0900
parents 7dc3c2332da5
children 6e959a05ae19
files yatexlib.el
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/yatexlib.el	Fri Feb 18 14:52:12 2011 +0900
+++ b/yatexlib.el	Fri Feb 18 15:33:21 2011 +0900
@@ -2,7 +2,7 @@
 ;;; YaTeX and yahtml common libraries, general functions and definitions
 ;;; yatexlib.el
 ;;; (c)1994-2009 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Wed Feb 16 19:58:33 2011 on firestorm
+;;; Last modified Fri Feb 18 15:05:08 2011 on firestorm
 ;;; $Id$
 
 ;; General variables
@@ -465,13 +465,12 @@
 ;;;###autoload
 (defun rindex (string char)
   (let ((pos (1- (length string)))(index -1))
-    (while (>= pos 0)
-      (cond
-       ((= (aref string pos) char)
-	(setq index pos) (setq pos -1))
-       (t (setq pos (1- pos))))
-      )
-    index))
+    (catch 'rindex
+      (while (>= pos 0)
+	(cond
+	 ((= (aref string pos) char)
+	  (throw 'rindex pos))
+	 (t (setq pos (1- pos))))))))
 
 ;;;###autoload
 (defun point-beginning-of-line ()

yatex.org