From ec61279bc8e30e66525a5dd4815b3e692b2909c0 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 26 Jul 2008 07:10:27 +0000 Subject: [PATCH] Provide better error for invalid match index in RE-MATCH-EXTRACT. --- v7/src/runtime/regexp.scm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/v7/src/runtime/regexp.scm b/v7/src/runtime/regexp.scm index fa1bc9556..cd6d628b2 100644 --- a/v7/src/runtime/regexp.scm +++ b/v7/src/runtime/regexp.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: regexp.scm,v 1.18 2008/01/30 20:02:34 cph Exp $ +$Id: regexp.scm,v 1.19 2008/07/26 07:10:27 cph Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -79,9 +79,11 @@ USA. (lambda () (set-re-registers! registers*))))) (define (re-match-extract string regs i) - (substring string - (re-match-start-index i regs) - (re-match-end-index i regs))) + (let ((start (re-match-start-index i regs)) + (end (re-match-end-index i regs))) + (if (not (and start end)) + (error:bad-range-argument i 'RE-MATCH-EXTRACT)) + (substring string start end))) (define (make-substring-operation primitive) (lambda (regexp string start end #!optional case-fold? syntax-table) -- 2.25.1