2016-08-19 155 views
2

在Windows上使用GHC時崩潰。它在Linux上完美運行。正則表達式替換在Windows上使用正則表達式compat

這是否有意義或有錯誤?

module Main where 

import qualified Text.Regex as Re -- from regex-compat 
import Debug.Trace 

main :: IO() 
main = do 
    putStr $ cleanWord "jan" 
    putStr $ cleanWord "dec" 
    putStr $ cleanWord "jun" -- crashes here 

cleanWord :: String -> String 
cleanWord word_ = 
    let word = trace (show word_) word_ in 
    let re = Re.mkRegexWithOpts "(jun|jul|aug|sep|oct|nov|dec)" True False in 
    Re.subRegex re word "" 

一些額外的細節

  1. 我與stack
  2. 它崩潰在這兩個GHCI和運行編譯可執行建設
  3. 我試圖啓用分析,但似乎無法人物瞭解如何才能正常工作。
+0

另外,什麼是例外? – Alec

+0

@Zeta更新,其regex-compat – Andre

+0

@Alec程序崩潰,控制檯輸出中沒有任何內容。 – Zeta

回答

0

改變正則表達式避免了這種情況下的錯誤。

現在這對我來說工作得很好

let re = Re.mkRegexWithOpts "(jul|aug|sep|oct|jun|nov|dec)" True False in 

即將jun移動到正則表達式的末尾。不是特別滿意,但它有效,這意味着我可以繼續。

@澤塔的評論認爲,這是與底層庫

這是一個錯誤,可能是在正則表達式,POSIX,一個錯誤,因爲它在 納入基本BSD的正則表達式庫從1994年的區別。在sslow中,將訪問 無效內存地址(-1(%rdx),rdx = 0)。

+0

記錄錯誤:https://sourceforge.net/p/lazy-regex/bugs/6/ – Andre