summaryrefslogtreecommitdiff
path: root/lib/Hosts.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Hosts.hs')
-rw-r--r--lib/Hosts.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Hosts.hs b/lib/Hosts.hs
index 5f09de1..0f1d9a6 100644
--- a/lib/Hosts.hs
+++ b/lib/Hosts.hs
@@ -162,6 +162,7 @@ chaddr n addr hosts =
162 where oo = (.) . (.) 162 where oo = (.) . (.)
163 (a,ws') = splitAt 2 ws 163 (a,ws') = splitAt 2 ws
164 164
165isLonerName :: L.ByteString -> Bool
165isLonerName line = length ws' <= 2 166isLonerName line = length ws' <= 2
166 where (x,_) = L.break (=='#') line 167 where (x,_) = L.break (=='#') line
167 ws = L.groupBy ( (==EQ) `oo` comparing isSpace) x 168 ws = L.groupBy ( (==EQ) `oo` comparing isSpace) x
@@ -186,12 +187,15 @@ cannonizeName name line = scrubName f line
186 where 187 where
187 (pre,rst) = break (==name) ws 188 (pre,rst) = break (==name) ws
188 189
190removeName :: L.ByteString -> Hosts -> Hosts
189removeName name hosts = hosts' 191removeName name hosts = hosts'
190 where 192 where
191 hosts' = scrubTrailingEmpties (maybe hosts (removeName0 name hosts) ns) 193 hosts' = scrubTrailingEmpties (maybe hosts (removeName0 name hosts) ns)
192 ns = Map.lookup name (namenum hosts) 194 ns = Map.lookup name (namenum hosts)
193 195
194 196
197removeName0 :: Foldable t =>
198 L.ByteString -> Hosts -> t Int -> Hosts
195removeName0 name hosts nums = hosts 199removeName0 name hosts nums = hosts
196 { namenum = Map.delete name (namenum hosts) 200 { namenum = Map.delete name (namenum hosts)
197 , numline = foldl' scrub (numline hosts) nums 201 , numline = foldl' scrub (numline hosts) nums