This commit was generated by cvs2svn to compensate for changes in r1647,
[chise/xemacs-chise.git.1] / lisp / replace.el
index 3b6165e..71b8054 100644 (file)
@@ -679,6 +679,7 @@ When searching for a match, this function use `replace-search-function' and `rep
        ;; Loop finding occurrences that perhaps should be replaced.
        (while (and keep-going
                    (not (eobp))
+                   (or (null limit) (< (point) limit))
                    (let ((case-fold-search qr-case-fold-search))
                      (funcall search-function search-string limit))
                    ;; If the search string matches immediately after
@@ -688,7 +689,8 @@ When searching for a match, this function use `replace-search-function' and `rep
                            (and regexp-flag
                                 (eq lastrepl (match-beginning 0))
                                 (not match-again)))
-                       (if (eobp)
+                       (if (or (eobp)
+                               (and limit (>= (point) limit)))
                            nil
                          ;; Don't replace the null string 
                          ;; right after end of previous replacement.