summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2009-12-17 00:46:04 +0000
committerpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2009-12-17 00:46:04 +0000
commit1af661dd41a6cd0a16d9bb3556827eb5128fb667 (patch)
treebc8fc78ed53eb0009d9ad9182d7c8bb2a68547d9
parent98b3b673ddd3b860b6e78ee3acc7b36c05fcd357 (diff)
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@12 9f8f72e9-4bf4-416e-b76e-7d4203597157
-rw-r--r--HsBot.hs26
1 files changed, 9 insertions, 17 deletions
diff --git a/HsBot.hs b/HsBot.hs
index 2a835d2..ac6876c 100644
--- a/HsBot.hs
+++ b/HsBot.hs
@@ -142,29 +142,21 @@ matches search string =
(list, rest) -> list ++ (matches search rest)
where occ :: String -> String -> Maybe (String, String)
occ search str = o' "" search str
- where o' pred [] str =
- Just (init . init $ reverse pred, str)
+ where o' pred [] str = Just (init . init $ reverse pred, str)
o' pred occ [] = Nothing
o' pred (m:occ) (s:str)
| m == s = o' (s:pred) occ str
| otherwise = o' (s:pred) search str
- split' str = map (filter (\x -> (x /= '-') && (x /= '+'))) $ split str ' '
- extrL str
- | last str == ' ' = []
- | otherwise = [last $ split' str]
- extrR str
- | str !! 0 == ' ' = []
- | otherwise = [split' str !! 0]
- m' (Just (a, "")) = (extrL a, "")
- m' (Just ("", b)) = (extrR b, b)
- m' (Just (a, b)) = ((extrL a) ++ (extrR b), b)
+ extr extrF = extrF . filter (\x -> (x /= '-') && (x /= '+'))
+ extrL str -- extract left side
+ | null str || last str == ' ' = []
+ | otherwise = [last $ split str ' ']
+ extrR str -- extract right side
+ | null str || str !! 0 == ' ' = []
+ | otherwise = [split str ' ' !! 0]
+ m' (Just (a, b)) = ((extr extrL a) ++ (extr extrR b), b)
m' Nothing = ([], [])
-test1 = matches "++" "++foo"
-test2 = matches "++" "foo++"
-test3 = matches "++" "++foo++"
-test4 = matches "++" "++foo ++bar++ --baz++"
-
processInput :: Conf -> Conf
processInput conf = loggMessage "foo" conf
where plus = matches "++" (line conf)