1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-23 00:43:28 +00:00
freebsd-ports/devel/asdlgen/files/patch-src_haskell_StdPkl.hs
Edwin Groothuis 6ec7d6368c New port: devel/asdlgen generate serializers for C,C++,Haskell,Icon,Java,ML
asdlGen generates data structure and serializer code from ASDL
	specifications [1]. It is especially helpful for exchanging
	tree like data structures between different programming languages.
	Currently C, C++, Haskell, Java, Icon, OCaml and SML are supported.
	Although the asdlGen project itself seems no longer actively
	maintained, ASDL is "alive" as it is used (at least) in the
	Moby [2] and Python [3,4] compilers.

	The port optionally installs a simple usage example [5] for all
	seven programming languages. I developed it primarily to test the
	port, but it could be helpful to users of asdlGen to get a quicker
	start, especially if a less familiar programming language is
	involved in their project. Reviewers/committers can easily make
	use of it via the "test-demo" target.

PR:		ports/117703
Submitted by:	Johannes 5 Joemann <joemann@beefree.free.de>
2008-05-24 06:39:32 +00:00

32 lines
1.0 KiB
Haskell

--- src/haskell/StdPkl.hs.orig 1999-09-13 00:27:00.000000000 +0200
+++ src/haskell/StdPkl.hs 2007-10-01 12:43:41.000000000 +0200
@@ -50,9 +50,9 @@
write_integral :: Integral a => a -> Handle -> IO ()
write_integral n s = loop (abs n)
where
- loop x | x <= 63 = hPutChar s (chr (toInt(finish (n<0) x)))
+ loop x | x <= 63 = hPutChar s (chr (fromIntegral(finish (n<0) x)))
| otherwise = do
- hPutChar s (chr (toInt(nibble x)))
+ hPutChar s (chr (fromIntegral(nibble x)))
loop (x `shiftr` 7)
nibble n = ((n `andb` 0x7f) `orb` 0x80) `andb` 0xff
finish False n = n `andb` 255
@@ -63,14 +63,14 @@
read_integral s
= do {
c <- hGetChar s;
- loop (fromInt (ord c)) 0 0
+ loop (fromIntegral (ord c)) 0 0
}
where
loop n acc shift =
if (continue_bit_set n) then
do {
c <- hGetChar s;
- loop (fromInt(ord c) `andb` 255)
+ loop (fromIntegral(ord c) `andb` 255)
(acc `orb` ((n `andb` 0x7f) `shiftl` shift))
(shift+7)
}