From c48ad065803b3766767713cb3866893713dade2b Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Wed, 11 Nov 1998 17:40:16 +0000
Subject: [PATCH] [project @ 1998-11-11 17:40:07 by sof] Fixed endian bug that
 struck when outputting on non-buffered handles

---
 ghc/lib/std/IO.lhs                 | 4 ++--
 ghc/lib/std/PrelHandle.lhs         | 2 +-
 ghc/lib/std/cbits/fileLookAhead.lc | 4 ++--
 ghc/lib/std/cbits/filePutc.lc      | 2 +-
 ghc/lib/std/cbits/stgio.h          | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ghc/lib/std/IO.lhs b/ghc/lib/std/IO.lhs
index 0baa75a6622c..5c8c9fb0b126 100644
--- a/ghc/lib/std/IO.lhs
+++ b/ghc/lib/std/IO.lhs
@@ -329,7 +329,7 @@ hPutChar :: Handle -> Char -> IO ()
 hPutChar handle c = do
     handle_  <- wantWriteableHandle "hPutChar" 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_
     if rc == 0
      then return ()
@@ -472,7 +472,7 @@ writeChars :: Addr -> String -> IO ()
 #endif
 writeChars fo "" = return ()
 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 
    then writeChars fo cs
    else constructErrorAndFail "writeChars"
diff --git a/ghc/lib/std/PrelHandle.lhs b/ghc/lib/std/PrelHandle.lhs
index 6d7a6c96282a..91ae3df5d751 100644
--- a/ghc/lib/std/PrelHandle.lhs
+++ b/ghc/lib/std/PrelHandle.lhs
@@ -791,7 +791,7 @@ pushback. (For unbuffered channels, the (default) push-back limit is
 hUngetChar :: Handle -> Char -> IO ()
 hUngetChar handle c = do
     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_
     if rc == (-1)
      then constructErrorAndFail "hUngetChar"
diff --git a/ghc/lib/std/cbits/fileLookAhead.lc b/ghc/lib/std/cbits/fileLookAhead.lc
index d6bb13b17de1..9be19ce4e988 100644
--- a/ghc/lib/std/cbits/fileLookAhead.lc
+++ b/ghc/lib/std/cbits/fileLookAhead.lc
@@ -35,7 +35,7 @@ StgForeignObj ptr;
          return c;
     }
 
-    rc = ungetChar(ptr,c);
+    rc = ungetChar(ptr,(char)c);
     if ( rc < 0 ) {
        return rc;
     } else {
@@ -46,7 +46,7 @@ StgForeignObj ptr;
 StgInt
 ungetChar(ptr,c)
 StgForeignObj ptr;
-StgInt c;
+StgChar c;
 {
   IOFileObject* fo = (IOFileObject*)ptr;
   int rc = 0, sz = 0;
diff --git a/ghc/lib/std/cbits/filePutc.lc b/ghc/lib/std/cbits/filePutc.lc
index b914cc62c50f..a6ebf3d15593 100644
--- a/ghc/lib/std/cbits/filePutc.lc
+++ b/ghc/lib/std/cbits/filePutc.lc
@@ -14,7 +14,7 @@
 StgInt
 filePutc(ptr, c)
 StgForeignObj ptr;
-StgInt c;
+StgChar c;
 {
     IOFileObject* fo = (IOFileObject*)ptr;
     int rc = 0;
diff --git a/ghc/lib/std/cbits/stgio.h b/ghc/lib/std/cbits/stgio.h
index 1a2071fb2b1d..2bce94b326b3 100644
--- a/ghc/lib/std/cbits/stgio.h
+++ b/ghc/lib/std/cbits/stgio.h
@@ -53,7 +53,7 @@ StgInt	fileGetc PROTO((StgForeignObj));
 
 /* fileLookAhead.lc */
 StgInt	fileLookAhead PROTO((StgForeignObj));
-StgInt	ungetChar PROTO((StgForeignObj,StgInt));
+StgInt	ungetChar PROTO((StgForeignObj,StgChar));
 
 /* fileObject.lc */
 void    setBufFlags PROTO((StgForeignObj, StgInt));
@@ -81,7 +81,7 @@ StgInt	getFilePosn PROTO((StgForeignObj));
 StgInt	setFilePosn PROTO((StgForeignObj, StgInt));
 
 /* filePutc.lc */
-StgInt	filePutc    PROTO((StgForeignObj, StgInt));
+StgInt	filePutc    PROTO((StgForeignObj, StgChar));
 
 /* fileSize.lc */
 StgInt	fileSize    PROTO((StgForeignObj, StgByteArray));
-- 
GitLab