Show
Ignore:
Timestamp:
10/11/05 00:53:39 (3 years ago)
Author:
autrijus
Message:

* saner detection for zero-width matches on s:g to kill

the infinite loop as reported by eric256++.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim/Match.hs

    r6793 r7551  
    113113        writeRef matchSV (VMatch match) 
    114114        str'    <- fromVal =<< evalExp subst 
    115         (after', ok') <- doReplace (genericDrop (matchTo match) str) (ok + 1) 
    116         return (concat [genericTake (matchFrom match) str, str', after'], ok') 
     115        -- XXX - on zero-width match, advance the cursor and, if can't, 
     116        --       don't even bother with the recursive call. 
     117        case (matchTo match, matchFrom match) of 
     118            (0, 0) -> if null str then return (str' ++ str, ok) else do 
     119                (after', ok') <- doReplace (tail str) (ok + 1) 
     120                return (concat [str' ++ (head str:after')], ok') 
     121            (to, from) -> do 
     122                (after', ok') <- doReplace (genericDrop to str) (ok + 1) 
     123                return (concat [genericTake from str, str', after'], ok') 
    117124 
    118125op2Match x (VSubst (rx, subst)) = do