@@ -35,12 +35,12 @@ compressCss = compressSeparators . stripComments . compressWhitespace
35compressSeparators :: String -> String
35compressSeparators :: String -> String
36compressSeparators [] = []
36compressSeparators [] = []
37compressSeparators str
37compressSeparators str
38− | isPrefixOf "\"" str = head str : retainConstants compressSeparators "\"" (drop 1 str)
38+ | isConstant = head str : retainConstants compressSeparators (head str) (drop 1 str)
39− | isPrefixOf "'" str = head str : retainConstants compressSeparators "'" (drop 1 str)
40 | stripFirst = compressSeparators (drop 1 str)
39 | stripFirst = compressSeparators (drop 1 str)
41 | stripSecond = compressSeparators (head str : (drop 2 str))
40 | stripSecond = compressSeparators (head str : (drop 2 str))
42 | otherwise = head str : compressSeparators (drop 1 str)
41 | otherwise = head str : compressSeparators (drop 1 str)
43+ isConstant = or $ map (isOfPrefix str) ["\"", "'"]
44 stripFirst = or $ map (isOfPrefix str) [" ", " {", " }", ";;", ";}"]
44 stripFirst = or $ map (isOfPrefix str) [" ", " {", " }", ";;", ";}"]
45 stripSecond = or $ map (isOfPrefix str) ["{ ", "} ", "; "]
45 stripSecond = or $ map (isOfPrefix str) ["{ ", "} ", "; "]
@@ -49,12 +49,12 @@ compressSeparators str
49compressWhitespace :: String -> String
49compressWhitespace :: String -> String
50compressWhitespace [] = []
50compressWhitespace [] = []
51compressWhitespace str
51compressWhitespace str
52− | isPrefixOf "\"" str = head str : retainConstants compressWhitespace "\"" (drop 1 str)
52+ | isConstant = head str : retainConstants compressWhitespace (head str) (drop 1 str)
53− | isPrefixOf "'" str = head str : retainConstants compressWhitespace "'" (drop 1 str)
54 | replaceOne = compressWhitespace (' ' : (drop 1 str))
53 | replaceOne = compressWhitespace (' ' : (drop 1 str))
55 | replaceTwo = compressWhitespace (' ' : (drop 2 str))
54 | replaceTwo = compressWhitespace (' ' : (drop 2 str))
56 | otherwise = head str : compressWhitespace (drop 1 str)
55 | otherwise = head str : compressWhitespace (drop 1 str)
57+ isConstant = or $ map (isOfPrefix str) ["\"", "'"]
58 replaceOne = or $ map (isOfPrefix str) ["\t", "\n", "\r"]
58 replaceOne = or $ map (isOfPrefix str) ["\t", "\n", "\r"]
59 replaceTwo = or $ map (isOfPrefix str) [" \t", " \n", " \r", " "]
59 replaceTwo = or $ map (isOfPrefix str) [" \t", " \n", " \r", " "]
@@ -63,11 +63,11 @@ compressWhitespace str
63stripComments :: String -> String
63stripComments :: String -> String
64stripComments [] = []
64stripComments [] = []
65stripComments str
65stripComments str
66− | isPrefixOf "\"" str = head str : retainConstants stripComments "\"" (drop 1 str)
66+ | isConstant = head str : retainConstants stripComments (head str) (drop 1 str)
67− | isPrefixOf "'" str = head str : retainConstants stripComments "'" (drop 1 str)
68 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
67 | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str
69 | otherwise = head str : stripComments (drop 1 str)
68 | otherwise = head str : stripComments (drop 1 str)
70+ isConstant = or $ map (isOfPrefix str) ["\"", "'"]
71 eatComments str'
71 eatComments str'
72 | null str' = []
72 | null str' = []
73 | isPrefixOf "*/" str' = drop 2 str'
73 | isPrefixOf "*/" str' = drop 2 str'
@@ -75,10 +75,10 @@ stripComments str
76--------------------------------------------------------------------------------
76--------------------------------------------------------------------------------
77-- | Helper function to handle string constants correctly.
77-- | Helper function to handle string constants correctly.
78−retainConstants :: (String -> String) -> String -> String -> String
78+retainConstants :: (String -> String) -> Char -> String -> String
79retainConstants f delim str
79retainConstants f delim str
80 | null str = []
80 | null str = []
81− | isPrefixOf delim str = head str : f (drop 1 str)
81+ | isPrefixOf [delim] str = head str : f (drop 1 str)
82 | otherwise = head str : retainConstants f delim (drop 1 str)
82 | otherwise = head str : retainConstants f delim (drop 1 str)
84--------------------------------------------------------------------------------
84--------------------------------------------------------------------------------