[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 15:05:54 UTC 2010


The following commit has been merged in the master branch:
commit 025aca833b1c8364d85e5b88cd4bfbfd6685790b
Author: John Goerzen <jgoerzen at complete.org>
Date:   Tue Dec 27 04:23:10 2005 +0100

    splitRe and subRe have been integrated into fptools; deprecate them here
    
    They're marked deprecated here.
    Also, their local implementations have been removed and are now simply
    pointers to the functions in Text.Regex.

diff --git a/MissingH/Str.hs b/MissingH/Str.hs
index 86a4530..ae49a37 100644
--- a/MissingH/Str.hs
+++ b/MissingH/Str.hs
@@ -1,5 +1,5 @@
 {- arch-tag: String utilities main file
-Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+Copyright (C) 2004-2005 John Goerzen <jgoerzen at complete.org>
 
 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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 {- |
    Module     : MissingH.Str
-   Copyright  : Copyright (C) 2004 John Goerzen
+   Copyright  : Copyright (C) 2004-2005 John Goerzen
    License    : GNU GPL, version 2 or above
 
    Maintainer : John Goerzen <jgoerzen at complete.org>
@@ -30,7 +30,8 @@ This module provides various helpful utilities for dealing with strings.
 Written by John Goerzen, jgoerzen\@complete.org
 -}
 
-module MissingH.Str(-- * Whitespace Removal
+module MissingH.Str
+                       (-- * Whitespace Removal
                         strip, lstrip, rstrip,
                         -- * Tests
                         -- | Note: These functions are aliases for functions
@@ -44,6 +45,9 @@ module MissingH.Str(-- * Whitespace Removal
 import MissingH.List(startswith, endswith, join, split, replace)
 import Text.Regex
 
+{-# DEPRECATED splitRe "Use Text.Regex.splitRegex instead" #-}
+{-# DEPRECATED subRe "Use Text.Regex.subRegex instead" #-}
+
 wschars = " \t\r\n"
 
 {- | Removes any whitespace characters that are present at the start
@@ -83,60 +87,21 @@ In the replacement string, @\"\\1\"@ refers to the first substring;
 @\"\\2\"@ to the second, etc; and @\"\\0\"@ to the entire match.
 @\"\\\\\\\\\"@ will insert a literal backslash.
 
+This code has been integrated into the standard Haskell libraries
+as Text.Regex.subRegex and is thus deprecated in MissingH.
 -}
 subRe :: Regex                          -- ^ Search pattern
       -> String                         -- ^ Input string
       -> String                         -- ^ Replacement text
       -> String                         -- ^ Output string
-subRe _ "" _ = ""
-subRe regexp inp repl = 
-    let bre = mkRegex "\\\\(\\\\|[0-9]+)"
-        lookup _ [] _ = []
-        lookup [] _ _ = []
-        lookup match repl groups =
-            case matchRegexAll bre repl of
-                Nothing -> repl
-                Just (lead, _, trail, bgroups) ->
-                    let newval = if (head bgroups) == "\\"
-                                 then "\\"
-                                 else let index = (read (head bgroups)) - 1
-                                          in
-                                          if index == -1
-                                             then match
-                                             else groups !! index
-                        in
-                        lead ++ newval ++ lookup match trail groups
-        in
-        case matchRegexAll regexp inp of
-            Nothing -> inp
-            Just (lead, match, trail, groups) ->
-              lead ++ lookup match repl groups ++ (subRe regexp trail repl)
+subRe = subRegex
 
 {- | Splits a string based on a regular expression.  The regular expression
 should identify one delimiter.
--}
-
-splitRe :: Regex -> String -> [String]
-splitRe _ [] = []
-splitRe delim str =
-    case matchRegexAll delim str of
-       Nothing -> [str]
-       Just (firstline, _, remainder, _) ->
-           if remainder == ""
-              then firstline : [] : []
-              else firstline : splitRe delim remainder
 
-{-
+This code has been integrated into the standard Haskell libraries
+as Text.Regex.splitRegex and is thus deprecated in MissingH.
+-}
 
 splitRe :: Regex -> String -> [String]
-splitRe delim [] = []
-splitRe delim str =
-    case matchRegexAll delim str of
-        Just (prefix, match, postfix, subex) ->
-            if (prefix == "") && (postfix == "") && (match == str) then
-               -- We matched just a delimiter
-               [] : [] : []
-            else prefix : splitRe delim postfix
-        Nothing -> [str]
-
--}
+splitRe = splitRegex

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list