Eric Kow <[email protected]> added the comment:
Applied, thanks!
(there aren't any actual tests, this just means I'll push it when I have
other patches to push).
PS: I used this Haskell file to decode your mail. It's basically a thin
wrapper around some functions in the Darcs source to qp-decode your message.
----------
assignedto: drcygnus -> cygnus
nosy: +kowey -dagit, darcs-users, drcygnus
status: amend-requested -> accepted-pending-tests
__________________________________
Darcs bug tracker <[email protected]>
<http://bugs.darcs.net/patch64>
__________________________________
import Data.Char
import Data.Word
import Data.ByteString as B
import Data.ByteString.Internal as B
import Data.ByteString.Char8 as BC
import System.IO.Unsafe
import ByteStringUtils
import Foreign.Ptr ( Ptr, plusPtr )
import Foreign.Storable
main = do
b <- qpdecode `fmap` B.getContents
B.putStrLn b
qpdecode :: B.ByteString -> B.ByteString
qpdecode s = unsafePerformIO
-- Add 1 as linesPS "\n" -> ["", ""] -> "\n\n"
$ B.createAndTrim (B.length s + 1) (\buf -> decode (linesPS s) buf 0)
decode :: [B.ByteString] -> Ptr Word8 -> Int -> IO Int
decode [] _ bufi = return bufi
decode (ps:pss) buf bufi
| B.null (dropSpace ps)
= do poke (buf `plusPtr` bufi) newline
decode pss buf (bufi+1)
| is_equals && B.length ps >= 3 && isHexDigit c1 && isHexDigit c2
= do poke (buf `plusPtr` bufi)
(toWord8 $ digitToInt c1 * 16 + digitToInt c2)
decode (B.drop 3 ps:pss) buf (bufi+1)
| is_equals && B.null (dropSpace (B.tail ps)) = decode pss buf bufi
| otherwise = do poke (buf `plusPtr` bufi) (B.head ps)
decode (B.tail ps:pss) buf (bufi+1)
where is_equals = BC.head ps == '='
c1 = BC.index ps 1
c2 = BC.index ps 2
newline = B.c2w '\n'
toWord8 :: Int -> Word8
toWord8 = fromIntegral
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users