Revision 256e28c4 htools/Ganeti/Ssconf.hs

b/htools/Ganeti/Ssconf.hs
38 38

  
39 39
import Control.Exception
40 40
import Control.Monad (liftM)
41
import Data.Char (isSpace)
42 41
import Data.Maybe (fromMaybe)
43 42
import qualified Network.Socket as Socket
44 43
import System.FilePath ((</>))
......
116 115
            keyToFilename (fromMaybe dpath optpath) $ key
117 116
  return (liftM (take maxFileSize) result)
118 117

  
119
-- | Strip space characthers (including newline). As this is
120
-- expensive, should only be run on small strings.
121
rstripSpace :: String -> String
122
rstripSpace = reverse . dropWhile isSpace . reverse
123

  
124 118
-- | Parses a string containing an IP family
125 119
parseIPFamily :: Int -> Result Socket.Family
126 120
parseIPFamily fam | fam == C.ip4Family = Ok Socket.AF_INET
......
131 125
getPrimaryIPFamily :: Maybe FilePath -> IO (Result Socket.Family)
132 126
getPrimaryIPFamily optpath = do
133 127
  result <- readSSConfFile optpath (Just (show C.ip4Family)) SSPrimaryIpFamily
134
  return (liftM rstripSpace result >>=
128
  return (liftM rStripSpace result >>=
135 129
          tryRead "Parsing af_family" >>= parseIPFamily)

Also available in: Unified diff