[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] regex issues
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] regex issues |
Date: |
Wed, 18 May 2005 22:01:31 +0200 |
On 5/15/05, Christian Jaeger <address@hidden> wrote:
> Hello
>
> Is this a bug?:
>
> (string-match-positions ".*needle.*" "hay needle stack" 2) -> #f
>
> Shouldn't it be giving ((2 16)) ?
> This is Version 1, Build 89, on Debian.
>
Here is a patch:
--- chicken-old/pcre.scm 2005-05-18 22:11:07.000000000 +0200
+++ chicken-new/pcre.scm 2005-05-18 21:56:07.000000000 +0200
@@ -174,7 +174,7 @@
(let ([si (if (pair? start) (##sys#slot start 0) 0)])
(##sys#check-exact si loc)
(set! b
- (cond [(string? regexp) (re-compile (string-append "^" regexp "$") loc)]
+ (cond [(string? regexp) (re-compile (string-append (if (fx> si 0) ""
"^") regexp "$") loc)]
[(##sys#structure? regexp 'regexp) (##sys#slot regexp 1)]
[else (##sys#signal-hook #:type-error loc "bad argument type -
not a string or compiled regexp" regexp)] ) )
(set! c (fx+ 1 (re-capture-count b)))
PCRE doesn't allow anchored patterns ("^") if a start position is given.
cheers,
felix