openbsd-ports/net/hpodder/patches/patch-FeedParser_hs
dcoppa a1d30b1ae5 Make code compatible with HaXml 1.20.*
Various fixes.

Zap USE_GROFF.

Ok kili@
2011-05-26 08:24:59 +00:00

64 lines
2.3 KiB
Plaintext

$OpenBSD: patch-FeedParser_hs,v 1.1 2011/05/26 08:24:59 dcoppa Exp $
make code compatible with HaXml 1.20
--- FeedParser.hs.orig Wed Jul 2 17:32:27 2008
+++ FeedParser.hs Tue May 24 13:32:57 2011
@@ -33,6 +33,7 @@ module FeedParser where
import Types
import Text.XML.HaXml
import Text.XML.HaXml.Parse
+import Text.XML.HaXml.Posn
import Utils
import Data.Maybe.Utils
import Data.Char
@@ -76,7 +77,7 @@ parse fp name =
let feeditems = getEnclosures doc
return $ Right $
(Feed {channeltitle = title, items = feeditems})
- where getContent (Document _ _ e _) = CElem e
+ where getContent (Document _ _ e _) = CElem e noPos
unifrob ('\xef':'\xbb':'\xbf':x) = x -- Strip off unicode BOM
unifrob x = x
@@ -121,13 +122,13 @@ channel =
-- Utilities
--------------------------------------------------
-attrofelem :: String -> Content -> Maybe AttValue
-attrofelem attrname (CElem inelem) =
+attrofelem :: String -> Content Posn -> Maybe AttValue
+attrofelem attrname (CElem inelem _) =
case unesc inelem of
Elem name al _ -> lookup attrname al
attrofelem _ _ =
error "attrofelem: called on something other than a CElem"
-stratt :: String -> Content -> Maybe [String]
+stratt :: String -> Content Posn -> Maybe [String]
stratt attrname content =
case attrofelem attrname content of
Just (AttValue x) -> Just (concat . map mapfunc $ x)
@@ -136,17 +137,18 @@ stratt attrname content =
mapfunc (Right _) = []
-- Finds the literal children of the named tag, and returns it/them
-tagof :: String -> CFilter
+tagof :: String -> CFilter Posn
tagof x = keep /> tag x -- /> txt
-- Retruns the literal string that tagof would find
-strof :: String -> Content -> String
+strof :: String -> Content Posn -> String
strof x y = forceEither $ strof_either x y
-strof_either :: String -> Content -> Either String String
+strof_either :: String -> Content Posn -> Either String String
strof_either x y =
case tagof x $ y of
- [CElem elem] -> Right $ verbatim $ tag x /> txt $ CElem (unesc elem)
+ [CElem elem pos] -> Right $ verbatim $ tag x /> txt
+ $ CElem (unesc elem) pos
z -> Left $ "strof: expecting CElem in " ++ x ++ ", got "
++ verbatim z ++ " at " ++ verbatim y