diff --git a/NEWS b/NEWS index 796da625d..8fc16d407 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,7 @@ available: Guile is now always configured in "maintainer mode". ** `symbol->string' now returns a read-only string, as per R5RS ** Literal strings as returned by `read' are now read-only, as per R5RS +** Fix incorrect handling of the FLAGS argument of `fold-matches' ** `guile-config link' now prints `-L$libdir' before `-lguile' ** Fix memory corruption involving GOOPS' `class-redefinition' ** Fix possible deadlock in `mutex-lock' diff --git a/ice-9/regex.scm b/ice-9/regex.scm index 21beb1665..61937d04f 100644 --- a/ice-9/regex.scm +++ b/ice-9/regex.scm @@ -1,4 +1,4 @@ -;;;; Copyright (C) 1997, 1999, 2001, 2004, 2005, 2006 Free Software Foundation, Inc. +;;;; Copyright (C) 1997, 1999, 2001, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -178,7 +178,7 @@ (define (fold-matches regexp string init proc . flags) (let ((regexp (if (regexp? regexp) regexp (make-regexp regexp))) - (flags (if (null? flags) 0 flags))) + (flags (if (null? flags) 0 (car flags)))) (let loop ((start 0) (value init) (abuts #f)) ; True if start abuts a previous match. diff --git a/test-suite/tests/regexp.test b/test-suite/tests/regexp.test index 3050af39b..0ca0203b6 100644 --- a/test-suite/tests/regexp.test +++ b/test-suite/tests/regexp.test @@ -1,7 +1,7 @@ ;;;; regexp.test --- test Guile's regular expression functions -*- scheme -*- ;;;; Jim Blandy --- September 1999 ;;;; -;;;; Copyright (C) 1999, 2004, 2006, 2007 Free Software Foundation, Inc. +;;;; Copyright (C) 1999, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -102,6 +102,29 @@ (let ((re (make-regexp "ab+"))) (regexp-exec re "aaaabbbb" 0 'bogus-flags-arg)))) +;;; +;;; fold-matches +;;; + +(with-test-prefix "fold-matches" + + (pass-if "without flags" + (equal? '("hello") + (fold-matches "^[a-z]+$" "hello" '() + (lambda (match result) + (cons (match:substring match) + result))))) + + (pass-if "with flags" + ;; Prior to 1.8.6, passing an additional flag would not work. + (null? + (fold-matches "^[a-z]+$" "hello" '() + (lambda (match result) + (cons (match:substring match) + result)) + (logior regexp/notbol regexp/noteol))))) + + ;;; ;;; regexp-quote ;;;