$OpenBSD: patch-FeedParser_hs,v 1.5 2012/09/18 17:12:56 dcoppa Exp $

Fix the "Invalid or incomplete multibyte or wide character" error
caused by some feeds: set binary mode on the handle before hGetContents
(upstream git commit bd08d07cc29893177efe8ef0e8be368657d56bbf)

Unbreak build with HaXml>=1.22

--- FeedParser.hs.orig	Tue Nov  8 16:49:38 2011
+++ FeedParser.hs	Tue Sep 18 17:22:05 2012
@@ -39,6 +39,7 @@ import Data.Maybe.Utils
 import Data.Char
 import Data.Either.Utils
 import Data.List
+import System.IO
 
 data Item = Item {itemtitle :: String,
                   itemguid :: Maybe String,
@@ -68,7 +69,8 @@ item2ep pc item =
 
 parse :: FilePath -> String -> IO (Either String Feed)
 parse fp name = 
-    do c <- readFile fp
+    do h <- openBinaryFile fp ReadMode
+       c <- hGetContents h
        case xmlParse' name (unifrob c) of
          Left x -> return (Left x)
          Right y ->
@@ -125,7 +127,7 @@ channel =
 attrofelem :: String -> Content Posn -> Maybe AttValue
 attrofelem attrname (CElem inelem _) =
     case unesc inelem of
-      Elem name al _ -> lookup attrname al
+      Elem name al _ -> lookup (N attrname) al
 attrofelem _ _ =
     error "attrofelem: called on something other than a CElem"
 stratt :: String -> Content Posn -> Maybe [String]
