@@ -226,14 +226,16 @@ string s = Parser $ \(S sb lb n) ->
226226endOfLine :: Parser ()
227227endOfLine = Parser $ \(S sb lb n) ->
228228 let bs = sb +: lb
229− in case I.w2c (U.unsafeHead sb) of
230− '\n' -> Right ((), mkState (LB.tail bs) (n + 1))
231− '\r' -> let (h,t) = LB.splitAt 2 bs
232− rn = L8.pack "\r\n"
233− in if h == rn
234− then Right ((), mkState t (n + 2))
235− else Right ((), mkState (LB.tail bs) (n + 1))
236− _ -> Left (bs, ["EOL"])
229+ in if SB.null sb
230+ then Left (bs, ["EOL"])
231+ else case I.w2c (U.unsafeHead sb) of
232+ '\n' -> Right ((), mkState (LB.tail bs) (n + 1))
233+ '\r' -> let (h,t) = LB.splitAt 2 bs
234+ rn = L8.pack "\r\n"
235+ in if h == rn
236+ then Right ((), mkState t (n + 2))
237+ else Right ((), mkState (LB.tail bs) (n + 1))
238+ _ -> Left (bs, ["EOL"])
237239
238240-- | Satisfy a literal string, after applying a transformation to both
239241-- it and the matching text.