From 08f93d7b44e4ea1bd3c0fc9f2a43b85587d2cf1a Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 18 Feb 2006 04:56:22 +0000 Subject: [PATCH] Fail regular-expression searches immediately at end of range. This prevents various infinite loops from patterns that match the null string. --- v7/src/edwin/regexp.scm | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/v7/src/edwin/regexp.scm b/v7/src/edwin/regexp.scm index 4f7bfe4cc..b1b3de086 100644 --- a/v7/src/edwin/regexp.scm +++ b/v7/src/edwin/regexp.scm @@ -1,10 +1,10 @@ #| -*-Scheme-*- -$Id: regexp.scm,v 1.83 2004/11/19 16:54:18 cph Exp $ +$Id: regexp.scm,v 1.84 2006/02/18 04:56:22 cph Exp $ Copyright 1986,1989,1991,1992,1993,1995 Massachusetts Institute of Technology Copyright 1996,1997,1999,2001,2002,2003 Massachusetts Institute of Technology -Copyright 2004 Massachusetts Institute of Technology +Copyright 2004,2006 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -215,24 +215,26 @@ USA. (make-mark group index))))) (define (re-search-buffer-forward regexp syntax-table group start end) - (let ((index - ((ucode-primitive re-search-buffer-forward) - (compiled-regexp/byte-stream regexp) - (compiled-regexp/translation-table regexp) - (syntax-table-argument syntax-table) - registers group start end))) - (set! match-group (compute-match-group group index)) - index)) + (and (fix:< start end) + (let ((index + ((ucode-primitive re-search-buffer-forward) + (compiled-regexp/byte-stream regexp) + (compiled-regexp/translation-table regexp) + (syntax-table-argument syntax-table) + registers group start end))) + (set! match-group (compute-match-group group index)) + index))) (define (re-search-buffer-backward regexp syntax-table group start end) - (let ((index - ((ucode-primitive re-search-buffer-backward) - (compiled-regexp/byte-stream regexp) - (compiled-regexp/translation-table regexp) - (syntax-table-argument syntax-table) - registers group start end))) - (set! match-group (compute-match-group group index)) - index)) + (and (fix:< start end) + (let ((index + ((ucode-primitive re-search-buffer-backward) + (compiled-regexp/byte-stream regexp) + (compiled-regexp/translation-table regexp) + (syntax-table-argument syntax-table) + registers group start end))) + (set! match-group (compute-match-group group index)) + index))) (define (re-match-buffer-forward regexp syntax-table group start end) (let ((index -- 2.25.1