ce-command-search: do not stack overflow on empty file

searching backwards does not have this problem
This commit is contained in:
xfnw 2024-07-19 19:56:33 -04:00
parent a79338d71b
commit d3391a6a03

18
ce.cl
View File

@ -258,14 +258,16 @@
"set point at next line to match argument"
(declare (ignore c))
(ce-reset-input)
(let ((inp (read-line)) (len (list-length buffer)))
(let ((match
(pregexp (if (string= "" inp) query (setq query inp)))))
(setq
outpoint
(ce-walk-match 1 match (ce-mod inpoint len) (1- len)))))
(setq inpoint outpoint)
(format t "~a~%" (car (nthcdr outpoint buffer))))
(if buffer
(progn
(let ((inp (read-line)) (len (list-length buffer)))
(let ((match
(pregexp (if (string= "" inp) query (setq query inp)))))
(setq outpoint
(ce-walk-match 1 match (ce-mod inpoint len) (1- len)))))
(setq inpoint outpoint)
(format t "~a~%" (car (nthcdr outpoint buffer))))
(progn (read-line) (format t errf))))
(defun ce-command-search-before (&optional c)
"set point at previous line to match argument"