Commit c48ad065 authored by sof's avatar sof
Browse files

[project @ 1998-11-11 17:40:07 by sof]

Fixed endian bug that struck when outputting on non-buffered handles
parent f2507326
...@@ -329,7 +329,7 @@ hPutChar :: Handle -> Char -> IO () ...@@ -329,7 +329,7 @@ hPutChar :: Handle -> Char -> IO ()
hPutChar handle c = do hPutChar handle c = do
handle_ <- wantWriteableHandle "hPutChar" handle handle_ <- wantWriteableHandle "hPutChar" handle
let fo = haFO__ handle_ let fo = haFO__ handle_
rc <- mayBlock fo (_ccall_ filePutc fo (ord c)) -- ConcHask: UNSAFE, may block. rc <- mayBlock fo (_ccall_ filePutc fo c) -- ConcHask: UNSAFE, may block.
writeHandle handle handle_ writeHandle handle handle_
if rc == 0 if rc == 0
then return () then return ()
...@@ -472,7 +472,7 @@ writeChars :: Addr -> String -> IO () ...@@ -472,7 +472,7 @@ writeChars :: Addr -> String -> IO ()
#endif #endif
writeChars fo "" = return () writeChars fo "" = return ()
writeChars fo (c:cs) = do writeChars fo (c:cs) = do
rc <- mayBlock fo (_ccall_ filePutc fo (ord c)) -- ConcHask: UNSAFE, may block. rc <- mayBlock fo (_ccall_ filePutc fo c) -- ConcHask: UNSAFE, may block.
if rc == 0 if rc == 0
then writeChars fo cs then writeChars fo cs
else constructErrorAndFail "writeChars" else constructErrorAndFail "writeChars"
......
...@@ -791,7 +791,7 @@ pushback. (For unbuffered channels, the (default) push-back limit is ...@@ -791,7 +791,7 @@ pushback. (For unbuffered channels, the (default) push-back limit is
hUngetChar :: Handle -> Char -> IO () hUngetChar :: Handle -> Char -> IO ()
hUngetChar handle c = do hUngetChar handle c = do
handle_ <- wantReadableHandle "hLookAhead" handle handle_ <- wantReadableHandle "hLookAhead" handle
rc <- _ccall_ ungetChar (haFO__ handle_) (ord c) -- ConcHask: SAFE, won't block rc <- _ccall_ ungetChar (haFO__ handle_) c -- ConcHask: SAFE, won't block
writeHandle handle handle_ writeHandle handle handle_
if rc == (-1) if rc == (-1)
then constructErrorAndFail "hUngetChar" then constructErrorAndFail "hUngetChar"
......
...@@ -35,7 +35,7 @@ StgForeignObj ptr; ...@@ -35,7 +35,7 @@ StgForeignObj ptr;
return c; return c;
} }
rc = ungetChar(ptr,c); rc = ungetChar(ptr,(char)c);
if ( rc < 0 ) { if ( rc < 0 ) {
return rc; return rc;
} else { } else {
...@@ -46,7 +46,7 @@ StgForeignObj ptr; ...@@ -46,7 +46,7 @@ StgForeignObj ptr;
StgInt StgInt
ungetChar(ptr,c) ungetChar(ptr,c)
StgForeignObj ptr; StgForeignObj ptr;
StgInt c; StgChar c;
{ {
IOFileObject* fo = (IOFileObject*)ptr; IOFileObject* fo = (IOFileObject*)ptr;
int rc = 0, sz = 0; int rc = 0, sz = 0;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
StgInt StgInt
filePutc(ptr, c) filePutc(ptr, c)
StgForeignObj ptr; StgForeignObj ptr;
StgInt c; StgChar c;
{ {
IOFileObject* fo = (IOFileObject*)ptr; IOFileObject* fo = (IOFileObject*)ptr;
int rc = 0; int rc = 0;
......
...@@ -53,7 +53,7 @@ StgInt fileGetc PROTO((StgForeignObj)); ...@@ -53,7 +53,7 @@ StgInt fileGetc PROTO((StgForeignObj));
/* fileLookAhead.lc */ /* fileLookAhead.lc */
StgInt fileLookAhead PROTO((StgForeignObj)); StgInt fileLookAhead PROTO((StgForeignObj));
StgInt ungetChar PROTO((StgForeignObj,StgInt)); StgInt ungetChar PROTO((StgForeignObj,StgChar));
/* fileObject.lc */ /* fileObject.lc */
void setBufFlags PROTO((StgForeignObj, StgInt)); void setBufFlags PROTO((StgForeignObj, StgInt));
...@@ -81,7 +81,7 @@ StgInt getFilePosn PROTO((StgForeignObj)); ...@@ -81,7 +81,7 @@ StgInt getFilePosn PROTO((StgForeignObj));
StgInt setFilePosn PROTO((StgForeignObj, StgInt)); StgInt setFilePosn PROTO((StgForeignObj, StgInt));
/* filePutc.lc */ /* filePutc.lc */
StgInt filePutc PROTO((StgForeignObj, StgInt)); StgInt filePutc PROTO((StgForeignObj, StgChar));
/* fileSize.lc */ /* fileSize.lc */
StgInt fileSize PROTO((StgForeignObj, StgByteArray)); StgInt fileSize PROTO((StgForeignObj, StgByteArray));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment