From: Chris Hanson Date: Mon, 17 Jan 2005 20:03:55 +0000 (+0000) Subject: Fix bug: SIGSEGV when M-x occur matches 0 lines. X-Git-Tag: 20090517-FFI~1387 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=e6cb0df1e34ee223a971c015c6c4fdb469059b2e;p=mit-scheme.git Fix bug: SIGSEGV when M-x occur matches 0 lines. --- diff --git a/v7/src/edwin/occur.scm b/v7/src/edwin/occur.scm index de7a2644d..5b37be930 100644 --- a/v7/src/edwin/occur.scm +++ b/v7/src/edwin/occur.scm @@ -1,8 +1,9 @@ #| -*-Scheme-*- -$Id: occur.scm,v 1.10 2004/10/23 04:01:09 cph Exp $ +$Id: occur.scm,v 1.11 2005/01/17 20:03:55 cph Exp $ Copyright 1992,1995,1997,2000,2003,2004 Massachusetts Institute of Technology +Copyright 2005 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -228,23 +229,25 @@ It serves as a menu to find any of the occurrences in this buffer. (reverse! occurrences)))))) (define (format-occurrences occurrences nlines output) - (let loop - ((occurrences occurrences) - (prev-ls #f) - (line 1)) - (let ((r (car occurrences)) - (m (mark-right-inserting-copy output))) - (let ((ls (line-start (region-start r) 0))) - (let ((line (+ line (count-lines (or prev-ls (group-start ls)) ls)))) - (format-occurrence ls (line-start (region-end r) 0) - line nlines - output) - (region-put! m output 'OCCURRENCE r) - (if (pair? (cdr occurrences)) - (begin - (if (not (= nlines 0)) - (insert-string "--------\n" output)) - (loop (cdr occurrences) ls line)))))))) + (if (pair? occurrences) + (let loop + ((occurrences occurrences) + (prev-ls #f) + (line 1)) + (let ((r (car occurrences)) + (m (mark-right-inserting-copy output))) + (let ((ls (line-start (region-start r) 0))) + (let ((line + (+ line (count-lines (or prev-ls (group-start ls)) ls)))) + (format-occurrence ls (line-start (region-end r) 0) + line nlines + output) + (region-put! m output 'OCCURRENCE r) + (if (pair? (cdr occurrences)) + (begin + (if (not (= nlines 0)) + (insert-string "--------\n" output)) + (loop (cdr occurrences) ls line))))))))) (define (format-occurrence rs re line nlines output) (let ((empty " "))